Execute in place

Last updated

In computer science, execute in place (XIP) is a method of executing programs directly from long-term storage rather than copying it into RAM. It is an extension of using shared memory to reduce the total amount of memory required.

Contents

Its general effect is that the program text consumes no writable memory, saving it for dynamic data, and that all instances of the program are run from a single copy.

For this to work, several criteria have to be met:

The storage requirements are usually met by using NOR flash memory or EEPROM, which can be addressed as individual words for read operations, although it is a bit slower than normal system RAM in most setups.

XIP during boot load

Typically, the First Stage Boot Loader is an XIP program that is linked to run at the address at which the flash chip(s) are mapped at power-up and contains a minimal program to set up the system RAM (which depends on the components used on the individual boards and cannot be generalized enough so that the proper sequence could be embedded into the processor hardware) and then loads the second stage bootloader or the OS kernel into RAM.

During this initialization, writable memory may not be available, so all computations have to be performed within the processor registers. For this reason, first stage boot loaders tend to be written in assembly language and only do the minimum to provide a normal execution environment for the next program. Some processors either embed a small amount of SRAM in the chip itself, [1] or allow using the onboard cache memory as RAM, [2] to make this first stage boot loader easier to write using high-level language.

For a kernel or bootloader, address space generally is assigned internally, so in order to use XIP for them, it is sufficient to instruct the linker to place unmodifiable and modifiable data in different address ranges and provide a mechanism for the modifiable data to be copied to writable memory before any code is run that assumes that data can be accessed normally. This can be done as part of the previous stage, or within a small code segment at the beginning of the program.

If address space is assigned externally, such as in an application program that is run on a system that does not provide virtual memory, the compiler needs to access all modifiable data by adding an offset to a pointer to a private copy of the data area. In this case, the external loader is responsible for setting up the instance specific memory areas.

BIOS and UEFI use XIP to initialize the main memory.

XIP as file system

XIP places requirements on file systems that are often difficult to meet. In systems without a page table, the entire file must be stored within consecutive bytes and must not be fragmented, while flash based file systems often aim to distribute data into sectors of the flash chip that have the least erase cycles and even out the wear on the chip, prolonging its lifetime.

All these complications and the speed tradeoff mean that XIP is generally only used for first stage bootloaders or when RAM is in extremely short supply. In particular, second through fourth generation video game consoles connect the ROM cartridge's address and data bus to that of the console, [3] which lets (for example) the Atari 2600 work with only the 128 bytes of RAM in its joystick interface IC.

A relatively new file system for Linux, called AXFS (Advanced XIP File System), aims to overcome some of the shortcomings associated with XIP, especially in regard to the in-place execution of user-space applications. It makes for instance possible to split up an executable binary file into "XIP regions", thus avoiding the restriction of fragmentation that was mentioned above.

A NetBSD implementation is also under development. [4]

See also

Related Research Articles

<span class="mw-page-title-main">BIOS</span> Firmware for hardware initialization and OS runtime services

In computing, BIOS is firmware used to provide runtime services for operating systems and programs and to perform hardware initialization during the booting process. The BIOS firmware comes pre-installed on an IBM PC or IBM PC compatible's system board and exists in some UEFI-based systems too as a compatibly support module to maintain compatibility operating systems that do not support UEFI native operation. The name originates from the Basic Input/Output System used in the CP/M operating system in 1975. The BIOS originally proprietary to the IBM PC has been reverse engineered by some companies looking to create compatible systems. The interface of that original system serves as a de facto standard.

<span class="mw-page-title-main">Booting</span> Process of starting a computer

In computing, booting is the process of starting a computer as initiated via hardware such as a button or by a software command. After it is switched on, a computer's central processing unit (CPU) has no software in its main memory, so some process must load software into memory before it can be executed. This may be done by hardware or firmware in the CPU, or by a separate processor in the computer system.

<span class="mw-page-title-main">GNU GRUB</span> Boot loader package

GNU GRUB is a boot loader package from the GNU Project. GRUB is the reference implementation of the Free Software Foundation's Multiboot Specification, which provides a user the choice to boot one of multiple operating systems installed on a computer or select a specific kernel configuration available on a particular operating system's partitions.

A boot disk is a removable digital data storage medium from which a computer can load and run (boot) an operating system or utility program. The computer must have a built-in program which will load and execute a program from a boot disk meeting certain standards.

<span class="mw-page-title-main">Bootloader</span> Software responsible for starting the computer and load other software to the CPU memory

A bootloader, also spelled as boot loader or called boot manager and bootstrap loader, is a computer program that is responsible for booting a computer.

The Macintosh Toolbox implements many of the high-level features of the Classic Mac OS, including a set of application programming interfaces for software development on the platform. The Toolbox consists of a number of "managers," software components such as QuickDraw, responsible for drawing onscreen graphics, and the Menu Manager, which maintain data structures describing the menu bar. As the original Macintosh was designed without virtual memory or memory protection, it was important to classify code according to when it should be loaded into memory or kept on disk, and how it should be accessed. The Toolbox consists of subroutines essential enough to be permanently kept in memory and accessible by a two-byte machine instruction; however it excludes core "kernel" functionality such as memory management and the file system. Note that the Toolbox does not draw the menu onscreen: menus were designed to have a customizable appearance, so the drawing code was stored in a resource, which could be on a disk.

