diff options
author | Huang, Ying <ying.huang@intel.com> | 2007-10-23 22:18:49 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2007-10-29 19:22:22 -0400 |
commit | aa69432a68fb0aec49551fd69fe920a6df572573 (patch) | |
tree | 65e354e8025a594bd8197885cbc9c9f557c730d6 /Documentation/i386 | |
parent | 076e21a0142ac33d53bc0cca58c6170d4ad14f5d (diff) |
x86 boot: document for 32 bit boot protocol
This patch documents the 32-bit boot protocol of x86. It has been used
by Kexec and LinuxBIOS. This patch is based on the proposal of Peter
Anvin.
Signed-off-by: Huang Ying <ying.huang@intel.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'Documentation/i386')
-rw-r--r-- | Documentation/i386/boot.txt | 38 | ||||
-rw-r--r-- | Documentation/i386/zero-page.txt | 122 |
2 files changed, 65 insertions, 95 deletions
diff --git a/Documentation/i386/boot.txt b/Documentation/i386/boot.txt index 2f75e750e4f..fc49b79bc1a 100644 --- a/Documentation/i386/boot.txt +++ b/Documentation/i386/boot.txt | |||
@@ -785,3 +785,41 @@ IMPORTANT: All the hooks are required to preserve %esp, %ebp, %esi and | |||
785 | After completing your hook, you should jump to the address | 785 | After completing your hook, you should jump to the address |
786 | that was in this field before your boot loader overwrote it | 786 | that was in this field before your boot loader overwrote it |
787 | (relocated, if appropriate.) | 787 | (relocated, if appropriate.) |
788 | |||
789 | |||
790 | **** 32-bit BOOT PROTOCOL | ||
791 | |||
792 | For machine with some new BIOS other than legacy BIOS, such as EFI, | ||
793 | LinuxBIOS, etc, and kexec, the 16-bit real mode setup code in kernel | ||
794 | based on legacy BIOS can not be used, so a 32-bit boot protocol needs | ||
795 | to be defined. | ||
796 | |||
797 | In 32-bit boot protocol, the first step in loading a Linux kernel | ||
798 | should be to setup the boot parameters (struct boot_params, | ||
799 | traditionally known as "zero page"). The memory for struct boot_params | ||
800 | should be allocated and initialized to all zero. Then the setup header | ||
801 | from offset 0x01f1 of kernel image on should be loaded into struct | ||
802 | boot_params and examined. The end of setup header can be calculated as | ||
803 | follow: | ||
804 | |||
805 | 0x0202 + byte value at offset 0x0201 | ||
806 | |||
807 | In addition to read/modify/write the setup header of the struct | ||
808 | boot_params as that of 16-bit boot protocol, the boot loader should | ||
809 | also fill the additional fields of the struct boot_params as that | ||
810 | described in zero-page.txt. | ||
811 | |||
812 | After setupping the struct boot_params, the boot loader can load the | ||
813 | 32/64-bit kernel in the same way as that of 16-bit boot protocol. | ||
814 | |||
815 | In 32-bit boot protocol, the kernel is started by jumping to the | ||
816 | 32-bit kernel entry point, which is the start address of loaded | ||
817 | 32/64-bit kernel. | ||
818 | |||
819 | At entry, the CPU must be in 32-bit protected mode with paging | ||
820 | disabled; a GDT must be loaded with the descriptors for selectors | ||
821 | __BOOT_CS(0x10) and __BOOT_DS(0x18); both descriptors must be 4G flat | ||
822 | segment; __BOOS_CS must have execute/read permission, and __BOOT_DS | ||
823 | must have read/write permission; CS must be __BOOT_CS and DS, ES, SS | ||
824 | must be __BOOT_DS; interrupt must be disabled; %esi must hold the base | ||
825 | address of the struct boot_params; %ebp, %edi and %ebx must be zero. | ||
diff --git a/Documentation/i386/zero-page.txt b/Documentation/i386/zero-page.txt index 6c0817c4568..169ad423a3d 100644 --- a/Documentation/i386/zero-page.txt +++ b/Documentation/i386/zero-page.txt | |||
@@ -1,99 +1,31 @@ | |||
1 | --------------------------------------------------------------------------- | 1 | The additional fields in struct boot_params as a part of 32-bit boot |
2 | !!!!!!!!!!!!!!!WARNING!!!!!!!! | 2 | protocol of kernel. These should be filled by bootloader or 16-bit |
3 | The zero page is a kernel internal data structure, not a stable ABI. It might change | 3 | real-mode setup code of the kernel. References/settings to it mainly |
4 | without warning and the kernel has no way to detect old version of it. | 4 | are in: |
5 | If you're writing some external code like a boot loader you should only use | ||
6 | the stable versioned real mode boot protocol described in boot.txt. Otherwise the kernel | ||
7 | might break you at any time. | ||
8 | !!!!!!!!!!!!!WARNING!!!!!!!!!!! | ||
9 | ---------------------------------------------------------------------------- | ||
10 | 5 | ||
11 | Summary of boot_params layout (kernel point of view) | 6 | include/asm-x86/bootparam.h |
12 | ( collected by Hans Lermen and Martin Mares ) | ||
13 | |||
14 | The contents of boot_params are used to pass parameters from the | ||
15 | 16-bit realmode code of the kernel to the 32-bit part. References/settings | ||
16 | to it mainly are in: | ||
17 | 7 | ||
18 | arch/i386/boot/setup.S | ||
19 | arch/i386/boot/video.S | ||
20 | arch/i386/kernel/head.S | ||
21 | arch/i386/kernel/setup.c | ||
22 | |||
23 | 8 | ||
24 | Offset Type Description | 9 | Offset Proto Name Meaning |
25 | ------ ---- ----------- | 10 | /Size |
26 | 0 32 bytes struct screen_info, SCREEN_INFO | ||
27 | ATTENTION, overlaps the following !!! | ||
28 | 2 unsigned short EXT_MEM_K, extended memory size in Kb (from int 0x15) | ||
29 | 0x20 unsigned short CL_MAGIC, commandline magic number (=0xA33F) | ||
30 | 0x22 unsigned short CL_OFFSET, commandline offset | ||
31 | Address of commandline is calculated: | ||
32 | 0x90000 + contents of CL_OFFSET | ||
33 | (only taken, when CL_MAGIC = 0xA33F) | ||
34 | 0x40 20 bytes struct apm_bios_info, APM_BIOS_INFO | ||
35 | 0x60 16 bytes Intel SpeedStep (IST) BIOS support information | ||
36 | 0x80 16 bytes hd0-disk-parameter from intvector 0x41 | ||
37 | 0x90 16 bytes hd1-disk-parameter from intvector 0x46 | ||
38 | 11 | ||
39 | 0xa0 16 bytes System description table truncated to 16 bytes. | 12 | 000/040 ALL screen_info Text mode or frame buffer information |
40 | ( struct sys_desc_table_struct ) | 13 | (struct screen_info) |
41 | 0xb0 - 0x13f Free. Add more parameters here if you really need them. | 14 | 040/014 ALL apm_bios_info APM BIOS information (struct apm_bios_info) |
42 | 0x140- 0x1be EDID_INFO Video mode setup | 15 | 060/010 ALL ist_info Intel SpeedStep (IST) BIOS support information |
43 | 16 | (struct ist_info) | |
44 | 0x1c4 unsigned long EFI system table pointer | 17 | 080/010 ALL hd0_info hd0 disk parameter, OBSOLETE!! |
45 | 0x1c8 unsigned long EFI memory descriptor size | 18 | 090/010 ALL hd1_info hd1 disk parameter, OBSOLETE!! |
46 | 0x1cc unsigned long EFI memory descriptor version | 19 | 0A0/010 ALL sys_desc_table System description table (struct sys_desc_table) |
47 | 0x1d0 unsigned long EFI memory descriptor map pointer | 20 | 140/080 ALL edid_info Video mode setup (struct edid_info) |
48 | 0x1d4 unsigned long EFI memory descriptor map size | 21 | 1C0/020 ALL efi_info EFI 32 information (struct efi_info) |
49 | 0x1e0 unsigned long ALT_MEM_K, alternative mem check, in Kb | 22 | 1E0/004 ALL alk_mem_k Alternative mem check, in KB |
50 | 0x1e4 unsigned long Scratch field for the kernel setup code | 23 | 1E4/004 ALL scratch Scratch field for the kernel setup code |
51 | 0x1e8 char number of entries in E820MAP (below) | 24 | 1E8/001 ALL e820_entries Number of entries in e820_map (below) |
52 | 0x1e9 unsigned char number of entries in EDDBUF (below) | 25 | 1E9/001 ALL eddbuf_entries Number of entries in eddbuf (below) |
53 | 0x1ea unsigned char number of entries in EDD_MBR_SIG_BUFFER (below) | 26 | 1EA/001 ALL edd_mbr_sig_buf_entries Number of entries in edd_mbr_sig_buffer |
54 | 0x1f1 char size of setup.S, number of sectors | 27 | (below) |
55 | 0x1f2 unsigned short MOUNT_ROOT_RDONLY (if !=0) | 28 | 290/040 ALL edd_mbr_sig_buffer EDD MBR signatures |
56 | 0x1f4 unsigned short size of compressed kernel-part in the | 29 | 2D0/A00 ALL e820_map E820 memory map table |
57 | (b)zImage-file (in 16 byte units, rounded up) | 30 | (array of struct e820entry) |
58 | 0x1f6 unsigned short swap_dev (unused AFAIK) | 31 | D00/1EC ALL eddbuf EDD data (array of struct edd_info) |
59 | 0x1f8 unsigned short RAMDISK_FLAGS | ||
60 | 0x1fa unsigned short VGA-Mode (old one) | ||
61 | 0x1fc unsigned short ORIG_ROOT_DEV (high=Major, low=minor) | ||
62 | 0x1ff char AUX_DEVICE_INFO | ||
63 | |||
64 | 0x200 short jump to start of setup code aka "reserved" field. | ||
65 | 0x202 4 bytes Signature for SETUP-header, ="HdrS" | ||
66 | 0x206 unsigned short Version number of header format | ||
67 | Current version is 0x0201... | ||
68 | 0x208 8 bytes (used by setup.S for communication with boot loaders, | ||
69 | look there) | ||
70 | 0x210 char LOADER_TYPE, = 0, old one | ||
71 | else it is set by the loader: | ||
72 | 0xTV: T=0 for LILO | ||
73 | 1 for Loadlin | ||
74 | 2 for bootsect-loader | ||
75 | 3 for SYSLINUX | ||
76 | 4 for ETHERBOOT | ||
77 | 5 for ELILO | ||
78 | 7 for GRuB | ||
79 | 8 for U-BOOT | ||
80 | 9 for Xen | ||
81 | V = version | ||
82 | 0x211 char loadflags: | ||
83 | bit0 = 1: kernel is loaded high (bzImage) | ||
84 | bit7 = 1: Heap and pointer (see below) set by boot | ||
85 | loader. | ||
86 | 0x212 unsigned short (setup.S) | ||
87 | 0x214 unsigned long KERNEL_START, where the loader started the kernel | ||
88 | 0x218 unsigned long INITRD_START, address of loaded ramdisk image | ||
89 | 0x21c unsigned long INITRD_SIZE, size in bytes of ramdisk image | ||
90 | 0x220 4 bytes (setup.S) | ||
91 | 0x224 unsigned short setup.S heap end pointer | ||
92 | 0x226 unsigned short zero_pad | ||
93 | 0x228 unsigned long cmd_line_ptr | ||
94 | 0x22c unsigned long ramdisk_max | ||
95 | 0x230 16 bytes trampoline | ||
96 | 0x290 - 0x2cf EDD_MBR_SIG_BUFFER (edd.S) | ||
97 | 0x2d0 - 0xd00 E820MAP | ||
98 | 0xd00 - 0xeff EDDBUF (edd.S) for disk signature read sector | ||
99 | 0xd00 - 0xeeb EDDBUF (edd.S) for edd data | ||