Almost portable second stage boot loader for Linux (boot2nd), Version 1.0.2 =========================================================================== What is it? =========== A second stage boot loader is used when Linux is bootstrapped from some other host OS (for example, Windows CE, EPOC etc). In such an environment booting Linux requires a 2 stage boot approach: - Starting a Linux kernel: To "start" Linux, the Linux kernel image must be loaded at a predefined location in physical memory and all data must be adjacent. "Starting" it is done by jumping to offset 0 in the kernel image. - First stage boot loader: This is software (application/devic driver etc) that runs natively under the host OS. The first stage boot loader will load the kernel file image and an optional initrd into memory. Although each of these buffers will be contiguously in the virtual address space of the process that loaded the files, they won't be contiguous in physical memory. Since the first stage boot loader must play by the rules of the host OS it can't just load the kernel at a specific physical location because it doesn't have any control over that. Instead, the 1st stage boot loader will build a table specifying for each 4KB Page in the kernel and initrd image, where that Page resides in physical memory. This assumes that the 1 stage boot loader is capable of translating virtual addresses into physical addresses. Apart from loading the kernel image and an optional initrd, the 1st stage boot loader also loads the second stage boot loader. Just as for the kernel and the initrd image, it will translate the virtual address of each Page in the second stage boot loader image into a physical one. After that, the first stage boot loader needs to pass control over to the second stage boot loader. To do that, it should disable interrupts and disable the MMU in the host OS. Depending on the host OS, a device driver running in priviliged mode is needed for this. Finally, the 1st stage boot loader passes control to the second stage boot loader by jumping to offset 0 in the second stage boot loader image first Page. - Second stage boot loader: The second stage boot loader will relocate the kernel and initrd images to their rightfull destination. The 1st stage boot loader will pass in a table with pointers to phsyical addresses of where the Pages for the kernel and initrd images reside. What is so special about boot2nd ================================ - It is developed for 95% in C, so it's highly reusuable. Note that boot2nd runs when the host OS is essentially "disabled". It does not rely on any OS nor does it link against special libraries. - It is designed to run position independently. It doesn't matter where the boot2nd image is loaded and it also doesn't matter if the individual Pages in the boot2nd image are or are not loaded adjacently into physical memory. Boot2nd is capable of relocating itself adjacently and it will patch itself to run position independently. - Boot2nd is capable of text output to 2bpp, 4bpp and 8bpp frame buffers, provided that the 1st stage bootloader passes in the frame buffer address. This is helpful for developers for debugging purposes and for end users to get visual feedback on the load process. - For testing purposes it has some CRC functions to verify that the relocation went ok. What projects is boot2nd being used in: ======================================= - PsiLinux: This is the project that aims to port Linux to the Psion devices such as Series 5, 5Mx (pro), Revo, Series 7 and netbook. Only the Series 7 uses boot2nd. The 1st stage boot loader is called Arlo. What's new in version 1.0.2: =========================== - Removed clearing of stack code. It caused a 4 byte overflow in the PAGE after the stack. When running Arlo as the EPOC shell this will typically corrupt the initrd image. What's new in version 1.0.1: ============================ - Adjust the linker script to do proper asserts on the size of the first page and the size of the got What's new in version 1.0: ========================== - Initial version Building instructions: ===================== - make all Tools used: =========== - gcc 2.95.3.test4 - bin-utils-2.10.1 + 2.10-2.10.10.1.patch License ======= boot2nd is released under the GNU General Public License. See the file copying for more info. Send comments and suggestions to: peter@yipton.demon.co.uk You can get the latest version of boot2nd from: http://www.yipton.net