23#ifndef MULTIBOOT_HEADER
24#define MULTIBOOT_HEADER 1
27#define MULTIBOOT_SEARCH 32768
28#define MULTIBOOT_HEADER_ALIGN 8
31#define MULTIBOOT2_HEADER_MAGIC 0xe85250d6
34#define MULTIBOOT2_BOOTLOADER_MAGIC 0x36d76289
37#define MULTIBOOT_MOD_ALIGN 0x00001000
40#define MULTIBOOT_INFO_ALIGN 0x00000008
44#define MULTIBOOT_TAG_ALIGN 8
45#define MULTIBOOT_TAG_TYPE_END 0
46#define MULTIBOOT_TAG_TYPE_CMDLINE 1
47#define MULTIBOOT_TAG_TYPE_BOOT_LOADER_NAME 2
48#define MULTIBOOT_TAG_TYPE_MODULE 3
49#define MULTIBOOT_TAG_TYPE_BASIC_MEMINFO 4
50#define MULTIBOOT_TAG_TYPE_BOOTDEV 5
51#define MULTIBOOT_TAG_TYPE_MMAP 6
52#define MULTIBOOT_TAG_TYPE_VBE 7
53#define MULTIBOOT_TAG_TYPE_FRAMEBUFFER 8
54#define MULTIBOOT_TAG_TYPE_ELF_SECTIONS 9
55#define MULTIBOOT_TAG_TYPE_APM 10
56#define MULTIBOOT_TAG_TYPE_EFI32 11
57#define MULTIBOOT_TAG_TYPE_EFI64 12
58#define MULTIBOOT_TAG_TYPE_SMBIOS 13
59#define MULTIBOOT_TAG_TYPE_ACPI_OLD 14
60#define MULTIBOOT_TAG_TYPE_ACPI_NEW 15
61#define MULTIBOOT_TAG_TYPE_NETWORK 16
62#define MULTIBOOT_TAG_TYPE_EFI_MMAP 17
63#define MULTIBOOT_TAG_TYPE_EFI_BS 18
64#define MULTIBOOT_TAG_TYPE_EFI32_IH 19
65#define MULTIBOOT_TAG_TYPE_EFI64_IH 20
66#define MULTIBOOT_TAG_TYPE_LOAD_BASE_ADDR 21
68#define MULTIBOOT_HEADER_TAG_END 0
69#define MULTIBOOT_HEADER_TAG_INFORMATION_REQUEST 1
70#define MULTIBOOT_HEADER_TAG_ADDRESS 2
71#define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS 3
72#define MULTIBOOT_HEADER_TAG_CONSOLE_FLAGS 4
73#define MULTIBOOT_HEADER_TAG_FRAMEBUFFER 5
74#define MULTIBOOT_HEADER_TAG_MODULE_ALIGN 6
75#define MULTIBOOT_HEADER_TAG_EFI_BS 7
76#define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI32 8
77#define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI64 9
78#define MULTIBOOT_HEADER_TAG_RELOCATABLE 10
80#define MULTIBOOT_ARCHITECTURE_I386 0
81#define MULTIBOOT_ARCHITECTURE_MIPS32 4
82#define MULTIBOOT_HEADER_TAG_OPTIONAL 1
84#define MULTIBOOT_LOAD_PREFERENCE_NONE 0
85#define MULTIBOOT_LOAD_PREFERENCE_LOW 1
86#define MULTIBOOT_LOAD_PREFERENCE_HIGH 2
88#define MULTIBOOT_CONSOLE_FLAGS_CONSOLE_REQUIRED 1
89#define MULTIBOOT_CONSOLE_FLAGS_EGA_TEXT_SUPPORTED 2
95typedef unsigned char multiboot_uint8_t;
96typedef unsigned short multiboot_uint16_t;
97typedef unsigned int multiboot_uint32_t;
98typedef unsigned long long multiboot_uint64_t;
100struct multiboot_header {
102 multiboot_uint32_t magic;
105 multiboot_uint32_t architecture;
108 multiboot_uint32_t header_length;
111 multiboot_uint32_t checksum;
114struct multiboot_header_tag {
115 multiboot_uint16_t type;
116 multiboot_uint16_t flags;
117 multiboot_uint32_t size;
120struct multiboot_header_tag_information_request {
121 multiboot_uint16_t type;
122 multiboot_uint16_t flags;
123 multiboot_uint32_t size;
124 multiboot_uint32_t requests[0];
127struct multiboot_header_tag_address {
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;
137struct multiboot_header_tag_entry_address {
138 multiboot_uint16_t type;
139 multiboot_uint16_t flags;
140 multiboot_uint32_t size;
141 multiboot_uint32_t entry_addr;
144struct multiboot_header_tag_console_flags {
145 multiboot_uint16_t type;
146 multiboot_uint16_t flags;
147 multiboot_uint32_t size;
148 multiboot_uint32_t console_flags;
151struct multiboot_header_tag_framebuffer {
152 multiboot_uint16_t type;
153 multiboot_uint16_t flags;
154 multiboot_uint32_t size;
155 multiboot_uint32_t width;
156 multiboot_uint32_t height;
157 multiboot_uint32_t depth;
160struct multiboot_header_tag_module_align {
161 multiboot_uint16_t type;
162 multiboot_uint16_t flags;
163 multiboot_uint32_t size;
166struct multiboot_header_tag_relocatable {
167 multiboot_uint16_t type;
168 multiboot_uint16_t flags;
169 multiboot_uint32_t size;
170 multiboot_uint32_t min_addr;
171 multiboot_uint32_t max_addr;
172 multiboot_uint32_t align;
173 multiboot_uint32_t preference;
176struct multiboot_color {
177 multiboot_uint8_t red;
178 multiboot_uint8_t green;
179 multiboot_uint8_t blue;
182struct multiboot_mmap_entry {
183 multiboot_uint64_t addr;
184 multiboot_uint64_t len;
185#define MULTIBOOT_MEMORY_AVAILABLE 1
186#define MULTIBOOT_MEMORY_RESERVED 2
187#define MULTIBOOT_MEMORY_ACPI_RECLAIMABLE 3
188#define MULTIBOOT_MEMORY_NVS 4
189#define MULTIBOOT_MEMORY_BADRAM 5
190 multiboot_uint32_t type;
191 multiboot_uint32_t zero;
193typedef struct multiboot_mmap_entry multiboot_memory_map_t;
195struct multiboot_info {
196 multiboot_uint32_t total_size;
197 multiboot_uint32_t reserved;
200struct multiboot_tag {
201 multiboot_uint32_t type;
202 multiboot_uint32_t size;
205static inline void *multiboot_tag_end(
void *tag)
207 return tag + ((
struct multiboot_tag *)tag)->size;
210struct multiboot_tag_string {
211 multiboot_uint32_t type;
212 multiboot_uint32_t size;
216struct multiboot_tag_module {
217 multiboot_uint32_t type;
218 multiboot_uint32_t size;
219 multiboot_uint32_t mod_start;
220 multiboot_uint32_t mod_end;
224struct multiboot_tag_basic_meminfo {
225 multiboot_uint32_t type;
226 multiboot_uint32_t size;
227 multiboot_uint32_t mem_lower;
228 multiboot_uint32_t mem_upper;
231struct multiboot_tag_bootdev {
232 multiboot_uint32_t type;
233 multiboot_uint32_t size;
234 multiboot_uint32_t biosdev;
235 multiboot_uint32_t slice;
236 multiboot_uint32_t part;
239struct multiboot_tag_mmap {
240 multiboot_uint32_t type;
241 multiboot_uint32_t size;
242 multiboot_uint32_t entry_size;
243 multiboot_uint32_t entry_version;
244 struct multiboot_mmap_entry entries[0];
247struct multiboot_vbe_info_block {
248 multiboot_uint8_t external_specification[512];
251struct multiboot_vbe_mode_info_block {
252 multiboot_uint8_t external_specification[256];
255struct multiboot_tag_vbe {
256 multiboot_uint32_t type;
257 multiboot_uint32_t size;
259 multiboot_uint16_t vbe_mode;
260 multiboot_uint16_t vbe_interface_seg;
261 multiboot_uint16_t vbe_interface_off;
262 multiboot_uint16_t vbe_interface_len;
264 struct multiboot_vbe_info_block vbe_control_info;
265 struct multiboot_vbe_mode_info_block vbe_mode_info;
268struct multiboot_tag_framebuffer_common {
269 multiboot_uint32_t type;
270 multiboot_uint32_t size;
272 multiboot_uint64_t framebuffer_addr;
273 multiboot_uint32_t framebuffer_pitch;
274 multiboot_uint32_t framebuffer_width;
275 multiboot_uint32_t framebuffer_height;
276 multiboot_uint8_t framebuffer_bpp;
277#define MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED 0
278#define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1
279#define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT 2
280 multiboot_uint8_t framebuffer_type;
281 multiboot_uint16_t reserved;
284struct multiboot_tag_framebuffer {
285 struct multiboot_tag_framebuffer_common common;
289 multiboot_uint16_t framebuffer_palette_num_colors;
290 struct multiboot_color framebuffer_palette[0];
293 multiboot_uint8_t framebuffer_red_field_position;
294 multiboot_uint8_t framebuffer_red_mask_size;
295 multiboot_uint8_t framebuffer_green_field_position;
296 multiboot_uint8_t framebuffer_green_mask_size;
297 multiboot_uint8_t framebuffer_blue_field_position;
298 multiboot_uint8_t framebuffer_blue_mask_size;
303struct multiboot_tag_elf_sections {
304 multiboot_uint32_t type;
305 multiboot_uint32_t size;
306 multiboot_uint32_t num;
307 multiboot_uint32_t entsize;
308 multiboot_uint32_t shndx;
312struct multiboot_tag_apm {
313 multiboot_uint32_t type;
314 multiboot_uint32_t size;
315 multiboot_uint16_t version;
316 multiboot_uint16_t cseg;
317 multiboot_uint32_t offset;
318 multiboot_uint16_t cseg_16;
319 multiboot_uint16_t dseg;
320 multiboot_uint16_t flags;
321 multiboot_uint16_t cseg_len;
322 multiboot_uint16_t cseg_16_len;
323 multiboot_uint16_t dseg_len;
326struct multiboot_tag_efi32 {
327 multiboot_uint32_t type;
328 multiboot_uint32_t size;
329 multiboot_uint32_t pointer;
332struct multiboot_tag_efi64 {
333 multiboot_uint32_t type;
334 multiboot_uint32_t size;
335 multiboot_uint64_t pointer;
338struct multiboot_tag_smbios {
339 multiboot_uint32_t type;
340 multiboot_uint32_t size;
341 multiboot_uint8_t major;
342 multiboot_uint8_t minor;
343 multiboot_uint8_t reserved[6];
344 multiboot_uint8_t tables[0];
347struct multiboot_tag_old_acpi {
348 multiboot_uint32_t type;
349 multiboot_uint32_t size;
350 multiboot_uint8_t rsdp[0];
353struct multiboot_tag_new_acpi {
354 multiboot_uint32_t type;
355 multiboot_uint32_t size;
356 multiboot_uint8_t rsdp[0];
359struct multiboot_tag_network {
360 multiboot_uint32_t type;
361 multiboot_uint32_t size;
362 multiboot_uint8_t dhcpack[0];
365struct multiboot_tag_efi_mmap {
366 multiboot_uint32_t type;
367 multiboot_uint32_t size;
368 multiboot_uint32_t descr_size;
369 multiboot_uint32_t descr_vers;
370 multiboot_uint8_t efi_mmap[0];
373struct multiboot_tag_efi32_ih {
374 multiboot_uint32_t type;
375 multiboot_uint32_t size;
376 multiboot_uint32_t pointer;
379struct multiboot_tag_efi64_ih {
380 multiboot_uint32_t type;
381 multiboot_uint32_t size;
382 multiboot_uint64_t pointer;
385struct multiboot_tag_load_base_addr {
386 multiboot_uint32_t type;
387 multiboot_uint32_t size;
388 multiboot_uint32_t load_base_addr;
391#define FOREACH_MULTIBOOT_TAG(_iter, _mbt) \
392 for (struct multiboot_tag *_iter = \
393 (void *)(_mbt) + sizeof(struct multiboot_info); \
394 _iter->type != MULTIBOOT_TAG_TYPE_END; \
395 _iter = (void *)align_up((native_t)_iter + _iter->size, \
396 MULTIBOOT_TAG_ALIGN))