xref: /freebsd/stand/efi/loader/arch/amd64/multiboot2.h (revision b077aed33b7b6aefca7b17ddb250cf521f938613)
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_EFI32_IH          19
64 #define MULTIBOOT_TAG_TYPE_EFI64_IH          20
65 #define MULTIBOOT_TAG_TYPE_LOAD_BASE_ADDR    21
66 
67 #define MULTIBOOT_HEADER_TAG_END  0
68 #define MULTIBOOT_HEADER_TAG_INFORMATION_REQUEST  1
69 #define MULTIBOOT_HEADER_TAG_ADDRESS  2
70 #define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS  3
71 #define MULTIBOOT_HEADER_TAG_CONSOLE_FLAGS  4
72 #define MULTIBOOT_HEADER_TAG_FRAMEBUFFER  5
73 #define MULTIBOOT_HEADER_TAG_MODULE_ALIGN  6
74 #define MULTIBOOT_HEADER_TAG_EFI_BS  7
75 #define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI64  9
76 #define MULTIBOOT_HEADER_TAG_RELOCATABLE  10
77 
78 #define MULTIBOOT2_ARCHITECTURE_I386  0
79 #define MULTIBOOT2_ARCHITECTURE_MIPS32  4
80 #define MULTIBOOT_HEADER_TAG_OPTIONAL 1
81 
82 #define MULTIBOOT_LOAD_PREFERENCE_NONE 0
83 #define MULTIBOOT_LOAD_PREFERENCE_LOW 1
84 #define MULTIBOOT_LOAD_PREFERENCE_HIGH 2
85 
86 #define MULTIBOOT_CONSOLE_FLAGS_CONSOLE_REQUIRED 1
87 #define MULTIBOOT_CONSOLE_FLAGS_EGA_TEXT_SUPPORTED 2
88 
89 #ifndef ASM_FILE
90 
91 typedef unsigned char		multiboot_uint8_t;
92 typedef unsigned short		multiboot_uint16_t;
93 typedef unsigned int		multiboot_uint32_t;
94 typedef unsigned long long	multiboot_uint64_t;
95 
96 struct multiboot_header
97 {
98   /* Must be MULTIBOOT_MAGIC - see above.  */
99   multiboot_uint32_t magic;
100 
101   /* ISA */
102   multiboot_uint32_t architecture;
103 
104   /* Total header length.  */
105   multiboot_uint32_t header_length;
106 
107   /* The above fields plus this one must equal 0 mod 2^32. */
108   multiboot_uint32_t checksum;
109 };
110 
111 struct multiboot_header_tag
112 {
113   multiboot_uint16_t type;
114   multiboot_uint16_t flags;
115   multiboot_uint32_t size;
116 };
117 
118 struct multiboot_header_tag_information_request
119 {
120   multiboot_uint16_t type;
121   multiboot_uint16_t flags;
122   multiboot_uint32_t size;
123   multiboot_uint32_t requests[0];
124 };
125 
126 struct multiboot_header_tag_address
127 {
128   multiboot_uint16_t type;
129   multiboot_uint16_t flags;
130   multiboot_uint32_t size;
131   multiboot_uint32_t header_addr;
132   multiboot_uint32_t load_addr;
133   multiboot_uint32_t load_end_addr;
134   multiboot_uint32_t bss_end_addr;
135 };
136 
137 struct multiboot_header_tag_entry_address
138 {
139   multiboot_uint16_t type;
140   multiboot_uint16_t flags;
141   multiboot_uint32_t size;
142   multiboot_uint32_t entry_addr;
143 };
144 
145 struct multiboot_header_tag_console_flags
146 {
147   multiboot_uint16_t type;
148   multiboot_uint16_t flags;
149   multiboot_uint32_t size;
150   multiboot_uint32_t console_flags;
151 };
152 
153 struct multiboot_header_tag_framebuffer
154 {
155   multiboot_uint16_t type;
156   multiboot_uint16_t flags;
157   multiboot_uint32_t size;
158   multiboot_uint32_t width;
159   multiboot_uint32_t height;
160   multiboot_uint32_t depth;
161 };
162 
163 struct multiboot_header_tag_module_align
164 {
165   multiboot_uint16_t type;
166   multiboot_uint16_t flags;
167   multiboot_uint32_t size;
168 };
169 
170 struct multiboot_header_tag_relocatable
171 {
172   multiboot_uint16_t type;
173   multiboot_uint16_t flags;
174   multiboot_uint32_t size;
175   multiboot_uint32_t min_addr;
176   multiboot_uint32_t max_addr;
177   multiboot_uint32_t align;
178   multiboot_uint32_t preference;
179 };
180 
181 struct multiboot_color
182 {
183   multiboot_uint8_t red;
184   multiboot_uint8_t green;
185   multiboot_uint8_t blue;
186 };
187 
188 struct multiboot_mmap_entry
189 {
190   multiboot_uint64_t addr;
191   multiboot_uint64_t len;
192 #define MULTIBOOT_MEMORY_AVAILABLE		1
193 #define MULTIBOOT_MEMORY_RESERVED		2
194 #define MULTIBOOT_MEMORY_ACPI_RECLAIMABLE       3
195 #define MULTIBOOT_MEMORY_NVS                    4
196 #define MULTIBOOT_MEMORY_BADRAM                 5
197   multiboot_uint32_t type;
198   multiboot_uint32_t zero;
199 };
200 typedef struct multiboot_mmap_entry multiboot_memory_map_t;
201 
202 struct multiboot_tag
203 {
204   multiboot_uint32_t type;
205   multiboot_uint32_t size;
206 };
207 
208 struct multiboot_tag_string
209 {
210   multiboot_uint32_t type;
211   multiboot_uint32_t size;
212   char string[0];
213 };
214 
215 struct multiboot_tag_module
216 {
217   multiboot_uint32_t type;
218   multiboot_uint32_t size;
219   multiboot_uint32_t mod_start;
220   multiboot_uint32_t mod_end;
221   char cmdline[0];
222 };
223 
224 struct multiboot_tag_basic_meminfo
225 {
226   multiboot_uint32_t type;
227   multiboot_uint32_t size;
228   multiboot_uint32_t mem_lower;
229   multiboot_uint32_t mem_upper;
230 };
231 
232 struct multiboot_tag_bootdev
233 {
234   multiboot_uint32_t type;
235   multiboot_uint32_t size;
236   multiboot_uint32_t biosdev;
237   multiboot_uint32_t slice;
238   multiboot_uint32_t part;
239 };
240 
241 struct multiboot_tag_mmap
242 {
243   multiboot_uint32_t type;
244   multiboot_uint32_t size;
245   multiboot_uint32_t entry_size;
246   multiboot_uint32_t entry_version;
247   struct multiboot_mmap_entry entries[0];
248 };
249 
250 struct multiboot_vbe_info_block
251 {
252   multiboot_uint8_t external_specification[512];
253 };
254 
255 struct multiboot_vbe_mode_info_block
256 {
257   multiboot_uint8_t external_specification[256];
258 };
259 
260 struct multiboot_tag_vbe
261 {
262   multiboot_uint32_t type;
263   multiboot_uint32_t size;
264 
265   multiboot_uint16_t vbe_mode;
266   multiboot_uint16_t vbe_interface_seg;
267   multiboot_uint16_t vbe_interface_off;
268   multiboot_uint16_t vbe_interface_len;
269 
270   struct multiboot_vbe_info_block vbe_control_info;
271   struct multiboot_vbe_mode_info_block vbe_mode_info;
272 };
273 
274 struct multiboot_tag_framebuffer_common
275 {
276   multiboot_uint32_t type;
277   multiboot_uint32_t size;
278 
279   multiboot_uint64_t framebuffer_addr;
280   multiboot_uint32_t framebuffer_pitch;
281   multiboot_uint32_t framebuffer_width;
282   multiboot_uint32_t framebuffer_height;
283   multiboot_uint8_t framebuffer_bpp;
284 #define MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED 0
285 #define MULTIBOOT_FRAMEBUFFER_TYPE_RGB     1
286 #define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT	2
287   multiboot_uint8_t framebuffer_type;
288   multiboot_uint16_t reserved;
289 };
290 
291 struct multiboot_tag_framebuffer
292 {
293   struct multiboot_tag_framebuffer_common common;
294 
295   union
296   {
297     struct
298     {
299       multiboot_uint16_t framebuffer_palette_num_colors;
300       struct multiboot_color framebuffer_palette[0];
301     };
302     struct
303     {
304       multiboot_uint8_t framebuffer_red_field_position;
305       multiboot_uint8_t framebuffer_red_mask_size;
306       multiboot_uint8_t framebuffer_green_field_position;
307       multiboot_uint8_t framebuffer_green_mask_size;
308       multiboot_uint8_t framebuffer_blue_field_position;
309       multiboot_uint8_t framebuffer_blue_mask_size;
310     };
311   };
312 };
313 
314 struct multiboot_tag_elf_sections
315 {
316   multiboot_uint32_t type;
317   multiboot_uint32_t size;
318   multiboot_uint32_t num;
319   multiboot_uint32_t entsize;
320   multiboot_uint32_t shndx;
321   char sections[0];
322 };
323 
324 struct multiboot_tag_apm
325 {
326   multiboot_uint32_t type;
327   multiboot_uint32_t size;
328   multiboot_uint16_t version;
329   multiboot_uint16_t cseg;
330   multiboot_uint32_t offset;
331   multiboot_uint16_t cseg_16;
332   multiboot_uint16_t dseg;
333   multiboot_uint16_t flags;
334   multiboot_uint16_t cseg_len;
335   multiboot_uint16_t cseg_16_len;
336   multiboot_uint16_t dseg_len;
337 };
338 
339 struct multiboot_tag_efi32
340 {
341   multiboot_uint32_t type;
342   multiboot_uint32_t size;
343   multiboot_uint32_t pointer;
344 };
345 
346 struct multiboot_tag_efi64
347 {
348   multiboot_uint32_t type;
349   multiboot_uint32_t size;
350   multiboot_uint64_t pointer;
351 };
352 
353 struct multiboot_tag_smbios
354 {
355   multiboot_uint32_t type;
356   multiboot_uint32_t size;
357   multiboot_uint8_t major;
358   multiboot_uint8_t minor;
359   multiboot_uint8_t reserved[6];
360   multiboot_uint8_t tables[0];
361 };
362 
363 struct multiboot_tag_old_acpi
364 {
365   multiboot_uint32_t type;
366   multiboot_uint32_t size;
367   multiboot_uint8_t rsdp[0];
368 };
369 
370 struct multiboot_tag_new_acpi
371 {
372   multiboot_uint32_t type;
373   multiboot_uint32_t size;
374   multiboot_uint8_t rsdp[0];
375 };
376 
377 struct multiboot_tag_network
378 {
379   multiboot_uint32_t type;
380   multiboot_uint32_t size;
381   multiboot_uint8_t dhcpack[0];
382 };
383 
384 struct multiboot_tag_efi_mmap
385 {
386   multiboot_uint32_t type;
387   multiboot_uint32_t size;
388   multiboot_uint32_t descr_size;
389   multiboot_uint32_t descr_vers;
390   multiboot_uint8_t efi_mmap[0];
391 };
392 
393 struct multiboot_tag_efi32_ih
394 {
395   multiboot_uint32_t type;
396   multiboot_uint32_t size;
397   multiboot_uint32_t pointer;
398 };
399 
400 struct multiboot_tag_efi64_ih
401 {
402   multiboot_uint32_t type;
403   multiboot_uint32_t size;
404   multiboot_uint64_t pointer;
405 };
406 
407 struct multiboot_tag_load_base_addr
408 {
409   multiboot_uint32_t type;
410   multiboot_uint32_t size;
411   multiboot_uint32_t load_base_addr;
412 };
413 
414 #endif /* ! ASM_FILE */
415 
416 #endif /* ! MULTIBOOT_HEADER */
417