1 /* multiboot.h - Multiboot 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 8192 27 #define MULTIBOOT_HEADER_ALIGN 4 28 29 /* The magic field should contain this. */ 30 #define MULTIBOOT_HEADER_MAGIC 0x1BADB002 31 32 /* This should be in %eax. */ 33 #define MULTIBOOT_BOOTLOADER_MAGIC 0x2BADB002 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 0x00000004 40 41 /* Flags set in the 'flags' member of the multiboot header. */ 42 43 /* Align all boot modules on i386 page (4KB) boundaries. */ 44 #define MULTIBOOT_PAGE_ALIGN 0x00000001 45 46 /* Must pass memory information to OS. */ 47 #define MULTIBOOT_MEMORY_INFO 0x00000002 48 49 /* Must pass video information to OS. */ 50 #define MULTIBOOT_VIDEO_MODE 0x00000004 51 52 /* This flag indicates the use of the address fields in the header. */ 53 #define MULTIBOOT_AOUT_KLUDGE 0x00010000 54 55 /* Flags to be set in the 'flags' member of the multiboot info structure. */ 56 57 /* is there basic lower/upper memory information? */ 58 #define MULTIBOOT_INFO_MEMORY 0x00000001 59 /* is there a boot device set? */ 60 #define MULTIBOOT_INFO_BOOTDEV 0x00000002 61 /* is the command-line defined? */ 62 #define MULTIBOOT_INFO_CMDLINE 0x00000004 63 /* are there modules to do something with? */ 64 #define MULTIBOOT_INFO_MODS 0x00000008 65 66 /* These next two are mutually exclusive */ 67 68 /* is there a symbol table loaded? */ 69 #define MULTIBOOT_INFO_AOUT_SYMS 0x00000010 70 /* is there an ELF section header table? */ 71 #define MULTIBOOT_INFO_ELF_SHDR 0X00000020 72 73 /* is there a full memory map? */ 74 #define MULTIBOOT_INFO_MEM_MAP 0x00000040 75 76 /* Is there drive info? */ 77 #define MULTIBOOT_INFO_DRIVE_INFO 0x00000080 78 79 /* Is there a config table? */ 80 #define MULTIBOOT_INFO_CONFIG_TABLE 0x00000100 81 82 /* Is there a boot loader name? */ 83 #define MULTIBOOT_INFO_BOOT_LOADER_NAME 0x00000200 84 85 /* Is there a APM table? */ 86 #define MULTIBOOT_INFO_APM_TABLE 0x00000400 87 88 /* Is there video information? */ 89 #define MULTIBOOT_INFO_VBE_INFO 0x00000800 90 #define MULTIBOOT_INFO_FRAMEBUFFER_INFO 0x00001000 91 92 struct multiboot_header 93 { 94 /* Must be MULTIBOOT_MAGIC - see above. */ 95 uint32_t magic; 96 97 /* Feature flags. */ 98 uint32_t flags; 99 100 /* The above fields plus this one must equal 0 mod 2^32. */ 101 uint32_t checksum; 102 103 /* These are only valid if MULTIBOOT_AOUT_KLUDGE is set. */ 104 uint32_t header_addr; 105 uint32_t load_addr; 106 uint32_t load_end_addr; 107 uint32_t bss_end_addr; 108 uint32_t entry_addr; 109 110 /* These are only valid if MULTIBOOT_VIDEO_MODE is set. */ 111 uint32_t mode_type; 112 uint32_t width; 113 uint32_t height; 114 uint32_t depth; 115 }; 116 117 /* The symbol table for a.out. */ 118 struct multiboot_aout_symbol_table 119 { 120 uint32_t tabsize; 121 uint32_t strsize; 122 uint32_t addr; 123 uint32_t reserved; 124 }; 125 typedef struct multiboot_aout_symbol_table multiboot_aout_symbol_table_t; 126 127 /* The section header table for ELF. */ 128 struct multiboot_elf_section_header_table 129 { 130 uint32_t num; 131 uint32_t size; 132 uint32_t addr; 133 uint32_t shndx; 134 }; 135 typedef struct multiboot_elf_section_header_table multiboot_elf_section_header_table_t; 136 137 struct multiboot_info 138 { 139 /* Multiboot info version number */ 140 uint32_t flags; 141 142 /* Available memory from BIOS */ 143 uint32_t mem_lower; 144 uint32_t mem_upper; 145 146 /* "root" partition */ 147 uint32_t boot_device; 148 149 /* Kernel command line */ 150 uint32_t cmdline; 151 152 /* Boot-Module list */ 153 uint32_t mods_count; 154 uint32_t mods_addr; 155 156 union 157 { 158 multiboot_aout_symbol_table_t aout_sym; 159 multiboot_elf_section_header_table_t elf_sec; 160 } u; 161 162 /* Memory Mapping buffer */ 163 uint32_t mmap_length; 164 uint32_t mmap_addr; 165 166 /* Drive Info buffer */ 167 uint32_t drives_length; 168 uint32_t drives_addr; 169 170 /* ROM configuration table */ 171 uint32_t config_table; 172 173 /* Boot Loader Name */ 174 uint32_t boot_loader_name; 175 176 /* APM table */ 177 uint32_t apm_table; 178 179 /* Video */ 180 uint32_t vbe_control_info; 181 uint32_t vbe_mode_info; 182 uint16_t vbe_mode; 183 uint16_t vbe_interface_seg; 184 uint16_t vbe_interface_off; 185 uint16_t vbe_interface_len; 186 187 uint64_t framebuffer_addr; 188 uint32_t framebuffer_pitch; 189 uint32_t framebuffer_width; 190 uint32_t framebuffer_height; 191 uint8_t framebuffer_bpp; 192 #define MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED 0 193 #define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1 194 #define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT 2 195 uint8_t framebuffer_type; 196 union 197 { 198 struct 199 { 200 uint32_t framebuffer_palette_addr; 201 uint16_t framebuffer_palette_num_colors; 202 }; 203 struct 204 { 205 uint8_t framebuffer_red_field_position; 206 uint8_t framebuffer_red_mask_size; 207 uint8_t framebuffer_green_field_position; 208 uint8_t framebuffer_green_mask_size; 209 uint8_t framebuffer_blue_field_position; 210 uint8_t framebuffer_blue_mask_size; 211 }; 212 }; 213 }; 214 typedef struct multiboot_info multiboot_info_t; 215 216 struct multiboot_color 217 { 218 uint8_t red; 219 uint8_t green; 220 uint8_t blue; 221 }; 222 223 struct multiboot_mmap_entry 224 { 225 uint32_t size; 226 uint64_t addr; 227 uint64_t len; 228 #define MULTIBOOT_MEMORY_AVAILABLE 1 229 #define MULTIBOOT_MEMORY_RESERVED 2 230 #define MULTIBOOT_MEMORY_ACPI_RECLAIMABLE 3 231 #define MULTIBOOT_MEMORY_NVS 4 232 #define MULTIBOOT_MEMORY_BADRAM 5 233 uint32_t type; 234 } __attribute__((packed)); 235 typedef struct multiboot_mmap_entry multiboot_memory_map_t; 236 237 struct multiboot_mod_list 238 { 239 /* the memory used goes from bytes 'mod_start' to 'mod_end-1' inclusive */ 240 uint32_t mod_start; 241 uint32_t mod_end; 242 243 /* Module command line */ 244 uint32_t cmdline; 245 246 /* padding to take it to 16 bytes (must be zero) */ 247 uint32_t pad; 248 }; 249 typedef struct multiboot_mod_list multiboot_module_t; 250 251 /* APM BIOS info. */ 252 struct multiboot_apm_info 253 { 254 uint16_t version; 255 uint16_t cseg; 256 uint32_t offset; 257 uint16_t cseg_16; 258 uint16_t dseg; 259 uint16_t flags; 260 uint16_t cseg_len; 261 uint16_t cseg_16_len; 262 uint16_t dseg_len; 263 }; 264 265 #endif /* ! MULTIBOOT_HEADER */ 266