1f1f238a9SChangbin Du.. SPDX-License-Identifier: GPL-2.0 2f1f238a9SChangbin Du 3f1f238a9SChangbin Du=========================== 4f1f238a9SChangbin DuThe Linux/x86 Boot Protocol 5f1f238a9SChangbin Du=========================== 61da177e4SLinus Torvalds 74039feb5SH. Peter AnvinOn the x86 platform, the Linux kernel uses a rather complicated boot 81da177e4SLinus Torvaldsconvention. This has evolved partially due to historical aspects, as 91da177e4SLinus Torvaldswell as the desire in the early days to have the kernel itself be a 101da177e4SLinus Torvaldsbootable image, the complicated PC memory model and due to changed 111da177e4SLinus Torvaldsexpectations in the PC industry caused by the effective demise of 121da177e4SLinus Torvaldsreal-mode DOS as a mainstream operating system. 131da177e4SLinus Torvalds 144039feb5SH. Peter AnvinCurrently, the following versions of the Linux/x86 boot protocol exist. 151da177e4SLinus Torvalds 16f1f238a9SChangbin Du============= ============================================================ 17f1f238a9SChangbin DuOld kernels zImage/Image support only. Some very early kernels 181da177e4SLinus Torvalds may not even support a command line. 191da177e4SLinus Torvalds 20f1f238a9SChangbin DuProtocol 2.00 (Kernel 1.3.73) Added bzImage and initrd support, as 211da177e4SLinus Torvalds well as a formalized way to communicate between the 221da177e4SLinus Torvalds boot loader and the kernel. setup.S made relocatable, 231da177e4SLinus Torvalds although the traditional setup area still assumed 241da177e4SLinus Torvalds writable. 251da177e4SLinus Torvalds 26f1f238a9SChangbin DuProtocol 2.01 (Kernel 1.3.76) Added a heap overrun warning. 271da177e4SLinus Torvalds 28f1f238a9SChangbin DuProtocol 2.02 (Kernel 2.4.0-test3-pre3) New command line protocol. 291da177e4SLinus Torvalds Lower the conventional memory ceiling. No overwrite 301da177e4SLinus Torvalds of the traditional setup area, thus making booting 311da177e4SLinus Torvalds safe for systems which use the EBDA from SMM or 32-bit 321da177e4SLinus Torvalds BIOS entry points. zImage deprecated but still 331da177e4SLinus Torvalds supported. 341da177e4SLinus Torvalds 35f1f238a9SChangbin DuProtocol 2.03 (Kernel 2.4.18-pre1) Explicitly makes the highest possible 361da177e4SLinus Torvalds initrd address available to the bootloader. 371da177e4SLinus Torvalds 38f1f238a9SChangbin DuProtocol 2.04 (Kernel 2.6.14) Extend the syssize field to four bytes. 398f9aeca7SBernhard Walle 40f1f238a9SChangbin DuProtocol 2.05 (Kernel 2.6.20) Make protected mode kernel relocatable. 41be274eeaSVivek Goyal Introduce relocatable_kernel and kernel_alignment fields. 42f8eeaaf4SH. Peter Anvin 43f1f238a9SChangbin DuProtocol 2.06 (Kernel 2.6.22) Added a field that contains the size of 444c0587e6SIan Campbell the boot command line. 458f9aeca7SBernhard Walle 46f1f238a9SChangbin DuProtocol 2.07 (Kernel 2.6.24) Added paravirtualised boot protocol. 474c0587e6SIan Campbell Introduced hardware_subarch and hardware_subarch_data 484c0587e6SIan Campbell and KEEP_SEGMENTS flag in load_flags. 494c0587e6SIan Campbell 50f1f238a9SChangbin DuProtocol 2.08 (Kernel 2.6.26) Added crc32 checksum and ELF format 512f6de3a1SBaodong Chen payload. Introduced payload_offset and payload_length 524c0587e6SIan Campbell fields to aid in locating the payload. 534c0587e6SIan Campbell 54f1f238a9SChangbin DuProtocol 2.09 (Kernel 2.6.26) Added a field of 64-bit physical 55fb884381SHuang, Ying pointer to single linked list of struct setup_data. 561da177e4SLinus Torvalds 57f1f238a9SChangbin DuProtocol 2.10 (Kernel 2.6.31) Added a protocol for relaxed alignment 58d297366bSH. Peter Anvin beyond the kernel_alignment added, new init_size and 595031296cSH. Peter Anvin pref_address fields. Added extended boot loader IDs. 60d297366bSH. Peter Anvin 61f1f238a9SChangbin DuProtocol 2.11 (Kernel 3.6) Added a field for offset of EFI handover 629ca8f72aSMatt Fleming protocol entry point. 639ca8f72aSMatt Fleming 64f1f238a9SChangbin DuProtocol 2.12 (Kernel 3.8) Added the xloadflags field and extension fields 65c9f3f2d8SMasanari Iida to struct boot_params for loading bzImage and ramdisk 6609c205afSH. Peter Anvin above 4G in 64bit. 6709c205afSH. Peter Anvin 68f1f238a9SChangbin DuProtocol 2.13 (Kernel 3.14) Support 32- and 64-bit flags being set in 6930cc0b6cSJuergen Gross xloadflags to support booting a 64-bit kernel from 32-bit 7030cc0b6cSJuergen Gross EFI 712c33c27fSDaniel Kiper 720854cbdbSRandy DunlapProtocol 2.14 BURNT BY INCORRECT COMMIT 730854cbdbSRandy Dunlap ae7e1238e68f2a472a125673ab506d49158c1889 7486b17aafSVegard Nossum ("x86/boot: Add ACPI RSDP address to setup_header") 752c33c27fSDaniel Kiper DO NOT USE!!! ASSUME SAME AS 2.13. 762c33c27fSDaniel Kiper 770854cbdbSRandy DunlapProtocol 2.15 (Kernel 5.5) Added the kernel_info and kernel_info.setup_type_max. 78f1f238a9SChangbin Du============= ============================================================ 7930cc0b6cSJuergen Gross 802c33c27fSDaniel Kiper.. note:: 812c33c27fSDaniel Kiper The protocol version number should be changed only if the setup header 822c33c27fSDaniel Kiper is changed. There is no need to update the version number if boot_params 832c33c27fSDaniel Kiper or kernel_info are changed. Additionally, it is recommended to use 842c33c27fSDaniel Kiper xloadflags (in this case the protocol version number should not be 852c33c27fSDaniel Kiper updated either) or kernel_info to communicate supported Linux kernel 862c33c27fSDaniel Kiper features to the boot loader. Due to very limited space available in 872c33c27fSDaniel Kiper the original setup header every update to it should be considered 882c33c27fSDaniel Kiper with great care. Starting from the protocol 2.15 the primary way to 892c33c27fSDaniel Kiper communicate things to the boot loader is the kernel_info. 902c33c27fSDaniel Kiper 91f1f238a9SChangbin Du 92f1f238a9SChangbin DuMemory Layout 93f1f238a9SChangbin Du============= 941da177e4SLinus Torvalds 951da177e4SLinus TorvaldsThe traditional memory map for the kernel loader, used for Image or 96f1f238a9SChangbin DuzImage kernels, typically looks like:: 971da177e4SLinus Torvalds 981da177e4SLinus Torvalds | | 991da177e4SLinus Torvalds 0A0000 +------------------------+ 1001da177e4SLinus Torvalds | Reserved for BIOS | Do not use. Reserved for BIOS EBDA. 1011da177e4SLinus Torvalds 09A000 +------------------------+ 102dec04cffSH. Peter Anvin | Command line | 103dec04cffSH. Peter Anvin | Stack/heap | For use by the kernel real-mode code. 1041da177e4SLinus Torvalds 098000 +------------------------+ 1051da177e4SLinus Torvalds | Kernel setup | The kernel real-mode code. 1061da177e4SLinus Torvalds 090200 +------------------------+ 1071da177e4SLinus Torvalds | Kernel boot sector | The kernel legacy boot sector. 1081da177e4SLinus Torvalds 090000 +------------------------+ 1091da177e4SLinus Torvalds | Protected-mode kernel | The bulk of the kernel image. 1101da177e4SLinus Torvalds 010000 +------------------------+ 1111da177e4SLinus Torvalds | Boot loader | <- Boot sector entry point 0000:7C00 1121da177e4SLinus Torvalds 001000 +------------------------+ 1131da177e4SLinus Torvalds | Reserved for MBR/BIOS | 1141da177e4SLinus Torvalds 000800 +------------------------+ 1151da177e4SLinus Torvalds | Typically used by MBR | 1161da177e4SLinus Torvalds 000600 +------------------------+ 1171da177e4SLinus Torvalds | BIOS use only | 1181da177e4SLinus Torvalds 000000 +------------------------+ 1191da177e4SLinus Torvalds 1201da177e4SLinus TorvaldsWhen using bzImage, the protected-mode kernel was relocated to 1211da177e4SLinus Torvalds0x100000 ("high memory"), and the kernel real-mode block (boot sector, 1221da177e4SLinus Torvaldssetup, and stack/heap) was made relocatable to any address between 1231da177e4SLinus Torvalds0x10000 and end of low memory. Unfortunately, in protocols 2.00 and 124dec04cffSH. Peter Anvin2.01 the 0x90000+ memory range is still used internally by the kernel; 125dec04cffSH. Peter Anvinthe 2.02 protocol resolves that problem. 1261da177e4SLinus Torvalds 1271da177e4SLinus TorvaldsIt is desirable to keep the "memory ceiling" -- the highest point in 1281da177e4SLinus Torvaldslow memory touched by the boot loader -- as low as possible, since 1291da177e4SLinus Torvaldssome newer BIOSes have begun to allocate some rather large amounts of 1301da177e4SLinus Torvaldsmemory, called the Extended BIOS Data Area, near the top of low 1311da177e4SLinus Torvaldsmemory. The boot loader should use the "INT 12h" BIOS call to verify 1321da177e4SLinus Torvaldshow much low memory is available. 1331da177e4SLinus Torvalds 1341da177e4SLinus TorvaldsUnfortunately, if INT 12h reports that the amount of memory is too 1351da177e4SLinus Torvaldslow, there is usually nothing the boot loader can do but to report an 1361da177e4SLinus Torvaldserror to the user. The boot loader should therefore be designed to 1371da177e4SLinus Torvaldstake up as little space in low memory as it reasonably can. For 1381da177e4SLinus TorvaldszImage or old bzImage kernels, which need data written into the 1391da177e4SLinus Torvalds0x90000 segment, the boot loader should make sure not to use memory 1401da177e4SLinus Torvaldsabove the 0x9A000 point; too many BIOSes will break above that point. 1411da177e4SLinus Torvalds 142dec04cffSH. Peter AnvinFor a modern bzImage kernel with boot protocol version >= 2.02, a 143f1f238a9SChangbin Dumemory layout like the following is suggested:: 144dec04cffSH. Peter Anvin 145dec04cffSH. Peter Anvin ~ ~ 146dec04cffSH. Peter Anvin | Protected-mode kernel | 147dec04cffSH. Peter Anvin 100000 +------------------------+ 148dec04cffSH. Peter Anvin | I/O memory hole | 149dec04cffSH. Peter Anvin 0A0000 +------------------------+ 150dec04cffSH. Peter Anvin | Reserved for BIOS | Leave as much as possible unused 151dec04cffSH. Peter Anvin ~ ~ 152dec04cffSH. Peter Anvin | Command line | (Can also be below the X+10000 mark) 153dec04cffSH. Peter Anvin X+10000 +------------------------+ 154dec04cffSH. Peter Anvin | Stack/heap | For use by the kernel real-mode code. 155dec04cffSH. Peter Anvin X+08000 +------------------------+ 156dec04cffSH. Peter Anvin | Kernel setup | The kernel real-mode code. 157dec04cffSH. Peter Anvin | Kernel boot sector | The kernel legacy boot sector. 158dec04cffSH. Peter Anvin X +------------------------+ 159dec04cffSH. Peter Anvin | Boot loader | <- Boot sector entry point 0000:7C00 160dec04cffSH. Peter Anvin 001000 +------------------------+ 161dec04cffSH. Peter Anvin | Reserved for MBR/BIOS | 162dec04cffSH. Peter Anvin 000800 +------------------------+ 163dec04cffSH. Peter Anvin | Typically used by MBR | 164dec04cffSH. Peter Anvin 000600 +------------------------+ 165dec04cffSH. Peter Anvin | BIOS use only | 166dec04cffSH. Peter Anvin 000000 +------------------------+ 167dec04cffSH. Peter Anvin 168f1f238a9SChangbin Du ... where the address X is as low as the design of the boot loader permits. 169dec04cffSH. Peter Anvin 1701da177e4SLinus Torvalds 171f1f238a9SChangbin DuThe Real-Mode Kernel Header 172f1f238a9SChangbin Du=========================== 1731da177e4SLinus Torvalds 1741da177e4SLinus TorvaldsIn the following text, and anywhere in the kernel boot sequence, "a 1751da177e4SLinus Torvaldssector" refers to 512 bytes. It is independent of the actual sector 1761da177e4SLinus Torvaldssize of the underlying medium. 1771da177e4SLinus Torvalds 1781da177e4SLinus TorvaldsThe first step in loading a Linux kernel should be to load the 1791da177e4SLinus Torvaldsreal-mode code (boot sector and setup code) and then examine the 1801da177e4SLinus Torvaldsfollowing header at offset 0x01f1. The real-mode code can total up to 1811da177e4SLinus Torvalds32K, although the boot loader may choose to load only the first two 1821da177e4SLinus Torvaldssectors (1K) and then examine the bootup sector size. 1831da177e4SLinus Torvalds 1841da177e4SLinus TorvaldsThe header looks like: 1851da177e4SLinus Torvalds 186f1f238a9SChangbin Du=========== ======== ===================== ============================================ 187f1f238a9SChangbin DuOffset/Size Proto Name Meaning 188f1f238a9SChangbin Du=========== ======== ===================== ============================================ 189f1f238a9SChangbin Du01F1/1 ALL(1) setup_sects The size of the setup in sectors 1901da177e4SLinus Torvalds01F2/2 ALL root_flags If set, the root is mounted readonly 191f1f238a9SChangbin Du01F4/4 2.04+(2) syssize The size of the 32-bit code in 16-byte paras 1921da177e4SLinus Torvalds01F8/2 ALL ram_size DO NOT USE - for bootsect.S use only 1931da177e4SLinus Torvalds01FA/2 ALL vid_mode Video mode control 1941da177e4SLinus Torvalds01FC/2 ALL root_dev Default root device number 1951da177e4SLinus Torvalds01FE/2 ALL boot_flag 0xAA55 magic number 1961da177e4SLinus Torvalds0200/2 2.00+ jump Jump instruction 1971da177e4SLinus Torvalds0202/4 2.00+ header Magic signature "HdrS" 1981da177e4SLinus Torvalds0206/2 2.00+ version Boot protocol version supported 1991da177e4SLinus Torvalds0208/4 2.00+ realmode_swtch Boot loader hook (see below) 200e56d0cfeSBaodong Chen020C/2 2.00+ start_sys_seg The load-low segment (0x1000) (obsolete) 2011da177e4SLinus Torvalds020E/2 2.00+ kernel_version Pointer to kernel version string 2021da177e4SLinus Torvalds0210/1 2.00+ type_of_loader Boot loader identifier 2031da177e4SLinus Torvalds0211/1 2.00+ loadflags Boot protocol option flags 2041da177e4SLinus Torvalds0212/2 2.00+ setup_move_size Move to high memory size (used with hooks) 2051da177e4SLinus Torvalds0214/4 2.00+ code32_start Boot loader hook (see below) 2061da177e4SLinus Torvalds0218/4 2.00+ ramdisk_image initrd load address (set by boot loader) 2071da177e4SLinus Torvalds021C/4 2.00+ ramdisk_size initrd size (set by boot loader) 2081da177e4SLinus Torvalds0220/4 2.00+ bootsect_kludge DO NOT USE - for bootsect.S use only 2091da177e4SLinus Torvalds0224/2 2.01+ heap_end_ptr Free memory after setup end 210f1f238a9SChangbin Du0226/1 2.02+(3) ext_loader_ver Extended boot loader version 211f1f238a9SChangbin Du0227/1 2.02+(3) ext_loader_type Extended boot loader ID 2121da177e4SLinus Torvalds0228/4 2.02+ cmd_line_ptr 32-bit pointer to the kernel command line 2133e920b53SBorislav Petkov022C/4 2.03+ initrd_addr_max Highest legal initrd address 214d263b213SVivek Goyal0230/4 2.05+ kernel_alignment Physical addr alignment required for kernel 215d263b213SVivek Goyal0234/1 2.05+ relocatable_kernel Whether kernel is relocatable or not 216d297366bSH. Peter Anvin0235/1 2.10+ min_alignment Minimum alignment, as a power of two 21709c205afSH. Peter Anvin0236/2 2.12+ xloadflags Boot protocol option flags 2188f9aeca7SBernhard Walle0238/4 2.06+ cmdline_size Maximum size of the kernel command line 219e5371ac5SRusty Russell023C/4 2.07+ hardware_subarch Hardware subarchitecture 220e5371ac5SRusty Russell0240/8 2.07+ hardware_subarch_data Subarchitecture-specific data 22187253d1bSIan Campbell0248/4 2.08+ payload_offset Offset of kernel payload 22287253d1bSIan Campbell024C/4 2.08+ payload_length Length of kernel payload 223fb884381SHuang, Ying0250/8 2.09+ setup_data 64-bit physical pointer to linked list 224fb884381SHuang, Ying of struct setup_data 225d297366bSH. Peter Anvin0258/8 2.10+ pref_address Preferred loading address 226d297366bSH. Peter Anvin0260/4 2.10+ init_size Linear memory required during initialization 2279ca8f72aSMatt Fleming0264/4 2.11+ handover_offset Offset of handover entry point 2282c33c27fSDaniel Kiper0268/4 2.15+ kernel_info_offset Offset of the kernel_info 229f1f238a9SChangbin Du=========== ======== ===================== ============================================ 2301da177e4SLinus Torvalds 231f1f238a9SChangbin Du.. note:: 232efba5970SAndy Shevchenko (1) For backwards compatibility, if the setup_sects field contains 0, 233efba5970SAndy Shevchenko the real value is 4. 2341da177e4SLinus Torvalds 235f8eeaaf4SH. Peter Anvin (2) For boot protocol prior to 2.04, the upper two bytes of the syssize 236f8eeaaf4SH. Peter Anvin field are unusable, which means the size of a bzImage kernel 237f8eeaaf4SH. Peter Anvin cannot be determined. 238f8eeaaf4SH. Peter Anvin 2395031296cSH. Peter Anvin (3) Ignored, but safe to set, for boot protocols 2.02-2.09. 2405031296cSH. Peter Anvin 2411da177e4SLinus TorvaldsIf the "HdrS" (0x53726448) magic number is not found at offset 0x202, 2421da177e4SLinus Torvaldsthe boot protocol version is "old". Loading an old kernel, the 243f1f238a9SChangbin Dufollowing parameters should be assumed:: 2441da177e4SLinus Torvalds 2451da177e4SLinus Torvalds Image type = zImage 2461da177e4SLinus Torvalds initrd not supported 2471da177e4SLinus Torvalds Real-mode kernel must be located at 0x90000. 2481da177e4SLinus Torvalds 2491da177e4SLinus TorvaldsOtherwise, the "version" field contains the protocol version, 2501da177e4SLinus Torvaldse.g. protocol version 2.01 will contain 0x0201 in this field. When 2511da177e4SLinus Torvaldssetting fields in the header, you must make sure only to set fields 2521da177e4SLinus Torvaldssupported by the protocol version in use. 2531da177e4SLinus Torvalds 2541da177e4SLinus Torvalds 255e156c617SEnrico WeigeltDetails of Header Fields 256f1f238a9SChangbin Du======================== 2571da177e4SLinus Torvalds 258dec04cffSH. Peter AnvinFor each field, some are information from the kernel to the bootloader 259dec04cffSH. Peter Anvin("read"), some are expected to be filled out by the bootloader 260dec04cffSH. Peter Anvin("write"), and some are expected to be read and modified by the 261dec04cffSH. Peter Anvinbootloader ("modify"). 262dec04cffSH. Peter Anvin 263dec04cffSH. Peter AnvinAll general purpose boot loaders should write the fields marked 264dec04cffSH. Peter Anvin(obligatory). Boot loaders who want to load the kernel at a 265dec04cffSH. Peter Anvinnonstandard address should fill in the fields marked (reloc); other 266dec04cffSH. Peter Anvinboot loaders can ignore those fields. 267dec04cffSH. Peter Anvin 268db2668fdSH. Peter AnvinThe byte order of all fields is little endian (this is x86, after all.) 269db2668fdSH. Peter Anvin 270f1f238a9SChangbin Du============ =========== 271e5371ac5SRusty RussellField name: setup_sects 272dec04cffSH. Peter AnvinType: read 273dec04cffSH. Peter AnvinOffset/size: 0x1f1/1 274dec04cffSH. Peter AnvinProtocol: ALL 275f1f238a9SChangbin Du============ =========== 276dec04cffSH. Peter Anvin 277dec04cffSH. Peter Anvin The size of the setup code in 512-byte sectors. If this field is 278dec04cffSH. Peter Anvin 0, the real value is 4. The real-mode code consists of the boot 279dec04cffSH. Peter Anvin sector (always one 512-byte sector) plus the setup code. 280dec04cffSH. Peter Anvin 281f1f238a9SChangbin Du============ ================= 282dec04cffSH. Peter AnvinField name: root_flags 283dec04cffSH. Peter AnvinType: modify (optional) 284dec04cffSH. Peter AnvinOffset/size: 0x1f2/2 285dec04cffSH. Peter AnvinProtocol: ALL 286f1f238a9SChangbin Du============ ================= 287dec04cffSH. Peter Anvin 288dec04cffSH. Peter Anvin If this field is nonzero, the root defaults to readonly. The use of 289dec04cffSH. Peter Anvin this field is deprecated; use the "ro" or "rw" options on the 290dec04cffSH. Peter Anvin command line instead. 291dec04cffSH. Peter Anvin 292f1f238a9SChangbin Du============ =============================================== 293dec04cffSH. Peter AnvinField name: syssize 294dec04cffSH. Peter AnvinType: read 295dec04cffSH. Peter AnvinOffset/size: 0x1f4/4 (protocol 2.04+) 0x1f4/2 (protocol ALL) 296dec04cffSH. Peter AnvinProtocol: 2.04+ 297f1f238a9SChangbin Du============ =============================================== 298dec04cffSH. Peter Anvin 299dec04cffSH. Peter Anvin The size of the protected-mode code in units of 16-byte paragraphs. 300dec04cffSH. Peter Anvin For protocol versions older than 2.04 this field is only two bytes 301dec04cffSH. Peter Anvin wide, and therefore cannot be trusted for the size of a kernel if 302dec04cffSH. Peter Anvin the LOAD_HIGH flag is set. 303dec04cffSH. Peter Anvin 304f1f238a9SChangbin Du============ =============== 305dec04cffSH. Peter AnvinField name: ram_size 306dec04cffSH. Peter AnvinType: kernel internal 307dec04cffSH. Peter AnvinOffset/size: 0x1f8/2 308dec04cffSH. Peter AnvinProtocol: ALL 309f1f238a9SChangbin Du============ =============== 310dec04cffSH. Peter Anvin 311dec04cffSH. Peter Anvin This field is obsolete. 312dec04cffSH. Peter Anvin 313f1f238a9SChangbin Du============ =================== 314dec04cffSH. Peter AnvinField name: vid_mode 315dec04cffSH. Peter AnvinType: modify (obligatory) 316dec04cffSH. Peter AnvinOffset/size: 0x1fa/2 317f1f238a9SChangbin Du============ =================== 318dec04cffSH. Peter Anvin 3191da177e4SLinus Torvalds Please see the section on SPECIAL COMMAND LINE OPTIONS. 3201da177e4SLinus Torvalds 321f1f238a9SChangbin Du============ ================= 322dec04cffSH. Peter AnvinField name: root_dev 323dec04cffSH. Peter AnvinType: modify (optional) 324dec04cffSH. Peter AnvinOffset/size: 0x1fc/2 325dec04cffSH. Peter AnvinProtocol: ALL 326f1f238a9SChangbin Du============ ================= 327dec04cffSH. Peter Anvin 328dec04cffSH. Peter Anvin The default root device device number. The use of this field is 329dec04cffSH. Peter Anvin deprecated, use the "root=" option on the command line instead. 330dec04cffSH. Peter Anvin 331f1f238a9SChangbin Du============ ========= 332dec04cffSH. Peter AnvinField name: boot_flag 333dec04cffSH. Peter AnvinType: read 334dec04cffSH. Peter AnvinOffset/size: 0x1fe/2 335dec04cffSH. Peter AnvinProtocol: ALL 336f1f238a9SChangbin Du============ ========= 337dec04cffSH. Peter Anvin 338dec04cffSH. Peter Anvin Contains 0xAA55. This is the closest thing old Linux kernels have 339dec04cffSH. Peter Anvin to a magic number. 340dec04cffSH. Peter Anvin 341f1f238a9SChangbin Du============ ======= 342dec04cffSH. Peter AnvinField name: jump 343dec04cffSH. Peter AnvinType: read 344dec04cffSH. Peter AnvinOffset/size: 0x200/2 345dec04cffSH. Peter AnvinProtocol: 2.00+ 346f1f238a9SChangbin Du============ ======= 347dec04cffSH. Peter Anvin 348dec04cffSH. Peter Anvin Contains an x86 jump instruction, 0xEB followed by a signed offset 349dec04cffSH. Peter Anvin relative to byte 0x202. This can be used to determine the size of 350dec04cffSH. Peter Anvin the header. 351dec04cffSH. Peter Anvin 352f1f238a9SChangbin Du============ ======= 353dec04cffSH. Peter AnvinField name: header 354dec04cffSH. Peter AnvinType: read 355dec04cffSH. Peter AnvinOffset/size: 0x202/4 356dec04cffSH. Peter AnvinProtocol: 2.00+ 357f1f238a9SChangbin Du============ ======= 358dec04cffSH. Peter Anvin 359dec04cffSH. Peter Anvin Contains the magic number "HdrS" (0x53726448). 360dec04cffSH. Peter Anvin 361f1f238a9SChangbin Du============ ======= 362dec04cffSH. Peter AnvinField name: version 36338418404SJuergen GrossType: read 364dec04cffSH. Peter AnvinOffset/size: 0x206/2 365dec04cffSH. Peter AnvinProtocol: 2.00+ 366f1f238a9SChangbin Du============ ======= 367dec04cffSH. Peter Anvin 368db2668fdSH. Peter Anvin Contains the boot protocol version, in (major << 8) + minor format, 369db2668fdSH. Peter Anvin e.g. 0x0204 for version 2.04, and 0x0a11 for a hypothetical version 370db2668fdSH. Peter Anvin 10.17. 371dec04cffSH. Peter Anvin 372f1f238a9SChangbin Du============ ================= 373e56d0cfeSBaodong ChenField name: realmode_swtch 374dec04cffSH. Peter AnvinType: modify (optional) 375dec04cffSH. Peter AnvinOffset/size: 0x208/4 376dec04cffSH. Peter AnvinProtocol: 2.00+ 377f1f238a9SChangbin Du============ ================= 378dec04cffSH. Peter Anvin 379db2668fdSH. Peter Anvin Boot loader hook (see ADVANCED BOOT LOADER HOOKS below.) 380dec04cffSH. Peter Anvin 381f1f238a9SChangbin Du============ ============= 382e56d0cfeSBaodong ChenField name: start_sys_seg 383dec04cffSH. Peter AnvinType: read 384a021e512SH. Peter AnvinOffset/size: 0x20c/2 385dec04cffSH. Peter AnvinProtocol: 2.00+ 386f1f238a9SChangbin Du============ ============= 387dec04cffSH. Peter Anvin 388dec04cffSH. Peter Anvin The load low segment (0x1000). Obsolete. 389dec04cffSH. Peter Anvin 390f1f238a9SChangbin Du============ ============== 391dec04cffSH. Peter AnvinField name: kernel_version 392dec04cffSH. Peter AnvinType: read 393dec04cffSH. Peter AnvinOffset/size: 0x20e/2 394dec04cffSH. Peter AnvinProtocol: 2.00+ 395f1f238a9SChangbin Du============ ============== 396dec04cffSH. Peter Anvin 397dec04cffSH. Peter Anvin If set to a nonzero value, contains a pointer to a NUL-terminated 398dec04cffSH. Peter Anvin human-readable kernel version number string, less 0x200. This can 399dec04cffSH. Peter Anvin be used to display the kernel version to the user. This value 400db2668fdSH. Peter Anvin should be less than (0x200 * setup_sects). 401db2668fdSH. Peter Anvin 402db2668fdSH. Peter Anvin For example, if this value is set to 0x1c00, the kernel version 403db2668fdSH. Peter Anvin number string can be found at offset 0x1e00 in the kernel file. 404db2668fdSH. Peter Anvin This is a valid value if and only if the "setup_sects" field 405f1f238a9SChangbin Du contains the value 15 or higher, as:: 406db2668fdSH. Peter Anvin 407db2668fdSH. Peter Anvin 0x1c00 < 15 * 0x200 (= 0x1e00) but 408db2668fdSH. Peter Anvin 0x1c00 >= 14 * 0x200 (= 0x1c00) 409db2668fdSH. Peter Anvin 410f1f238a9SChangbin Du 0x1c00 >> 9 = 14, So the minimum value for setup_secs is 15. 411dec04cffSH. Peter Anvin 412f1f238a9SChangbin Du============ ================== 413dec04cffSH. Peter AnvinField name: type_of_loader 414dec04cffSH. Peter AnvinType: write (obligatory) 415dec04cffSH. Peter AnvinOffset/size: 0x210/1 416dec04cffSH. Peter AnvinProtocol: 2.00+ 417f1f238a9SChangbin Du============ ================== 418dec04cffSH. Peter Anvin 4191da177e4SLinus Torvalds If your boot loader has an assigned id (see table below), enter 4201da177e4SLinus Torvalds 0xTV here, where T is an identifier for the boot loader and V is 4211da177e4SLinus Torvalds a version number. Otherwise, enter 0xFF here. 4221da177e4SLinus Torvalds 4235031296cSH. Peter Anvin For boot loader IDs above T = 0xD, write T = 0xE to this field and 4245031296cSH. Peter Anvin write the extended ID minus 0x10 to the ext_loader_type field. 4255031296cSH. Peter Anvin Similarly, the ext_loader_ver field can be used to provide more than 4265031296cSH. Peter Anvin four bits for the bootloader version. 4275031296cSH. Peter Anvin 428f1f238a9SChangbin Du For example, for T = 0x15, V = 0x234, write:: 4295031296cSH. Peter Anvin 4305031296cSH. Peter Anvin type_of_loader <- 0xE4 4315031296cSH. Peter Anvin ext_loader_type <- 0x05 4325031296cSH. Peter Anvin ext_loader_ver <- 0x23 4335031296cSH. Peter Anvin 434c5e5c42aSH. Peter Anvin Assigned boot loader ids (hexadecimal): 435c5e5c42aSH. Peter Anvin 436f1f238a9SChangbin Du == ======================================= 437f1f238a9SChangbin Du 0 LILO 438f1f238a9SChangbin Du (0x00 reserved for pre-2.00 bootloader) 4391da177e4SLinus Torvalds 1 Loadlin 440f1f238a9SChangbin Du 2 bootsect-loader 441f1f238a9SChangbin Du (0x20, all other values reserved) 4425031296cSH. Peter Anvin 3 Syslinux 443cd34ab8bSH. Peter Anvin 4 Etherboot/gPXE/iPXE 4441da177e4SLinus Torvalds 5 ELILO 4459ee670fdSKOSAKI Motohiro 7 GRUB 4465031296cSH. Peter Anvin 8 U-Boot 447354332eeSJeremy Fitzhardinge 9 Xen 448c229ec5dSH. Peter Anvin A Gujin 449dec04cffSH. Peter Anvin B Qemu 4505031296cSH. Peter Anvin C Arcturus Networks uCbootloader 4514bfe24acSH. Peter Anvin D kexec-tools 4525031296cSH. Peter Anvin E Extended (see ext_loader_type) 4535031296cSH. Peter Anvin F Special (0xFF = undefined) 454c5e5c42aSH. Peter Anvin 10 Reserved 455f1f238a9SChangbin Du 11 Minimal Linux Bootloader 456f1f238a9SChangbin Du <http://sebastian-plotz.blogspot.de> 457686966d8SH. Peter Anvin 12 OVMF UEFI virtualization stack 458a27e292bSAhmad Fatoum 13 barebox 459f1f238a9SChangbin Du == ======================================= 4601da177e4SLinus Torvalds 461f1f238a9SChangbin Du Please contact <hpa@zytor.com> if you need a bootloader ID value assigned. 4621da177e4SLinus Torvalds 463f1f238a9SChangbin Du============ =================== 464dec04cffSH. Peter AnvinField name: loadflags 465dec04cffSH. Peter AnvinType: modify (obligatory) 466dec04cffSH. Peter AnvinOffset/size: 0x211/1 467dec04cffSH. Peter AnvinProtocol: 2.00+ 468f1f238a9SChangbin Du============ =================== 4691da177e4SLinus Torvalds 470dec04cffSH. Peter Anvin This field is a bitmask. 4711da177e4SLinus Torvalds 472dec04cffSH. Peter Anvin Bit 0 (read): LOADED_HIGH 473f1f238a9SChangbin Du 474dec04cffSH. Peter Anvin - If 0, the protected-mode code is loaded at 0x10000. 475dec04cffSH. Peter Anvin - If 1, the protected-mode code is loaded at 0x100000. 476de372ecdSH. Peter Anvin 477d4bd4415SMiroslav Benes Bit 1 (kernel internal): KASLR_FLAG 478f1f238a9SChangbin Du 47978cac48cSBorislav Petkov - Used internally by the compressed kernel to communicate 48078cac48cSBorislav Petkov KASLR status to kernel proper. 481f1f238a9SChangbin Du 482f1f238a9SChangbin Du - If 1, KASLR enabled. 483f1f238a9SChangbin Du - If 0, KASLR disabled. 48478cac48cSBorislav Petkov 4854039feb5SH. Peter Anvin Bit 5 (write): QUIET_FLAG 486f1f238a9SChangbin Du 4874039feb5SH. Peter Anvin - If 0, print early messages. 4884039feb5SH. Peter Anvin - If 1, suppress early messages. 489f1f238a9SChangbin Du 4904039feb5SH. Peter Anvin This requests to the kernel (decompressor and early 4914039feb5SH. Peter Anvin kernel) to not write early messages that require 4924039feb5SH. Peter Anvin accessing the display hardware directly. 4934039feb5SH. Peter Anvin 49467a6af7aSArvind Sankar Bit 6 (obsolete): KEEP_SEGMENTS 495f1f238a9SChangbin Du 496e5371ac5SRusty Russell Protocol: 2.07+ 497f1f238a9SChangbin Du 49867a6af7aSArvind Sankar - This flag is obsolete. 499e5371ac5SRusty Russell 500dec04cffSH. Peter Anvin Bit 7 (write): CAN_USE_HEAP 501f1f238a9SChangbin Du 502dec04cffSH. Peter Anvin Set this bit to 1 to indicate that the value entered in the 503dec04cffSH. Peter Anvin heap_end_ptr is valid. If this field is clear, some setup code 504dec04cffSH. Peter Anvin functionality will be disabled. 5051da177e4SLinus Torvalds 506f1f238a9SChangbin Du 507f1f238a9SChangbin Du============ =================== 508dec04cffSH. Peter AnvinField name: setup_move_size 509dec04cffSH. Peter AnvinType: modify (obligatory) 510dec04cffSH. Peter AnvinOffset/size: 0x212/2 511dec04cffSH. Peter AnvinProtocol: 2.00-2.01 512f1f238a9SChangbin Du============ =================== 5131da177e4SLinus Torvalds 514dec04cffSH. Peter Anvin When using protocol 2.00 or 2.01, if the real mode kernel is not 515dec04cffSH. Peter Anvin loaded at 0x90000, it gets moved there later in the loading 516dec04cffSH. Peter Anvin sequence. Fill in this field if you want additional data (such as 517dec04cffSH. Peter Anvin the kernel command line) moved in addition to the real-mode kernel 518dec04cffSH. Peter Anvin itself. 519dec04cffSH. Peter Anvin 520dec04cffSH. Peter Anvin The unit is bytes starting with the beginning of the boot sector. 521dec04cffSH. Peter Anvin 522dec04cffSH. Peter Anvin This field is can be ignored when the protocol is 2.02 or higher, or 523dec04cffSH. Peter Anvin if the real-mode code is loaded at 0x90000. 524dec04cffSH. Peter Anvin 525f1f238a9SChangbin Du============ ======================== 526dec04cffSH. Peter AnvinField name: code32_start 527dec04cffSH. Peter AnvinType: modify (optional, reloc) 528dec04cffSH. Peter AnvinOffset/size: 0x214/4 529dec04cffSH. Peter AnvinProtocol: 2.00+ 530f1f238a9SChangbin Du============ ======================== 531dec04cffSH. Peter Anvin 532dec04cffSH. Peter Anvin The address to jump to in protected mode. This defaults to the load 533dec04cffSH. Peter Anvin address of the kernel, and can be used by the boot loader to 534dec04cffSH. Peter Anvin determine the proper load address. 535dec04cffSH. Peter Anvin 536dec04cffSH. Peter Anvin This field can be modified for two purposes: 537dec04cffSH. Peter Anvin 538f1f238a9SChangbin Du 1. as a boot loader hook (see Advanced Boot Loader Hooks below.) 539dec04cffSH. Peter Anvin 540dec04cffSH. Peter Anvin 2. if a bootloader which does not install a hook loads a 541dec04cffSH. Peter Anvin relocatable kernel at a nonstandard address it will have to modify 542dec04cffSH. Peter Anvin this field to point to the load address. 543dec04cffSH. Peter Anvin 544f1f238a9SChangbin Du============ ================== 545dec04cffSH. Peter AnvinField name: ramdisk_image 546dec04cffSH. Peter AnvinType: write (obligatory) 547dec04cffSH. Peter AnvinOffset/size: 0x218/4 548dec04cffSH. Peter AnvinProtocol: 2.00+ 549f1f238a9SChangbin Du============ ================== 550dec04cffSH. Peter Anvin 551dec04cffSH. Peter Anvin The 32-bit linear address of the initial ramdisk or ramfs. Leave at 552dec04cffSH. Peter Anvin zero if there is no initial ramdisk/ramfs. 553dec04cffSH. Peter Anvin 554f1f238a9SChangbin Du============ ================== 555dec04cffSH. Peter AnvinField name: ramdisk_size 556dec04cffSH. Peter AnvinType: write (obligatory) 557dec04cffSH. Peter AnvinOffset/size: 0x21c/4 558dec04cffSH. Peter AnvinProtocol: 2.00+ 559f1f238a9SChangbin Du============ ================== 560dec04cffSH. Peter Anvin 561dec04cffSH. Peter Anvin Size of the initial ramdisk or ramfs. Leave at zero if there is no 562dec04cffSH. Peter Anvin initial ramdisk/ramfs. 563dec04cffSH. Peter Anvin 564f1f238a9SChangbin Du============ =============== 565dec04cffSH. Peter AnvinField name: bootsect_kludge 566dec04cffSH. Peter AnvinType: kernel internal 567dec04cffSH. Peter AnvinOffset/size: 0x220/4 568dec04cffSH. Peter AnvinProtocol: 2.00+ 569f1f238a9SChangbin Du============ =============== 570dec04cffSH. Peter Anvin 571dec04cffSH. Peter Anvin This field is obsolete. 572dec04cffSH. Peter Anvin 573f1f238a9SChangbin Du============ ================== 574dec04cffSH. Peter AnvinField name: heap_end_ptr 575dec04cffSH. Peter AnvinType: write (obligatory) 576dec04cffSH. Peter AnvinOffset/size: 0x224/2 577dec04cffSH. Peter AnvinProtocol: 2.01+ 578f1f238a9SChangbin Du============ ================== 579dec04cffSH. Peter Anvin 580dec04cffSH. Peter Anvin Set this field to the offset (from the beginning of the real-mode 581dec04cffSH. Peter Anvin code) of the end of the setup stack/heap, minus 0x0200. 582dec04cffSH. Peter Anvin 583f1f238a9SChangbin Du============ ================ 5845031296cSH. Peter AnvinField name: ext_loader_ver 5855031296cSH. Peter AnvinType: write (optional) 5865031296cSH. Peter AnvinOffset/size: 0x226/1 5875031296cSH. Peter AnvinProtocol: 2.02+ 588f1f238a9SChangbin Du============ ================ 5895031296cSH. Peter Anvin 5905031296cSH. Peter Anvin This field is used as an extension of the version number in the 5915031296cSH. Peter Anvin type_of_loader field. The total version number is considered to be 5925031296cSH. Peter Anvin (type_of_loader & 0x0f) + (ext_loader_ver << 4). 5935031296cSH. Peter Anvin 5945031296cSH. Peter Anvin The use of this field is boot loader specific. If not written, it 5955031296cSH. Peter Anvin is zero. 5965031296cSH. Peter Anvin 5975031296cSH. Peter Anvin Kernels prior to 2.6.31 did not recognize this field, but it is safe 5985031296cSH. Peter Anvin to write for protocol version 2.02 or higher. 5995031296cSH. Peter Anvin 600f1f238a9SChangbin Du============ ===================================================== 6015031296cSH. Peter AnvinField name: ext_loader_type 6025031296cSH. Peter AnvinType: write (obligatory if (type_of_loader & 0xf0) == 0xe0) 6035031296cSH. Peter AnvinOffset/size: 0x227/1 6045031296cSH. Peter AnvinProtocol: 2.02+ 605f1f238a9SChangbin Du============ ===================================================== 6065031296cSH. Peter Anvin 6075031296cSH. Peter Anvin This field is used as an extension of the type number in 6085031296cSH. Peter Anvin type_of_loader field. If the type in type_of_loader is 0xE, then 6095031296cSH. Peter Anvin the actual type is (ext_loader_type + 0x10). 6105031296cSH. Peter Anvin 6115031296cSH. Peter Anvin This field is ignored if the type in type_of_loader is not 0xE. 6125031296cSH. Peter Anvin 6135031296cSH. Peter Anvin Kernels prior to 2.6.31 did not recognize this field, but it is safe 6145031296cSH. Peter Anvin to write for protocol version 2.02 or higher. 6155031296cSH. Peter Anvin 616f1f238a9SChangbin Du============ ================== 617dec04cffSH. Peter AnvinField name: cmd_line_ptr 618dec04cffSH. Peter AnvinType: write (obligatory) 619dec04cffSH. Peter AnvinOffset/size: 0x228/4 620dec04cffSH. Peter AnvinProtocol: 2.02+ 621f1f238a9SChangbin Du============ ================== 622dec04cffSH. Peter Anvin 623dec04cffSH. Peter Anvin Set this field to the linear address of the kernel command line. 624dec04cffSH. Peter Anvin The kernel command line can be located anywhere between the end of 625dec04cffSH. Peter Anvin the setup heap and 0xA0000; it does not have to be located in the 626dec04cffSH. Peter Anvin same 64K segment as the real-mode code itself. 627dec04cffSH. Peter Anvin 6281da177e4SLinus Torvalds Fill in this field even if your boot loader does not support a 629dec04cffSH. Peter Anvin command line, in which case you can point this to an empty string 630dec04cffSH. Peter Anvin (or better yet, to the string "auto".) If this field is left at 631dec04cffSH. Peter Anvin zero, the kernel will assume that your boot loader does not support 632dec04cffSH. Peter Anvin the 2.02+ protocol. 6331da177e4SLinus Torvalds 634f1f238a9SChangbin Du============ =============== 6353e920b53SBorislav PetkovField name: initrd_addr_max 636dec04cffSH. Peter AnvinType: read 637dec04cffSH. Peter AnvinOffset/size: 0x22c/4 638dec04cffSH. Peter AnvinProtocol: 2.03+ 639f1f238a9SChangbin Du============ =============== 640dec04cffSH. Peter Anvin 641dec04cffSH. Peter Anvin The maximum address that may be occupied by the initial 642dec04cffSH. Peter Anvin ramdisk/ramfs contents. For boot protocols 2.02 or earlier, this 643dec04cffSH. Peter Anvin field is not present, and the maximum address is 0x37FFFFFF. (This 644dec04cffSH. Peter Anvin address is defined as the address of the highest safe byte, so if 645dec04cffSH. Peter Anvin your ramdisk is exactly 131072 bytes long and this field is 6461da177e4SLinus Torvalds 0x37FFFFFF, you can start your ramdisk at 0x37FE0000.) 6471da177e4SLinus Torvalds 648f1f238a9SChangbin Du============ ============================ 649dec04cffSH. Peter AnvinField name: kernel_alignment 650d297366bSH. Peter AnvinType: read/modify (reloc) 651dec04cffSH. Peter AnvinOffset/size: 0x230/4 652d297366bSH. Peter AnvinProtocol: 2.05+ (read), 2.10+ (modify) 653f1f238a9SChangbin Du============ ============================ 654dec04cffSH. Peter Anvin 655d297366bSH. Peter Anvin Alignment unit required by the kernel (if relocatable_kernel is 656d297366bSH. Peter Anvin true.) A relocatable kernel that is loaded at an alignment 657d297366bSH. Peter Anvin incompatible with the value in this field will be realigned during 658d297366bSH. Peter Anvin kernel initialization. 659d297366bSH. Peter Anvin 660d297366bSH. Peter Anvin Starting with protocol version 2.10, this reflects the kernel 661d297366bSH. Peter Anvin alignment preferred for optimal performance; it is possible for the 662d297366bSH. Peter Anvin loader to modify this field to permit a lesser alignment. See the 663d297366bSH. Peter Anvin min_alignment and pref_address field below. 664dec04cffSH. Peter Anvin 665f1f238a9SChangbin Du============ ================== 666dec04cffSH. Peter AnvinField name: relocatable_kernel 667dec04cffSH. Peter AnvinType: read (reloc) 668dec04cffSH. Peter AnvinOffset/size: 0x234/1 669dec04cffSH. Peter AnvinProtocol: 2.05+ 670f1f238a9SChangbin Du============ ================== 671dec04cffSH. Peter Anvin 672dec04cffSH. Peter Anvin If this field is nonzero, the protected-mode part of the kernel can 673dec04cffSH. Peter Anvin be loaded at any address that satisfies the kernel_alignment field. 674dec04cffSH. Peter Anvin After loading, the boot loader must set the code32_start field to 675dec04cffSH. Peter Anvin point to the loaded code, or to a boot loader hook. 676dec04cffSH. Peter Anvin 677f1f238a9SChangbin Du============ ============= 678d297366bSH. Peter AnvinField name: min_alignment 679d297366bSH. Peter AnvinType: read (reloc) 680d297366bSH. Peter AnvinOffset/size: 0x235/1 681d297366bSH. Peter AnvinProtocol: 2.10+ 682f1f238a9SChangbin Du============ ============= 683d297366bSH. Peter Anvin 684d297366bSH. Peter Anvin This field, if nonzero, indicates as a power of two the minimum 685d297366bSH. Peter Anvin alignment required, as opposed to preferred, by the kernel to boot. 686d297366bSH. Peter Anvin If a boot loader makes use of this field, it should update the 687f1f238a9SChangbin Du kernel_alignment field with the alignment unit desired; typically:: 688d297366bSH. Peter Anvin 689f23d79d6SAndy Shevchenko kernel_alignment = 1 << min_alignment; 690d297366bSH. Peter Anvin 691d297366bSH. Peter Anvin There may be a considerable performance cost with an excessively 692d297366bSH. Peter Anvin misaligned kernel. Therefore, a loader should typically try each 693d297366bSH. Peter Anvin power-of-two alignment from kernel_alignment down to this alignment. 694d297366bSH. Peter Anvin 695f1f238a9SChangbin Du============ ========== 69609c205afSH. Peter AnvinField name: xloadflags 69709c205afSH. Peter AnvinType: read 69809c205afSH. Peter AnvinOffset/size: 0x236/2 69909c205afSH. Peter AnvinProtocol: 2.12+ 700f1f238a9SChangbin Du============ ========== 70109c205afSH. Peter Anvin 70209c205afSH. Peter Anvin This field is a bitmask. 70309c205afSH. Peter Anvin 70409c205afSH. Peter Anvin Bit 0 (read): XLF_KERNEL_64 705f1f238a9SChangbin Du 70609c205afSH. Peter Anvin - If 1, this kernel has the legacy 64-bit entry point at 0x200. 70709c205afSH. Peter Anvin 70809c205afSH. Peter Anvin Bit 1 (read): XLF_CAN_BE_LOADED_ABOVE_4G 709f1f238a9SChangbin Du 71009c205afSH. Peter Anvin - If 1, kernel/boot_params/cmdline/ramdisk can be above 4G. 71109c205afSH. Peter Anvin 71209c205afSH. Peter Anvin Bit 2 (read): XLF_EFI_HANDOVER_32 713f1f238a9SChangbin Du 71409c205afSH. Peter Anvin - If 1, the kernel supports the 32-bit EFI handoff entry point 71509c205afSH. Peter Anvin given at handover_offset. 71609c205afSH. Peter Anvin 71709c205afSH. Peter Anvin Bit 3 (read): XLF_EFI_HANDOVER_64 718f1f238a9SChangbin Du 71909c205afSH. Peter Anvin - If 1, the kernel supports the 64-bit EFI handoff entry point 72009c205afSH. Peter Anvin given at handover_offset + 0x200. 72109c205afSH. Peter Anvin 722456a29ddSDave Young Bit 4 (read): XLF_EFI_KEXEC 723f1f238a9SChangbin Du 724456a29ddSDave Young - If 1, the kernel supports kexec EFI boot with EFI runtime support. 725456a29ddSDave Young 726f1f238a9SChangbin Du 727f1f238a9SChangbin Du============ ============ 728dec04cffSH. Peter AnvinField name: cmdline_size 729dec04cffSH. Peter AnvinType: read 730dec04cffSH. Peter AnvinOffset/size: 0x238/4 731dec04cffSH. Peter AnvinProtocol: 2.06+ 732f1f238a9SChangbin Du============ ============ 733dec04cffSH. Peter Anvin 7348f9aeca7SBernhard Walle The maximum size of the command line without the terminating 7358f9aeca7SBernhard Walle zero. This means that the command line can contain at most 736dec04cffSH. Peter Anvin cmdline_size characters. With protocol version 2.05 and earlier, the 737dec04cffSH. Peter Anvin maximum size was 255. 7388f9aeca7SBernhard Walle 739f1f238a9SChangbin Du============ ==================================== 740e5371ac5SRusty RussellField name: hardware_subarch 7414039feb5SH. Peter AnvinType: write (optional, defaults to x86/PC) 742e5371ac5SRusty RussellOffset/size: 0x23c/4 743e5371ac5SRusty RussellProtocol: 2.07+ 744f1f238a9SChangbin Du============ ==================================== 745e5371ac5SRusty Russell 746e5371ac5SRusty Russell In a paravirtualized environment the hardware low level architectural 747e5371ac5SRusty Russell pieces such as interrupt handling, page table handling, and 748e5371ac5SRusty Russell accessing process control registers needs to be done differently. 749e5371ac5SRusty Russell 750e5371ac5SRusty Russell This field allows the bootloader to inform the kernel we are in one 751e5371ac5SRusty Russell one of those environments. 752e5371ac5SRusty Russell 753f1f238a9SChangbin Du ========== ============================== 754e5371ac5SRusty Russell 0x00000000 The default x86/PC environment 755e5371ac5SRusty Russell 0x00000001 lguest 756e5371ac5SRusty Russell 0x00000002 Xen 757*9fc78ffaSAndy Shevchenko 0x00000003 Intel MID (Moorestown, CloverTrail, Merrifield, Moorefield) 758c751e17bSThomas Gleixner 0x00000004 CE4100 TV Platform 759f1f238a9SChangbin Du ========== ============================== 760e5371ac5SRusty Russell 761f1f238a9SChangbin Du============ ========================= 762e5371ac5SRusty RussellField name: hardware_subarch_data 7634039feb5SH. Peter AnvinType: write (subarch-dependent) 764e5371ac5SRusty RussellOffset/size: 0x240/8 765e5371ac5SRusty RussellProtocol: 2.07+ 766f1f238a9SChangbin Du============ ========================= 767e5371ac5SRusty Russell 768e5371ac5SRusty Russell A pointer to data that is specific to hardware subarch 7694039feb5SH. Peter Anvin This field is currently unused for the default x86/PC environment, 7704039feb5SH. Peter Anvin do not modify. 771e5371ac5SRusty Russell 772f1f238a9SChangbin Du============ ============== 77387253d1bSIan CampbellField name: payload_offset 774099e1377SIan CampbellType: read 775099e1377SIan CampbellOffset/size: 0x248/4 776099e1377SIan CampbellProtocol: 2.08+ 777f1f238a9SChangbin Du============ ============== 778099e1377SIan Campbell 779e1286f2cSPhilipp Kohlbecher If non-zero then this field contains the offset from the beginning 780e1286f2cSPhilipp Kohlbecher of the protected-mode code to the payload. 781099e1377SIan Campbell 78287253d1bSIan Campbell The payload may be compressed. The format of both the compressed and 78387253d1bSIan Campbell uncompressed data should be determined using the standard magic 784ee287587SH. Peter Anvin numbers. The currently supported compression formats are gzip 78530314804SLasse Collin (magic numbers 1F 8B or 1F 9E), bzip2 (magic number 42 5A), LZMA 786fb46d057SNick Terrell (magic number 5D 00), XZ (magic number FD 37), LZ4 (magic number 787fb46d057SNick Terrell 02 21) and ZSTD (magic number 28 B5). The uncompressed payload is 788fb46d057SNick Terrell currently always ELF (magic number 7F 45 4C 46). 78987253d1bSIan Campbell 790f1f238a9SChangbin Du============ ============== 79187253d1bSIan CampbellField name: payload_length 792099e1377SIan CampbellType: read 793099e1377SIan CampbellOffset/size: 0x24c/4 794099e1377SIan CampbellProtocol: 2.08+ 795f1f238a9SChangbin Du============ ============== 796099e1377SIan Campbell 79787253d1bSIan Campbell The length of the payload. 7981da177e4SLinus Torvalds 799f1f238a9SChangbin Du============ =============== 8004039feb5SH. Peter AnvinField name: setup_data 8014039feb5SH. Peter AnvinType: write (special) 8024039feb5SH. Peter AnvinOffset/size: 0x250/8 8034039feb5SH. Peter AnvinProtocol: 2.09+ 804f1f238a9SChangbin Du============ =============== 8054039feb5SH. Peter Anvin 8064039feb5SH. Peter Anvin The 64-bit physical pointer to NULL terminated single linked list of 8074039feb5SH. Peter Anvin struct setup_data. This is used to define a more extensible boot 8084039feb5SH. Peter Anvin parameters passing mechanism. The definition of struct setup_data is 809f1f238a9SChangbin Du as follow:: 8104039feb5SH. Peter Anvin 8114039feb5SH. Peter Anvin struct setup_data { 812f23d79d6SAndy Shevchenko __u64 next; 813f23d79d6SAndy Shevchenko __u32 type; 814f23d79d6SAndy Shevchenko __u32 len; 815f23d79d6SAndy Shevchenko __u8 data[]; 816f23d79d6SAndy Shevchenko } 8174039feb5SH. Peter Anvin 8184039feb5SH. Peter Anvin Where, the next is a 64-bit physical pointer to the next node of 8194039feb5SH. Peter Anvin linked list, the next field of the last node is 0; the type is used 8204039feb5SH. Peter Anvin to identify the contents of data; the len is the length of data 8214039feb5SH. Peter Anvin field; the data holds the real payload. 8224039feb5SH. Peter Anvin 8234039feb5SH. Peter Anvin This list may be modified at a number of points during the bootup 8244039feb5SH. Peter Anvin process. Therefore, when modifying this list one should always make 8254039feb5SH. Peter Anvin sure to consider the case where the linked list already contains 8264039feb5SH. Peter Anvin entries. 8274039feb5SH. Peter Anvin 828b3c72fc9SDaniel Kiper The setup_data is a bit awkward to use for extremely large data objects, 829b3c72fc9SDaniel Kiper both because the setup_data header has to be adjacent to the data object 830b3c72fc9SDaniel Kiper and because it has a 32-bit length field. However, it is important that 831b3c72fc9SDaniel Kiper intermediate stages of the boot process have a way to identify which 832b3c72fc9SDaniel Kiper chunks of memory are occupied by kernel data. 833b3c72fc9SDaniel Kiper 834b3c72fc9SDaniel Kiper Thus setup_indirect struct and SETUP_INDIRECT type were introduced in 835e43630edSDaniel W. S. Almeida protocol 2.15:: 836b3c72fc9SDaniel Kiper 837b3c72fc9SDaniel Kiper struct setup_indirect { 838b3c72fc9SDaniel Kiper __u32 type; 839b3c72fc9SDaniel Kiper __u32 reserved; /* Reserved, must be set to zero. */ 840b3c72fc9SDaniel Kiper __u64 len; 841b3c72fc9SDaniel Kiper __u64 addr; 842b3c72fc9SDaniel Kiper }; 843b3c72fc9SDaniel Kiper 844b3c72fc9SDaniel Kiper The type member is a SETUP_INDIRECT | SETUP_* type. However, it cannot be 845b3c72fc9SDaniel Kiper SETUP_INDIRECT itself since making the setup_indirect a tree structure 846b3c72fc9SDaniel Kiper could require a lot of stack space in something that needs to parse it 847b3c72fc9SDaniel Kiper and stack space can be limited in boot contexts. 848b3c72fc9SDaniel Kiper 849b3c72fc9SDaniel Kiper Let's give an example how to point to SETUP_E820_EXT data using setup_indirect. 850e43630edSDaniel W. S. Almeida In this case setup_data and setup_indirect will look like this:: 851b3c72fc9SDaniel Kiper 852b3c72fc9SDaniel Kiper struct setup_data { 853f23d79d6SAndy Shevchenko .next = 0, /* or <addr_of_next_setup_data_struct> */ 854f23d79d6SAndy Shevchenko .type = SETUP_INDIRECT, 855f23d79d6SAndy Shevchenko .len = sizeof(setup_indirect), 856f23d79d6SAndy Shevchenko .data[sizeof(setup_indirect)] = (struct setup_indirect) { 857f23d79d6SAndy Shevchenko .type = SETUP_INDIRECT | SETUP_E820_EXT, 858f23d79d6SAndy Shevchenko .reserved = 0, 859f23d79d6SAndy Shevchenko .len = <len_of_SETUP_E820_EXT_data>, 860f23d79d6SAndy Shevchenko .addr = <addr_of_SETUP_E820_EXT_data>, 861f23d79d6SAndy Shevchenko }, 862b3c72fc9SDaniel Kiper } 863b3c72fc9SDaniel Kiper 864b3c72fc9SDaniel Kiper.. note:: 865b3c72fc9SDaniel Kiper SETUP_INDIRECT | SETUP_NONE objects cannot be properly distinguished 866b3c72fc9SDaniel Kiper from SETUP_INDIRECT itself. So, this kind of objects cannot be provided 867b3c72fc9SDaniel Kiper by the bootloaders. 868b3c72fc9SDaniel Kiper 869f1f238a9SChangbin Du============ ============ 870d297366bSH. Peter AnvinField name: pref_address 871d297366bSH. Peter AnvinType: read (reloc) 872d297366bSH. Peter AnvinOffset/size: 0x258/8 873d297366bSH. Peter AnvinProtocol: 2.10+ 874f1f238a9SChangbin Du============ ============ 875d297366bSH. Peter Anvin 876d297366bSH. Peter Anvin This field, if nonzero, represents a preferred load address for the 877d297366bSH. Peter Anvin kernel. A relocating bootloader should attempt to load at this 878d297366bSH. Peter Anvin address if possible. 879d297366bSH. Peter Anvin 880d297366bSH. Peter Anvin A non-relocatable kernel will unconditionally move itself and to run 88143b1d3e6SChris Koch at this address. A relocatable kernel will move itself to this address if it 88243b1d3e6SChris Koch loaded below this address. 883d297366bSH. Peter Anvin 884f1f238a9SChangbin Du============ ======= 885d297366bSH. Peter AnvinField name: init_size 886d297366bSH. Peter AnvinType: read 88711e48feeSDarren HartOffset/size: 0x260/4 888f1f238a9SChangbin Du============ ======= 889d297366bSH. Peter Anvin 890d297366bSH. Peter Anvin This field indicates the amount of linear contiguous memory starting 891d297366bSH. Peter Anvin at the kernel runtime start address that the kernel needs before it 892d297366bSH. Peter Anvin is capable of examining its memory map. This is not the same thing 893d297366bSH. Peter Anvin as the total amount of memory the kernel needs to boot, but it can 894d297366bSH. Peter Anvin be used by a relocating boot loader to help select a safe load 895d297366bSH. Peter Anvin address for the kernel. 896d297366bSH. Peter Anvin 897f1f238a9SChangbin Du The kernel runtime start address is determined by the following algorithm:: 898d297366bSH. Peter Anvin 899be4ca6c5SAndy Shevchenko if (relocatable_kernel) { 900be4ca6c5SAndy Shevchenko if (load_address < pref_address) 901be4ca6c5SAndy Shevchenko load_address = pref_address; 902be4ca6c5SAndy Shevchenko runtime_start = align_up(load_address, kernel_alignment); 903be4ca6c5SAndy Shevchenko } else { 904be4ca6c5SAndy Shevchenko runtime_start = pref_address; 905be4ca6c5SAndy Shevchenko } 906be4ca6c5SAndy Shevchenko 907be4ca6c5SAndy ShevchenkoHence the necessary memory window location and size can be estimated by 908be4ca6c5SAndy Shevchenkoa boot loader as:: 909be4ca6c5SAndy Shevchenko 910be4ca6c5SAndy Shevchenko memory_window_start = runtime_start; 911be4ca6c5SAndy Shevchenko memory_window_size = init_size; 912d297366bSH. Peter Anvin 913f1f238a9SChangbin Du============ =============== 9149ca8f72aSMatt FlemingField name: handover_offset 9159ca8f72aSMatt FlemingType: read 9169ca8f72aSMatt FlemingOffset/size: 0x264/4 917f1f238a9SChangbin Du============ =============== 9189ca8f72aSMatt Fleming 9199ca8f72aSMatt Fleming This field is the offset from the beginning of the kernel image to 9209ca8f72aSMatt Fleming the EFI handover protocol entry point. Boot loaders using the EFI 9219ca8f72aSMatt Fleming handover protocol to boot the kernel should jump to this offset. 9229ca8f72aSMatt Fleming 9239ca8f72aSMatt Fleming See EFI HANDOVER PROTOCOL below for more details. 9249ca8f72aSMatt Fleming 9252c33c27fSDaniel Kiper============ ================== 9262c33c27fSDaniel KiperField name: kernel_info_offset 9272c33c27fSDaniel KiperType: read 9282c33c27fSDaniel KiperOffset/size: 0x268/4 9292c33c27fSDaniel KiperProtocol: 2.15+ 9302c33c27fSDaniel Kiper============ ================== 9312c33c27fSDaniel Kiper 9322c33c27fSDaniel Kiper This field is the offset from the beginning of the kernel image to the 9332c33c27fSDaniel Kiper kernel_info. The kernel_info structure is embedded in the Linux image 9342c33c27fSDaniel Kiper in the uncompressed protected mode region. 9352c33c27fSDaniel Kiper 9362c33c27fSDaniel Kiper 9372c33c27fSDaniel KiperThe kernel_info 9382c33c27fSDaniel Kiper=============== 9392c33c27fSDaniel Kiper 9402c33c27fSDaniel KiperThe relationships between the headers are analogous to the various data 941f23d79d6SAndy Shevchenkosections:: 9422c33c27fSDaniel Kiper 9432c33c27fSDaniel Kiper setup_header = .data 9442c33c27fSDaniel Kiper boot_params/setup_data = .bss 9452c33c27fSDaniel Kiper 946f23d79d6SAndy ShevchenkoWhat is missing from the above list? That's right:: 9472c33c27fSDaniel Kiper 9482c33c27fSDaniel Kiper kernel_info = .rodata 9492c33c27fSDaniel Kiper 9502c33c27fSDaniel KiperWe have been (ab)using .data for things that could go into .rodata or .bss for 9512c33c27fSDaniel Kipera long time, for lack of alternatives and -- especially early on -- inertia. 9522c33c27fSDaniel KiperAlso, the BIOS stub is responsible for creating boot_params, so it isn't 9532c33c27fSDaniel Kiperavailable to a BIOS-based loader (setup_data is, though). 9542c33c27fSDaniel Kiper 9552c33c27fSDaniel Kipersetup_header is permanently limited to 144 bytes due to the reach of the 9562c33c27fSDaniel Kiper2-byte jump field, which doubles as a length field for the structure, combined 9572c33c27fSDaniel Kiperwith the size of the "hole" in struct boot_params that a protected-mode loader 9582c33c27fSDaniel Kiperor the BIOS stub has to copy it into. It is currently 119 bytes long, which 9592c33c27fSDaniel Kiperleaves us with 25 very precious bytes. This isn't something that can be fixed 9602c33c27fSDaniel Kiperwithout revising the boot protocol entirely, breaking backwards compatibility. 9612c33c27fSDaniel Kiper 9622c33c27fSDaniel Kiperboot_params proper is limited to 4096 bytes, but can be arbitrarily extended 9632c33c27fSDaniel Kiperby adding setup_data entries. It cannot be used to communicate properties of 9642c33c27fSDaniel Kiperthe kernel image, because it is .bss and has no image-provided content. 9652c33c27fSDaniel Kiper 9662c33c27fSDaniel Kiperkernel_info solves this by providing an extensible place for information about 9672c33c27fSDaniel Kiperthe kernel image. It is readonly, because the kernel cannot rely on a 9682c33c27fSDaniel Kiperbootloader copying its contents anywhere, but that is OK; if it becomes 9692c33c27fSDaniel Kipernecessary it can still contain data items that an enabled bootloader would be 9702c33c27fSDaniel Kiperexpected to copy into a setup_data chunk. 9712c33c27fSDaniel Kiper 9722c33c27fSDaniel KiperAll kernel_info data should be part of this structure. Fixed size data have to 9732c33c27fSDaniel Kiperbe put before kernel_info_var_len_data label. Variable size data have to be put 9742c33c27fSDaniel Kiperafter kernel_info_var_len_data label. Each chunk of variable size data has to 975e43630edSDaniel W. S. Almeidabe prefixed with header/magic and its size, e.g.:: 9762c33c27fSDaniel Kiper 9772c33c27fSDaniel Kiper kernel_info: 9782c33c27fSDaniel Kiper .ascii "LToP" /* Header, Linux top (structure). */ 9792c33c27fSDaniel Kiper .long kernel_info_var_len_data - kernel_info 9802c33c27fSDaniel Kiper .long kernel_info_end - kernel_info 9812c33c27fSDaniel Kiper .long 0x01234567 /* Some fixed size data for the bootloaders. */ 9822c33c27fSDaniel Kiper kernel_info_var_len_data: 9832c33c27fSDaniel Kiper example_struct: /* Some variable size data for the bootloaders. */ 9842c33c27fSDaniel Kiper .ascii "0123" /* Header/Magic. */ 9852c33c27fSDaniel Kiper .long example_struct_end - example_struct 9862c33c27fSDaniel Kiper .ascii "Struct" 9872c33c27fSDaniel Kiper .long 0x89012345 9882c33c27fSDaniel Kiper example_struct_end: 9892c33c27fSDaniel Kiper example_strings: /* Some variable size data for the bootloaders. */ 9902c33c27fSDaniel Kiper .ascii "ABCD" /* Header/Magic. */ 9912c33c27fSDaniel Kiper .long example_strings_end - example_strings 9922c33c27fSDaniel Kiper .asciz "String_0" 9932c33c27fSDaniel Kiper .asciz "String_1" 9942c33c27fSDaniel Kiper example_strings_end: 9952c33c27fSDaniel Kiper kernel_info_end: 9962c33c27fSDaniel Kiper 9972c33c27fSDaniel KiperThis way the kernel_info is self-contained blob. 9982c33c27fSDaniel Kiper 9992c33c27fSDaniel Kiper.. note:: 10002c33c27fSDaniel Kiper Each variable size data header/magic can be any 4-character string, 10012c33c27fSDaniel Kiper without \0 at the end of the string, which does not collide with 10022c33c27fSDaniel Kiper existing variable length data headers/magics. 10032c33c27fSDaniel Kiper 10042c33c27fSDaniel Kiper 10052c33c27fSDaniel KiperDetails of the kernel_info Fields 10062c33c27fSDaniel Kiper================================= 10072c33c27fSDaniel Kiper 10082c33c27fSDaniel Kiper============ ======== 10092c33c27fSDaniel KiperField name: header 10102c33c27fSDaniel KiperOffset/size: 0x0000/4 10112c33c27fSDaniel Kiper============ ======== 10122c33c27fSDaniel Kiper 10132c33c27fSDaniel Kiper Contains the magic number "LToP" (0x506f544c). 10142c33c27fSDaniel Kiper 10152c33c27fSDaniel Kiper============ ======== 10162c33c27fSDaniel KiperField name: size 10172c33c27fSDaniel KiperOffset/size: 0x0004/4 10182c33c27fSDaniel Kiper============ ======== 10192c33c27fSDaniel Kiper 10202c33c27fSDaniel Kiper This field contains the size of the kernel_info including kernel_info.header. 10212c33c27fSDaniel Kiper It does not count kernel_info.kernel_info_var_len_data size. This field should be 10222c33c27fSDaniel Kiper used by the bootloaders to detect supported fixed size fields in the kernel_info 10232c33c27fSDaniel Kiper and beginning of kernel_info.kernel_info_var_len_data. 10242c33c27fSDaniel Kiper 10252c33c27fSDaniel Kiper============ ======== 10262c33c27fSDaniel KiperField name: size_total 10272c33c27fSDaniel KiperOffset/size: 0x0008/4 10282c33c27fSDaniel Kiper============ ======== 10292c33c27fSDaniel Kiper 10302c33c27fSDaniel Kiper This field contains the size of the kernel_info including kernel_info.header 10312c33c27fSDaniel Kiper and kernel_info.kernel_info_var_len_data. 10322c33c27fSDaniel Kiper 103300cd1c15SDaniel Kiper============ ============== 103400cd1c15SDaniel KiperField name: setup_type_max 103500cd1c15SDaniel KiperOffset/size: 0x000c/4 103600cd1c15SDaniel Kiper============ ============== 103700cd1c15SDaniel Kiper 1038b3c72fc9SDaniel Kiper This field contains maximal allowed type for setup_data and setup_indirect structs. 103900cd1c15SDaniel Kiper 10404039feb5SH. Peter Anvin 1041f1f238a9SChangbin DuThe Kernel Command Line 1042f1f238a9SChangbin Du======================= 10431da177e4SLinus Torvalds 10441da177e4SLinus TorvaldsThe kernel command line has become an important way for the boot 10451da177e4SLinus Torvaldsloader to communicate with the kernel. Some of its options are also 10461da177e4SLinus Torvaldsrelevant to the boot loader itself, see "special command line options" 10471da177e4SLinus Torvaldsbelow. 10481da177e4SLinus Torvalds 10498f9aeca7SBernhard WalleThe kernel command line is a null-terminated string. The maximum 10508f9aeca7SBernhard Wallelength can be retrieved from the field cmdline_size. Before protocol 10518f9aeca7SBernhard Walleversion 2.06, the maximum was 255 characters. A string that is too 10528f9aeca7SBernhard Wallelong will be automatically truncated by the kernel. 10531da177e4SLinus Torvalds 10541da177e4SLinus TorvaldsIf the boot protocol version is 2.02 or later, the address of the 10551da177e4SLinus Torvaldskernel command line is given by the header field cmd_line_ptr (see 1056f8eeaaf4SH. Peter Anvinabove.) This address can be anywhere between the end of the setup 1057f8eeaaf4SH. Peter Anvinheap and 0xA0000. 10581da177e4SLinus Torvalds 10591da177e4SLinus TorvaldsIf the protocol version is *not* 2.02 or higher, the kernel 10601da177e4SLinus Torvaldscommand line is entered using the following protocol: 10611da177e4SLinus Torvalds 1062f1f238a9SChangbin Du - At offset 0x0020 (word), "cmd_line_magic", enter the magic 10631da177e4SLinus Torvalds number 0xA33F. 10641da177e4SLinus Torvalds 1065f1f238a9SChangbin Du - At offset 0x0022 (word), "cmd_line_offset", enter the offset 10661da177e4SLinus Torvalds of the kernel command line (relative to the start of the 10671da177e4SLinus Torvalds real-mode kernel). 10681da177e4SLinus Torvalds 1069f1f238a9SChangbin Du - The kernel command line *must* be within the memory region 10701da177e4SLinus Torvalds covered by setup_move_size, so you may need to adjust this 10711da177e4SLinus Torvalds field. 10721da177e4SLinus Torvalds 10731da177e4SLinus Torvalds 1074f1f238a9SChangbin DuMemory Layout of The Real-Mode Code 1075f1f238a9SChangbin Du=================================== 1076de372ecdSH. Peter Anvin 1077de372ecdSH. Peter AnvinThe real-mode code requires a stack/heap to be set up, as well as 1078de372ecdSH. Peter Anvinmemory allocated for the kernel command line. This needs to be done 1079de372ecdSH. Peter Anvinin the real-mode accessible memory in bottom megabyte. 1080de372ecdSH. Peter Anvin 1081de372ecdSH. Peter AnvinIt should be noted that modern machines often have a sizable Extended 1082de372ecdSH. Peter AnvinBIOS Data Area (EBDA). As a result, it is advisable to use as little 1083de372ecdSH. Peter Anvinof the low megabyte as possible. 1084de372ecdSH. Peter Anvin 1085de372ecdSH. Peter AnvinUnfortunately, under the following circumstances the 0x90000 memory 1086de372ecdSH. Peter Anvinsegment has to be used: 1087de372ecdSH. Peter Anvin 1088de372ecdSH. Peter Anvin - When loading a zImage kernel ((loadflags & 0x01) == 0). 1089de372ecdSH. Peter Anvin - When loading a 2.01 or earlier boot protocol kernel. 1090de372ecdSH. Peter Anvin 1091f1f238a9SChangbin Du.. note:: 1092f1f238a9SChangbin Du For the 2.00 and 2.01 boot protocols, the real-mode code 1093de372ecdSH. Peter Anvin can be loaded at another address, but it is internally 1094de372ecdSH. Peter Anvin relocated to 0x90000. For the "old" protocol, the 1095de372ecdSH. Peter Anvin real-mode code must be loaded at 0x90000. 1096de372ecdSH. Peter Anvin 1097de372ecdSH. Peter AnvinWhen loading at 0x90000, avoid using memory above 0x9a000. 1098de372ecdSH. Peter Anvin 1099de372ecdSH. Peter AnvinFor boot protocol 2.02 or higher, the command line does not have to be 1100de372ecdSH. Peter Anvinlocated in the same 64K segment as the real-mode setup code; it is 1101de372ecdSH. Peter Anvinthus permitted to give the stack/heap the full 64K segment and locate 1102de372ecdSH. Peter Anvinthe command line above it. 1103de372ecdSH. Peter Anvin 1104de372ecdSH. Peter AnvinThe kernel command line should not be located below the real-mode 1105de372ecdSH. Peter Anvincode, nor should it be located in high memory. 1106de372ecdSH. Peter Anvin 1107de372ecdSH. Peter Anvin 1108d56b699dSBjorn HelgaasSample Boot Configuration 1109f1f238a9SChangbin Du========================= 11101da177e4SLinus Torvalds 11111da177e4SLinus TorvaldsAs a sample configuration, assume the following layout of the real 1112f1f238a9SChangbin Dumode segment. 11131da177e4SLinus Torvalds 1114de372ecdSH. Peter Anvin When loading below 0x90000, use the entire segment: 1115de372ecdSH. Peter Anvin 1116f1f238a9SChangbin Du ============= =================== 1117de372ecdSH. Peter Anvin 0x0000-0x7fff Real mode kernel 1118de372ecdSH. Peter Anvin 0x8000-0xdfff Stack and heap 1119de372ecdSH. Peter Anvin 0xe000-0xffff Kernel command line 1120f1f238a9SChangbin Du ============= =================== 1121de372ecdSH. Peter Anvin 1122de372ecdSH. Peter Anvin When loading at 0x90000 OR the protocol version is 2.01 or earlier: 1123de372ecdSH. Peter Anvin 1124f1f238a9SChangbin Du ============= =================== 1125de372ecdSH. Peter Anvin 0x0000-0x7fff Real mode kernel 1126de372ecdSH. Peter Anvin 0x8000-0x97ff Stack and heap 1127de372ecdSH. Peter Anvin 0x9800-0x9fff Kernel command line 1128f1f238a9SChangbin Du ============= =================== 11291da177e4SLinus Torvalds 1130f1f238a9SChangbin DuSuch a boot loader should enter the following fields in the header:: 11311da177e4SLinus Torvalds 11321da177e4SLinus Torvalds unsigned long base_ptr; /* base address for real-mode segment */ 11331da177e4SLinus Torvalds 1134f23d79d6SAndy Shevchenko if (setup_sects == 0) 11351da177e4SLinus Torvalds setup_sects = 4; 11361da177e4SLinus Torvalds 11371da177e4SLinus Torvalds if (protocol >= 0x0200) { 11381da177e4SLinus Torvalds type_of_loader = <type code>; 11391da177e4SLinus Torvalds if (loading_initrd) { 11401da177e4SLinus Torvalds ramdisk_image = <initrd_address>; 11411da177e4SLinus Torvalds ramdisk_size = <initrd_size>; 11421da177e4SLinus Torvalds } 1143de372ecdSH. Peter Anvin 1144de372ecdSH. Peter Anvin if (protocol >= 0x0202 && loadflags & 0x01) 1145de372ecdSH. Peter Anvin heap_end = 0xe000; 1146de372ecdSH. Peter Anvin else 1147de372ecdSH. Peter Anvin heap_end = 0x9800; 1148de372ecdSH. Peter Anvin 11491da177e4SLinus Torvalds if (protocol >= 0x0201) { 1150de372ecdSH. Peter Anvin heap_end_ptr = heap_end - 0x200; 11511da177e4SLinus Torvalds loadflags |= 0x80; /* CAN_USE_HEAP */ 11521da177e4SLinus Torvalds } 1153de372ecdSH. Peter Anvin 11541da177e4SLinus Torvalds if (protocol >= 0x0202) { 1155de372ecdSH. Peter Anvin cmd_line_ptr = base_ptr + heap_end; 1156de372ecdSH. Peter Anvin strcpy(cmd_line_ptr, cmdline); 11571da177e4SLinus Torvalds } else { 11581da177e4SLinus Torvalds cmd_line_magic = 0xA33F; 1159de372ecdSH. Peter Anvin cmd_line_offset = heap_end; 1160de372ecdSH. Peter Anvin setup_move_size = heap_end + strlen(cmdline) + 1; 1161de372ecdSH. Peter Anvin strcpy(base_ptr + cmd_line_offset, cmdline); 11621da177e4SLinus Torvalds } 11631da177e4SLinus Torvalds } else { 11641da177e4SLinus Torvalds /* Very old kernel */ 11651da177e4SLinus Torvalds 1166de372ecdSH. Peter Anvin heap_end = 0x9800; 1167de372ecdSH. Peter Anvin 11681da177e4SLinus Torvalds cmd_line_magic = 0xA33F; 1169de372ecdSH. Peter Anvin cmd_line_offset = heap_end; 11701da177e4SLinus Torvalds 1171f23d79d6SAndy Shevchenko /* A very old kernel MUST have its real-mode code loaded at 0x90000 */ 11721da177e4SLinus Torvalds if (base_ptr != 0x90000) { 11731da177e4SLinus Torvalds /* Copy the real-mode kernel */ 11741da177e4SLinus Torvalds memcpy(0x90000, base_ptr, (setup_sects + 1) * 512); 11751da177e4SLinus Torvalds base_ptr = 0x90000; /* Relocated */ 11761da177e4SLinus Torvalds } 11771da177e4SLinus Torvalds 1178de372ecdSH. Peter Anvin strcpy(0x90000 + cmd_line_offset, cmdline); 1179de372ecdSH. Peter Anvin 11801da177e4SLinus Torvalds /* It is recommended to clear memory up to the 32K mark */ 1181f23d79d6SAndy Shevchenko memset(0x90000 + (setup_sects + 1) * 512, 0, (64 - (setup_sects + 1)) * 512); 11821da177e4SLinus Torvalds } 11831da177e4SLinus Torvalds 11841da177e4SLinus Torvalds 1185f1f238a9SChangbin DuLoading The Rest of The Kernel 1186f1f238a9SChangbin Du============================== 11871da177e4SLinus Torvalds 1188f8eeaaf4SH. Peter AnvinThe 32-bit (non-real-mode) kernel starts at offset (setup_sects + 1) * 512 1189f8eeaaf4SH. Peter Anvinin the kernel file (again, if setup_sects == 0 the real value is 4.) 1190f8eeaaf4SH. Peter AnvinIt should be loaded at address 0x10000 for Image/zImage kernels and 11911da177e4SLinus Torvalds0x100000 for bzImage kernels. 11921da177e4SLinus Torvalds 11931da177e4SLinus TorvaldsThe kernel is a bzImage kernel if the protocol >= 2.00 and the 0x01 1194f1f238a9SChangbin Dubit (LOAD_HIGH) in the loadflags field is set:: 11951da177e4SLinus Torvalds 11961da177e4SLinus Torvalds is_bzImage = (protocol >= 0x0200) && (loadflags & 0x01); 11971da177e4SLinus Torvalds load_address = is_bzImage ? 0x100000 : 0x10000; 11981da177e4SLinus Torvalds 1199efba5970SAndy Shevchenko.. note:: 1200efba5970SAndy Shevchenko Image/zImage kernels can be up to 512K in size, and thus use the entire 1201efba5970SAndy Shevchenko 0x10000-0x90000 range of memory. This means it is pretty much a 1202efba5970SAndy Shevchenko requirement for these kernels to load the real-mode part at 0x90000. 1203efba5970SAndy Shevchenko bzImage kernels allow much more flexibility. 12041da177e4SLinus Torvalds 1205f1f238a9SChangbin DuSpecial Command Line Options 1206f1f238a9SChangbin Du============================ 12071da177e4SLinus Torvalds 12081da177e4SLinus TorvaldsIf the command line provided by the boot loader is entered by the 12091da177e4SLinus Torvaldsuser, the user may expect the following command line options to work. 12101da177e4SLinus TorvaldsThey should normally not be deleted from the kernel command line even 12111da177e4SLinus Torvaldsthough not all of them are actually meaningful to the kernel. Boot 12121da177e4SLinus Torvaldsloader authors who need additional command line options for the boot 12131da177e4SLinus Torvaldsloader itself should get them registered in 12148c27ceffSMauro Carvalho ChehabDocumentation/admin-guide/kernel-parameters.rst to make sure they will not 12151da177e4SLinus Torvaldsconflict with actual kernel options now or in the future. 12161da177e4SLinus Torvalds 12171da177e4SLinus Torvalds vga=<mode> 12181da177e4SLinus Torvalds <mode> here is either an integer (in C notation, either 12191da177e4SLinus Torvalds decimal, octal, or hexadecimal) or one of the strings 12201da177e4SLinus Torvalds "normal" (meaning 0xFFFF), "ext" (meaning 0xFFFE) or "ask" 12211da177e4SLinus Torvalds (meaning 0xFFFD). This value should be entered into the 12221da177e4SLinus Torvalds vid_mode field, as it is used by the kernel before the command 12231da177e4SLinus Torvalds line is parsed. 12241da177e4SLinus Torvalds 12251da177e4SLinus Torvalds mem=<size> 1226de372ecdSH. Peter Anvin <size> is an integer in C notation optionally followed by 1227de372ecdSH. Peter Anvin (case insensitive) K, M, G, T, P or E (meaning << 10, << 20, 1228de372ecdSH. Peter Anvin << 30, << 40, << 50 or << 60). This specifies the end of 1229de372ecdSH. Peter Anvin memory to the kernel. This affects the possible placement of 1230de372ecdSH. Peter Anvin an initrd, since an initrd should be placed near end of 12311da177e4SLinus Torvalds memory. Note that this is an option to *both* the kernel and 12321da177e4SLinus Torvalds the bootloader! 12331da177e4SLinus Torvalds 12341da177e4SLinus Torvalds initrd=<file> 12351da177e4SLinus Torvalds An initrd should be loaded. The meaning of <file> is 12361da177e4SLinus Torvalds obviously bootloader-dependent, and some boot loaders 12371da177e4SLinus Torvalds (e.g. LILO) do not have such a command. 12381da177e4SLinus Torvalds 12391da177e4SLinus TorvaldsIn addition, some boot loaders add the following options to the 12401da177e4SLinus Torvaldsuser-specified command line: 12411da177e4SLinus Torvalds 12421da177e4SLinus Torvalds BOOT_IMAGE=<file> 12431da177e4SLinus Torvalds The boot image which was loaded. Again, the meaning of <file> 12441da177e4SLinus Torvalds is obviously bootloader-dependent. 12451da177e4SLinus Torvalds 12461da177e4SLinus Torvalds auto 12471da177e4SLinus Torvalds The kernel was booted without explicit user intervention. 12481da177e4SLinus Torvalds 12491da177e4SLinus TorvaldsIf these options are added by the boot loader, it is highly 12501da177e4SLinus Torvaldsrecommended that they are located *first*, before the user-specified 12511da177e4SLinus Torvaldsor configuration-specified command line. Otherwise, "init=/bin/sh" 12521da177e4SLinus Torvaldsgets confused by the "auto" option. 12531da177e4SLinus Torvalds 12541da177e4SLinus Torvalds 1255f1f238a9SChangbin DuRunning the Kernel 1256f1f238a9SChangbin Du================== 12571da177e4SLinus Torvalds 12581da177e4SLinus TorvaldsThe kernel is started by jumping to the kernel entry point, which is 12591da177e4SLinus Torvaldslocated at *segment* offset 0x20 from the start of the real mode 12601da177e4SLinus Torvaldskernel. This means that if you loaded your real-mode kernel code at 12611da177e4SLinus Torvalds0x90000, the kernel entry point is 9020:0000. 12621da177e4SLinus Torvalds 12631da177e4SLinus TorvaldsAt entry, ds = es = ss should point to the start of the real-mode 12641da177e4SLinus Torvaldskernel code (0x9000 if the code is loaded at 0x90000), sp should be 12651da177e4SLinus Torvaldsset up properly, normally pointing to the top of the heap, and 12661da177e4SLinus Torvaldsinterrupts should be disabled. Furthermore, to guard against bugs in 12671da177e4SLinus Torvaldsthe kernel, it is recommended that the boot loader sets fs = gs = ds = 12681da177e4SLinus Torvaldses = ss. 12691da177e4SLinus Torvalds 1270f1f238a9SChangbin DuIn our example from above, we would do:: 12711da177e4SLinus Torvalds 1272f23d79d6SAndy Shevchenko /* 1273f23d79d6SAndy Shevchenko * Note: in the case of the "old" kernel protocol, base_ptr must 1274f23d79d6SAndy Shevchenko * be == 0x90000 at this point; see the previous sample code. 1275f23d79d6SAndy Shevchenko */ 12761da177e4SLinus Torvalds seg = base_ptr >> 4; 12771da177e4SLinus Torvalds 12781da177e4SLinus Torvalds cli(); /* Enter with interrupts disabled! */ 12791da177e4SLinus Torvalds 12801da177e4SLinus Torvalds /* Set up the real-mode kernel stack */ 12811da177e4SLinus Torvalds _SS = seg; 1282de372ecdSH. Peter Anvin _SP = heap_end; 12831da177e4SLinus Torvalds 12841da177e4SLinus Torvalds _DS = _ES = _FS = _GS = seg; 12851da177e4SLinus Torvalds jmp_far(seg + 0x20, 0); /* Run the kernel */ 12861da177e4SLinus Torvalds 12871da177e4SLinus TorvaldsIf your boot sector accesses a floppy drive, it is recommended to 12881da177e4SLinus Torvaldsswitch off the floppy motor before running the kernel, since the 12891da177e4SLinus Torvaldskernel boot leaves interrupts off and thus the motor will not be 12901da177e4SLinus Torvaldsswitched off, especially if the loaded kernel has the floppy driver as 12911da177e4SLinus Torvaldsa demand-loaded module! 12921da177e4SLinus Torvalds 12931da177e4SLinus Torvalds 1294f1f238a9SChangbin DuAdvanced Boot Loader Hooks 1295f1f238a9SChangbin Du========================== 12961da177e4SLinus Torvalds 12971da177e4SLinus TorvaldsIf the boot loader runs in a particularly hostile environment (such as 12981da177e4SLinus TorvaldsLOADLIN, which runs under DOS) it may be impossible to follow the 12991da177e4SLinus Torvaldsstandard memory location requirements. Such a boot loader may use the 13001da177e4SLinus Torvaldsfollowing hooks that, if set, are invoked by the kernel at the 13011da177e4SLinus Torvaldsappropriate time. The use of these hooks should probably be 13021da177e4SLinus Torvaldsconsidered an absolutely last resort! 13031da177e4SLinus Torvalds 13041da177e4SLinus TorvaldsIMPORTANT: All the hooks are required to preserve %esp, %ebp, %esi and 13051da177e4SLinus Torvalds%edi across invocation. 13061da177e4SLinus Torvalds 13071da177e4SLinus Torvalds realmode_swtch: 13081da177e4SLinus Torvalds A 16-bit real mode far subroutine invoked immediately before 13091da177e4SLinus Torvalds entering protected mode. The default routine disables NMI, so 13101da177e4SLinus Torvalds your routine should probably do so, too. 13111da177e4SLinus Torvalds 13121da177e4SLinus Torvalds code32_start: 13131da177e4SLinus Torvalds A 32-bit flat-mode routine *jumped* to immediately after the 13141da177e4SLinus Torvalds transition to protected mode, but before the kernel is 1315de372ecdSH. Peter Anvin uncompressed. No segments, except CS, are guaranteed to be 1316de372ecdSH. Peter Anvin set up (current kernels do, but older ones do not); you should 1317de372ecdSH. Peter Anvin set them up to BOOT_DS (0x18) yourself. 13181da177e4SLinus Torvalds 13191da177e4SLinus Torvalds After completing your hook, you should jump to the address 1320db2668fdSH. Peter Anvin that was in this field before your boot loader overwrote it 1321db2668fdSH. Peter Anvin (relocated, if appropriate.) 1322aa69432aSHuang, Ying 1323aa69432aSHuang, Ying 1324f1f238a9SChangbin Du32-bit Boot Protocol 1325f1f238a9SChangbin Du==================== 1326aa69432aSHuang, Ying 1327aa69432aSHuang, YingFor machine with some new BIOS other than legacy BIOS, such as EFI, 1328aa69432aSHuang, YingLinuxBIOS, etc, and kexec, the 16-bit real mode setup code in kernel 1329aa69432aSHuang, Yingbased on legacy BIOS can not be used, so a 32-bit boot protocol needs 1330aa69432aSHuang, Yingto be defined. 1331aa69432aSHuang, Ying 1332aa69432aSHuang, YingIn 32-bit boot protocol, the first step in loading a Linux kernel 1333aa69432aSHuang, Yingshould be to setup the boot parameters (struct boot_params, 1334aa69432aSHuang, Yingtraditionally known as "zero page"). The memory for struct boot_params 1335aa69432aSHuang, Yingshould be allocated and initialized to all zero. Then the setup header 1336aa69432aSHuang, Yingfrom offset 0x01f1 of kernel image on should be loaded into struct 1337aa69432aSHuang, Yingboot_params and examined. The end of setup header can be calculated as 1338f1f238a9SChangbin Dufollow:: 1339aa69432aSHuang, Ying 1340aa69432aSHuang, Ying 0x0202 + byte value at offset 0x0201 1341aa69432aSHuang, Ying 1342aa69432aSHuang, YingIn addition to read/modify/write the setup header of the struct 1343aa69432aSHuang, Yingboot_params as that of 16-bit boot protocol, the boot loader should 13440c768983SHeinrich Schuchardtalso fill the additional fields of the struct boot_params as 1345ff61f079SJonathan Corbetdescribed in chapter Documentation/arch/x86/zero-page.rst. 1346aa69432aSHuang, Ying 1347c6039f4aSKees CookAfter setting up the struct boot_params, the boot loader can load the 1348aa69432aSHuang, Ying32/64-bit kernel in the same way as that of 16-bit boot protocol. 1349aa69432aSHuang, Ying 1350aa69432aSHuang, YingIn 32-bit boot protocol, the kernel is started by jumping to the 1351aa69432aSHuang, Ying32-bit kernel entry point, which is the start address of loaded 1352aa69432aSHuang, Ying32/64-bit kernel. 1353aa69432aSHuang, Ying 1354aa69432aSHuang, YingAt entry, the CPU must be in 32-bit protected mode with paging 1355aa69432aSHuang, Yingdisabled; a GDT must be loaded with the descriptors for selectors 1356aa69432aSHuang, Ying__BOOT_CS(0x10) and __BOOT_DS(0x18); both descriptors must be 4G flat 1357c6039f4aSKees Cooksegment; __BOOT_CS must have execute/read permission, and __BOOT_DS 1358aa69432aSHuang, Yingmust have read/write permission; CS must be __BOOT_CS and DS, ES, SS 1359aa69432aSHuang, Yingmust be __BOOT_DS; interrupt must be disabled; %esi must hold the base 1360aa69432aSHuang, Yingaddress of the struct boot_params; %ebp, %edi and %ebx must be zero. 13619ca8f72aSMatt Fleming 1362f1f238a9SChangbin Du64-bit Boot Protocol 1363f1f238a9SChangbin Du==================== 13648ee2f2dfSYinghai Lu 13658ee2f2dfSYinghai LuFor machine with 64bit cpus and 64bit kernel, we could use 64bit bootloader 13668ee2f2dfSYinghai Luand we need a 64-bit boot protocol. 13678ee2f2dfSYinghai Lu 13688ee2f2dfSYinghai LuIn 64-bit boot protocol, the first step in loading a Linux kernel 13698ee2f2dfSYinghai Lushould be to setup the boot parameters (struct boot_params, 13708ee2f2dfSYinghai Lutraditionally known as "zero page"). The memory for struct boot_params 13718ee2f2dfSYinghai Lucould be allocated anywhere (even above 4G) and initialized to all zero. 13728ee2f2dfSYinghai LuThen, the setup header at offset 0x01f1 of kernel image on should be 13738ee2f2dfSYinghai Luloaded into struct boot_params and examined. The end of setup header 1374f1f238a9SChangbin Ducan be calculated as follows:: 13758ee2f2dfSYinghai Lu 13768ee2f2dfSYinghai Lu 0x0202 + byte value at offset 0x0201 13778ee2f2dfSYinghai Lu 13788ee2f2dfSYinghai LuIn addition to read/modify/write the setup header of the struct 13798ee2f2dfSYinghai Luboot_params as that of 16-bit boot protocol, the boot loader should 13808ee2f2dfSYinghai Lualso fill the additional fields of the struct boot_params as described 1381ff61f079SJonathan Corbetin chapter Documentation/arch/x86/zero-page.rst. 13828ee2f2dfSYinghai Lu 13838ee2f2dfSYinghai LuAfter setting up the struct boot_params, the boot loader can load 13848ee2f2dfSYinghai Lu64-bit kernel in the same way as that of 16-bit boot protocol, but 13858ee2f2dfSYinghai Lukernel could be loaded above 4G. 13868ee2f2dfSYinghai Lu 13878ee2f2dfSYinghai LuIn 64-bit boot protocol, the kernel is started by jumping to the 13888ee2f2dfSYinghai Lu64-bit kernel entry point, which is the start address of loaded 13898ee2f2dfSYinghai Lu64-bit kernel plus 0x200. 13908ee2f2dfSYinghai Lu 13918ee2f2dfSYinghai LuAt entry, the CPU must be in 64-bit mode with paging enabled. 13928ee2f2dfSYinghai LuThe range with setup_header.init_size from start address of loaded 13938ee2f2dfSYinghai Lukernel and zero page and command line buffer get ident mapping; 13948ee2f2dfSYinghai Lua GDT must be loaded with the descriptors for selectors 13958ee2f2dfSYinghai Lu__BOOT_CS(0x10) and __BOOT_DS(0x18); both descriptors must be 4G flat 13968ee2f2dfSYinghai Lusegment; __BOOT_CS must have execute/read permission, and __BOOT_DS 13978ee2f2dfSYinghai Lumust have read/write permission; CS must be __BOOT_CS and DS, ES, SS 13988ee2f2dfSYinghai Lumust be __BOOT_DS; interrupt must be disabled; %rsi must hold the base 13998ee2f2dfSYinghai Luaddress of the struct boot_params. 14008ee2f2dfSYinghai Lu 14018b84769aSArd BiesheuvelEFI Handover Protocol (deprecated) 14028b84769aSArd Biesheuvel================================== 14039ca8f72aSMatt Fleming 14049ca8f72aSMatt FlemingThis protocol allows boot loaders to defer initialisation to the EFI 14059ca8f72aSMatt Flemingboot stub. The boot loader is required to load the kernel/initrd(s) 14069ca8f72aSMatt Flemingfrom the boot media and jump to the EFI handover protocol entry point 14079ca8f72aSMatt Flemingwhich is hdr->handover_offset bytes from the beginning of 14089ca8f72aSMatt Flemingstartup_{32,64}. 14099ca8f72aSMatt Fleming 14108b84769aSArd BiesheuvelThe boot loader MUST respect the kernel's PE/COFF metadata when it comes 14118b84769aSArd Biesheuvelto section alignment, the memory footprint of the executable image beyond 14128b84769aSArd Biesheuvelthe size of the file itself, and any other aspect of the PE/COFF header 14138b84769aSArd Biesheuvelthat may affect correct operation of the image as a PE/COFF binary in the 14148b84769aSArd Biesheuvelexecution context provided by the EFI firmware. 14158b84769aSArd Biesheuvel 1416f1f238a9SChangbin DuThe function prototype for the handover entry point looks like this:: 14179ca8f72aSMatt Fleming 1418f23d79d6SAndy Shevchenko void efi_stub_entry(void *handle, efi_system_table_t *table, struct boot_params *bp); 14199ca8f72aSMatt Fleming 14209ca8f72aSMatt Fleming'handle' is the EFI image handle passed to the boot loader by the EFI 14219ca8f72aSMatt Flemingfirmware, 'table' is the EFI system table - these are the first two 14229ca8f72aSMatt Flemingarguments of the "handoff state" as described in section 2.3 of the 14239ca8f72aSMatt FlemingUEFI specification. 'bp' is the boot loader-allocated boot params. 14249ca8f72aSMatt Fleming 1425f1f238a9SChangbin DuThe boot loader *must* fill out the following fields in bp:: 14269ca8f72aSMatt Fleming 1427f1f238a9SChangbin Du - hdr.cmd_line_ptr 1428f1f238a9SChangbin Du - hdr.ramdisk_image (if applicable) 1429f1f238a9SChangbin Du - hdr.ramdisk_size (if applicable) 14309ca8f72aSMatt Fleming 14319ca8f72aSMatt FlemingAll other fields should be zero. 14328b84769aSArd Biesheuvel 1433efba5970SAndy Shevchenko.. note:: 1434efba5970SAndy Shevchenko The EFI Handover Protocol is deprecated in favour of the ordinary PE/COFF 14358b84769aSArd Biesheuvel entry point, combined with the LINUX_EFI_INITRD_MEDIA_GUID based initrd 14368b84769aSArd Biesheuvel loading protocol (refer to [0] for an example of the bootloader side of 14378b84769aSArd Biesheuvel this), which removes the need for any knowledge on the part of the EFI 14388b84769aSArd Biesheuvel bootloader regarding the internal representation of boot_params or any 14398b84769aSArd Biesheuvel requirements/limitations regarding the placement of the command line 14408b84769aSArd Biesheuvel and ramdisk in memory, or the placement of the kernel image itself. 14418b84769aSArd Biesheuvel 14428b84769aSArd Biesheuvel[0] https://github.com/u-boot/u-boot/commit/ec80b4735a593961fe701cc3a5d717d4739b0fd0 1443