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