Jump to content

Execute in place: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
m Adding category Category:Linux (using HotCat)
m v2.05b - Bot T20 CW#61 - Fix errors for CW project (Reference before punctuation)
 
(45 intermediate revisions by 36 users not shown)
Line 1: Line 1:
{{Short description|Computer science concept}}
{{refimprove|date=August 2009}}
{{redirect|XIP|the file extension|.XIP|the ISO 639 code xip|Shipibo language}}
In [[computer science]], '''execute in place''' (XIP) is a method of executing programs directly from long term storage rather than copying it into [[Random access memory|RAM]]. It is an extension of using [[shared memory]] to reduce the total amount of memory required.
{{more citations needed|date=August 2009}}
In [[computer science]], '''execute in place''' ('''XIP''') is a method of executing programs directly from long-term storage rather than copying it into [[random-access memory|RAM]]. It is an extension of using [[shared memory]] to reduce the total amount of memory required.


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.
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:
For this to work, several criteria have to be met:
* The storage must provide a similar interface to the [[Central processing unit|CPU]] as regular memory (or an adaptive layer must be present),
* The storage must provide a similar interface to the [[Central processing unit|CPU]] as regular memory (or an adaptive layer must be present).
* This interface must provide sufficiently fast read operations with a random access pattern,
* This interface must provide sufficiently fast read operations with a [[random access]] pattern.
* The [[file system]], if one is used, needs to expose appropriate mapping functions,
* The [[file system]], if one is used, needs to expose appropriate mapping functions.
* The program must either be [[Linker (computing)|linked]] to be aware of the address the storage appears at in the system, or must be position-independent,
* The program must either be [[Linker (computing)|linked]] to be aware of the address the storage appears at in the system or be [[Position-independent code|position-independent]].
* The program must not modify data within the loaded image.
* The program must not modify data within the loaded image.


The storage requirements are usually met by using NOR [[flash memory]], which can be addressed as individual words for read operations, although it is a bit slower than normal system RAM in most setups.
The storage requirements are usually met by using [[Flash memory#NOR memories|NOR flash memory]] or [[EEPROM]], which can be byte-addressed 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 (computer science)|kernel]] into RAM.
In x86 systems, 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 (operating system)|kernel]] into RAM.


During this initialization, no writable memory is available, so all computations have to be performed within the processor registers. For this reason, first stage boot loaders tend to be written in assembler language and only do the minimum to provide a normal execution environment for the next program.
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,<ref>Samsung S3C2416X have 64kB embedded SRAM available on the system bus</ref> or allow using the onboard cache memory as RAM,<ref>Broadcom BCM2835 uses its Level 2 Cache as boot loader RAM before SDRAM is initialized</ref> 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.
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.
Line 21: Line 24:
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.
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.


