xref: /titanic_44/usr/src/uts/common/sys/multiboot2.h (revision e84622ca60e336e723b4e107b019b1ecb4542eb3)
1 /*
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 /*
23  * Copyright 2016 Toomas Soome <tsoome@me.com>
24  */
25 
26 /*
27  * This header contains definitions for Multiboot 2 boot protocol, based on
28  * the reference implementation by grub 2.
29  *
30  * At the time this was written (Jan 2017), the Multiboot 2 documentation is in
31  * process of being rewritten and the information in the specification is not
32  * entirely correct. Instead, you must rely on grub 2 source code.
33  *
34  * This header provides essential support for the Multiboot 2 specification
35  * for illumos and makes it possible to pass the needed structures from the
36  * boot loader to the kernel.
37  */
38 
39 #ifndef	_SYS_MULTIBOOT2_H
40 #define	_SYS_MULTIBOOT2_H
41 
42 #ifdef	__cplusplus
43 extern "C" {
44 #endif
45 
46 /* How many bytes from the start of the file we search for the header.  */
47 #define	MULTIBOOT_SEARCH			32768
48 #define	MULTIBOOT_HEADER_ALIGN			8
49 
50 /* The magic field should contain this.  */
51 #define	MULTIBOOT2_HEADER_MAGIC			0xe85250d6
52 
53 /* This should be in %eax.  */
54 #define	MULTIBOOT2_BOOTLOADER_MAGIC		0x36d76289
55 
56 /* Alignment of multiboot modules.  */
57 #if defined(__i386) || defined(__amd64)
58 #define	MULTIBOOT_MOD_ALIGN			0x00001000
59 #else
60 #error No architecture defined
61 #endif
62 
63 /* Alignment of the multiboot info structure.  */
64 #define	MULTIBOOT_INFO_ALIGN			0x00000008
65 
66 /* Flags set in the 'flags' member of the multiboot header.  */
67 
68 #define	MULTIBOOT_TAG_ALIGN			8
69 #define	MULTIBOOT_TAG_TYPE_END			0
70 #define	MULTIBOOT_TAG_TYPE_CMDLINE		1
71 #define	MULTIBOOT_TAG_TYPE_BOOT_LOADER_NAME	2
72 #define	MULTIBOOT_TAG_TYPE_MODULE		3
73 #define	MULTIBOOT_TAG_TYPE_BASIC_MEMINFO	4
74 #define	MULTIBOOT_TAG_TYPE_BOOTDEV		5
75 #define	MULTIBOOT_TAG_TYPE_MMAP			6
76 #define	MULTIBOOT_TAG_TYPE_VBE			7
77 #define	MULTIBOOT_TAG_TYPE_FRAMEBUFFER		8
78 #define	MULTIBOOT_TAG_TYPE_ELF_SECTIONS		9
79 #define	MULTIBOOT_TAG_TYPE_APM			10
80 #define	MULTIBOOT_TAG_TYPE_EFI32		11
81 #define	MULTIBOOT_TAG_TYPE_EFI64		12
82 #define	MULTIBOOT_TAG_TYPE_SMBIOS		13
83 #define	MULTIBOOT_TAG_TYPE_ACPI_OLD		14
84 #define	MULTIBOOT_TAG_TYPE_ACPI_NEW		15
85 #define	MULTIBOOT_TAG_TYPE_NETWORK		16
86 #define	MULTIBOOT_TAG_TYPE_EFI_MMAP		17
87 #define	MULTIBOOT_TAG_TYPE_EFI_BS		18
88 #define	MULTIBOOT_TAG_TYPE_EFI32_IH		19
89 #define	MULTIBOOT_TAG_TYPE_EFI64_IH		20
90 #define	MULTIBOOT_TAG_TYPE_LOAD_BASE_ADDR	21
91 
92 #define	MULTIBOOT_HEADER_TAG_END			0
93 #define	MULTIBOOT_HEADER_TAG_INFORMATION_REQUEST	1
94 #define	MULTIBOOT_HEADER_TAG_ADDRESS			2
95 #define	MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS		3
96 #define	MULTIBOOT_HEADER_TAG_CONSOLE_FLAGS		4
97 #define	MULTIBOOT_HEADER_TAG_FRAMEBUFFER		5
98 #define	MULTIBOOT_HEADER_TAG_MODULE_ALIGN		6
99 #define	MULTIBOOT_HEADER_TAG_EFI_BS			7
100 #define	MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI32	8
101 #define	MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI64	9
102 #define	MULTIBOOT_HEADER_TAG_RELOCATABLE		10
103 
104 #define	MULTIBOOT_ARCHITECTURE_I386	0
105 #define	MULTIBOOT_ARCHITECTURE_MIPS32	4
106 #define	MULTIBOOT_HEADER_TAG_OPTIONAL	1
107 
108 /* Hints for relocatable kernel load preference */
109 #define	MULTIBOOT_LOAD_PREFERENCE_NONE	0
110 #define	MULTIBOOT_LOAD_PREFERENCE_LOW	1
111 #define	MULTIBOOT_LOAD_PREFERENCE_HIGH	2
112 
113 /* Values for console_flags field in tag multiboot_header_tag_console_flags. */
114 #define	MULTIBOOT_CONSOLE_FLAGS_CONSOLE_REQUIRED	1
115 #define	MULTIBOOT_CONSOLE_FLAGS_EGA_TEXT_SUPPORTED	2
116 
117 #ifndef _ASM
118 
119 #include <sys/stdint.h>
120 
121 #pragma pack(1)
122 
123 typedef struct multiboot_header_tag {
124 	uint16_t mbh_type;
125 	uint16_t mbh_flags;
126 	uint32_t mbh_size;
127 } multiboot_header_tag_t;
128 
129 typedef struct multiboot2_header {
130 	/* Must be MULTIBOOT2_MAGIC - see above.  */
131 	uint32_t mb2_magic;
132 
133 	/* ISA */
134 	uint32_t mb2_architecture;
135 
136 	/* Total header length.  */
137 	uint32_t mb2_header_length;
138 
139 	/* The above fields plus this one must equal 0 mod 2^32. */
140 	uint32_t mb2_checksum;
141 	multiboot_header_tag_t mb2_tags[];
142 } multiboot2_header_t;
143 
144 typedef struct multiboot_header_tag_information_request {
145 	uint16_t mbh_type;
146 	uint16_t mbh_flags;
147 	uint32_t mbh_size;
148 	uint32_t mbh_requests[];
149 } multiboot_header_tag_information_request_t;
150 
151 typedef struct multiboot_header_tag_address {
152 	uint16_t mbh_type;
153 	uint16_t mbh_flags;
154 	uint32_t mbh_size;
155 	uint32_t mbh_header_addr;
156 	uint32_t mbh_load_addr;
157 	uint32_t mbh_load_end_addr;
158 	uint32_t mbh_bss_end_addr;
159 } multiboot_header_tag_address_t;
160 
161 typedef struct multiboot_header_tag_entry_address {
162 	uint16_t mbh_type;
163 	uint16_t mbh_flags;
164 	uint32_t mbh_size;
165 	uint32_t mbh_entry_addr;
166 } multiboot_header_tag_entry_address_t;
167 
168 typedef struct multiboot_header_tag_console_flags {
169 	uint16_t mbh_type;
170 	uint16_t mbh_flags;
171 	uint32_t mbh_size;
172 	uint32_t mbh_console_flags;
173 } multiboot_header_tag_console_flags_t;
174 
175 typedef struct multiboot_header_tag_framebuffer {
176 	uint16_t mbh_type;
177 	uint16_t mbh_flags;
178 	uint32_t mbh_size;
179 	uint32_t mbh_width;
180 	uint32_t mbh_height;
181 	uint32_t mbh_depth;
182 } multiboot_header_tag_framebuffer_t;
183 
184 typedef struct multiboot_header_tag_module_align {
185 	uint16_t mbh_type;
186 	uint16_t mbh_flags;
187 	uint32_t mbh_size;
188 } multiboot_header_tag_module_align_t;
189 
190 typedef struct multiboot_header_tag_relocatable {
191 	uint16_t mbh_type;
192 	uint16_t mbh_flags;
193 	uint32_t mbh_size;
194 	uint32_t mbh_min_addr;
195 	uint32_t mbh_max_addr;
196 	uint32_t mbh_align;
197 	uint32_t mbh_preference;
198 } multiboot_header_tag_relocatable_t;
199 
200 typedef struct multiboot_color {
201 	uint8_t mb_red;
202 	uint8_t mb_green;
203 	uint8_t mb_blue;
204 } multiboot_color_t;
205 
206 typedef struct multiboot_mmap_entry {
207 	uint64_t mmap_addr;
208 	uint64_t mmap_len;
209 #define	MULTIBOOT_MEMORY_AVAILABLE		1
210 #define	MULTIBOOT_MEMORY_RESERVED		2
211 #define	MULTIBOOT_MEMORY_ACPI_RECLAIMABLE	3
212 #define	MULTIBOOT_MEMORY_NVS			4
213 #define	MULTIBOOT_MEMORY_BADRAM			5
214 	uint32_t mmap_type;
215 	uint32_t mmap_reserved;
216 } multiboot_mmap_entry_t;
217 
218 typedef struct multiboot_tag {
219 	uint32_t mb_type;
220 	uint32_t mb_size;
221 } multiboot_tag_t;
222 
223 typedef struct multiboot2_info_header {
224 	uint32_t mbi_total_size;
225 	uint32_t mbi_reserved;
226 	multiboot_tag_t mbi_tags[];
227 } multiboot2_info_header_t;
228 
229 typedef struct multiboot_tag_string {
230 	uint32_t mb_type;
231 	uint32_t mb_size;
232 	char mb_string[];
233 } multiboot_tag_string_t;
234 
235 typedef struct multiboot_tag_module {
236 	uint32_t mb_type;
237 	uint32_t mb_size;
238 	uint32_t mb_mod_start;
239 	uint32_t mb_mod_end;
240 	char mb_cmdline[];
241 } multiboot_tag_module_t;
242 
243 typedef struct multiboot_tag_basic_meminfo {
244 	uint32_t mb_type;
245 	uint32_t mb_size;
246 	uint32_t mb_mem_lower;
247 	uint32_t mb_mem_upper;
248 } multiboot_tag_basic_meminfo_t;
249 
250 typedef struct multiboot_tag_bootdev {
251 	uint32_t mb_type;
252 	uint32_t mb_size;
253 	uint32_t mb_biosdev;
254 	uint32_t mb_slice;
255 	uint32_t mb_part;
256 } multiboot_tag_bootdev_t;
257 
258 typedef struct multiboot_tag_mmap {
259 	uint32_t mb_type;
260 	uint32_t mb_size;
261 	uint32_t mb_entry_size;
262 	uint32_t mb_entry_version;
263 	uint8_t mb_entries[];
264 } multiboot_tag_mmap_t;
265 
266 struct multiboot_vbe_info_block {
267 	uint8_t vbe_external_specification[512];
268 };
269 
270 struct multiboot_vbe_mode_info_block {
271 	uint8_t vbe_external_specification[256];
272 };
273 
274 typedef struct multiboot_tag_vbe {
275 	uint32_t mb_type;
276 	uint32_t mb_size;
277 
278 	uint16_t vbe_mode;
279 	uint16_t vbe_interface_seg;
280 	uint16_t vbe_interface_off;
281 	uint16_t vbe_interface_len;
282 
283 	struct multiboot_vbe_info_block vbe_control_info;
284 	struct multiboot_vbe_mode_info_block vbe_mode_info;
285 } multiboot_tag_vbe_t;
286 
287 struct multiboot_tag_framebuffer_common {
288 	uint32_t mb_type;
289 	uint32_t mb_size;
290 
291 	uint64_t framebuffer_addr;
292 	uint32_t framebuffer_pitch;
293 	uint32_t framebuffer_width;
294 	uint32_t framebuffer_height;
295 	uint8_t framebuffer_bpp;
296 #define	MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED	0
297 #define	MULTIBOOT_FRAMEBUFFER_TYPE_RGB		1
298 #define	MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT	2
299 	uint8_t framebuffer_type;
300 	uint16_t mb_reserved;
301 };
302 
303 typedef struct multiboot_tag_framebuffer {
304 	struct multiboot_tag_framebuffer_common framebuffer_common;
305 
306 	union {
307 		struct {
308 			uint16_t framebuffer_palette_num_colors;
309 			multiboot_color_t framebuffer_palette[];
310 		} fb1;
311 		struct {
312 			uint8_t framebuffer_red_field_position;
313 			uint8_t framebuffer_red_mask_size;
314 			uint8_t framebuffer_green_field_position;
315 			uint8_t framebuffer_green_mask_size;
316 			uint8_t framebuffer_blue_field_position;
317 			uint8_t framebuffer_blue_mask_size;
318 		} fb2;
319 	} u;
320 } multiboot_tag_framebuffer_t;
321 
322 typedef struct multiboot_tag_elf_sections {
323 	uint32_t mb_type;
324 	uint32_t mb_size;
325 	uint32_t mb_num;
326 	uint32_t mb_entsize;
327 	uint32_t mb_shndx;
328 	char mb_sections[];
329 } multiboot_tag_elf_sections_t;
330 
331 typedef struct multiboot_tag_apm {
332 	uint32_t mb_type;
333 	uint32_t mb_size;
334 	uint16_t mb_version;
335 	uint16_t mb_cseg;
336 	uint32_t mb_offset;
337 	uint16_t mb_cseg_16;
338 	uint16_t mb_dseg;
339 	uint16_t mb_flags;
340 	uint16_t mb_cseg_len;
341 	uint16_t mb_cseg_16_len;
342 	uint16_t mb_dseg_len;
343 } multiboot_tag_apm_t;
344 
345 typedef struct multiboot_tag_efi32 {
346 	uint32_t mb_type;
347 	uint32_t mb_size;
348 	uint32_t mb_pointer;
349 } multiboot_tag_efi32_t;
350 
351 typedef struct multiboot_tag_efi64 {
352 	uint32_t mb_type;
353 	uint32_t mb_size;
354 	uint64_t mb_pointer;
355 } multiboot_tag_efi64_t;
356 
357 typedef struct multiboot_tag_smbios {
358 	uint32_t mb_type;
359 	uint32_t mb_size;
360 	uint8_t mb_major;
361 	uint8_t mb_minor;
362 	uint8_t mb_reserved[6];
363 	uint8_t mb_tables[];
364 } multiboot_tag_smbios_t;
365 
366 typedef struct multiboot_tag_old_acpi {
367 	uint32_t mb_type;
368 	uint32_t mb_size;
369 	uint8_t mb_rsdp[];
370 } multiboot_tag_old_acpi_t;
371 
372 typedef struct multiboot_tag_new_acpi {
373 	uint32_t mb_type;
374 	uint32_t mb_size;
375 	uint8_t mb_rsdp[];
376 } multiboot_tag_new_acpi_t;
377 
378 typedef struct multiboot_tag_network {
379 	uint32_t mb_type;
380 	uint32_t mb_size;
381 	uint8_t mb_dhcpack[];
382 } multiboot_tag_network_t;
383 
384 typedef struct multiboot_tag_efi_mmap {
385 	uint32_t mb_type;
386 	uint32_t mb_size;
387 	uint32_t mb_descr_size;
388 	uint32_t mb_descr_vers;
389 	uint8_t mb_efi_mmap[];
390 } multiboot_tag_efi_mmap_t;
391 
392 typedef struct multiboot_tag_efi32_ih {
393 	uint32_t mb_type;
394 	uint32_t mb_size;
395 	uint32_t mb_pointer;
396 } multiboot_tag_efi32_ih_t;
397 
398 typedef struct multiboot_tag_efi64_ih {
399 	uint32_t mb_type;
400 	uint32_t mb_size;
401 	uint64_t mb_pointer;
402 } multiboot_tag_efi64_ih_t;
403 
404 typedef struct multiboot_tag_load_base_addr {
405 	uint32_t mb_type;
406 	uint32_t mb_size;
407 	uint32_t mb_load_base_addr;
408 } multiboot_tag_load_base_addr_t;
409 
410 #pragma pack()
411 
412 #endif /* !_ASM */
413 
414 #ifdef	__cplusplus
415 }
416 #endif
417 
418 #endif /* !_SYS_MULTIBOOT2_H */
419