@@ -50,6 +50,10 @@ Protocol 2.08: (Kernel 2.6.26) Added crc32 checksum and ELF format
5050Protocol 2.09: (Kernel 2.6.26) Added a field of 64-bit physical
5151 pointer to single linked list of struct setup_data.
5252
53+ Protocol 2.10: (Kernel 2.6.31) Added a protocol for relaxed alignment
54+ beyond the kernel_alignment added, new init_size and
55+ pref_address fields. Added extended boot loader IDs.
56+
5357**** MEMORY LAYOUT
5458
5559The traditional memory map for the kernel loader, used for Image or
@@ -168,12 +172,13 @@ Offset Proto Name Meaning
168172021C/4 2.00+ ramdisk_size initrd size (set by boot loader)
1691730220/4 2.00+ bootsect_kludge DO NOT USE - for bootsect.S use only
1701740224/2 2.01+ heap_end_ptr Free memory after setup end
171- 0226/2 N/A pad1 Unused
175+ 0226/1 2.02+(3 ext_loader_ver Extended boot loader version
176+ 0227/1 2.02+(3 ext_loader_type Extended boot loader ID
1721770228/4 2.02+ cmd_line_ptr 32-bit pointer to the kernel command line
173178022C/4 2.03+ ramdisk_max Highest legal initrd address
1741790230/4 2.05+ kernel_alignment Physical addr alignment required for kernel
1751800234/1 2.05+ relocatable_kernel Whether kernel is relocatable or not
176- 0235/1 N/A pad2 Unused
181+ 0235/1 2.10+ min_alignment Minimum alignment, as a power of two
1771820236/2 N/A pad3 Unused
1781830238/4 2.06+ cmdline_size Maximum size of the kernel command line
179184023C/4 2.07+ hardware_subarch Hardware subarchitecture
@@ -182,6 +187,8 @@ Offset Proto Name Meaning
182187024C/4 2.08+ payload_length Length of kernel payload
1831880250/8 2.09+ setup_data 64-bit physical pointer to linked list
184189 of struct setup_data
190+ 0258/8 2.10+ pref_address Preferred loading address
191+ 0260/4 2.10+ init_size Linear memory required during initialization
185192
186193(1) For backwards compatibility, if the setup_sects field contains 0, the
187194 real value is 4.
@@ -190,6 +197,8 @@ Offset Proto Name Meaning
190197 field are unusable, which means the size of a bzImage kernel
191198 cannot be determined.
192199
200+ (3) Ignored, but safe to set, for boot protocols 2.02-2.09.
201+
193202If the "HdrS" (0x53726448) magic number is not found at offset 0x202,
194203the boot protocol version is "old". Loading an old kernel, the
195204following parameters should be assumed:
@@ -343,18 +352,32 @@ Protocol: 2.00+
343352 0xTV here, where T is an identifier for the boot loader and V is
344353 a version number. Otherwise, enter 0xFF here.
345354
355+ For boot loader IDs above T = 0xD, write T = 0xE to this field and
356+ write the extended ID minus 0x10 to the ext_loader_type field.
357+ Similarly, the ext_loader_ver field can be used to provide more than
358+ four bits for the bootloader version.
359+
360+ For example, for T = 0x15, V = 0x234, write:
361+
362+ type_of_loader <- 0xE4
363+ ext_loader_type <- 0x05
364+ ext_loader_ver <- 0x23
365+
346366 Assigned boot loader ids:
347367 0 LILO (0x00 reserved for pre-2.00 bootloader)
348368 1 Loadlin
349369 2 bootsect-loader (0x20, all other values reserved)
350- 3 SYSLINUX
351- 4 EtherBoot
370+ 3 Syslinux
371+ 4 Etherboot/gPXE
352372 5 ELILO
353373 7 GRUB
354- 8 U-BOOT
374+ 8 U-Boot
355375 9 Xen
356376 A Gujin
357377 B Qemu
378+ C Arcturus Networks uCbootloader
379+ E Extended (see ext_loader_type)
380+ F Special (0xFF = undefined)
358381
359382 Please contact <hpa@zytor.com> if you need a bootloader ID
360383 value assigned.
@@ -453,6 +476,35 @@ Protocol: 2.01+
453476 Set this field to the offset (from the beginning of the real-mode
454477 code) of the end of the setup stack/heap, minus 0x0200.
455478
479+ Field name: ext_loader_ver
480+ Type: write (optional)
481+ Offset/size: 0x226/1
482+ Protocol: 2.02+
483+
484+ This field is used as an extension of the version number in the
485+ type_of_loader field. The total version number is considered to be
486+ (type_of_loader & 0x0f) + (ext_loader_ver << 4).
487+
488+ The use of this field is boot loader specific. If not written, it
489+ is zero.
490+
491+ Kernels prior to 2.6.31 did not recognize this field, but it is safe
492+ to write for protocol version 2.02 or higher.
493+
494+ Field name: ext_loader_type
495+ Type: write (obligatory if (type_of_loader & 0xf0) == 0xe0)
496+ Offset/size: 0x227/1
497+ Protocol: 2.02+
498+
499+ This field is used as an extension of the type number in
500+ type_of_loader field. If the type in type_of_loader is 0xE, then
501+ the actual type is (ext_loader_type + 0x10).
502+
503+ This field is ignored if the type in type_of_loader is not 0xE.
504+
505+ Kernels prior to 2.6.31 did not recognize this field, but it is safe
506+ to write for protocol version 2.02 or higher.
507+
456508Field name: cmd_line_ptr
457509Type: write (obligatory)
458510Offset/size: 0x228/4
@@ -482,11 +534,19 @@ Protocol: 2.03+
482534 0x37FFFFFF, you can start your ramdisk at 0x37FE0000.)
483535
484536Field name: kernel_alignment
485- Type: read (reloc)
537+ Type: read/modify (reloc)
486538Offset/size: 0x230/4
487- Protocol: 2.05+
539+ Protocol: 2.05+ (read), 2.10+ (modify)
540+
541+ Alignment unit required by the kernel (if relocatable_kernel is
542+ true.) A relocatable kernel that is loaded at an alignment
543+ incompatible with the value in this field will be realigned during
544+ kernel initialization.
488545
489- Alignment unit required by the kernel (if relocatable_kernel is true.)
546+ Starting with protocol version 2.10, this reflects the kernel
547+ alignment preferred for optimal performance; it is possible for the
548+ loader to modify this field to permit a lesser alignment. See the
549+ min_alignment and pref_address field below.
490550
491551Field name: relocatable_kernel
492552Type: read (reloc)
@@ -498,6 +558,22 @@ Protocol: 2.05+
498558 After loading, the boot loader must set the code32_start field to
499559 point to the loaded code, or to a boot loader hook.
500560
561+ Field name: min_alignment
562+ Type: read (reloc)
563+ Offset/size: 0x235/1
564+ Protocol: 2.10+
565+
566+ This field, if nonzero, indicates as a power of two the minimum
567+ alignment required, as opposed to preferred, by the kernel to boot.
568+ If a boot loader makes use of this field, it should update the
569+ kernel_alignment field with the alignment unit desired; typically:
570+
571+ kernel_alignment = 1 << min_alignment
572+
573+ There may be a considerable performance cost with an excessively
574+ misaligned kernel. Therefore, a loader should typically try each
575+ power-of-two alignment from kernel_alignment down to this alignment.
576+
501577Field name: cmdline_size
502578Type: read
503579Offset/size: 0x238/4
@@ -582,6 +658,36 @@ Protocol: 2.09+
582658 sure to consider the case where the linked list already contains
583659 entries.
584660
661+ Field name: pref_address
662+ Type: read (reloc)
663+ Offset/size: 0x258/8
664+ Protocol: 2.10+
665+
666+ This field, if nonzero, represents a preferred load address for the
667+ kernel. A relocating bootloader should attempt to load at this
668+ address if possible.
669+
670+ A non-relocatable kernel will unconditionally move itself and to run
671+ at this address.
672+
673+ Field name: init_size
674+ Type: read
675+ Offset/size: 0x25c/4
676+
677+ This field indicates the amount of linear contiguous memory starting
678+ at the kernel runtime start address that the kernel needs before it
679+ is capable of examining its memory map. This is not the same thing
680+ as the total amount of memory the kernel needs to boot, but it can
681+ be used by a relocating boot loader to help select a safe load
682+ address for the kernel.
683+
684+ The kernel runtime start address is determined by the following algorithm:
685+
686+ if (relocatable_kernel)
687+ runtime_start = align_up(load_address, kernel_alignment)
688+ else
689+ runtime_start = pref_address
690+
585691
586692**** THE IMAGE CHECKSUM
587693
0 commit comments