1/* $NetBSD: multiboot.h,v 1.7 2008/10/11 11:06:19 joerg 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) 44struct 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) 68extern 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) 91struct 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 paddr_t unused_mi_vbe_interface_seg; 138 paddr_t unused_mi_vbe_interface_off; 139 uint32_t unused_mi_vbe_interface_len; 140}; 141 142/* --------------------------------------------------------------------- */ 143 144/* 145 * Drive information. This describes an entry in the drives table as 146 * pointed to by mi_drives_addr. 147 */ 148struct multiboot_drive { 149 uint32_t md_length; 150 uint8_t md_number; 151 uint8_t md_mode; 152 uint16_t md_cylinders; 153 uint8_t md_heads; 154 uint8_t md_sectors; 155 156 /* The variable-sized 'ports' field comes here, so this structure 157 * can be longer. */ 158}; 159 160/* --------------------------------------------------------------------- */ 161 162/* 163 * Memory mapping. This describes an entry in the memory mappings table 164 * as pointed to by mi_mmap_addr. 165 * 166 * Be aware that mm_size specifies the size of all other fields *except* 167 * for mm_size. In order to jump between two different entries, you 168 * have to count mm_size + 4 bytes. 169 */ 170struct multiboot_mmap { 171 uint32_t mm_size; 172 uint64_t mm_base_addr; 173 uint64_t mm_length; 174 uint32_t mm_type; 175}; 176 177/* 178 * Modules. This describes an entry in the modules table as pointed 179 * to by mi_mods_addr. 180 */ 181 182struct multiboot_module { 183 uint32_t mmo_start; 184 uint32_t mmo_end; 185 char * mmo_string; 186 uint32_t mmo_reserved; 187}; 188 189#endif /* !defined(_LOCORE) */ 190 191/* --------------------------------------------------------------------- */ 192 193/* 194 * Prototypes for public functions defined in multiboot.c. 195 */ 196#if !defined(_LOCORE) && defined(_KERNEL) 197void multiboot_pre_reloc(struct multiboot_info *); 198void multiboot_post_reloc(void); 199void multiboot_print_info(void); 200bool multiboot_ksyms_addsyms_elf(void); 201#endif /* !defined(_LOCORE) */ 202 203/* --------------------------------------------------------------------- */ 204