• Home
  • Raw
  • Download

Lines Matching +full:boot +full:- +full:loader

1 .. SPDX-License-Identifier: GPL-2.0
4 The Linux/x86 Boot Protocol
7 On the x86 platform, the Linux kernel uses a rather complicated boot
12 real-mode DOS as a mainstream operating system.
14 Currently, the following versions of the Linux/x86 boot protocol exist.
22 boot loader and the kernel. setup.S made relocatable,
28 Protocol 2.02 (Kernel 2.4.0-test3-pre3) New command line protocol.
31 safe for systems which use the EBDA from SMM or 32-bit
35 Protocol 2.03 (Kernel 2.4.18-pre1) Explicitly makes the highest possible
44 the boot command line.
46 Protocol 2.07 (Kernel 2.6.24) Added paravirtualised boot protocol.
54 Protocol 2.09 (Kernel 2.6.26) Added a field of 64-bit physical
59 pref_address fields. Added extended boot loader IDs.
68 Protocol 2.13 (Kernel 3.14) Support 32- and 64-bit flags being set in
69 xloadflags to support booting a 64-bit kernel from 32-bit
74 (x86/boot: Add ACPI RSDP address to setup_header)
86 features to the boot loader. Due to very limited space available in
89 communicate things to the boot loader is the kernel_info.
95 The traditional memory map for the kernel loader, used for Image or
99 0A0000 +------------------------+
101 09A000 +------------------------+
103 | Stack/heap | For use by the kernel real-mode code.
104 098000 +------------------------+
105 | Kernel setup | The kernel real-mode code.
106 090200 +------------------------+
107 | Kernel boot sector | The kernel legacy boot sector.
108 090000 +------------------------+
109 | Protected-mode kernel | The bulk of the kernel image.
110 010000 +------------------------+
111 | Boot loader | <- Boot sector entry point 0000:7C00
112 001000 +------------------------+
114 000800 +------------------------+
116 000600 +------------------------+
118 000000 +------------------------+
120 When using bzImage, the protected-mode kernel was relocated to
121 0x100000 ("high memory"), and the kernel real-mode block (boot sector,
127 It is desirable to keep the "memory ceiling" -- the highest point in
128 low memory touched by the boot loader -- as low as possible, since
131 memory. The boot loader should use the "INT 12h" BIOS call to verify
135 low, there is usually nothing the boot loader can do but to report an
136 error to the user. The boot loader should therefore be designed to
139 0x90000 segment, the boot loader should make sure not to use memory
142 For a modern bzImage kernel with boot protocol version >= 2.02, a
146 | Protected-mode kernel |
147 100000 +------------------------+
149 0A0000 +------------------------+
153 X+10000 +------------------------+
154 | Stack/heap | For use by the kernel real-mode code.
155 X+08000 +------------------------+
156 | Kernel setup | The kernel real-mode code.
157 | Kernel boot sector | The kernel legacy boot sector.
158 X +------------------------+
159 | Boot loader | <- Boot sector entry point 0000:7C00
160 001000 +------------------------+
162 000800 +------------------------+
164 000600 +------------------------+
166 000000 +------------------------+
168 ... where the address X is as low as the design of the boot loader permits.
171 The Real-Mode Kernel Header
174 In the following text, and anywhere in the kernel boot sequence, "a
179 real-mode code (boot sector and setup code) and then examine the
180 following header at offset 0x01f1. The real-mode code can total up to
181 32K, although the boot loader may choose to load only the first two
191 01F4/4 2.04+(2) syssize The size of the 32-bit code in 16-byte paras
192 01F8/2 ALL ram_size DO NOT USE - for bootsect.S use only
198 0206/2 2.00+ version Boot protocol version supported
199 0208/4 2.00+ realmode_swtch Boot loader hook (see below)
200 020C/2 2.00+ start_sys_seg The load-low segment (0x1000) (obsolete)
202 0210/1 2.00+ type_of_loader Boot loader identifier
203 0211/1 2.00+ loadflags Boot protocol option flags
205 0214/4 2.00+ code32_start Boot loader hook (see below)
206 0218/4 2.00+ ramdisk_image initrd load address (set by boot loader)
207 021C/4 2.00+ ramdisk_size initrd size (set by boot loader)
208 0220/4 2.00+ bootsect_kludge DO NOT USE - for bootsect.S use only
210 0226/1 2.02+(3) ext_loader_ver Extended boot loader version
211 0227/1 2.02+(3) ext_loader_type Extended boot loader ID
212 0228/4 2.02+ cmd_line_ptr 32-bit pointer to the kernel command line
217 0236/2 2.12+ xloadflags Boot protocol option flags
220 0240/8 2.07+ hardware_subarch_data Subarchitecture-specific data
223 0250/8 2.09+ setup_data 64-bit physical pointer to linked list
235 (2) For boot protocol prior to 2.04, the upper two bytes of the syssize
239 (3) Ignored, but safe to set, for boot protocols 2.02-2.09.
242 the boot protocol version is "old". Loading an old kernel, the
247 Real-mode kernel must be located at 0x90000.
263 All general purpose boot loaders should write the fields marked
264 (obligatory). Boot loaders who want to load the kernel at a
266 boot loaders can ignore those fields.
277 The size of the setup code in 512-byte sectors. If this field is
278 0, the real value is 4. The real-mode code consists of the boot
279 sector (always one 512-byte sector) plus the setup code.
299 The size of the protected-mode code in units of 16-byte paragraphs.
368 Contains the boot protocol version, in (major << 8)+minor format,
379 Boot loader hook (see ADVANCED BOOT LOADER HOOKS below.)
397 If set to a nonzero value, contains a pointer to a NUL-terminated
398 human-readable kernel version number string, less 0x200. This can
419 If your boot loader has an assigned id (see table below), enter
420 0xTV here, where T is an identifier for the boot loader and V is
423 For boot loader IDs above T = 0xD, write T = 0xE to this field and
430 type_of_loader <- 0xE4
431 ext_loader_type <- 0x05
432 ext_loader_ver <- 0x23
434 Assigned boot loader ids (hexadecimal):
438 (0x00 reserved for pre-2.00 bootloader)
440 2 bootsect-loader
446 8 U-Boot
451 D kexec-tools
456 <http://sebastian-plotz.blogspot.de>
473 - If 0, the protected-mode code is loaded at 0x10000.
474 - If 1, the protected-mode code is loaded at 0x100000.
478 - Used internally by the compressed kernel to communicate
481 - If 1, KASLR enabled.
482 - If 0, KASLR disabled.
486 - If 0, print early messages.
487 - If 1, suppress early messages.
497 - This flag is obsolete.
510 Protocol: 2.00-2.01
516 the kernel command line) moved in addition to the real-mode kernel
519 The unit is bytes starting with the beginning of the boot sector.
522 if the real-mode code is loaded at 0x90000.
532 address of the kernel, and can be used by the boot loader to
537 1. as a boot loader hook (see Advanced Boot Loader Hooks below.)
550 The 32-bit linear address of the initial ramdisk or ramfs. Leave at
579 Set this field to the offset (from the beginning of the real-mode
593 The use of this field is boot loader specific. If not written, it
625 same 64K segment as the real-mode code itself.
627 Fill in this field even if your boot loader does not support a
630 zero, the kernel will assume that your boot loader does not support
641 ramdisk/ramfs contents. For boot protocols 2.02 or earlier, this
661 loader to modify this field to permit a lesser alignment. See the
671 If this field is nonzero, the protected-mode part of the kernel can
673 After loading, the boot loader must set the code32_start field to
674 point to the loaded code, or to a boot loader hook.
684 alignment required, as opposed to preferred, by the kernel to boot.
685 If a boot loader makes use of this field, it should update the
691 misaligned kernel. Therefore, a loader should typically try each
692 power-of-two alignment from kernel_alignment down to this alignment.
705 - If 1, this kernel has the legacy 64-bit entry point at 0x200.
709 - If 1, kernel/boot_params/cmdline/ramdisk can be above 4G.
713 - If 1, the kernel supports the 32-bit EFI handoff entry point
718 - If 1, the kernel supports the 64-bit EFI handoff entry point
723 - If 1, the kernel supports kexec EFI boot with EFI runtime support.
762 Type: write (subarch-dependent)
778 If non-zero then this field contains the offset from the beginning
779 of the protected-mode code to the payload.
805 The 64-bit physical pointer to NULL terminated single linked list of
806 struct setup_data. This is used to define a more extensible boot
817 Where, the next is a 64-bit physical pointer to the next node of
829 and because it has a 32-bit length field. However, it is important that
830 intermediate stages of the boot process have a way to identify which
846 and stack space can be limited in boot contexts.
879 A non-relocatable kernel will unconditionally move itself and to run
891 as the total amount of memory the kernel needs to boot, but it can
892 be used by a relocating boot loader to help select a safe load
909 the EFI handover protocol entry point. Boot loaders using the EFI
910 handover protocol to boot the kernel should jump to this offset.
940 a long time, for lack of alternatives and -- especially early on -- inertia.
942 available to a BIOS-based loader (setup_data is, though).
945 2-byte jump field, which doubles as a length field for the structure, combined
946 with the size of the "hole" in struct boot_params that a protected-mode loader
949 without revising the boot protocol entirely, breaking backwards compatibility.
953 the kernel image, because it is .bss and has no image-provided content.
968 .long kernel_info_var_len_data - kernel_info
969 .long kernel_info_end - kernel_info
974 .long example_struct_end - example_struct
980 .long example_strings_end - example_strings
986 This way the kernel_info is self-contained blob.
989 Each variable size data header/magic can be any 4-character string,
1033 From boot protocol version 2.08 onwards the CRC-32 is calculated over
1043 The kernel command line has become an important way for the boot
1044 loader to communicate with the kernel. Some of its options are also
1045 relevant to the boot loader itself, see "special command line options"
1048 The kernel command line is a null-terminated string. The maximum
1053 If the boot protocol version is 2.02 or later, the address of the
1061 - At offset 0x0020 (word), "cmd_line_magic", enter the magic
1064 - At offset 0x0022 (word), "cmd_line_offset", enter the offset
1066 real-mode kernel).
1068 - The kernel command line *must* be within the memory region
1073 Memory Layout of The Real-Mode Code
1076 The real-mode code requires a stack/heap to be set up, as well as
1078 in the real-mode accessible memory in bottom megabyte.
1087 - When loading a zImage kernel ((loadflags & 0x01) == 0).
1088 - When loading a 2.01 or earlier boot protocol kernel.
1091 For the 2.00 and 2.01 boot protocols, the real-mode code
1094 real-mode code must be loaded at 0x90000.
1098 For boot protocol 2.02 or higher, the command line does not have to be
1099 located in the same 64K segment as the real-mode setup code; it is
1103 The kernel command line should not be located below the real-mode
1107 Sample Boot Configuartion
1116 0x0000-0x7fff Real mode kernel
1117 0x8000-0xdfff Stack and heap
1118 0xe000-0xffff Kernel command line
1124 0x0000-0x7fff Real mode kernel
1125 0x8000-0x97ff Stack and heap
1126 0x9800-0x9fff Kernel command line
1129 Such a boot loader should enter the following fields in the header::
1131 unsigned long base_ptr; /* base address for real-mode segment */
1150 heap_end_ptr = heap_end - 0x200;
1171 /* A very old kernel MUST have its real-mode code
1175 /* Copy the real-mode kernel */
1184 (64-(setup_sects+1))*512);
1191 The 32-bit (non-real-mode) kernel starts at offset (setup_sects+1)*512
1203 the entire 0x10000-0x90000 range of memory. This means it is pretty
1204 much a requirement for these kernels to load the real-mode part at
1210 If the command line provided by the boot loader is entered by the
1213 though not all of them are actually meaningful to the kernel. Boot
1214 loader authors who need additional command line options for the boot
1215 loader itself should get them registered in
1216 Documentation/admin-guide/kernel-parameters.rst to make sure they will not
1238 obviously bootloader-dependent, and some boot loaders
1241 In addition, some boot loaders add the following options to the
1242 user-specified command line:
1245 The boot image which was loaded. Again, the meaning of <file>
1246 is obviously bootloader-dependent.
1251 If these options are added by the boot loader, it is highly
1252 recommended that they are located *first*, before the user-specified
1253 or configuration-specified command line. Otherwise, "init=/bin/sh"
1262 kernel. This means that if you loaded your real-mode kernel code at
1265 At entry, ds = es = ss should point to the start of the real-mode
1269 the kernel, it is recommended that the boot loader sets fs = gs = ds =
1281 /* Set up the real-mode kernel stack */
1288 If your boot sector accesses a floppy drive, it is recommended to
1290 kernel boot leaves interrupts off and thus the motor will not be
1292 a demand-loaded module!
1295 Advanced Boot Loader Hooks
1298 If the boot loader runs in a particularly hostile environment (such as
1300 standard memory location requirements. Such a boot loader may use the
1309 A 16-bit real mode far subroutine invoked immediately before
1314 A 32-bit flat-mode routine *jumped* to immediately after the
1321 that was in this field before your boot loader overwrote it
1325 32-bit Boot Protocol
1329 LinuxBIOS, etc, and kexec, the 16-bit real mode setup code in kernel
1330 based on legacy BIOS can not be used, so a 32-bit boot protocol needs
1333 In 32-bit boot protocol, the first step in loading a Linux kernel
1334 should be to setup the boot parameters (struct boot_params,
1344 boot_params as that of 16-bit boot protocol, the boot loader should
1346 described in chapter :doc:`zero-page`.
1348 After setting up the struct boot_params, the boot loader can load the
1349 32/64-bit kernel in the same way as that of 16-bit boot protocol.
1351 In 32-bit boot protocol, the kernel is started by jumping to the
1352 32-bit kernel entry point, which is the start address of loaded
1353 32/64-bit kernel.
1355 At entry, the CPU must be in 32-bit protected mode with paging
1363 64-bit Boot Protocol
1367 and we need a 64-bit boot protocol.
1369 In 64-bit boot protocol, the first step in loading a Linux kernel
1370 should be to setup the boot parameters (struct boot_params,
1380 boot_params as that of 16-bit boot protocol, the boot loader should
1382 in chapter :doc:`zero-page`.
1384 After setting up the struct boot_params, the boot loader can load
1385 64-bit kernel in the same way as that of 16-bit boot protocol, but
1388 In 64-bit boot protocol, the kernel is started by jumping to the
1389 64-bit kernel entry point, which is the start address of loaded
1390 64-bit kernel plus 0x200.
1392 At entry, the CPU must be in 64-bit mode with paging enabled.
1405 This protocol allows boot loaders to defer initialisation to the EFI
1406 boot stub. The boot loader is required to load the kernel/initrd(s)
1407 from the boot media and jump to the EFI handover protocol entry point
1408 which is hdr->handover_offset bytes from the beginning of
1411 The boot loader MUST respect the kernel's PE/COFF metadata when it comes
1421 'handle' is the EFI image handle passed to the boot loader by the EFI
1422 firmware, 'table' is the EFI system table - these are the first two
1424 UEFI specification. 'bp' is the boot loader-allocated boot params.
1426 The boot loader *must* fill out the following fields in bp::
1428 - hdr.cmd_line_ptr
1429 - hdr.ramdisk_image (if applicable)
1430 - hdr.ramdisk_size (if applicable)
1442 [0] https://github.com/u-boot/u-boot/commit/ec80b4735a593961fe701cc3a5d717d4739b0fd0