In x86 systems, typically the [[BIOS]] / [[UEFI]] ROM is mapped to a fixed memory address space upon power-on,<ref> {{Cite web |date=2007-03-08 |title=Dude, Where's My 4 Gigabytes of RAM? |url=https://blog.codinghorror.com/dude-wheres-my-4-gigabytes-of-ram/ |access-date=2024-08-31 |website=Coding Horror}}</ref> and BIOS / UEFI in x86 systems use XIP to initialize the [[main memory]]. In ARM and RISC-V embedded systems, typically the SoC built-in [[Boot ROM]] is mapped to a fixed memory address space upon power-on, and the Boot ROM can find and load an embedded bootloader such as [[Das U-Boot]] from [[NAND flash memory]], and that boot process does not use a dedicated [[EEPROM]] chip.
XIP places requirements on file systems that are often difficult to meet. The entire file must be stored within consecutive bytes and may 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.


==XIP as file system==
All these complications and the speed tradeoff mean that XIP is generally only used for first stage bootloaders or when memory is in extremely short supply.
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 [[Wear leveling|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,<ref name="Balaska">{{cite patent|country=US|number=4485457|title=Memory system including RAM and page switchable ROM|status=patent|fdate=1983-05-31|gdate=1984-11-27|inventor=Richard K. Balaska, Robert L. Hunter, and Scott S. Robinson|assign1=CBS Inc.}}</ref> which lets (for example) the [[Atari 2600 hardware#Technical specifications|Atari 2600]] work with only the 128 bytes of RAM in its [[MOS Technology 6532|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 fragementation that was mentioned above.


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 and kernel space|user-space]] applications. For example, it makes it possible to split up an executable binary file into "XIP regions", thus avoiding the restriction of fragmentation that was mentioned above.
== References ==

<references />
A [[NetBSD]] implementation is also under development.<ref>{{cite web
# Wilshire, Phil. [http://www.ucdot.org/article.pl?sid=02/08/28/0434210&mode=thread "eXecute In Place (XIP) overview"], ''uCdot'', August 28, 2002. Accessed September 25, 2007.
| url = http://www.bsdcan.org/2010/schedule/attachments/127_xip.pdf
# Wellhöfer, Sören [http://www.scribd.com/doc/19855245/Application-eXecuteInPlace-XIP-with-Linux-and-AXFS "Application eXecute-In-Place (XIP) with Linux and AXFS"], September 17, 2009. Accessed September 17, 2009.
| title = eXecute-In-Place (XIP) Support for NetBSD
| first = Masao | last = Uebayashi | date = 2010-04-05 | publisher = [[BSDCan]]
}}</ref>


==See also==
==See also==
*[[Comparison of file systems]]
*[[Comparison of file systems]]
*[[ROM cartridge]]
*[[Firmware]]
*[[AXFS]]
*[[AXFS]]

== References ==
<references />


==External links==
==External links==
* {{cite web
*[http://www.kernel.org/doc/ols/2004/ols2004v1-pages-79-88.pdf Kernel.org - Methods to Improve Bootup Time in Linux - XIP Design Tradeoffs]
| url = https://www.kernel.org/doc/ols/2004/ols2004v1-pages-79-88.pdf
*[http://elinux.org/Kernel_XIP eLinux.org - Kernel XIP]
| title = Methods to Improve Bootup Time in Linux
*[http://www.denx.de/wiki/bin/view/DULG/ConfigureLinuxForXIP Configure Linux for XIP (Execution In Place) on PowerPC]
| publisher = [[Ottawa Linux Symposium]] | year = 2004
*[http://elinux.org/Application_XIP eLinux.org - Linux Application XIP]
| first = Tim R. | last = Bird
*[http://linuxvm.org/Patches/index.html Linux for S/390 - Execute in Place file system driver - xip2fs]
}}
*[http://www.kernel.org/doc/ols/2008/ols2008v1-pages-211-218.pdf Kernel.org - Introducing the Advanced XIP File System]
* {{cite web
*[http://numonyx.com/en-US/MemoryProducts/Software/Pages/NumonyxAXFS.aspx Numonyx - Advanced XIP filesystem for Linux]
| url = https://www.kernel.org/doc/ols/2008/ols2008v1-pages-211-218.pdf
[[Category:Computer file systems]]
| first = Jared | last = Hulbert | year = 2008
[[Category:Linux]]
| publisher = [[Ottawa Linux Symposium]]
| title = Introducing the Advanced XIP File System
}}
* {{cite web | last = Wilshire | first = Phil | url = http://www.ucdot.org/article.pl?sid=02/08/28/0434210&mode=thread | title = eXecute In Place (XIP) overview | work = uCdot | date = 2002-08-28 | access-date = 2007-09-25 | archive-url = https://web.archive.org/web/20071020090413/http://www.ucdot.org/article.pl?sid=02%2F08%2F28%2F0434210&mode=thread | archive-date = 2007-10-20 | url-status = dead }}
* {{cite web
| last = Wellhöfer | first = Sören
| url = https://www.scribd.com/doc/19855245/Application-eXecuteInPlace-XIP-with-Linux-and-AXFS
| title = Application eXecute-In-Place (XIP) with Linux and AXFS
| date = 2009-09-17 | access-date = 2009-09-17
}}
* {{cite web
| url = http://www.denx.de/wiki/bin/view/DULG/ConfigureLinuxForXIP
| title = Configure Linux for XIP (Execution In Place) on PowerPC
| publisher = DENX Software Engineering
}}
* {{cite web
| url = http://elinux.org/Kernel_XIP
| title = Kernel XIP
| work = Embedded Linux Wiki
}}
* {{cite web
| url = http://elinux.org/Application_XIP
| title = Linux Application XIP
| work = Embedded Linux Wiki
}}
* {{cite web
| url = http://linuxvm.org/Patches/index.html
| work = Linux for S/390
| title = Execute in Place file system driver - xip2fs
}}


{{Firmware and booting}}
[[ca:Execució en plaça]]

[[ru:Execute in place]]
[[Category:Computer file systems]]
[[Category:Firmware]]

Latest revision as of 05:32, 9 September 2024

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.

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 must provide a similar interface to the CPU as regular memory (or an adaptive layer must be present).
  • This interface must provide sufficiently fast read operations with a random access pattern.
  • The file system, if one is used, needs to expose appropriate mapping functions.
  • The program must either be linked to be aware of the address the storage appears at in the system or be position-independent.
  • The program must not modify data within the loaded image.

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

XIP during boot load

[edit]

In x86 systems, 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.

In x86 systems, typically the BIOS / UEFI ROM is mapped to a fixed memory address space upon power-on,[3] and BIOS / UEFI in x86 systems use XIP to initialize the main memory. In ARM and RISC-V embedded systems, typically the SoC built-in Boot ROM is mapped to a fixed memory address space upon power-on, and the Boot ROM can find and load an embedded bootloader such as Das U-Boot from NAND flash memory, and that boot process does not use a dedicated EEPROM chip.

XIP as file system

[edit]

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,[4] 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. For example, it makes it 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.[5]

See also

[edit]

References

[edit]
  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. ^ "Dude, Where's My 4 Gigabytes of RAM?". Coding Horror. 2007-03-08. Retrieved 2024-08-31.
  4. ^ US patent 4485457, 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. 
  5. ^ Uebayashi, Masao (2010-04-05). "eXecute-In-Place (XIP) Support for NetBSD" (PDF). BSDCan.
[edit]