<span class="mw-page-title-main">UEFI</span> Operating system software specification

The Unified Extensible Firmware Interface (UEFI) is a publicly available specification that defines a software interface between an operating system and platform firmware. UEFI replaces the legacy Basic Input/Output System (BIOS) boot firmware originally present in all IBM PC-compatible personal computers, with most UEFI firmware implementations providing support for legacy BIOS services. UEFI can support remote diagnostics and repair of computers, even with no operating system installed.

vmlinux

vmlinux is a statically linked executable file that contains the Linux kernel in one of the object file formats supported by Linux, which includes Executable and Linkable Format (ELF) and Common Object File Format (COFF). The vmlinux file might be required for kernel debugging, symbol table generation or other operations, but must be made bootable before being used as an operating system kernel by adding a multiboot header, bootsector and setup routines.

coreboot Open-source computer firmware

coreboot, formerly known as LinuxBIOS, is a software project aimed at replacing proprietary firmware found in most computers with a lightweight firmware designed to perform only the minimum number of tasks necessary to load and run a modern 32-bit or 64-bit operating system.

In Linux systems, initrd is a scheme for loading a temporary root file system into memory, to be used as part of the Linux startup process. initrd and initramfs refer to two different methods of achieving this. Both are commonly used to make preparations before the real root file system can be mounted.

The boot ROM is a type of ROM that is used for booting a computer system.

quik is a boot loader designed to start Linux on Apple Macintosh PowerPC systems based on the Old World ROM architecture. It was originally written by Paul Mackerras, and portions of its code were reused in all other Linux boot loaders for PowerPC, including the one known as BootX, which is dependent on the Mac OS. Quik's loader boots from Open Firmware and bypasses the Mac OS entirely. New World ROM systems use yaboot.

<span class="mw-page-title-main">Das U-Boot</span> Open-source, primary boot the devices operating system kernel

Das U-Boot is an open-source, primary boot loader used in embedded devices to package the instructions to boot the device's operating system kernel. It is available for a number of computer architectures, including 68k, ARM, Blackfin, MicroBlaze, MIPS, Nios, SuperH, PPC, RISC-V and x86.

<span class="mw-page-title-main">Live USB</span> USB drive with a full bootable operating system

A live USB is a portable USB-attached external data storage device containing a full operating system that can be booted from. The term is reminiscent of USB flash drives but may encompass an external hard disk drive or solid-state drive, though they may be referred to as "live HDD" and "live SSD" respectively. They are the evolutionary next step after live CDs, but with the added benefit of writable storage, allowing customizations to the booted operating system. Live USBs can be used in embedded systems for system administration, data recovery, or test driving, and can persistently save settings and install software packages on the USB device.

Linux startup process is the multi-stage initialization process performed during booting a Linux installation. It is in many ways similar to the BSD and other Unix-style boot processes, from which it derives.

<span class="mw-page-title-main">Read-only memory</span> Electronic memory that cannot be changed

Read-only memory (ROM) is a type of non-volatile memory used in computers and other electronic devices. Data stored in ROM cannot be electronically modified after the manufacture of the memory device. Read-only memory is useful for storing software that is rarely changed during the life of the system, also known as firmware. Software applications for programmable devices can be distributed as plug-in cartridges containing ROM.

AXFS is a compressed read-only file system for Linux, initially developed at Intel, and now maintained at Numonyx. It was designed to use execute in place (XIP) alongside compression aiming to reduce boot and program load times, while retaining a small memory footprint for embedded devices. This is achieved by mixing compressed and uncompressed pages in the same executable file. AXFS is free software.

In computing, a devicetree is a data structure describing the hardware components of a particular computer so that the operating system's kernel can use and manage those components, including the CPU or CPUs, the memory, the buses and the integrated peripherals.

Xbox modding is the practice of circumventing the built-in hardware and software security mechanisms of the Xbox video game console.

The booting process of Android devices starts at the power-on of the SoC and ends at the visibility of the home screen, or special modes like recovery and fastboot. The boot process of devices that run Android is influenced by the firmware design of the SoC manufacturers.

References

  1. Samsung S3C2416X have 64kB embedded SRAM available on the system bus
  2. Broadcom BCM2835 uses its Level 2 Cache as boot loader RAM before SDRAM is initialized
  3. USpatent 4485457A,Richard K. Balaska, Robert L. Hunter, and Scott S. Robinson,"Memory system including RAM and page switchable ROM",issued 1984-11-27, assigned to CBS Inc.
  4. Uebayashi, Masao (2010-04-05). "eXecute-In-Place (XIP) Support for NetBSD" (PDF). BSDCan.