1 /* $NetBSD: multiboot.h,v 1.9 2018/04/13 01:49:47 khorben Exp $ */ 2 3 /*- 4 * Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Julio M. Merino Vidal. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 /* --------------------------------------------------------------------- */ 33 34 /* 35 * Multiboot header structure. 36 */ 37 #define MULTIBOOT_HEADER_MAGIC 0x1BADB002 38 #define MULTIBOOT_HEADER_MODS_ALIGNED 0x00000001 39 #define MULTIBOOT_HEADER_WANT_MEMORY 0x00000002 40 #define MULTIBOOT_HEADER_HAS_VBE 0x00000004 41 #define MULTIBOOT_HEADER_HAS_ADDR 0x00010000 42 43 #if !defined(_LOCORE) 44 struct multiboot_header { 45 uint32_t mh_magic; 46 uint32_t mh_flags; 47 uint32_t mh_checksum; 48 49 /* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_ADDR. */ 50 paddr_t mh_header_addr; 51 paddr_t mh_load_addr; 52 paddr_t mh_load_end_addr; 53 paddr_t mh_bss_end_addr; 54 paddr_t mh_entry_addr; 55 56 /* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_VBE. */ 57 uint32_t mh_mode_type; 58 uint32_t mh_width; 59 uint32_t mh_height; 60 uint32_t mh_depth; 61 }; 62 #endif /* !defined(_LOCORE) */ 63 64 /* 65 * Symbols defined in locore.S. 66 */ 67 #if !defined(_LOCORE) && defined(_KERNEL) 68 extern struct multiboot_header *Multiboot_Header; 69 #endif /* !defined(_LOCORE) && defined(_KERNEL) */ 70 71 /* --------------------------------------------------------------------- */ 72 73 /* 74 * Multiboot information structure. 75 */ 76 #define MULTIBOOT_INFO_MAGIC 0x2BADB002 77 #define MULTIBOOT_INFO_HAS_MEMORY 0x00000001 78 #define MULTIBOOT_INFO_HAS_BOOT_DEVICE 0x00000002 79 #define MULTIBOOT_INFO_HAS_CMDLINE 0x00000004 80 #define MULTIBOOT_INFO_HAS_MODS 0x00000008 81 #define MULTIBOOT_INFO_HAS_AOUT_SYMS 0x00000010 82 #define MULTIBOOT_INFO_HAS_ELF_SYMS 0x00000020 83 #define MULTIBOOT_INFO_HAS_MMAP 0x00000040 84 #define MULTIBOOT_INFO_HAS_DRIVES 0x00000080 85 #define MULTIBOOT_INFO_HAS_CONFIG_TABLE 0x00000100 86 #define MULTIBOOT_INFO_HAS_LOADER_NAME 0x00000200 87 #define MULTIBOOT_INFO_HAS_APM_TABLE 0x00000400 88 #define MULTIBOOT_INFO_HAS_VBE 0x00000800 89 90 #if !defined(_LOCORE) 91 struct multiboot_info { 92 uint32_t mi_flags; 93 94 /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_MEMORY. */ 95 uint32_t mi_mem_lower; 96 uint32_t mi_mem_upper; 97 98 /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_BOOT_DEVICE. */ 99 uint8_t mi_boot_device_part3; 100 uint8_t mi_boot_device_part2; 101 uint8_t mi_boot_device_part1; 102 uint8_t mi_boot_device_drive; 103 104 /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_CMDLINE. */ 105 char * mi_cmdline; 106 107 /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_MODS. */ 108 uint32_t mi_mods_count; 109 vaddr_t mi_mods_addr; 110 111 /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_{AOUT,ELF}_SYMS. */ 112 uint32_t mi_elfshdr_num; 113 uint32_t mi_elfshdr_size; 114 vaddr_t mi_elfshdr_addr; 115 uint32_t mi_elfshdr_shndx; 116 117 /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_MMAP. */ 118 uint32_t mi_mmap_length; 119 vaddr_t mi_mmap_addr; 120 121 /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_DRIVES. */ 122 uint32_t mi_drives_length; 123 vaddr_t mi_drives_addr; 124 125 /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_CONFIG_TABLE. */ 126 void * unused_mi_config_table; 127 128 /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_LOADER_NAME. */ 129 char * mi_loader_name; 130 131 /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_APM. */ 132 void * unused_mi_apm_table; 133 134 /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_VBE. */ 135 void * unused_mi_vbe_control_info; 136 void * unused_mi_vbe_mode_info; 137 uint16_t unused_mi_vbe_mode; 138 uint16_t unused_mi_vbe_interface_seg; 139 uint16_t unused_mi_vbe_interface_off; 140 uint16_t unused_mi_vbe_interface_len; 141 }; 142 143 /* --------------------------------------------------------------------- */ 144 145 /* 146 * Drive information. This describes an entry in the drives table as 147 * pointed to by mi_drives_addr. 148 */ 149 struct multiboot_drive { 150 uint32_t md_length; 151 uint8_t md_number; 152 uint8_t md_mode; 153 uint16_t md_cylinders; 154 uint8_t md_heads; 155 uint8_t md_sectors; 156 157 /* The variable-sized 'ports' field comes here, so this structure 158 * can be longer. */ 159 }; 160 161 /* --------------------------------------------------------------------- */ 162 163 /* 164 * Memory mapping. This describes an entry in the memory mappings table 165 * as pointed to by mi_mmap_addr. 166 * 167 * Be aware that mm_size specifies the size of all other fields *except* 168 * for mm_size. In order to jump between two different entries, you 169 * have to count mm_size + 4 bytes. 170 */ 171 struct multiboot_mmap { 172 uint32_t mm_size; 173 uint64_t mm_base_addr; 174 uint64_t mm_length; 175 uint32_t mm_type; 176 }; 177 178 /* 179 * Modules. This describes an entry in the modules table as pointed 180 * to by mi_mods_addr. 181 */ 182 183 struct multiboot_module { 184 uint32_t mmo_start; 185 uint32_t mmo_end; 186 char * mmo_string; 187 uint32_t mmo_reserved; 188 }; 189 190 #endif /* !defined(_LOCORE) */ 191 192 /* --------------------------------------------------------------------- */ 193 194 /* 195 * Prototypes for public functions defined in multiboot.c. 196 */ 197 #if !defined(_LOCORE) && defined(_KERNEL) 198 void multiboot_pre_reloc(struct multiboot_info *); 199 void multiboot_post_reloc(void); 200 void multiboot_print_info(void); 201 bool multiboot_ksyms_addsyms_elf(void); 202 #endif /* !defined(_LOCORE) */ 203 204 /* --------------------------------------------------------------------- */ 205