1 | /*␊ |
2 | * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.␊ |
3 | *␊ |
4 | * @APPLE_LICENSE_HEADER_START@␊ |
5 | * ␊ |
6 | * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights␊ |
7 | * Reserved. This file contains Original Code and/or Modifications of␊ |
8 | * Original Code as defined in and that are subject to the Apple Public␊ |
9 | * Source License Version 2.0 (the "License"). You may not use this file␊ |
10 | * except in compliance with the License. Please obtain a copy of the␊ |
11 | * License at http://www.apple.com/publicsource and read it before using␊ |
12 | * this file.␊ |
13 | * ␊ |
14 | * The Original Code and all software distributed under the License are␊ |
15 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER␊ |
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,␊ |
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,␊ |
18 | * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the␊ |
19 | * License for the specific language governing rights and limitations␊ |
20 | * under the License.␊ |
21 | * ␊ |
22 | * @APPLE_LICENSE_HEADER_END@␊ |
23 | */␊ |
24 | /* Useful types. */␊ |
25 | ␊ |
26 | #ifndef __LIBSAIO_SAIO_TYPES_H␊ |
27 | #define __LIBSAIO_SAIO_TYPES_H␊ |
28 | ␊ |
29 | #include <sys/reboot.h>␊ |
30 | #include <sys/types.h>␊ |
31 | #include "bios.h"␊ |
32 | #ifdef NBP_SUPPORT␊ |
33 | #include "nbp_cmd.h"␊ |
34 | #else␊ |
35 | #include <IOKit/IOTypes.h>␊ |
36 | #endif␊ |
37 | #include "bootXnu.h"␊ |
38 | ␊ |
39 | #if DEBUG␊ |
40 | #define DEBUG_DISK(x) printf x␊ |
41 | #else␊ |
42 | #define DEBUG_DISK(x)␊ |
43 | #endif␊ |
44 | ␊ |
45 | /*␊ |
46 | * Keys used in system Boot.plist␊ |
47 | */␊ |
48 | #define kGraphicsModeKey␉"Graphics Mode"␊ |
49 | #define kTextModeKey␉␉"Text Mode"␊ |
50 | #define kQuietBootKey␉␉"Quiet Boot"␊ |
51 | #define kKernelFlagsKey␉␉"Kernel Flags"␊ |
52 | #define kMKextCacheKey␉␉"MKext Cache"␊ |
53 | #define kKernelNameKey␉␉"Kernel"␊ |
54 | #define kKernelCacheKey "Kernel Cache"␊ |
55 | #define kUseKernelCache "UseKernelCache" ␊ |
56 | #define kBootDeviceKey␉␉"Boot Device"␊ |
57 | #define kTimeoutKey␉␉␉"Timeout"␊ |
58 | #define kRootDeviceKey␉␉"rd"␊ |
59 | #define kBootUUIDKey␉␉"boot-uuid"␊ |
60 | #define kHelperRootUUIDKey␉"Root UUID"␊ |
61 | #define kPlatformKey␉␉"platform"␊ |
62 | #define kCDROMPromptKey␉␉"CD-ROM Prompt"␊ |
63 | #define kCDROMOptionKey␉␉"CD-ROM Option Key"␊ |
64 | #define kRescanPromptKey␉"Rescan Prompt"␊ |
65 | #define kRescanKey␉␉ "Rescan"␊ |
66 | #define kScanSingleDriveKey␉"Scan Single Drive"␊ |
67 | #define kInsantMenuKey␉␉"Instant Menu"␊ |
68 | #define kDefaultKernel␉␉"mach_kernel"␊ |
69 | #define kWaitForKeypressKey␉"Wait"␊ |
70 | /* AsereBLN: added the other keys */␊ |
71 | ␊ |
72 | #define kProductVersion␉␉"ProductVersion"␉/* boot.c */␊ |
73 | #define karch␉␉␉␉"arch"␉␉␉␉/* boot.c */␊ |
74 | #define kDeviceProperties␉"device-properties"␉/* device_inject.c */␊ |
75 | #define kHidePartition␉␉"Hide Partition"␉/* disk.c */␊ |
76 | #define kRenamePartition␉"Rename Partition"␉/* disk.c */␊ |
77 | #define kSMBIOSKey␉␉␉"SMBIOS"␉␉␉/* fake_efi.c */␊ |
78 | #define kSystemID␉␉␉"SystemId"␉␉␉/* fake_efi.c */␊ |
79 | #define kSystemType␉␉␉"SystemType"␉␉/* fake_efi.c */␊ |
80 | #define kPCIRootUID␉␉␉"PCIRootUID"␉␉/* pci_root.c */␊ |
81 | #define kDefaultPartition␉"Default Partition"␉/* sys.c */␊ |
82 | #define kAcpiMethod␉␉␉"Acpi2Method"␉␉␉␉// 2 (= method 2) for some machines that may hang on acpi 2 (aka acpi 64 bit) detection (replace the old kUnsafeACPI "UnsafeACPI") ␉␊ |
83 | ␊ |
84 | #define PLATFORM_NAME_LEN 64␊ |
85 | #define ROOT_PATH_LEN 256␊ |
86 | ␊ |
87 | #define DEFAULT_SCREEN_WIDTH 1024␊ |
88 | #define DEFAULT_SCREEN_HEIGHT 768␊ |
89 | ␊ |
90 | /*␊ |
91 | * Max size fo config data array, in bytes.␊ |
92 | */␊ |
93 | #define IO_CONFIG_DATA_SIZE␉␉40960 // was 4096 // was 163840␊ |
94 | ␊ |
95 | #define rand_tab_len 100␊ |
96 | ␊ |
97 | struct ran_obj {␊ |
98 | ␉int tab[rand_tab_len];␊ |
99 | ␉int rmin;␉␊ |
100 | ␉int n;␊ |
101 | };␊ |
102 | ␊ |
103 | typedef struct tm_t␊ |
104 | {␊ |
105 | int tm_sec ; /* seconds after minute [0-61] (61 allows for 2 leap-seconds)*/␊ |
106 | int tm_min ; /* minutes after hour [0-59] */␊ |
107 | int tm_hour ; /* hours after midnight [0-23] */␊ |
108 | int tm_mday ; /* day of the month [1-31] */␊ |
109 | int tm_mon ; /* month of year [0-11] */␊ |
110 | int tm_year ; /* current year-1900 */␊ |
111 | ␊ |
112 | }tm_t;␊ |
113 | ␊ |
114 | typedef unsigned long entry_t;␊ |
115 | ␊ |
116 | typedef struct {␊ |
117 | unsigned int sectors:8;␊ |
118 | unsigned int heads:8;␊ |
119 | unsigned int cylinders:16;␊ |
120 | } compact_diskinfo_t;␊ |
121 | ␊ |
122 | struct driveParameters {␊ |
123 | int cylinders;␊ |
124 | int sectors;␊ |
125 | int heads;␊ |
126 | int totalDrives;␊ |
127 | };␊ |
128 | ␊ |
129 | struct Tag {␊ |
130 | ␉long type;␊ |
131 | ␉char *string;␊ |
132 | ␉long␉ offset;␊ |
133 | ␉struct Tag *tag;␊ |
134 | ␉struct Tag *tagNext;␊ |
135 | };␊ |
136 | typedef struct Tag Tag, *TagPtr;␊ |
137 | ␊ |
138 | typedef struct {␊ |
139 | ␉char␉plist[IO_CONFIG_DATA_SIZE];␉// buffer for plist␊ |
140 | ␉TagPtr␉dictionary;␉␉// buffer for xml dictionary␊ |
141 | ␉bool canOverride; // flag to mark a dictionary can be overriden␊ |
142 | } config_file_t;␊ |
143 | ␊ |
144 | /*␊ |
145 | * BIOS drive information.␊ |
146 | */␊ |
147 | struct boot_drive_info {␊ |
148 | struct drive_params {␊ |
149 | ␉unsigned short buf_size;␊ |
150 | ␉unsigned short info_flags;␊ |
151 | ␉unsigned long phys_cyls;␊ |
152 | ␉unsigned long phys_heads;␊ |
153 | ␉unsigned long phys_spt;␊ |
154 | ␉unsigned long long phys_sectors;␊ |
155 | ␉unsigned short phys_nbps;␊ |
156 | ␉unsigned short dpte_offset;␊ |
157 | ␉unsigned short dpte_segment;␊ |
158 | ␉unsigned short key;␊ |
159 | ␉unsigned char path_len;␊ |
160 | ␉unsigned char reserved1;␊ |
161 | ␉unsigned short reserved2;␊ |
162 | ␉unsigned char bus_type[4];␊ |
163 | ␉unsigned char interface_type[8];␊ |
164 | ␉unsigned char interface_path[8];␊ |
165 | ␉unsigned char dev_path[8];␊ |
166 | ␉unsigned char reserved3;␊ |
167 | ␉unsigned char checksum;␊ |
168 | } params __attribute__((packed));␊ |
169 | struct drive_dpte {␊ |
170 | ␉unsigned short io_port_base;␊ |
171 | ␉unsigned short control_port_base;␊ |
172 | ␉unsigned char head_flags;␊ |
173 | ␉unsigned char vendor_info;␊ |
174 | ␉unsigned char irq : 4;␊ |
175 | ␉unsigned char irq_unused : 4;␊ |
176 | ␉unsigned char block_count;␊ |
177 | ␉unsigned char dma_channel : 4;␊ |
178 | ␉unsigned char dma_type : 4;␊ |
179 | ␉unsigned char pio_type : 4;␊ |
180 | ␉unsigned char pio_unused : 4;␊ |
181 | ␉unsigned short option_flags;␊ |
182 | ␉unsigned short reserved;␊ |
183 | ␉unsigned char revision;␊ |
184 | ␉unsigned char checksum;␊ |
185 | } dpte __attribute__((packed));␊ |
186 | } __attribute__((packed));␊ |
187 | typedef struct boot_drive_info boot_drive_info_t;␊ |
188 | ␊ |
189 | struct driveInfo {␊ |
190 | boot_drive_info_t di;␊ |
191 | int uses_ebios;␊ |
192 | int no_emulation;␊ |
193 | int biosdev;␊ |
194 | int valid;␊ |
195 | };␊ |
196 | ␊ |
197 | typedef struct FinderInfo {␊ |
198 | unsigned char data[16];␊ |
199 | } FinderInfo;␊ |
200 | ␊ |
201 | struct BootVolume;␊ |
202 | typedef struct BootVolume * BVRef;␊ |
203 | typedef struct BootVolume * CICell;␊ |
204 | ␊ |
205 | typedef long (*FSInit)(CICell ih);␊ |
206 | typedef long (*FSLoadFile)(CICell ih, char * filePath);␊ |
207 | typedef long (*FSReadFile)(CICell ih, char *filePath, void *base, uint64_t offset, uint64_t length);␊ |
208 | typedef long (*FSGetFileBlock)(CICell ih, char *filePath, unsigned long long *firstBlock);␊ |
209 | typedef long (*FSGetDirEntry)(CICell ih, char * dirPath, long long * dirIndex,␊ |
210 | char ** name, long * flags, long * time,␊ |
211 | FinderInfo * finderInfo, long * infoValid);␊ |
212 | typedef long (*FSGetUUID)(CICell ih, char *uuidStr);␊ |
213 | typedef void (*BVGetDescription)(CICell ih, char * str, long strMaxLen);␊ |
214 | // Can be just pointed to free or a special free function␊ |
215 | typedef void (*BVFree)(CICell ih);␊ |
216 | ␊ |
217 | struct iob {␊ |
218 | unsigned int i_flgs; /* see F_* below */␊ |
219 | unsigned int i_offset; /* seek byte offset in file */␊ |
220 | int i_filesize; /* size of file */␊ |
221 | char * i_buf; /* file load address */␊ |
222 | };␊ |
223 | ␊ |
224 | #define BPS 512 /* sector size of the device */␊ |
225 | #define F_READ 0x1 /* file opened for reading */␊ |
226 | #define F_WRITE 0x2 /* file opened for writing */␊ |
227 | #define F_ALLOC 0x4 /* buffer allocated */␊ |
228 | #define F_FILE 0x8 /* file instead of device */␊ |
229 | #define F_NBSF 0x10 /* no bad sector forwarding */␊ |
230 | #define F_SSI 0x40 /* set skip sector inhibit */␊ |
231 | #define F_MEM 0x80 /* memory instead of file or device */␊ |
232 | ␊ |
233 | struct dirstuff {␊ |
234 | char * dir_path; /* directory path */␊ |
235 | long long dir_index; /* directory entry index */␊ |
236 | BVRef dir_bvr; /* volume reference */␊ |
237 | };␊ |
238 | ␊ |
239 | #define BVSTRLEN 32␊ |
240 | ␊ |
241 | struct BootVolume {␊ |
242 | BVRef next; /* list linkage pointer */␊ |
243 | int biosdev; /* BIOS device number */␊ |
244 | int type; /* device type (floppy, hd, network) */␊ |
245 | unsigned int flags; /* attribute flags */␊ |
246 | BVGetDescription description; /* BVGetDescription function */␊ |
247 | int part_no; /* partition number (1 based) */␊ |
248 | unsigned int part_boff; /* partition block offset */␊ |
249 | unsigned int part_type; /* partition type */␊ |
250 | unsigned int fs_boff; /* 1st block # of next read */␊ |
251 | unsigned int fs_byteoff; /* Byte offset for read within block */␊ |
252 | FSLoadFile fs_loadfile; /* FSLoadFile function */␊ |
253 | FSReadFile fs_readfile; /* FSReadFile function */␊ |
254 | FSGetDirEntry fs_getdirentry; /* FSGetDirEntry function */␊ |
255 | FSGetFileBlock fs_getfileblock; /* FSGetFileBlock function */␊ |
256 | FSGetUUID fs_getuuid; /* FSGetUUID function */␊ |
257 | unsigned int bps; /* bytes per sector for this device */␊ |
258 | char name[BVSTRLEN]; /* (name of partition) */␊ |
259 | char type_name[BVSTRLEN]; /* (type of partition, eg. Apple_HFS) */␊ |
260 | BVFree bv_free; /* BVFree function */␊ |
261 | uint32_t modTime;␊ |
262 | char␉␉␉ label[BVSTRLEN]; /* partition volume label */␊ |
263 | char␉␉␉ altlabel[BVSTRLEN]; /* partition volume label */␊ |
264 | bool filtered; /* newFilteredBVChain() will set to TRUE */␊ |
265 | bool visible; /* will shown in the device list */␊ |
266 | char␉␉␉ OSVersion[8];␊ |
267 | bool␉␉␉ kernelfound; /* mach_kernel found in default location, currently only /mach_kernel is supported */␊ |
268 | bool OSisServer; /* 1 = OS X server , 0 = OS X client, not to be confused with Platform->CPU.isServer which means it tries to emulate an xserve in the smbios */␊ |
269 | };␊ |
270 | ␊ |
271 | enum {␊ |
272 | kBVFlagPrimary = 0x01,␊ |
273 | kBVFlagNativeBoot = 0x02,␊ |
274 | kBVFlagForeignBoot = 0x04,␊ |
275 | kBVFlagBootable = 0x08,␊ |
276 | kBVFlagEFISystem = 0x10,␊ |
277 | #ifdef BOOT_HELPER_SUPPORT␊ |
278 | kBVFlagBooter = 0x20,␊ |
279 | #endif␊ |
280 | kBVFlagSystemVolume = 0x40␊ |
281 | };␊ |
282 | ␊ |
283 | enum {␊ |
284 | kBIOSDevTypeFloppy = 0x00,␊ |
285 | kBIOSDevTypeHardDrive = 0x80,␊ |
286 | kBIOSDevTypeNetwork = 0xE0,␊ |
287 | kBIOSDevUnitMask = 0x0F,␊ |
288 | kBIOSDevTypeMask = 0xF0,␊ |
289 | kBIOSDevMask = 0xFF␊ |
290 | };␊ |
291 | ␊ |
292 | enum {␊ |
293 | ␉␊ |
294 | ␉kPartitionTypeHFS␉ = 0xAF,␊ |
295 | ␉kPartitionTypeHPFS = 0x07,␊ |
296 | ␉kPartitionTypeFAT16 = 0x06,␊ |
297 | ␉kPartitionTypeFAT32 = 0x0c,␊ |
298 | ␉kPartitionTypeEXT3 = 0x83,␊ |
299 | ␉kPartitionTypeFreeBSD = 0xa5,␊ |
300 | ␉kPartitionTypeOpenBSD = 0xa6,␊ |
301 | ␉kPartitionTypeBEFS␉ = 0xEB␊ |
302 | };␊ |
303 | ␊ |
304 | //#define BIOS_DEV_TYPE(d) ((d) & kBIOSDevTypeMask)␊ |
305 | #define BIOS_DEV_UNIT(bvr) ((bvr)->biosdev - (bvr)->type)␊ |
306 | ␊ |
307 | #ifndef max␊ |
308 | #define max(a,b) ((a) > (b) ? (a) : (b))␊ |
309 | #endif␊ |
310 | ␊ |
311 | #ifndef min␊ |
312 | #define min(a,b) ((a) < (b) ? (a) : (b))␊ |
313 | #endif␊ |
314 | ␊ |
315 | #define␉round2(x, m)␉(((x) + (m / 2)) & ~(m - 1))␊ |
316 | #define roundup2(x, m) (((x) + m - 1) & ~(m - 1))␊ |
317 | ␊ |
318 | #define MAKEKERNDEV(t, u, p) MAKEBOOTDEV(t, 0, 0, u, p)␊ |
319 | ␊ |
320 | enum {␊ |
321 | kNetworkDeviceType = kBIOSDevTypeNetwork,␊ |
322 | kBlockDeviceType = kBIOSDevTypeHardDrive␊ |
323 | };␊ |
324 | ␊ |
325 | enum {␊ |
326 | kCursorTypeHidden = 0x0100,␊ |
327 | kCursorTypeUnderline = 0x0607␊ |
328 | };␊ |
329 | ␊ |
330 | #endif /* !__LIBSAIO_SAIO_TYPES_H */␊ |
331 | |