2ff1621a429e7aa8420074fa2738ceacbc5e3bf2
[grub.git] / include / grub / i386 / linux.h
1 /*
2  *  GRUB  --  GRand Unified Bootloader
3  *  Copyright (C) 1999,2000,2001,2002,2003,2004,2007,2008,2009  Free Software Foundation, Inc.
4  *
5  *  GRUB is free software: you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation, either version 3 of the License, or
8  *  (at your option) any later version.
9  *
10  *  GRUB is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
17  */
18
19 #ifndef GRUB_I386_LINUX_HEADER
20 #define GRUB_I386_LINUX_HEADER  1
21
22 #define GRUB_LINUX_MAGIC_SIGNATURE      0x53726448      /* "HdrS" */
23 #define GRUB_LINUX_DEFAULT_SETUP_SECTS  4
24 #define GRUB_LINUX_INITRD_MAX_ADDRESS   0x37FFFFFF
25 #define GRUB_LINUX_MAX_SETUP_SECTS      64
26 #define GRUB_LINUX_BOOT_LOADER_TYPE     0x72
27 #define GRUB_LINUX_HEAP_END_OFFSET      (0x9000 - 0x200)
28
29 #define GRUB_LINUX_BZIMAGE_ADDR         0x100000
30 #define GRUB_LINUX_ZIMAGE_ADDR          0x10000
31 #define GRUB_LINUX_OLD_REAL_MODE_ADDR   0x90000
32 #define GRUB_LINUX_SETUP_STACK          0x9000
33
34 #define GRUB_LINUX_FLAG_BIG_KERNEL      0x1
35 #define GRUB_LINUX_FLAG_QUIET           0x20
36 #define GRUB_LINUX_FLAG_CAN_USE_HEAP    0x80
37
38 /* Linux's video mode selection support. Actually I hate it!  */
39 #define GRUB_LINUX_VID_MODE_NORMAL      0xFFFF
40 #define GRUB_LINUX_VID_MODE_EXTENDED    0xFFFE
41 #define GRUB_LINUX_VID_MODE_ASK         0xFFFD
42 #define GRUB_LINUX_VID_MODE_VESA_START  0x0300
43
44 #define GRUB_LINUX_CL_MAGIC             0xA33F
45
46 #ifdef __x86_64__
47
48 #define GRUB_LINUX_EFI_SIGNATURE        \
49   ('4' << 24 | '6' << 16 | 'L' << 8 | 'E')
50
51 #else
52
53 #define GRUB_LINUX_EFI_SIGNATURE        \
54   ('2' << 24 | '3' << 16 | 'L' << 8 | 'E')
55
56 #endif
57
58 #define GRUB_LINUX_EFI_SIGNATURE_0204   \
59   ('L' << 24 | 'I' << 16 | 'F' << 8 | 'E')
60
61 #define GRUB_LINUX_OFW_SIGNATURE        \
62   (' ' << 24 | 'W' << 16 | 'F' << 8 | 'O')
63
64 #ifndef ASM_FILE
65
66 #define GRUB_E820_RAM        1
67 #define GRUB_E820_RESERVED   2
68 #define GRUB_E820_ACPI       3
69 #define GRUB_E820_NVS        4
70 #define GRUB_E820_BADRAM     5
71
72 struct grub_e820_mmap
73 {
74   grub_uint64_t addr;
75   grub_uint64_t size;
76   grub_uint32_t type;
77 } GRUB_PACKED;
78
79 enum
80   {
81     GRUB_VIDEO_LINUX_TYPE_TEXT = 0x01,
82     GRUB_VIDEO_LINUX_TYPE_VESA = 0x23,    /* VESA VGA in graphic mode.  */
83     GRUB_VIDEO_LINUX_TYPE_EFIFB = 0x70,    /* EFI Framebuffer.  */
84     GRUB_VIDEO_LINUX_TYPE_SIMPLE = 0x70    /* Linear framebuffer without any additional functions.  */
85   };
86
87 /* For the Linux/i386 boot protocol version 2.10.  */
88 struct linux_kernel_header
89 {
90   grub_uint8_t code1[0x0020];
91   grub_uint16_t cl_magic;               /* Magic number 0xA33F */
92   grub_uint16_t cl_offset;              /* The offset of command line */
93   grub_uint8_t code2[0x01F1 - 0x0020 - 2 - 2];
94   grub_uint8_t setup_sects;             /* The size of the setup in sectors */
95   grub_uint16_t root_flags;             /* If the root is mounted readonly */
96   grub_uint16_t syssize;                /* obsolete */
97   grub_uint16_t swap_dev;               /* obsolete */
98   grub_uint16_t ram_size;               /* obsolete */
99   grub_uint16_t vid_mode;               /* Video mode control */
100   grub_uint16_t root_dev;               /* Default root device number */
101   grub_uint16_t boot_flag;              /* 0xAA55 magic number */
102   grub_uint16_t jump;                   /* Jump instruction */
103   grub_uint32_t header;                 /* Magic signature "HdrS" */
104   grub_uint16_t version;                /* Boot protocol version supported */
105   grub_uint32_t realmode_swtch;         /* Boot loader hook */
106   grub_uint16_t start_sys;              /* The load-low segment (obsolete) */
107   grub_uint16_t kernel_version;         /* Points to kernel version string */
108   grub_uint8_t type_of_loader;          /* Boot loader identifier */
109 #define LINUX_LOADER_ID_LILO            0x0
110 #define LINUX_LOADER_ID_LOADLIN         0x1
111 #define LINUX_LOADER_ID_BOOTSECT        0x2
112 #define LINUX_LOADER_ID_SYSLINUX        0x3
113 #define LINUX_LOADER_ID_ETHERBOOT       0x4
114 #define LINUX_LOADER_ID_ELILO           0x5
115 #define LINUX_LOADER_ID_GRUB            0x7
116 #define LINUX_LOADER_ID_UBOOT           0x8
117 #define LINUX_LOADER_ID_XEN             0x9
118 #define LINUX_LOADER_ID_GUJIN           0xa
119 #define LINUX_LOADER_ID_QEMU            0xb
120   grub_uint8_t loadflags;               /* Boot protocol option flags */
121   grub_uint16_t setup_move_size;        /* Move to high memory size */
122   grub_uint32_t code32_start;           /* Boot loader hook */
123   grub_uint32_t ramdisk_image;          /* initrd load address */
124   grub_uint32_t ramdisk_size;           /* initrd size */
125   grub_uint32_t bootsect_kludge;        /* obsolete */
126   grub_uint16_t heap_end_ptr;           /* Free memory after setup end */
127   grub_uint16_t pad1;                   /* Unused */
128   grub_uint32_t cmd_line_ptr;           /* Points to the kernel command line */
129   grub_uint32_t initrd_addr_max;        /* Highest address for initrd */
130   grub_uint32_t kernel_alignment;
131   grub_uint8_t relocatable;
132   grub_uint8_t min_alignment;
133   grub_uint8_t pad[2];
134   grub_uint32_t cmdline_size;
135   grub_uint32_t hardware_subarch;
136   grub_uint64_t hardware_subarch_data;
137   grub_uint32_t payload_offset;
138   grub_uint32_t payload_length;
139   grub_uint64_t setup_data;
140   grub_uint64_t pref_address;
141   grub_uint32_t init_size;
142 } GRUB_PACKED;
143
144 /* Boot parameters for Linux based on 2.6.12. This is used by the setup
145    sectors of Linux, and must be simulated by GRUB on EFI, because
146    the setup sectors depend on BIOS.  */
147 struct linux_kernel_params
148 {
149   grub_uint8_t video_cursor_x;          /* 0 */
150   grub_uint8_t video_cursor_y;
151
152   grub_uint16_t ext_mem;                /* 2 */
153
154   grub_uint16_t video_page;             /* 4 */
155   grub_uint8_t video_mode;              /* 6 */
156   grub_uint8_t video_width;             /* 7 */
157
158   grub_uint8_t padding1[0xa - 0x8];
159
160   grub_uint16_t video_ega_bx;           /* a */
161
162   grub_uint8_t padding2[0xe - 0xc];
163
164   grub_uint8_t video_height;            /* e */
165   grub_uint8_t have_vga;                /* f */
166   grub_uint16_t font_size;              /* 10 */
167
168   grub_uint16_t lfb_width;              /* 12 */
169   grub_uint16_t lfb_height;             /* 14 */
170   grub_uint16_t lfb_depth;              /* 16 */
171   grub_uint32_t lfb_base;               /* 18 */
172   grub_uint32_t lfb_size;               /* 1c */
173
174   grub_uint16_t cl_magic;               /* 20 */
175   grub_uint16_t cl_offset;
176
177   grub_uint16_t lfb_line_len;           /* 24 */
178   grub_uint8_t red_mask_size;           /* 26 */
179   grub_uint8_t red_field_pos;
180   grub_uint8_t green_mask_size;
181   grub_uint8_t green_field_pos;
182   grub_uint8_t blue_mask_size;
183   grub_uint8_t blue_field_pos;
184   grub_uint8_t reserved_mask_size;
185   grub_uint8_t reserved_field_pos;
186   grub_uint16_t vesapm_segment;         /* 2e */
187   grub_uint16_t vesapm_offset;          /* 30 */
188   grub_uint16_t lfb_pages;              /* 32 */
189   grub_uint16_t vesa_attrib;            /* 34 */
190   grub_uint32_t capabilities;           /* 36 */
191
192   grub_uint8_t padding3[0x40 - 0x3a];
193
194   grub_uint16_t apm_version;            /* 40 */
195   grub_uint16_t apm_code_segment;       /* 42 */
196   grub_uint32_t apm_entry;              /* 44 */
197   grub_uint16_t apm_16bit_code_segment; /* 48 */
198   grub_uint16_t apm_data_segment;       /* 4a */
199   grub_uint16_t apm_flags;              /* 4c */
200   grub_uint32_t apm_code_len;           /* 4e */
201   grub_uint16_t apm_data_len;           /* 52 */
202
203   grub_uint8_t padding4[0x60 - 0x54];
204
205   grub_uint32_t ist_signature;          /* 60 */
206   grub_uint32_t ist_command;            /* 64 */
207   grub_uint32_t ist_event;              /* 68 */
208   grub_uint32_t ist_perf_level;         /* 6c */
209
210   grub_uint8_t padding5[0x80 - 0x70];
211
212   grub_uint8_t hd0_drive_info[0x10];    /* 80 */
213   grub_uint8_t hd1_drive_info[0x10];    /* 90 */
214   grub_uint16_t rom_config_len;         /* a0 */
215
216   grub_uint8_t padding6[0xb0 - 0xa2];
217
218   grub_uint32_t ofw_signature;          /* b0 */
219   grub_uint32_t ofw_num_items;          /* b4 */
220   grub_uint32_t ofw_cif_handler;        /* b8 */
221   grub_uint32_t ofw_idt;                /* bc */
222
223   grub_uint8_t padding7[0x1b8 - 0xc0];
224
225   union
226     {
227       struct
228         {
229           grub_uint32_t efi_system_table;       /* 1b8 */
230           grub_uint32_t padding7_1;             /* 1bc */
231           grub_uint32_t efi_signature;          /* 1c0 */
232           grub_uint32_t efi_mem_desc_size;      /* 1c4 */
233           grub_uint32_t efi_mem_desc_version;   /* 1c8 */
234           grub_uint32_t efi_mmap_size;          /* 1cc */
235           grub_uint32_t efi_mmap;               /* 1d0 */
236         } v0204;
237       struct
238         {
239           grub_uint32_t padding7_1;             /* 1b8 */
240           grub_uint32_t padding7_2;             /* 1bc */
241           grub_uint32_t efi_signature;          /* 1c0 */
242           grub_uint32_t efi_system_table;       /* 1c4 */
243           grub_uint32_t efi_mem_desc_size;      /* 1c8 */
244           grub_uint32_t efi_mem_desc_version;   /* 1cc */
245           grub_uint32_t efi_mmap;               /* 1d0 */
246           grub_uint32_t efi_mmap_size;          /* 1d4 */
247         } v0206;
248       struct
249         {
250           grub_uint32_t padding7_1;             /* 1b8 */
251           grub_uint32_t padding7_2;             /* 1bc */
252           grub_uint32_t efi_signature;          /* 1c0 */
253           grub_uint32_t efi_system_table;       /* 1c4 */
254           grub_uint32_t efi_mem_desc_size;      /* 1c8 */
255           grub_uint32_t efi_mem_desc_version;   /* 1cc */
256           grub_uint32_t efi_mmap;               /* 1d0 */
257           grub_uint32_t efi_mmap_size;          /* 1d4 */
258           grub_uint32_t efi_system_table_hi;    /* 1d8 */
259           grub_uint32_t efi_mmap_hi;            /* 1dc */
260         } v0208;
261     };
262
263   grub_uint32_t alt_mem;                /* 1e0 */
264
265   grub_uint8_t padding8[0x1e8 - 0x1e4];
266
267   grub_uint8_t mmap_size;               /* 1e8 */
268
269   grub_uint8_t padding9[0x1f1 - 0x1e9];
270
271   grub_uint8_t setup_sects;             /* The size of the setup in sectors */
272   grub_uint16_t root_flags;             /* If the root is mounted readonly */
273   grub_uint16_t syssize;                /* obsolete */
274   grub_uint16_t swap_dev;               /* obsolete */
275   grub_uint16_t ram_size;               /* obsolete */
276   grub_uint16_t vid_mode;               /* Video mode control */
277   grub_uint16_t root_dev;               /* Default root device number */
278
279   grub_uint8_t padding10;               /* 1fe */
280   grub_uint8_t ps_mouse;                /* 1ff */
281
282   grub_uint16_t jump;                   /* Jump instruction */
283   grub_uint32_t header;                 /* Magic signature "HdrS" */
284   grub_uint16_t version;                /* Boot protocol version supported */
285   grub_uint32_t realmode_swtch;         /* Boot loader hook */
286   grub_uint16_t start_sys;              /* The load-low segment (obsolete) */
287   grub_uint16_t kernel_version;         /* Points to kernel version string */
288   grub_uint8_t type_of_loader;          /* Boot loader identifier */
289   grub_uint8_t loadflags;               /* Boot protocol option flags */
290   grub_uint16_t setup_move_size;        /* Move to high memory size */
291   grub_uint32_t code32_start;           /* Boot loader hook */
292   grub_uint32_t ramdisk_image;          /* initrd load address */
293   grub_uint32_t ramdisk_size;           /* initrd size */
294   grub_uint32_t bootsect_kludge;        /* obsolete */
295   grub_uint16_t heap_end_ptr;           /* Free memory after setup end */
296   grub_uint8_t ext_loader_ver;          /* Extended loader version */
297   grub_uint8_t ext_loader_type;         /* Extended loader type */  
298   grub_uint32_t cmd_line_ptr;           /* Points to the kernel command line */
299   grub_uint32_t initrd_addr_max;        /* Maximum initrd address */
300   grub_uint32_t kernel_alignment;       /* Alignment of the kernel */
301   grub_uint8_t relocatable_kernel;      /* Is the kernel relocatable */
302   grub_uint8_t pad1[3];
303   grub_uint32_t cmdline_size;           /* Size of the kernel command line */
304   grub_uint32_t hardware_subarch;
305   grub_uint64_t hardware_subarch_data;
306   grub_uint32_t payload_offset;
307   grub_uint32_t payload_length;
308   grub_uint64_t setup_data;
309   grub_uint8_t pad2[120];               /* 258 */
310   struct grub_e820_mmap e820_map[(0x400 - 0x2d0) / 20]; /* 2d0 */
311
312 } GRUB_PACKED;
313 #endif /* ! ASM_FILE */
314
315 #endif /* ! GRUB_I386_LINUX_HEADER */