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 | ␊ |
71 | /* AsereBLN: added the other keys */␊ |
72 | ␊ |
73 | #define kProductVersion␉␉"ProductVersion"␉/* boot.c */␊ |
74 | #define karch␉␉␉␉"arch"␉␉␉␉/* boot.c */␊ |
75 | #define kDeviceProperties␉"device-properties"␉/* device_inject.c */␊ |
76 | #define kHidePartition␉␉"Hide Partition"␉/* disk.c */␊ |
77 | #define kRenamePartition␉"Rename Partition"␉/* disk.c */␊ |
78 | #define kSMBIOSKey␉␉␉"SMBIOS"␉␉␉/* fake_efi.c */␊ |
79 | #define kSystemID␉␉␉"SystemId"␉␉␉/* fake_efi.c */␊ |
80 | #define kSystemType␉␉␉"SystemType"␉␉/* fake_efi.c */␊ |
81 | #define kPCIRootUID␉␉␉"PCIRootUID"␉␉/* pci_root.c */␊ |
82 | #define kDefaultPartition␉"Default Partition"␉/* sys.c */␊ |
83 | ␊ |
84 | ␊ |
85 | #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") ␉␊ |
86 | #define kRebootOnPanic␉␉"RebootOnPanic"␊ |
87 | #define kEnableHiDPI␉␉"EnableHiDPI"␉␉// enable High resolution display (aka Retina)␊ |
88 | ␊ |
89 | ␊ |
90 | #define PLATFORM_NAME_LEN 64␊ |
91 | #define ROOT_PATH_LEN 256␊ |
92 | ␊ |
93 | #define DEFAULT_SCREEN_WIDTH 1024␊ |
94 | #define DEFAULT_SCREEN_HEIGHT 768␊ |
95 | ␊ |
96 | /*␊ |
97 | * Max size fo config data array, in bytes.␊ |
98 | */␊ |
99 | #define IO_CONFIG_DATA_SIZE␉␉40960 // was 4096 // was 163840␊ |
100 | ␊ |
101 | struct tm {␊ |
102 | ␉int␉tm_sec;␉␉/* seconds after the minute [0-60] */␊ |
103 | ␉int␉tm_min;␉␉/* minutes after the hour [0-59] */␊ |
104 | ␉int␉tm_hour;␉/* hours since midnight [0-23] */␊ |
105 | ␉int␉tm_mday;␉/* day of the month [1-31] */␊ |
106 | ␉int␉tm_mon;␉␉/* months since January [0-11] */␊ |
107 | ␉int␉tm_year;␉/* years since 1900 */␊ |
108 | ␉int␉tm_wday;␉/* days since Sunday [0-6] */␊ |
109 | ␉int␉tm_yday;␉/* days since January 1 [0-365] */␊ |
110 | ␉int␉tm_isdst;␉/* Daylight Savings Time flag */␊ |
111 | ␉long␉tm_gmtoff;␉/* offset from CUT in seconds */␊ |
112 | ␉char␉*tm_zone;␉/* timezone abbreviation */␊ |
113 | };␊ |
114 | ␊ |
115 | /** System time structure */␊ |
116 | struct timeval {␊ |
117 | ␉time_t tv_sec; /**< Seconds */␊ |
118 | ␉suseconds_t tv_usec; /**< Microseconds */␊ |
119 | };␊ |
120 | ␊ |
121 | typedef struct tm_t␊ |
122 | {␊ |
123 | int tm_sec ; /* seconds after minute [0-61] (61 allows for 2 leap-seconds)*/␊ |
124 | int tm_min ; /* minutes after hour [0-59] */␊ |
125 | int tm_hour ; /* hours after midnight [0-23] */␊ |
126 | int tm_mday ; /* day of the month [1-31] */␊ |
127 | int tm_mon ; /* month of year [0-11] */␊ |
128 | int tm_year ; /* current year-1900 */␊ |
129 | ␊ |
130 | }tm_t;␊ |
131 | ␊ |
132 | typedef unsigned long entry_t;␊ |
133 | ␊ |
134 | typedef struct {␊ |
135 | unsigned int sectors:8;␊ |
136 | unsigned int heads:8;␊ |
137 | unsigned int cylinders:16;␊ |
138 | } compact_diskinfo_t;␊ |
139 | ␊ |
140 | struct driveParameters {␊ |
141 | int cylinders;␊ |
142 | int sectors;␊ |
143 | int heads;␊ |
144 | int totalDrives;␊ |
145 | };␊ |
146 | ␊ |
147 | struct Tag {␊ |
148 | ␉long type;␊ |
149 | ␉char *string;␊ |
150 | ␉long␉ offset;␊ |
151 | ␉struct Tag *tag;␊ |
152 | ␉struct Tag *tagNext;␊ |
153 | };␊ |
154 | typedef struct Tag Tag, *TagPtr;␊ |
155 | ␊ |
156 | typedef struct {␊ |
157 | ␉char␉plist[IO_CONFIG_DATA_SIZE];␉// buffer for plist␊ |
158 | ␉TagPtr␉dictionary;␉␉// buffer for xml dictionary␊ |
159 | ␉bool canOverride; // flag to mark a dictionary can be overriden␊ |
160 | } config_file_t;␊ |
161 | ␊ |
162 | /*␊ |
163 | * BIOS drive information.␊ |
164 | */␊ |
165 | struct boot_drive_info {␊ |
166 | struct drive_params {␊ |
167 | ␉unsigned short buf_size;␊ |
168 | ␉unsigned short info_flags;␊ |
169 | ␉unsigned long phys_cyls;␊ |
170 | ␉unsigned long phys_heads;␊ |
171 | ␉unsigned long phys_spt;␊ |
172 | ␉unsigned long long phys_sectors;␊ |
173 | ␉unsigned short phys_nbps;␊ |
174 | ␉unsigned short dpte_offset;␊ |
175 | ␉unsigned short dpte_segment;␊ |
176 | ␉unsigned short key;␊ |
177 | ␉unsigned char path_len;␊ |
178 | ␉unsigned char reserved1;␊ |
179 | ␉unsigned short reserved2;␊ |
180 | ␉unsigned char bus_type[4];␊ |
181 | ␉unsigned char interface_type[8];␊ |
182 | ␉unsigned char interface_path[8];␊ |
183 | ␉unsigned char dev_path[8];␊ |
184 | ␉unsigned char reserved3;␊ |
185 | ␉unsigned char checksum;␊ |
186 | } params __attribute__((packed));␊ |
187 | struct drive_dpte {␊ |
188 | ␉unsigned short io_port_base;␊ |
189 | ␉unsigned short control_port_base;␊ |
190 | ␉unsigned char head_flags;␊ |
191 | ␉unsigned char vendor_info;␊ |
192 | ␉unsigned char irq : 4;␊ |
193 | ␉unsigned char irq_unused : 4;␊ |
194 | ␉unsigned char block_count;␊ |
195 | ␉unsigned char dma_channel : 4;␊ |
196 | ␉unsigned char dma_type : 4;␊ |
197 | ␉unsigned char pio_type : 4;␊ |
198 | ␉unsigned char pio_unused : 4;␊ |
199 | ␉unsigned short option_flags;␊ |
200 | ␉unsigned short reserved;␊ |
201 | ␉unsigned char revision;␊ |
202 | ␉unsigned char checksum;␊ |
203 | } dpte __attribute__((packed));␊ |
204 | } __attribute__((packed));␊ |
205 | typedef struct boot_drive_info boot_drive_info_t;␊ |
206 | ␊ |
207 | struct driveInfo {␊ |
208 | boot_drive_info_t di;␊ |
209 | int uses_ebios;␊ |
210 | int no_emulation;␊ |
211 | int biosdev;␊ |
212 | int valid;␊ |
213 | };␊ |
214 | ␊ |
215 | typedef struct FinderInfo {␊ |
216 | unsigned char data[16];␊ |
217 | } FinderInfo;␊ |
218 | ␊ |
219 | struct BootVolume;␊ |
220 | typedef struct BootVolume * BVRef;␊ |
221 | typedef struct BootVolume * CICell;␊ |
222 | ␊ |
223 | typedef long (*FSInit)(CICell ih);␊ |
224 | typedef long (*FSLoadFile)(CICell ih, char * filePath);␊ |
225 | typedef long (*FSReadFile)(CICell ih, char *filePath, void *base, uint64_t offset, uint64_t length);␊ |
226 | typedef long (*FSGetFileBlock)(CICell ih, char *filePath, unsigned long long *firstBlock);␊ |
227 | typedef long (*FSGetDirEntry)(CICell ih, char * dirPath, long long * dirIndex,␊ |
228 | char ** name, long * flags, long * time,␊ |
229 | FinderInfo * finderInfo, long * infoValid);␊ |
230 | typedef long (*FSGetUUID)(CICell ih, char *uuidStr, long strMaxLen);␊ |
231 | typedef void (*BVGetDescription)(CICell ih, char * str, long strMaxLen);␊ |
232 | // Can be just pointed to free or a special free function␊ |
233 | typedef void (*BVFree)(CICell ih);␊ |
234 | ␊ |
235 | struct iob {␊ |
236 | unsigned int i_flgs; /* see F_* below */␊ |
237 | unsigned int i_offset; /* seek byte offset in file */␊ |
238 | int i_filesize; /* size of file */␊ |
239 | char * i_buf; /* file load address */␊ |
240 | };␊ |
241 | ␊ |
242 | #define BPS 512 /* sector size of the device */␊ |
243 | #define F_READ 0x1 /* file opened for reading */␊ |
244 | #define F_WRITE 0x2 /* file opened for writing */␊ |
245 | #define F_ALLOC 0x4 /* buffer allocated */␊ |
246 | #define F_FILE 0x8 /* file instead of device */␊ |
247 | #define F_NBSF 0x10 /* no bad sector forwarding */␊ |
248 | #define F_SSI 0x40 /* set skip sector inhibit */␊ |
249 | #define F_MEM 0x80 /* memory instead of file or device */␊ |
250 | ␊ |
251 | struct dirstuff {␊ |
252 | char * dir_path; /* directory path */␊ |
253 | long long dir_index; /* directory entry index */␊ |
254 | BVRef dir_bvr; /* volume reference */␊ |
255 | };␊ |
256 | ␊ |
257 | #define BVSTRLEN 32␊ |
258 | ␊ |
259 | struct BootVolume {␊ |
260 | BVRef next; /* list linkage pointer */␊ |
261 | int biosdev; /* BIOS device number */␊ |
262 | int type; /* device type (floppy, hd, network) */␊ |
263 | unsigned int flags; /* attribute flags */␊ |
264 | BVGetDescription description; /* BVGetDescription function */␊ |
265 | int part_no; /* partition number (1 based) */␊ |
266 | unsigned int part_boff; /* partition block offset */␊ |
267 | unsigned int part_type; /* partition type */␊ |
268 | unsigned int fs_boff; /* 1st block # of next read */␊ |
269 | unsigned int fs_byteoff; /* Byte offset for read within block */␊ |
270 | FSLoadFile fs_loadfile; /* FSLoadFile function */␊ |
271 | FSReadFile fs_readfile; /* FSReadFile function */␊ |
272 | FSGetDirEntry fs_getdirentry; /* FSGetDirEntry function */␊ |
273 | FSGetFileBlock fs_getfileblock; /* FSGetFileBlock function */␊ |
274 | FSGetUUID fs_getuuid; /* FSGetUUID function */␊ |
275 | unsigned int bps; /* bytes per sector for this device */␊ |
276 | char name[BVSTRLEN]; /* (name of partition) */␊ |
277 | char type_name[BVSTRLEN]; /* (type of partition, eg. Apple_HFS) */␊ |
278 | BVFree bv_free; /* BVFree function */␊ |
279 | uint32_t modTime;␊ |
280 | char␉␉␉ label[BVSTRLEN]; /* partition volume label */␊ |
281 | char␉␉␉ altlabel[BVSTRLEN]; /* partition volume label */␊ |
282 | bool filtered; /* newFilteredBVChain() will set to TRUE */␊ |
283 | bool visible; /* will shown in the device list */␊ |
284 | char␉␉␉ OSVersion[8];␊ |
285 | bool␉␉␉ kernelfound; /* mach_kernel found in default location, currently only /mach_kernel is supported */␊ |
286 | 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 */␊ |
287 | };␊ |
288 | ␊ |
289 | enum {␊ |
290 | kBVFlagPrimary = 0x01,␊ |
291 | kBVFlagNativeBoot = 0x02,␊ |
292 | kBVFlagForeignBoot = 0x04,␊ |
293 | kBVFlagBootable = 0x08,␊ |
294 | kBVFlagEFISystem = 0x10,␊ |
295 | #ifdef BOOT_HELPER_SUPPORT␊ |
296 | kBVFlagBooter = 0x20,␊ |
297 | #endif␊ |
298 | kBVFlagSystemVolume = 0x40␊ |
299 | };␊ |
300 | ␊ |
301 | enum {␊ |
302 | kBIOSDevTypeFloppy = 0x00,␊ |
303 | kBIOSDevTypeHardDrive = 0x80,␊ |
304 | kBIOSDevTypeNetwork = 0xE0,␊ |
305 | kBIOSDevUnitMask = 0x0F,␊ |
306 | kBIOSDevTypeMask = 0xF0,␊ |
307 | kBIOSDevMask = 0xFF␊ |
308 | };␊ |
309 | ␊ |
310 | enum {␊ |
311 | ␉␊ |
312 | ␉kPartitionTypeHFS␉ = 0xAF,␊ |
313 | ␉kPartitionTypeHPFS = 0x07,␊ |
314 | ␉kPartitionTypeFAT16 = 0x06,␊ |
315 | ␉kPartitionTypeFAT32 = 0x0c,␊ |
316 | ␉kPartitionTypeEXT3 = 0x83,␊ |
317 | ␉kPartitionTypeFreeBSD = 0xa5,␊ |
318 | ␉kPartitionTypeOpenBSD = 0xa6,␊ |
319 | ␉kPartitionTypeBEFS␉ = 0xEB␊ |
320 | };␊ |
321 | ␊ |
322 | //#define BIOS_DEV_TYPE(d) ((d) & kBIOSDevTypeMask)␊ |
323 | #define BIOS_DEV_UNIT(bvr) ((bvr)->biosdev - (bvr)->type)␊ |
324 | ␊ |
325 | #ifndef max␊ |
326 | #define max(a,b) ((a) > (b) ? (a) : (b))␊ |
327 | #endif␊ |
328 | ␊ |
329 | #ifndef min␊ |
330 | #define min(a,b) ((a) < (b) ? (a) : (b))␊ |
331 | #endif␊ |
332 | ␊ |
333 | #define␉round2(x, m)␉(((x) + (m / 2)) & ~(m - 1))␊ |
334 | #define roundup2(x, m) (((x) + m - 1) & ~(m - 1))␊ |
335 | ␊ |
336 | #define MAKEKERNDEV(t, u, p) MAKEBOOTDEV(t, 0, 0, u, p)␊ |
337 | ␊ |
338 | enum {␊ |
339 | kNetworkDeviceType = kBIOSDevTypeNetwork,␊ |
340 | kBlockDeviceType = kBIOSDevTypeHardDrive␊ |
341 | };␊ |
342 | ␊ |
343 | enum {␊ |
344 | kCursorTypeHidden = 0x0100,␊ |
345 | kCursorTypeUnderline = 0x0607␊ |
346 | };␊ |
347 | ␊ |
348 | #endif /* !__LIBSAIO_SAIO_TYPES_H */␊ |
349 | |