1 #ifndef LUNAIX_MULTIBOOT_HEADER
2 #define LUNAIX_MULTIBOOT_HEADER 1
4 // References https://www.gnu.org/software/grub/manual/multiboot/multiboot.html
6 /* This should be in %eax. */
7 #define MULTIBOOT_BOOTLOADER_MAGIC 0x2BADB002
9 /* Alignment of multiboot modules. */
10 #define MULTIBOOT_MOD_ALIGN 0x00001000
12 /* Alignment of the multiboot info structure. */
13 #define MULTIBOOT_INFO_ALIGN 0x00000004
15 /* Flags set in the ’flags’ member of the multiboot header. */
17 /* Align all boot modules on i386 page (4KB) boundaries. */
18 #define MULTIBOOT_PAGE_ALIGN 0x00000001
20 /* Must pass memory information to OS. */
21 #define MULTIBOOT_MEMORY_INFO 0x00000002
23 /* Must pass video information to OS. */
24 #define MULTIBOOT_VIDEO_MODE 0x00000004
26 /* This flag indicates the use of the address fields in the header. */
27 #define MULTIBOOT_AOUT_KLUDGE 0x00010000
29 /* Flags to be set in the ’flags’ member of the multiboot info structure. */
31 /* is there basic lower/upper memory information? */
32 #define MULTIBOOT_INFO_MEMORY 0x00000001
33 /* is there a boot device set? */
34 #define MULTIBOOT_INFO_BOOTDEV 0x00000002
35 /* is the command-line defined? */
36 #define MULTIBOOT_INFO_CMDLINE 0x00000004
37 /* are there modules to do something with? */
38 #define MULTIBOOT_INFO_MODS 0x00000008
40 /* These next two are mutually exclusive */
42 /* is there a symbol table loaded? */
43 #define MULTIBOOT_INFO_AOUT_SYMS 0x00000010
44 /* is there an ELF section header table? */
45 #define MULTIBOOT_INFO_ELF_SHDR 0X00000020
47 /* is there a full memory map? */
48 #define MULTIBOOT_INFO_MEM_MAP 0x00000040
50 /* Is there drive info? */
51 #define MULTIBOOT_INFO_DRIVE_INFO 0x00000080
53 /* Is there a config table? */
54 #define MULTIBOOT_INFO_CONFIG_TABLE 0x00000100
56 /* Is there a boot loader name? */
57 #define MULTIBOOT_INFO_BOOT_LOADER_NAME 0x00000200
59 /* Is there a APM table? */
60 #define MULTIBOOT_INFO_APM_TABLE 0x00000400
62 /* Is there video information? */
63 #define MULTIBOOT_INFO_VBE_INFO 0x00000800
64 #define MULTIBOOT_INFO_FRAMEBUFFER_INFO 0x00001000
66 #define present(flags, info) ((flags) & (info))
70 typedef unsigned char multiboot_uint8_t;
71 typedef unsigned short multiboot_uint16_t;
72 typedef unsigned int multiboot_uint32_t;
73 typedef unsigned long long multiboot_uint64_t;
75 struct multiboot_symbol_table
77 multiboot_uint32_t tabsize;
78 multiboot_uint32_t strsize;
79 multiboot_uint32_t addr;
80 multiboot_uint32_t reserved;
82 typedef struct multiboot_symbol_table multiboot_symbol_table_t;
84 /* The section header table for ELF. */
85 struct multiboot_elf_section_header_table
87 multiboot_uint32_t num;
88 multiboot_uint32_t size;
89 multiboot_uint32_t addr;
90 multiboot_uint32_t shndx;
92 typedef struct multiboot_elf_section_header_table
93 multiboot_elf_section_header_table_t;
97 /* Multiboot info version number */
98 multiboot_uint32_t flags;
100 /* Available memory from BIOS */
101 multiboot_uint32_t mem_lower;
102 multiboot_uint32_t mem_upper;
104 /* "root" partition */
105 multiboot_uint32_t boot_device;
107 /* Kernel command line */
108 multiboot_uint32_t cmdline;
110 /* Boot-Module list */
111 multiboot_uint32_t mods_count;
112 multiboot_uint32_t mods_addr;
116 multiboot_symbol_table_t aout_sym;
117 multiboot_elf_section_header_table_t elf_sec;
120 /* Memory Mapping buffer */
121 multiboot_uint32_t mmap_length;
122 multiboot_uint32_t mmap_addr;
124 /* Drive Info buffer */
125 multiboot_uint32_t drives_length;
126 multiboot_uint32_t drives_addr;
128 /* ROM configuration table */
129 multiboot_uint32_t config_table;
131 /* Boot Loader Name */
132 multiboot_uint32_t boot_loader_name;
135 multiboot_uint32_t apm_table;
138 multiboot_uint32_t vbe_control_info;
139 multiboot_uint32_t vbe_mode_info;
140 multiboot_uint16_t vbe_mode;
141 multiboot_uint16_t vbe_interface_seg;
142 multiboot_uint16_t vbe_interface_off;
143 multiboot_uint16_t vbe_interface_len;
145 multiboot_uint64_t framebuffer_addr;
146 multiboot_uint32_t framebuffer_pitch;
147 multiboot_uint32_t framebuffer_width;
148 multiboot_uint32_t framebuffer_height;
149 multiboot_uint8_t framebuffer_bpp;
150 #define MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED 0
151 #define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1
152 #define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT 2
153 multiboot_uint8_t framebuffer_type;
158 multiboot_uint32_t framebuffer_palette_addr;
159 multiboot_uint16_t framebuffer_palette_num_colors;
163 multiboot_uint8_t framebuffer_red_field_position;
164 multiboot_uint8_t framebuffer_red_mask_size;
165 multiboot_uint8_t framebuffer_green_field_position;
166 multiboot_uint8_t framebuffer_green_mask_size;
167 multiboot_uint8_t framebuffer_blue_field_position;
168 multiboot_uint8_t framebuffer_blue_mask_size;
172 typedef struct multiboot_info multiboot_info_t;
174 struct multiboot_color
176 multiboot_uint8_t red;
177 multiboot_uint8_t green;
178 multiboot_uint8_t blue;
181 struct multiboot_mmap_entry
183 multiboot_uint32_t size;
184 multiboot_uint32_t addr_low;
185 multiboot_uint32_t addr_high;
186 multiboot_uint32_t len_low;
187 multiboot_uint32_t len_high;
188 #define MULTIBOOT_MEMORY_AVAILABLE 1
189 #define MULTIBOOT_MEMORY_RESERVED 2
190 #define MULTIBOOT_MEMORY_ACPI_RECLAIMABLE 3
191 #define MULTIBOOT_MEMORY_NVS 4
192 #define MULTIBOOT_MEMORY_BADRAM 5
193 multiboot_uint32_t type;
194 } __attribute__((packed));
196 typedef struct multiboot_mmap_entry multiboot_memory_map_t;
198 struct multiboot_mod_list
200 /* the memory used goes from bytes ’mod_start’ to ’mod_end-1’ inclusive */
201 multiboot_uint32_t mod_start;
202 multiboot_uint32_t mod_end;
204 /* Module command line */
205 multiboot_uint32_t cmdline;
207 /* padding to take it to 16 bytes (must be zero) */
208 multiboot_uint32_t pad;
210 typedef struct multiboot_mod_list multiboot_module_t;
213 struct multiboot_apm_info
215 multiboot_uint16_t version;
216 multiboot_uint16_t cseg;
217 multiboot_uint32_t offset;
218 multiboot_uint16_t cseg_16;
219 multiboot_uint16_t dseg;
220 multiboot_uint16_t flags;
221 multiboot_uint16_t cseg_len;
222 multiboot_uint16_t cseg_16_len;
223 multiboot_uint16_t dseg_len;
226 #define MB_MMAP_ENTRY_SIZE sizeof(multiboot_memory_map_t)