2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
30 #ifndef _PEXPERT_I386_BOOT_H
31 #define _PEXPERT_I386_BOOT_H
34 * What the booter leaves behind for the kernel.
38 * Maximum number of boot drivers that can be loaded.
43 * Types of boot driver that may be loaded by the booter.
46 kBootDriverTypeInvalid
= 0,
47 kBootDriverTypeKEXT
= 1,
48 kBootDriverTypeMKEXT
= 2
52 unsigned long address
; // address where driver was loaded
53 unsigned long size
; // number of bytes
54 unsigned long type
; // driver type
58 * APM BIOS information.
61 unsigned short major_vers
; // == 0 if not present
62 unsigned short minor_vers
;
63 unsigned long cs32_base
;
64 unsigned long cs16_base
;
65 unsigned long ds_base
;
66 unsigned long cs_length
;
67 unsigned long ds_length
;
68 unsigned long entry_offset
;
71 unsigned long mode_16
:1;
72 unsigned long mode_32
:1;
73 unsigned long idle_slows_cpu
:1;
74 unsigned long reserved
:29;
78 unsigned long connected
;
82 * PCI bus information.
84 typedef struct _PCI_bus_info_t
{
87 unsigned char configMethod1
:1;
88 unsigned char configMethod2
:1;
90 unsigned char specialCycle1
:1;
91 unsigned char specialCycle2
:1;
95 unsigned char maxBusNum
;
96 unsigned char majorVersion
;
97 unsigned char minorVersion
;
98 unsigned char BIOSPresent
;
105 unsigned long v_baseAddr
; // Base address of video memory
106 unsigned long v_display
; // Display Code (if Applicable
107 unsigned long v_rowBytes
; // Number of bytes per pixel row
108 unsigned long v_width
; // Width
109 unsigned long v_height
; // Height
110 unsigned long v_depth
; // Pixel Depth
113 typedef struct boot_video boot_video
;
115 #define GRAPHICS_MODE 1
120 * INT15, E820h - Query System Address Map.
122 * Documented in ACPI Specification Rev 2.0,
123 * Chapter 15 (System Address Map Interfaces).
127 * ACPI defined memory range types.
130 kMemoryRangeUsable
= 1, // RAM usable by the OS.
131 kMemoryRangeReserved
= 2, // Reserved. (Do not use)
132 kMemoryRangeACPI
= 3, // ACPI tables. Can be reclaimed.
133 kMemoryRangeNVS
= 4, // ACPI NVS memory. (Do not use)
135 /* Undefined types should be treated as kMemoryRangeReserved */
139 * Memory range descriptor.
141 typedef struct MemoryRange
{
142 unsigned long long base
; // 64-bit base address
143 unsigned long long length
; // 64-bit length in bytes
144 unsigned long type
; // type of memory range
145 unsigned long reserved
;
148 #define kMemoryMapCountMax 40
151 * BIOS drive information.
153 struct boot_drive_info
{
154 struct drive_params
{
155 unsigned short buf_size
;
156 unsigned short info_flags
;
157 unsigned long phys_cyls
;
158 unsigned long phys_heads
;
159 unsigned long phys_spt
;
160 unsigned long long phys_sectors
;
161 unsigned short phys_nbps
;
162 unsigned short dpte_offset
;
163 unsigned short dpte_segment
;
165 unsigned char path_len
;
166 unsigned char reserved1
;
167 unsigned short reserved2
;
168 unsigned char bus_type
[4];
169 unsigned char interface_type
[8];
170 unsigned char interface_path
[8];
171 unsigned char dev_path
[8];
172 unsigned char reserved3
;
173 unsigned char checksum
;
174 } params
__attribute__((packed
));
176 unsigned short io_port_base
;
177 unsigned short control_port_base
;
178 unsigned char head_flags
;
179 unsigned char vendor_info
;
180 unsigned char irq
: 4;
181 unsigned char irq_unused
: 4;
182 unsigned char block_count
;
183 unsigned char dma_channel
: 4;
184 unsigned char dma_type
: 4;
185 unsigned char pio_type
: 4;
186 unsigned char pio_unused
: 4;
187 unsigned short option_flags
;
188 unsigned short reserved
;
189 unsigned char revision
;
190 unsigned char checksum
;
191 } dpte
__attribute__((packed
));
192 } __attribute__((packed
));
193 typedef struct boot_drive_info boot_drive_info_t
;
195 #define MAX_BIOS_DEVICES 8
197 #define OLD_BOOT_STRING_LEN 160
198 #define BOOT_STRING_LEN 1024
199 #define CONFIG_SIZE (12 * 4096)
201 /* Old structure for compatibility */
205 char bootString
[OLD_BOOT_STRING_LEN
]; // boot arguments
206 int magicCookie
; // KERNBOOTMAGIC
207 int numIDEs
; // number of IDE drives
208 int rootdev
; // root device
209 int convmem
; // conventional memory
210 int extmem
; // extended memory
211 char bootFile
[128]; // kernel file name
212 int firstAddr0
; // first address for kern convmem
213 int diskInfo
[4]; // info for bios dev 80-83
214 int graphicsMode
; // booted in graphics mode?
215 int kernDev
; // device kernel was fetched from
216 int numBootDrivers
; // number of drivers loaded
217 char * configEnd
; // pointer to end of config files
218 int kaddr
; // kernel load address
219 int ksize
; // size of kernel
220 driver_config_t driverConfig
[NDRIVERS
];
221 char _reserved
[2052];
223 PCI_bus_info_t pciInfo
;
224 APM_config_t apmConfig
;
225 char config
[CONFIG_SIZE
];
228 #define KERNSTRUCT_ADDR ((KERNBOOTSTRUCT *) 0x11000)
229 #define KERNBOOTMAGIC 0xa7a7a7a7
231 #define BOOT_LINE_LENGTH 256
234 * Video information..
238 unsigned long v_baseAddr
; /* Base address of video memory */
239 unsigned long v_display
; /* Display Code (if Applicable */
240 unsigned long v_rowBytes
; /* Number of bytes per pixel row */
241 unsigned long v_width
; /* Width */
242 unsigned long v_height
; /* Height */
243 unsigned long v_depth
; /* Pixel Depth */
246 typedef struct Boot_Video Boot_Video
;
248 /* DRAM Bank definitions - describes physical memory layout.
250 #define kMaxDRAMBanks 26 /* maximum number of DRAM banks */
254 unsigned long base
; /* physical base of DRAM bank */
255 unsigned long size
; /* size of bank */
257 typedef struct DRAMBank DRAMBank
;
260 /* Boot argument structure - passed into Mach kernel at boot time.
262 #define kBootArgsVersion 1
263 #define kBootArgsRevision 1
265 typedef struct boot_args
{
266 unsigned short Revision
; /* Revision of boot_args structure */
267 unsigned short Version
; /* Version of boot_args structure */
268 char CommandLine
[BOOT_LINE_LENGTH
]; /* Passed in command line */
269 DRAMBank PhysicalDRAM
[kMaxDRAMBanks
]; /* base and range pairs for the 26 DRAM banks */
270 Boot_Video Video
; /* Video Information */
271 unsigned long machineType
; /* Machine Type (gestalt) */
272 void *deviceTreeP
; /* Base of flattened device tree */
273 unsigned long deviceTreeLength
;/* Length of flattened tree */
274 unsigned long topOfKernelData
;/* Highest address used in kernel data area */
277 extern boot_args passed_args
;
282 #define KERNEL_BOOT_MAGIC 0xa5b6d7e8
284 typedef struct KernelBootArgs
{
285 unsigned int magicCookie
; // KERNEL_BOOT_MAGIC
286 unsigned short version
;
287 unsigned short revision
;
288 unsigned int size
; // size of KernelBootArgs structure
289 int numDrives
; // number of BIOS drives
290 int rootdev
; // root device
291 int convmem
; // conventional memory
292 int extmem
; // extended memory
293 unsigned int firstAddr0
; // first address for kern convmem
294 int graphicsMode
; // booted in graphics mode?
295 int kernDev
; // device kernel was fetched from
296 int numBootDrivers
; // number of drivers loaded
297 char * configEnd
; // pointer to end of config files
298 unsigned int kaddr
; // kernel load address
299 unsigned int ksize
; // size of kernel
300 char bootFile
[128]; // kernel file name
301 char bootString
[BOOT_STRING_LEN
]; // boot arguments
302 driver_config_t driverConfig
[NDRIVERS
];
303 unsigned long memoryMapCount
;
304 MemoryRange memoryMap
[kMemoryMapCountMax
];
305 boot_drive_info_t driveInfo
[MAX_BIOS_DEVICES
];
307 PCI_bus_info_t pciInfo
;
308 APM_config_t apmConfig
;
309 char config
[CONFIG_SIZE
];
313 #endif /* _PEXPERT_I386_BOOT_H */