1/*  multiboot2.h - Multiboot 2 header file.  */
2/*  Copyright (C) 1999,2003,2007,2008,2009,2010  Free Software Foundation, Inc.
3 *
4 *  Permission is hereby granted, free of charge, to any person obtaining a copy
5 *  of this software and associated documentation files (the "Software"), to
6 *  deal in the Software without restriction, including without limitation the
7 *  rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 *  sell copies of the Software, and to permit persons to whom the Software is
9 *  furnished to do so, subject to the following conditions:
10 *
11 *  The above copyright notice and this permission notice shall be included in
12 *  all copies or substantial portions of the Software.
13 *
14 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL ANY
17 *  DEVELOPER OR DISTRIBUTOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18 *  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
19 *  IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 */
21
22#ifndef MULTIBOOT_HEADER
23#define MULTIBOOT_HEADER 1
24
25/* How many bytes from the start of the file we search for the header.  */
26#define MULTIBOOT_SEARCH			32768
27#define MULTIBOOT_HEADER_ALIGN			8
28
29/* The magic field should contain this.  */
30#define MULTIBOOT2_HEADER_MAGIC			0xe85250d6
31
32/* This should be in %eax.  */
33#define MULTIBOOT2_BOOTLOADER_MAGIC		0x36d76289
34
35/* Alignment of multiboot modules.  */
36#define MULTIBOOT_MOD_ALIGN			0x00001000
37
38/* Alignment of the multiboot info structure.  */
39#define MULTIBOOT_INFO_ALIGN			0x00000008
40
41/* Flags set in the 'flags' member of the multiboot header.  */
42
43#define MULTIBOOT_TAG_ALIGN                  8
44#define MULTIBOOT_TAG_TYPE_END               0
45#define MULTIBOOT_TAG_TYPE_CMDLINE           1
46#define MULTIBOOT_TAG_TYPE_BOOT_LOADER_NAME  2
47#define MULTIBOOT_TAG_TYPE_MODULE            3
48#define MULTIBOOT_TAG_TYPE_BASIC_MEMINFO     4
49#define MULTIBOOT_TAG_TYPE_BOOTDEV           5
50#define MULTIBOOT_TAG_TYPE_MMAP              6
51#define MULTIBOOT_TAG_TYPE_VBE               7
52#define MULTIBOOT_TAG_TYPE_FRAMEBUFFER       8
53#define MULTIBOOT_TAG_TYPE_ELF_SECTIONS      9
54#define MULTIBOOT_TAG_TYPE_APM               10
55#define MULTIBOOT_TAG_TYPE_EFI32             11
56#define MULTIBOOT_TAG_TYPE_EFI64             12
57#define MULTIBOOT_TAG_TYPE_SMBIOS            13
58#define MULTIBOOT_TAG_TYPE_ACPI_OLD          14
59#define MULTIBOOT_TAG_TYPE_ACPI_NEW          15
60#define MULTIBOOT_TAG_TYPE_NETWORK           16
61#define MULTIBOOT_TAG_TYPE_EFI_MMAP          17
62#define MULTIBOOT_TAG_TYPE_EFI_BS            18
63#define MULTIBOOT_TAG_TYPE_MODULE_64         19
64
65#define MULTIBOOT_HEADER_TAG_END  0
66#define MULTIBOOT_HEADER_TAG_INFORMATION_REQUEST  1
67#define MULTIBOOT_HEADER_TAG_ADDRESS  2
68#define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS  3
69#define MULTIBOOT_HEADER_TAG_CONSOLE_FLAGS  4
70#define MULTIBOOT_HEADER_TAG_FRAMEBUFFER  5
71#define MULTIBOOT_HEADER_TAG_MODULE_ALIGN  6
72#define MULTIBOOT_HEADER_TAG_EFI_BS  7
73
74#define MULTIBOOT_ARCHITECTURE_I386  0
75#define MULTIBOOT_ARCHITECTURE_MIPS32  4
76#define MULTIBOOT_ARCHITECTURE_AARCH64 183
77#define MULTIBOOT_HEADER_TAG_OPTIONAL 1
78
79#define MULTIBOOT_CONSOLE_FLAGS_CONSOLE_REQUIRED 1
80#define MULTIBOOT_CONSOLE_FLAGS_EGA_TEXT_SUPPORTED 2
81
82#ifndef ASM_FILE
83
84typedef unsigned char		multiboot_uint8_t;
85typedef unsigned short		multiboot_uint16_t;
86typedef unsigned int		multiboot_uint32_t;
87typedef unsigned long long	multiboot_uint64_t;
88
89struct multiboot_header
90{
91  /* Must be MULTIBOOT_MAGIC - see above.  */
92  multiboot_uint32_t magic;
93
94  /* ISA */
95  multiboot_uint32_t architecture;
96
97  /* Total header length.  */
98  multiboot_uint32_t header_length;
99
100  /* The above fields plus this one must equal 0 mod 2^32. */
101  multiboot_uint32_t checksum;
102};
103
104struct multiboot_header_tag
105{
106  multiboot_uint16_t type;
107  multiboot_uint16_t flags;
108  multiboot_uint32_t size;
109};
110
111struct multiboot_header_tag_information_request
112{
113  multiboot_uint16_t type;
114  multiboot_uint16_t flags;
115  multiboot_uint32_t size;
116  multiboot_uint32_t requests[0];
117};
118
119struct multiboot_header_tag_address
120{
121  multiboot_uint16_t type;
122  multiboot_uint16_t flags;
123  multiboot_uint32_t size;
124  multiboot_uint32_t header_addr;
125  multiboot_uint32_t load_addr;
126  multiboot_uint32_t load_end_addr;
127  multiboot_uint32_t bss_end_addr;
128};
129
130struct multiboot_header_tag_entry_address
131{
132  multiboot_uint16_t type;
133  multiboot_uint16_t flags;
134  multiboot_uint32_t size;
135  multiboot_uint32_t entry_addr;
136};
137
138struct multiboot_header_tag_console_flags
139{
140  multiboot_uint16_t type;
141  multiboot_uint16_t flags;
142  multiboot_uint32_t size;
143  multiboot_uint32_t console_flags;
144};
145
146struct multiboot_header_tag_framebuffer
147{
148  multiboot_uint16_t type;
149  multiboot_uint16_t flags;
150  multiboot_uint32_t size;
151  multiboot_uint32_t width;
152  multiboot_uint32_t height;
153  multiboot_uint32_t depth;
154};
155
156struct multiboot_header_tag_module_align
157{
158  multiboot_uint16_t type;
159  multiboot_uint16_t flags;
160  multiboot_uint32_t size;
161};
162
163struct multiboot_color
164{
165  multiboot_uint8_t red;
166  multiboot_uint8_t green;
167  multiboot_uint8_t blue;
168};
169
170struct multiboot_mmap_entry
171{
172  multiboot_uint64_t addr;
173  multiboot_uint64_t len;
174#define MULTIBOOT_MEMORY_AVAILABLE		1
175#define MULTIBOOT_MEMORY_RESERVED		2
176#define MULTIBOOT_MEMORY_ACPI_RECLAIMABLE       3
177#define MULTIBOOT_MEMORY_NVS                    4
178#define MULTIBOOT_MEMORY_BADRAM                 5
179  multiboot_uint32_t type;
180  multiboot_uint32_t zero;
181} GRUB_PACKED;
182typedef struct multiboot_mmap_entry multiboot_memory_map_t;
183
184struct multiboot_tag
185{
186  multiboot_uint32_t type;
187  multiboot_uint32_t size;
188};
189
190struct multiboot_tag_string
191{
192  multiboot_uint32_t type;
193  multiboot_uint32_t size;
194  char string[0];
195};
196
197struct multiboot_tag_module
198{
199  multiboot_uint32_t type;
200  multiboot_uint32_t size;
201  multiboot_uint32_t mod_start;
202  multiboot_uint32_t mod_end;
203  char cmdline[0];
204};
205
206struct multiboot_tag_module_64
207{
208  multiboot_uint32_t type;
209  multiboot_uint32_t size;
210  multiboot_uint64_t mod_start;
211  multiboot_uint64_t mod_end;
212  char cmdline[0];
213};
214
215struct multiboot_tag_basic_meminfo
216{
217  multiboot_uint32_t type;
218  multiboot_uint32_t size;
219  multiboot_uint32_t mem_lower;
220  multiboot_uint32_t mem_upper;
221};
222
223struct multiboot_tag_bootdev
224{
225  multiboot_uint32_t type;
226  multiboot_uint32_t size;
227  multiboot_uint32_t biosdev;
228  multiboot_uint32_t slice;
229  multiboot_uint32_t part;
230};
231
232struct multiboot_tag_mmap
233{
234  multiboot_uint32_t type;
235  multiboot_uint32_t size;
236  multiboot_uint32_t entry_size;
237  multiboot_uint32_t entry_version;
238  struct multiboot_mmap_entry entries[0];
239};
240
241struct multiboot_vbe_info_block
242{
243  multiboot_uint8_t external_specification[512];
244};
245
246struct multiboot_vbe_mode_info_block
247{
248  multiboot_uint8_t external_specification[256];
249};
250
251struct multiboot_tag_vbe
252{
253  multiboot_uint32_t type;
254  multiboot_uint32_t size;
255
256  multiboot_uint16_t vbe_mode;
257  multiboot_uint16_t vbe_interface_seg;
258  multiboot_uint16_t vbe_interface_off;
259  multiboot_uint16_t vbe_interface_len;
260
261  struct multiboot_vbe_info_block vbe_control_info;
262  struct multiboot_vbe_mode_info_block vbe_mode_info;
263};
264
265struct multiboot_tag_framebuffer_common
266{
267  multiboot_uint32_t type;
268  multiboot_uint32_t size;
269
270  multiboot_uint64_t framebuffer_addr;
271  multiboot_uint32_t framebuffer_pitch;
272  multiboot_uint32_t framebuffer_width;
273  multiboot_uint32_t framebuffer_height;
274  multiboot_uint8_t framebuffer_bpp;
275#define MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED 0
276#define MULTIBOOT_FRAMEBUFFER_TYPE_RGB     1
277#define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT	2
278  multiboot_uint8_t framebuffer_type;
279  multiboot_uint16_t reserved;
280};
281
282struct multiboot_tag_framebuffer
283{
284  struct multiboot_tag_framebuffer_common common;
285
286  union
287  {
288    struct
289    {
290      multiboot_uint16_t framebuffer_palette_num_colors;
291      struct multiboot_color framebuffer_palette[0];
292    };
293    struct
294    {
295      multiboot_uint8_t framebuffer_red_field_position;
296      multiboot_uint8_t framebuffer_red_mask_size;
297      multiboot_uint8_t framebuffer_green_field_position;
298      multiboot_uint8_t framebuffer_green_mask_size;
299      multiboot_uint8_t framebuffer_blue_field_position;
300      multiboot_uint8_t framebuffer_blue_mask_size;
301    };
302  };
303};
304
305struct multiboot_tag_elf_sections
306{
307  multiboot_uint32_t type;
308  multiboot_uint32_t size;
309  multiboot_uint32_t num;
310  multiboot_uint32_t entsize;
311  multiboot_uint32_t shndx;
312  char sections[0];
313};
314
315struct multiboot_tag_apm
316{
317  multiboot_uint32_t type;
318  multiboot_uint32_t size;
319  multiboot_uint16_t version;
320  multiboot_uint16_t cseg;
321  multiboot_uint32_t offset;
322  multiboot_uint16_t cseg_16;
323  multiboot_uint16_t dseg;
324  multiboot_uint16_t flags;
325  multiboot_uint16_t cseg_len;
326  multiboot_uint16_t cseg_16_len;
327  multiboot_uint16_t dseg_len;
328};
329
330struct multiboot_tag_efi32
331{
332  multiboot_uint32_t type;
333  multiboot_uint32_t size;
334  multiboot_uint32_t pointer;
335};
336
337struct multiboot_tag_efi64
338{
339  multiboot_uint32_t type;
340  multiboot_uint32_t size;
341  multiboot_uint64_t pointer;
342};
343
344struct multiboot_tag_smbios
345{
346  multiboot_uint32_t type;
347  multiboot_uint32_t size;
348  multiboot_uint8_t major;
349  multiboot_uint8_t minor;
350  multiboot_uint8_t reserved[6];
351  multiboot_uint8_t tables[0];
352};
353
354struct multiboot_tag_old_acpi
355{
356  multiboot_uint32_t type;
357  multiboot_uint32_t size;
358  multiboot_uint8_t rsdp[0];
359};
360
361struct multiboot_tag_new_acpi
362{
363  multiboot_uint32_t type;
364  multiboot_uint32_t size;
365  multiboot_uint8_t rsdp[0];
366};
367
368struct multiboot_tag_network
369{
370  multiboot_uint32_t type;
371  multiboot_uint32_t size;
372  multiboot_uint8_t dhcpack[0];
373};
374
375struct multiboot_tag_efi_mmap
376{
377  multiboot_uint32_t type;
378  multiboot_uint32_t size;
379  multiboot_uint32_t descr_size;
380  multiboot_uint32_t descr_vers;
381  multiboot_uint8_t efi_mmap[0];
382};
383
384#define MULTIBOOT_MODULE_SIZE(mod)      ((mod).mod_end - (mod).mod_start)
385
386#endif /* ! ASM_FILE */
387
388#endif /* ! MULTIBOOT_HEADER */
389