1 /* $NetBSD: multiboot.h,v 1.3 2006/02/04 11:24:42 jmmv 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 * Space reserved after the kernel image to stick the symbol table. 49 * The boot loader will leave this memory untouched (it will be treated 50 * as if it was part of the BSS section). 51 */ 52 #if !defined(MULTIBOOT_SYMTAB_SPACE) 53 # define MULTIBOOT_SYMTAB_SPACE 1048576 54 #endif 55 56 /* --------------------------------------------------------------------- */ 57 58 /* 59 * Multiboot header structure. 60 */ 61 #define MULTIBOOT_HEADER_MAGIC 0x1BADB002 62 #define MULTIBOOT_HEADER_MODS_ALIGNED 0x00000001 63 #define MULTIBOOT_HEADER_WANT_MEMORY 0x00000002 64 #define MULTIBOOT_HEADER_HAS_VBE 0x00000004 65 #define MULTIBOOT_HEADER_HAS_ADDR 0x00010000 66 67 #if !defined(_LOCORE) 68 struct multiboot_header { 69 uint32_t mh_magic; 70 uint32_t mh_flags; 71 uint32_t mh_checksum; 72 73 /* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_ADDR. */ 74 paddr_t mh_header_addr; 75 paddr_t mh_load_addr; 76 paddr_t mh_load_end_addr; 77 paddr_t mh_bss_end_addr; 78 paddr_t mh_entry_addr; 79 80 /* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_VBE. */ 81 uint32_t mh_mode_type; 82 uint32_t mh_width; 83 uint32_t mh_height; 84 uint32_t mh_depth; 85 }; 86 #endif /* !defined(_LOCORE) */ 87 88 /* 89 * Symbols defined in locore.S. 90 */ 91 #if !defined(_LOCORE) 92 extern struct multiboot_header *Multiboot_Header; 93 #endif /* !defined(_LOCORE) */ 94 95 /* --------------------------------------------------------------------- */ 96 97 /* 98 * Multiboot information structure. 99 */ 100 #define MULTIBOOT_INFO_MAGIC 0x2BADB002 101 #define MULTIBOOT_INFO_HAS_MEMORY 0x00000001 102 #define MULTIBOOT_INFO_HAS_BOOT_DEVICE 0x00000002 103 #define MULTIBOOT_INFO_HAS_CMDLINE 0x00000004 104 #define MULTIBOOT_INFO_HAS_MODS 0x00000008 105 #define MULTIBOOT_INFO_HAS_AOUT_SYMS 0x00000010 106 #define MULTIBOOT_INFO_HAS_ELF_SYMS 0x00000020 107 #define MULTIBOOT_INFO_HAS_MMAP 0x00000040 108 #define MULTIBOOT_INFO_HAS_DRIVES 0x00000080 109 #define MULTIBOOT_INFO_HAS_CONFIG_TABLE 0x00000100 110 #define MULTIBOOT_INFO_HAS_LOADER_NAME 0x00000200 111 #define MULTIBOOT_INFO_HAS_APM_TABLE 0x00000400 112 #define MULTIBOOT_INFO_HAS_VBE 0x00000800 113 114 #if !defined(_LOCORE) 115 struct multiboot_info { 116 uint32_t mi_flags; 117 118 /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_MEMORY. */ 119 uint32_t mi_mem_lower; 120 uint32_t mi_mem_upper; 121 122 /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_BOOT_DEVICE. */ 123 uint8_t mi_boot_device_part3; 124 uint8_t mi_boot_device_part2; 125 uint8_t mi_boot_device_part1; 126 uint8_t mi_boot_device_drive; 127 128 /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_CMDLINE. */ 129 char * mi_cmdline; 130 131 /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_MODS. */ 132 uint32_t unused_mi_mods_count; 133 vaddr_t unused_mi_mods_addr; 134 135 /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_{AOUT,ELF}_SYMS. */ 136 uint32_t mi_elfshdr_num; 137 uint32_t mi_elfshdr_size; 138 vaddr_t mi_elfshdr_addr; 139 uint32_t mi_elfshdr_shndx; 140 141 /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_MMAP. */ 142 uint32_t mi_mmap_length; 143 vaddr_t mi_mmap_addr; 144 145 /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_DRIVES. */ 146 uint32_t mi_drives_length; 147 vaddr_t mi_drives_addr; 148 149 /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_CONFIG_TABLE. */ 150 void * unused_mi_config_table; 151 152 /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_LOADER_NAME. */ 153 char * mi_loader_name; 154 155 /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_APM. */ 156 void * unused_mi_apm_table; 157 158 /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_VBE. */ 159 void * unused_mi_vbe_control_info; 160 void * unused_mi_vbe_mode_info; 161 paddr_t unused_mi_vbe_interface_seg; 162 paddr_t unused_mi_vbe_interface_off; 163 uint32_t unused_mi_vbe_interface_len; 164 }; 165 166 /* --------------------------------------------------------------------- */ 167 168 /* 169 * Drive information. This describes an entry in the drives table as 170 * pointed to by mi_drives_addr. 171 */ 172 struct multiboot_drive { 173 uint32_t md_length; 174 uint8_t md_number; 175 uint8_t md_mode; 176 uint16_t md_cylinders; 177 uint8_t md_heads; 178 uint8_t md_sectors; 179 180 /* The variable-sized 'ports' field comes here, so this structure 181 * can be longer. */ 182 }; 183 184 /* --------------------------------------------------------------------- */ 185 186 /* 187 * Memory mapping. This describes an entry in the memory mappings table 188 * as pointed to by mi_mmap_addr. 189 * 190 * Be aware that mm_size specifies the size of all other fields *except* 191 * for mm_size. In order to jump between two different entries, you 192 * have to count mm_size + 4 bytes. 193 */ 194 struct multiboot_mmap { 195 uint32_t mm_size; 196 uint64_t mm_base_addr; 197 uint64_t mm_length; 198 uint32_t mm_type; 199 }; 200 201 #endif /* !defined(_LOCORE) */ 202 203 /* --------------------------------------------------------------------- */ 204 205 /* 206 * Prototypes for public functions defined in multiboot.c. 207 */ 208 #if !defined(_LOCORE) 209 void multiboot_pre_reloc(struct multiboot_info *); 210 void multiboot_post_reloc(void); 211 void multiboot_print_info(void); 212 #endif /* !defined(_LOCORE) */ 213 214 /* --------------------------------------------------------------------- */ 215 216 #endif /* defined(MULTIBOOT) */ 217 218 #endif /* defined(_KERNEL) */ 219