1 /* 2 * Copyright (C) 2021-2022 Intel Corporation. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 /* multiboot_std.h - Multiboot standard header file. */ 8 /* 9 * Reference: 10 * https://www.gnu.org/software/grub/manual/multiboot/multiboot.html 11 * https://www.gnu.org/software/grub/manual/multiboot2/multiboot.html 12 */ 13 14 /* Copyright (C) 1999,2003,2007,2008,2009,2010 Free Software Foundation, Inc. 15 * 16 * Permission is hereby granted, free of charge, to any person obtaining a copy 17 * of this software and associated documentation files (the "Software"), to 18 * deal in the Software without restriction, including without limitation the 19 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 20 * sell copies of the Software, and to permit persons to whom the Software is 21 * furnished to do so, subject to the following conditions: 22 * 23 * The above copyright notice and this permission notice shall be included in 24 * all copies or substantial portions of the Software. 25 * 26 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 27 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 28 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ANY 29 * DEVELOPER OR DISTRIBUTOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 30 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 31 * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 32 */ 33 34 #ifndef MULTIBOOT_STD_H 35 #define MULTIBOOT_STD_H 36 37 #define MULTIBOOT_HEADER_MAGIC 0x1BADB002 38 #define MULTIBOOT_INFO_MAGIC 0x2BADB002U 39 40 /* MULTIBOOT HEADER FLAGS */ 41 #define MULTIBOOT_HEADER_NEED_MEMINFO 0x00000002 42 43 /* MULTIBOOT INFO FLAGS */ 44 #define MULTIBOOT_INFO_HAS_CMDLINE 0x00000004U 45 #define MULTIBOOT_INFO_HAS_MODS 0x00000008U 46 #define MULTIBOOT_INFO_HAS_MMAP 0x00000040U 47 #define MULTIBOOT_INFO_HAS_DRIVES 0x00000080U 48 #define MULTIBOOT_INFO_HAS_LOADER_NAME 0x00000200U 49 50 #ifndef ASSEMBLER 51 52 struct multiboot_header { 53 /* Must be MULTIBOOT_MAGIC - see above. */ 54 uint32_t magic; 55 56 /* Feature flags. */ 57 uint32_t flags; 58 59 /* The above fields plus this one must equal 0 mod 2^32. */ 60 uint32_t checksum; 61 62 /* These are only valid if MULTIBOOT_AOUT_KLUDGE is set. */ 63 uint32_t header_addr; 64 uint32_t load_addr; 65 uint32_t load_end_addr; 66 uint32_t bss_end_addr; 67 uint32_t entry_addr; 68 69 /* These are only valid if MULTIBOOT_VIDEO_MODE is set. */ 70 uint32_t mode_type; 71 uint32_t width; 72 uint32_t height; 73 uint32_t depth; 74 } __packed; 75 76 #define MULTIBOOT_MEMORY_AVAILABLE 1U 77 #define MULTIBOOT_MEMORY_RESERVED 2U 78 #define MULTIBOOT_MEMORY_ACPI_RECLAIMABLE 3U 79 #define MULTIBOOT_MEMORY_NVS 4U 80 #define MULTIBOOT_MEMORY_BADRAM 5U 81 struct multiboot_mmap { 82 uint32_t size; 83 uint64_t baseaddr; 84 uint64_t length; 85 uint32_t type; 86 } __packed; 87 88 struct multiboot_module { 89 uint32_t mm_mod_start; 90 uint32_t mm_mod_end; 91 uint32_t mm_string; 92 uint32_t mm_reserved; 93 } __packed; 94 95 struct multiboot_info { 96 uint32_t mi_flags; 97 98 /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_MEMORY. */ 99 uint32_t mi_mem_lower; 100 uint32_t mi_mem_upper; 101 102 /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_BOOT_DEVICE. */ 103 uint8_t mi_boot_device_part3; 104 uint8_t mi_boot_device_part2; 105 uint8_t mi_boot_device_part1; 106 uint8_t mi_boot_device_drive; 107 108 /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_CMDLINE. */ 109 uint32_t mi_cmdline; 110 111 /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_MODS. */ 112 uint32_t mi_mods_count; 113 uint32_t mi_mods_addr; 114 115 /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_{AOUT,ELF}_SYMS. */ 116 uint32_t mi_elfshdr_num; 117 uint32_t mi_elfshdr_size; 118 uint32_t mi_elfshdr_addr; 119 uint32_t mi_elfshdr_shndx; 120 121 /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_MMAP. */ 122 uint32_t mi_mmap_length; 123 uint32_t mi_mmap_addr; 124 125 /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_DRIVES. */ 126 uint32_t mi_drives_length; 127 uint32_t mi_drives_addr; 128 129 /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_CONFIG_TABLE. */ 130 uint32_t unused_mi_config_table; 131 132 /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_LOADER_NAME. */ 133 uint32_t mi_loader_name; 134 135 /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_APM. */ 136 uint32_t unused_mi_apm_table; 137 138 /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_VBE. */ 139 uint32_t unused_mi_vbe_control_info; 140 uint32_t unused_mi_vbe_mode_info; 141 uint16_t unused_mi_vbe_mode; 142 uint16_t unused_mi_vbe_interface_seg; 143 uint16_t unused_mi_vbe_interface_off; 144 uint16_t unused_mi_vbe_interface_len; 145 } __packed; 146 #endif 147 148 #ifdef CONFIG_MULTIBOOT2 149 #define MULTIBOOT2_HEADER_ALIGN 8 150 151 #define MULTIBOOT2_HEADER_MAGIC 0xe85250d6U 152 153 /* This should be in %eax. */ 154 #define MULTIBOOT2_INFO_MAGIC 0x36d76289U 155 156 /* Alignment of the multiboot info structure. */ 157 #define MULTIBOOT2_INFO_ALIGN 0x00000008U 158 159 /* Flags set in the 'flags' member of the multiboot header. */ 160 161 #define MULTIBOOT2_TAG_ALIGN 8U 162 #define MULTIBOOT2_TAG_TYPE_END 0U 163 #define MULTIBOOT2_TAG_TYPE_CMDLINE 1U 164 #define MULTIBOOT2_TAG_TYPE_BOOT_LOADER_NAME 2U 165 #define MULTIBOOT2_TAG_TYPE_MODULE 3U 166 #define MULTIBOOT2_TAG_TYPE_BASIC_MEMINFO 4U 167 #define MULTIBOOT2_TAG_TYPE_BOOTDEV 5U 168 #define MULTIBOOT2_TAG_TYPE_MMAP 6U 169 #define MULTIBOOT2_TAG_TYPE_VBE 7U 170 #define MULTIBOOT2_TAG_TYPE_FRAMEBUFFER 8U 171 #define MULTIBOOT2_TAG_TYPE_ELF_SECTIONS 9U 172 #define MULTIBOOT2_TAG_TYPE_APM 10U 173 #define MULTIBOOT2_TAG_TYPE_EFI32 11U 174 #define MULTIBOOT2_TAG_TYPE_EFI64 12U 175 #define MULTIBOOT2_TAG_TYPE_SMBIOS 13U 176 #define MULTIBOOT2_TAG_TYPE_ACPI_OLD 14U 177 #define MULTIBOOT2_TAG_TYPE_ACPI_NEW 15U 178 #define MULTIBOOT2_TAG_TYPE_NETWORK 16U 179 #define MULTIBOOT2_TAG_TYPE_EFI_MMAP 17U 180 #define MULTIBOOT2_TAG_TYPE_EFI_BS 18U 181 #define MULTIBOOT2_TAG_TYPE_EFI32_IH 19U 182 #define MULTIBOOT2_TAG_TYPE_EFI64_IH 20U 183 #define MULTIBOOT2_TAG_TYPE_LOAD_BASE_ADDR 21U 184 185 #define MULTIBOOT2_HEADER_TAG_END 0 186 #define MULTIBOOT2_HEADER_TAG_INFORMATION_REQUEST 1 187 #define MULTIBOOT2_HEADER_TAG_ADDRESS 2 188 #define MULTIBOOT2_HEADER_TAG_ENTRY_ADDRESS 3 189 #define MULTIBOOT2_HEADER_TAG_CONSOLE_FLAGS 4 190 #define MULTIBOOT2_HEADER_TAG_FRAMEBUFFER 5 191 #define MULTIBOOT2_HEADER_TAG_MODULE_ALIGN 6 192 #define MULTIBOOT2_HEADER_TAG_EFI_BS 7 193 #define MULTIBOOT2_HEADER_TAG_ENTRY_ADDRESS_EFI32 8 194 #define MULTIBOOT2_HEADER_TAG_ENTRY_ADDRESS_EFI64 9 195 #define MULTIBOOT2_HEADER_TAG_RELOCATABLE 10 196 197 #define MULTIBOOT2_ARCHITECTURE_I386 0 198 #define MULTIBOOT2_ARCHITECTURE_MIPS32 4 199 200 #ifndef ASSEMBLER 201 202 struct multiboot2_mmap_entry { 203 uint64_t addr; 204 uint64_t len; 205 uint32_t type; 206 uint32_t zero; 207 }; 208 209 struct multiboot2_tag { 210 uint32_t type; 211 uint32_t size; 212 }; 213 214 struct multiboot2_tag_string { 215 uint32_t type; 216 uint32_t size; 217 char string[0]; 218 }; 219 220 struct multiboot2_tag_module { 221 uint32_t type; 222 uint32_t size; 223 uint32_t mod_start; 224 uint32_t mod_end; 225 char cmdline[0]; 226 }; 227 228 struct multiboot2_tag_mmap { 229 uint32_t type; 230 uint32_t size; 231 uint32_t entry_size; 232 uint32_t entry_version; 233 struct multiboot2_mmap_entry entries[0]; 234 }; 235 236 struct multiboot2_tag_new_acpi { 237 uint32_t type; 238 uint32_t size; 239 uint8_t rsdp[0]; 240 }; 241 242 struct multiboot2_tag_efi64 { 243 uint32_t type; 244 uint32_t size; 245 uint64_t pointer; 246 }; 247 248 struct multiboot2_tag_efi_mmap { 249 uint32_t type; 250 uint32_t size; 251 uint32_t descr_size; 252 uint32_t descr_vers; 253 uint8_t efi_mmap[0]; 254 }; 255 #endif 256 257 #endif /* CONFIG_MULTIBOOT2 */ 258 259 #endif /* MULTIBOOT2_STD_H */ 260