1 /* $NetBSD: multiboot.h,v 1.8 2009/02/22 18:05:42 ahoka Exp $ */
4 * Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Julio M. Merino Vidal.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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.
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.
31 #ifndef __MULTIBOOT_H__
32 #define __MULTIBOOT_H__
34 #if !defined(_KERNEL) && defined(_STANDALONE)
36 /* --------------------------------------------------------------------- */
39 * Multiboot header structure.
41 #define MULTIBOOT_HEADER_MAGIC 0x1BADB002
42 #define MULTIBOOT_HEADER_MODS_ALIGNED 0x00000001
43 #define MULTIBOOT_HEADER_WANT_MEMORY 0x00000002
44 #define MULTIBOOT_HEADER_HAS_VBE 0x00000004
45 #define MULTIBOOT_HEADER_HAS_ADDR 0x00010000
48 struct multiboot_header
{
53 /* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_ADDR. */
54 paddr_t mh_header_addr
;
56 paddr_t mh_load_end_addr
;
57 paddr_t mh_bss_end_addr
;
58 paddr_t mh_entry_addr
;
60 /* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_VBE. */
61 uint32_t mh_mode_type
;
66 #endif /* !defined(_LOCORE) */
69 * Symbols defined in locore.S.
71 #if !defined(_LOCORE) && defined(_KERNEL)
72 extern struct multiboot_header
*Multiboot_Header
;
73 #endif /* !defined(_LOCORE) && defined(_KERNEL) */
75 /* --------------------------------------------------------------------- */
78 * Multiboot information structure.
80 #define MULTIBOOT_INFO_MAGIC 0x2BADB002
81 #define MULTIBOOT_INFO_HAS_MEMORY 0x00000001
82 #define MULTIBOOT_INFO_HAS_BOOT_DEVICE 0x00000002
83 #define MULTIBOOT_INFO_HAS_CMDLINE 0x00000004
84 #define MULTIBOOT_INFO_HAS_MODS 0x00000008
85 #define MULTIBOOT_INFO_HAS_AOUT_SYMS 0x00000010
86 #define MULTIBOOT_INFO_HAS_ELF_SYMS 0x00000020
87 #define MULTIBOOT_INFO_HAS_MMAP 0x00000040
88 #define MULTIBOOT_INFO_HAS_DRIVES 0x00000080
89 #define MULTIBOOT_INFO_HAS_CONFIG_TABLE 0x00000100
90 #define MULTIBOOT_INFO_HAS_LOADER_NAME 0x00000200
91 #define MULTIBOOT_INFO_HAS_APM_TABLE 0x00000400
92 #define MULTIBOOT_INFO_HAS_VBE 0x00000800
95 struct multiboot_info
{
98 /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_MEMORY. */
99 uint32_t mi_mem_lower
;
100 uint32_t mi_mem_upper
;
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
;
108 /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_CMDLINE. */
111 /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_MODS. */
112 uint32_t mi_mods_count
;
113 vaddr_t mi_mods_addr
;
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 vaddr_t mi_elfshdr_addr
;
119 uint32_t mi_elfshdr_shndx
;
121 /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_MMAP. */
122 uint32_t mi_mmap_length
;
123 vaddr_t mi_mmap_addr
;
125 /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_DRIVES. */
126 uint32_t mi_drives_length
;
127 vaddr_t mi_drives_addr
;
129 /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_CONFIG_TABLE. */
130 void * unused_mi_config_table
;
132 /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_LOADER_NAME. */
133 char * mi_loader_name
;
135 /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_APM. */
136 void * unused_mi_apm_table
;
138 /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_VBE. */
139 void * unused_mi_vbe_control_info
;
140 void * unused_mi_vbe_mode_info
;
141 paddr_t unused_mi_vbe_interface_seg
;
142 paddr_t unused_mi_vbe_interface_off
;
143 uint32_t unused_mi_vbe_interface_len
;
146 /* --------------------------------------------------------------------- */
149 * Drive information. This describes an entry in the drives table as
150 * pointed to by mi_drives_addr.
152 struct multiboot_drive
{
156 uint16_t md_cylinders
;
160 /* The variable-sized 'ports' field comes here, so this structure
164 /* --------------------------------------------------------------------- */
167 * Memory mapping. This describes an entry in the memory mappings table
168 * as pointed to by mi_mmap_addr.
170 * Be aware that mm_size specifies the size of all other fields *except*
171 * for mm_size. In order to jump between two different entries, you
172 * have to count mm_size + 4 bytes.
174 struct multiboot_mmap
{
176 uint64_t mm_base_addr
;
182 * Modules. This describes an entry in the modules table as pointed
183 * to by mi_mods_addr.
186 struct multiboot_module
{
190 uint32_t mmo_reserved
;
193 #endif /* !defined(_LOCORE) */
195 /* --------------------------------------------------------------------- */
198 * Prototypes for public functions defined in multiboot.c.
200 #if !defined(_LOCORE) && defined(_KERNEL)
201 void multiboot_pre_reloc(struct multiboot_info
*);
202 void multiboot_post_reloc(void);
203 void multiboot_print_info(void);
204 bool multiboot_ksyms_addsyms_elf(void);
205 #endif /* !defined(_LOCORE) */
207 /* --------------------------------------------------------------------- */
208 #else /* !defined(_KERNEL) && defined(_STANDALONE) */
209 /* LSC FIXME: OLD MINIX DEFINITION: should be removed and replace with
210 definition above... */
211 #define MULTIBOOT_HEADER_MAGIC 0x1BADB002
213 #define MULTIBOOT_BOOTLOADER_MAGIC 0x2BADB002
215 /* Must pass memory information to OS. */
216 #define MULTIBOOT_PAGE_ALIGN 0x00000001
218 #define MULTIBOOT_MEMORY_INFO 0x00000002
220 #define MULTIBOOT_VIDEO_MODE 0x00000004
222 #define MULTIBOOT_AOUT_KLUDGE 0x00010000
224 /* consts used for Multiboot pre-init */
226 #define MULTIBOOT_VIDEO_MODE_EGA 1
228 #define MULTIBOOT_VIDEO_BUFFER 0xB8000
230 /* Usable lower memory chunk has a upper bound */
231 #define MULTIBOOT_LOWER_MEM_MAX 0x7f800
233 #define MULTIBOOT_CONSOLE_LINES 25
234 #define MULTIBOOT_CONSOLE_COLS 80
236 #define MULTIBOOT_VIDEO_BUFFER_BYTES \
237 (MULTIBOOT_CONSOLE_LINES*MULTIBOOT_CONSOLE_COLS*2)
239 #define MULTIBOOT_STACK_SIZE 4096
240 #define MULTIBOOT_PARAM_BUF_SIZE 1024
242 #define MULTIBOOT_MAX_MODS 20
244 /* Flags to be set in the ’flags’ member of the multiboot info structure. */
246 #define MULTIBOOT_INFO_MEMORY 0x00000001
247 #define MULTIBOOT_INFO_MEM_MAP 0x00000040
249 /* Is there a boot device set? */
250 #define MULTIBOOT_INFO_BOOTDEV 0x00000002
252 /* Is the command-line defined? */
253 #define MULTIBOOT_INFO_CMDLINE 0x00000004
255 /* Are there modules to do something with? */
256 #define MULTIBOOT_INFO_MODS 0x00000008
258 #define MULTIBOOT_HIGH_MEM_BASE 0x100000
262 #include <sys/types.h>
263 /* The symbol table for a.out. */
264 struct multiboot_aout_symbol_table
271 /* The section header table for ELF. */
272 struct multiboot_elf_section_header_table
280 typedef struct multiboot_elf_section_header_table multiboot_elf_section_header_table_t
;
281 typedef struct multiboot_aout_symbol_table multiboot_aout_symbol_table_t
;
283 struct multiboot_info
285 /* Multiboot info version number */
287 /* Available memory from BIOS */
288 u32_t mem_lower_unused
; /* minix uses memmap instead */
289 u32_t mem_upper_unused
;
290 /* "root" partition */
292 /* Kernel command line */
294 /* Boot-Module list */
299 multiboot_aout_symbol_table_t aout_sym
;
300 multiboot_elf_section_header_table_t elf_sec
;
302 /* Memory Mapping buffer */
305 /* Drive Info buffer */
308 /* ROM configuration table */
310 /* Boot Loader Name */
311 u32_t boot_loader_name
;
315 u32_t vbe_control_info
;
318 u16_t vbe_interface_seg
;
319 u16_t vbe_interface_off
;
320 u16_t vbe_interface_len
;
322 typedef struct multiboot_info multiboot_info_t
;
324 struct multiboot_mod_list
326 /* Memory used goes from bytes 'mod_start' to 'mod_end-1' inclusive */
329 /* Module command line */
331 /* Pad struct to 16 bytes (must be zero) */
334 typedef struct multiboot_mod_list multiboot_module_t
;
336 #define MULTIBOOT_MEMORY_AVAILABLE 1
337 #define MULTIBOOT_MEMORY_RESERVED 2
338 struct multiboot_mmap_entry
343 #define MULTIBOOT_MEMORY_AVAILABLE 1
344 #define MULTIBOOT_MEMORY_RESERVED 2
346 } __attribute__((packed
));
347 typedef struct multiboot_mmap_entry multiboot_memory_map_t
;
349 #endif /* __ASSEMBLY__ */
350 #endif /* !defined(_KERNEL) && defined(_STANDALONE) */
351 #endif /* __MULTIBOOT_H__ */