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