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 <sys/param.h>␊ |
32 | #include "bios.h"␊ |
33 | #include "nbp_cmd.h"␊ |
34 | #include "bootargs.h"␊ |
35 | ␊ |
36 | #if DEBUG␊ |
37 | ␉#define DEBUG_DISK(x) printf x␊ |
38 | #else␊ |
39 | ␉#define DEBUG_DISK(x)␊ |
40 | #endif␊ |
41 | ␊ |
42 | typedef unsigned long entry_t;␊ |
43 | ␊ |
44 | typedef struct␊ |
45 | {␊ |
46 | ␉unsigned int sectors:8;␊ |
47 | ␉unsigned int heads:8;␊ |
48 | ␉unsigned int cylinders:16;␊ |
49 | } compact_diskinfo_t;␊ |
50 | ␊ |
51 | ␊ |
52 | struct driveParameters␊ |
53 | {␊ |
54 | ␉int cylinders;␊ |
55 | ␉int sectors;␊ |
56 | ␉int heads;␊ |
57 | ␉int totalDrives;␊ |
58 | };␊ |
59 | ␊ |
60 | typedef struct Tag␊ |
61 | {␊ |
62 | ␉long␉␉type;␊ |
63 | ␉char␉ *string;␊ |
64 | ␉long␉␉offset;␊ |
65 | ␉struct Tag *tag;␊ |
66 | ␉struct Tag *tagNext;␊ |
67 | } Tag, *TagPtr;␊ |
68 | ␊ |
69 | /*␊ |
70 | * Max size fo config data array, in bytes.␊ |
71 | */␊ |
72 | #define IO_CONFIG_DATA_SIZE␉␉40960 // was 4096 // was 163840␊ |
73 | ␊ |
74 | typedef struct␊ |
75 | {␊ |
76 | ␉char␉plist[IO_CONFIG_DATA_SIZE];␉// buffer for plist␊ |
77 | ␉TagPtr␉dictionary;␉␉␉// buffer for xml dictionary␊ |
78 | ␉bool␉canOverride;␉␉␉// flag to mark a dictionary can be overriden␊ |
79 | } config_file_t;␊ |
80 | ␊ |
81 | /*␊ |
82 | * BIOS drive information.␊ |
83 | */␊ |
84 | typedef struct boot_drive_info␊ |
85 | {␊ |
86 | ␉struct drive_params␊ |
87 | ␉{␊ |
88 | ␉␉unsigned short buf_size;␊ |
89 | ␉␉unsigned short info_flags;␊ |
90 | ␉␉unsigned long phys_cyls;␊ |
91 | ␉␉unsigned long phys_heads;␊ |
92 | ␉␉unsigned long phys_spt;␊ |
93 | ␉␉unsigned long long phys_sectors;␊ |
94 | ␉␉unsigned short phys_nbps;␊ |
95 | ␉␉unsigned short dpte_offset;␊ |
96 | ␉␉unsigned short dpte_segment;␊ |
97 | ␉␉unsigned short key;␊ |
98 | ␉␉unsigned char path_len;␊ |
99 | ␉␉unsigned char reserved1;␊ |
100 | ␉␉unsigned short reserved2;␊ |
101 | ␉␉unsigned char bus_type[4];␊ |
102 | ␉␉unsigned char interface_type[8];␊ |
103 | ␉␉unsigned char interface_path[8];␊ |
104 | ␉␉unsigned char dev_path[16];␊ |
105 | ␉␉unsigned char reserved3;␊ |
106 | ␉␉unsigned char checksum;␊ |
107 | ␉} params __attribute__((packed));␊ |
108 | ␊ |
109 | ␉struct drive_dpte␊ |
110 | ␉{␊ |
111 | ␉␉unsigned short io_port_base;␊ |
112 | ␉␉unsigned short control_port_base;␊ |
113 | ␉␉unsigned char head_flags;␊ |
114 | ␉␉unsigned char vendor_info;␊ |
115 | ␉␉unsigned char irq : 4;␊ |
116 | ␉␉unsigned char irq_unused : 4;␊ |
117 | ␉␉unsigned char block_count;␊ |
118 | ␉␉unsigned char dma_channel : 4;␊ |
119 | ␉␉unsigned char dma_type : 4;␊ |
120 | ␉␉unsigned char pio_type : 4;␊ |
121 | ␉␉unsigned char pio_unused : 4;␊ |
122 | ␉␉unsigned short option_flags;␊ |
123 | ␉␉unsigned short reserved;␊ |
124 | ␉␉unsigned char revision;␊ |
125 | ␉␉unsigned char checksum;␊ |
126 | } dpte __attribute__((packed));␊ |
127 | } __attribute__((packed)) boot_drive_info_t;␊ |
128 | ␊ |
129 | ␊ |
130 | struct driveInfo␊ |
131 | {␊ |
132 | ␉boot_drive_info_t di;␊ |
133 | ␊ |
134 | ␉int uses_ebios;␊ |
135 | ␉int no_emulation;␊ |
136 | ␉int biosdev;␊ |
137 | ␉int valid;␊ |
138 | };␊ |
139 | ␊ |
140 | ␊ |
141 | typedef struct FinderInfo␊ |
142 | {␊ |
143 | ␉unsigned char data[16];␊ |
144 | } FinderInfo;␊ |
145 | ␊ |
146 | ␊ |
147 | struct␉␉BootVolume;␊ |
148 | typedef struct␉BootVolume *BVRef;␊ |
149 | typedef struct␉BootVolume *CICell;␊ |
150 | ␊ |
151 | typedef long (*FSInit)(CICell ih);␊ |
152 | typedef long (*FSLoadFile)(CICell ih, char * filePath);␊ |
153 | typedef long (*FSReadFile)(CICell ih, char *filePath, void *base, uint64_t offset, uint64_t length);␊ |
154 | typedef long (*FSGetFileBlock)(CICell ih, char *filePath, unsigned long long *firstBlock);␊ |
155 | typedef long (*FSGetDirEntry)(CICell ih, char * dirPath, long long * dirIndex,␊ |
156 | ␉␉␉␉␉␉␉ char ** name, long * flags, u_int32_t * time,␊ |
157 | ␉␉␉␉␉␉␉ FinderInfo * finderInfo, long * infoValid);␊ |
158 | typedef long (*FSGetUUID)(CICell ih, char *uuidStr);␊ |
159 | typedef void (*BVGetDescription)(CICell ih, char * str, long strMaxLen);␊ |
160 | // Can be just pointed to free or a special free function␊ |
161 | typedef void (*BVFree)(CICell ih);␊ |
162 | ␊ |
163 | struct iob {␊ |
164 | ␉char * i_buf; /* file load address */␊ |
165 | ␉unsigned int i_flgs; /* see F_* below */␊ |
166 | ␉unsigned int i_offset; /* seek byte offset in file */␊ |
167 | ␉int i_filesize; /* size of file */␊ |
168 | };␊ |
169 | ␊ |
170 | #define BPS␉ 512␉␉␉␉/* sector size of the device */␊ |
171 | #define F_READ␉ 0x1␉␉␉␉/* file opened for reading */␊ |
172 | #define F_WRITE␉ 0x2␉␉␉␉/* file opened for writing */␊ |
173 | #define F_ALLOC␉ 0x4␉␉␉␉/* buffer allocated */␊ |
174 | #define F_FILE␉ 0x8␉␉␉␉/* file instead of device */␊ |
175 | #define F_NBSF␉ 0x10␉␉␉␉/* no bad sector forwarding */␊ |
176 | #define F_SSI␉ 0x40␉␉␉␉/* set skip sector inhibit */␊ |
177 | #define F_MEM␉ 0x80␉␉␉␉/* memory instead of file or device */␊ |
178 | ␊ |
179 | struct dirstuff {␊ |
180 | ␉char *␉␉ dir_path;␉␉/* directory path */␊ |
181 | ␉long long␉ dir_index;␉␉/* directory entry index */␊ |
182 | ␉BVRef␉␉ dir_bvr;␉␉/* volume reference */␊ |
183 | };␊ |
184 | ␊ |
185 | #define BVSTRLEN 36 // changed from 32 to 36 due to gpt partition name length␊ |
186 | #define OSVERSTRLEN 9␊ |
187 | ␊ |
188 | struct BootVolume {␊ |
189 | ␉BVRef␉␉␉next;␉␉␉/* list linkage pointer */␊ |
190 | ␉int␉␉␉biosdev;␉␉/* BIOS device number */␊ |
191 | ␉int␉␉␉type;␉␉␉/* device type (floppy, hd, network) */␊ |
192 | ␉unsigned int␉␉flags;␉␉␉/* attribute flags */␊ |
193 | ␉BVGetDescription␉description;␉␉/* BVGetDescription function */␊ |
194 | ␉int␉␉␉part_no;␉␉/* partition number (1 based) */␊ |
195 | ␉unsigned int␉␉part_boff;␉␉/* partition block offset */␊ |
196 | ␉unsigned int␉␉part_type;␉␉/* partition type */␊ |
197 | ␉unsigned int␉␉fs_boff;␉␉/* 1st block # of next read */␊ |
198 | ␉unsigned int␉␉fs_byteoff;␉␉/* Byte offset for read within block */␊ |
199 | ␉FSLoadFile␉␉fs_loadfile;␉␉/* FSLoadFile function */␊ |
200 | ␉FSReadFile␉␉fs_readfile;␉␉/* FSReadFile function */␊ |
201 | ␉FSGetDirEntry␉␉fs_getdirentry;␉␉/* FSGetDirEntry function */␊ |
202 | ␉FSGetFileBlock␉␉fs_getfileblock;␉/* FSGetFileBlock function */␊ |
203 | ␉FSGetUUID␉␉fs_getuuid;␉␉/* FSGetUUID function */␊ |
204 | ␉unsigned int␉␉bps;␉␉␉/* bytes per sector for this device */␊ |
205 | ␉char␉␉␉name[BVSTRLEN];␉␉/* (name of partition) */␊ |
206 | ␉char␉␉␉type_name[BVSTRLEN];␉/* (type of partition, eg. Apple_HFS) */␊ |
207 | ␉BVFree␉␉␉bv_free;␉␉/* BVFree function */␊ |
208 | ␉uint32_t␉␉modTime;␊ |
209 | ␉char␉␉␉label[BVSTRLEN];␉/* partition volume label */␊ |
210 | ␉char␉␉␉altlabel[BVSTRLEN];␉/* alternate partition volume label */␊ |
211 | ␉bool␉␉␉filtered;␉␉/* newFilteredBVChain() will set to TRUE */␊ |
212 | ␉bool␉␉␉visible;␉␉/* will shown in the device list */␊ |
213 | ␉char␉␉␉OSVersion[OSVERSTRLEN]; /* Null terminated string from '/System/Library/CoreServices/SystemVersion.plist/ProductVersion' e.g. "10.10.10" - hope will not reach e.g. 111.222.333 soon:) If so, OSVERSTRLEN 9 change to 12 */␊ |
214 | ␉bool␉␉␉OSisServer;␉␉/* 1 = OS X server , 0 = OS X client */␊ |
215 | ␉bool␉␉␉OSisInstaller;␉␉/* 1 = OS X Install partition / recovery partition , 0 = OS X Install */␊ |
216 | ␊ |
217 | };␊ |
218 | ␊ |
219 | enum␊ |
220 | {␊ |
221 | ␉kBVFlagZero␉␉␉= 0x00,␊ |
222 | ␉kBVFlagPrimary␉␉␉= 0x01,␊ |
223 | ␉kBVFlagNativeBoot␉␉= 0x02,␊ |
224 | ␉kBVFlagForeignBoot␉␉= 0x04,␊ |
225 | ␉kBVFlagBootable␉␉␉= 0x08,␊ |
226 | ␉kBVFlagEFISystem␉␉= 0x10,␊ |
227 | ␉kBVFlagBooter␉␉␉= 0x20,␊ |
228 | ␉kBVFlagSystemVolume␉␉= 0x40,␊ |
229 | ␉kBVFlagInstallVolume␉␉= 0x80␊ |
230 | };␊ |
231 | ␊ |
232 | enum␊ |
233 | {␊ |
234 | ␉kBIOSDevTypeFloppy␉␉= 0x00,␊ |
235 | ␉kBIOSDevTypeHardDrive␉␉= 0x80,␊ |
236 | ␉kBIOSDevTypeNetwork␉␉= 0xE0,␊ |
237 | ␉kBIOSDevUnitMask␉␉= 0x0F,␊ |
238 | ␉kBIOSDevTypeMask␉␉= 0xF0,␊ |
239 | ␉kBIOSDevMask␉␉␉= 0xFF␊ |
240 | };␊ |
241 | ␊ |
242 | enum␊ |
243 | {␊ |
244 | ␉//KPartitionTypeFAT12␉␉= 0x01, // FAT12␊ |
245 | ␉kPartitionTypeHPFS␉␉= 0x07, // Mac OS X␊ |
246 | ␉kPartitionTypeFAT16␉␉= 0x06, // FAT16␊ |
247 | ␉kPartitionTypeFAT32␉␉= 0x0C, // FAT32␊ |
248 | ␉kPartitionTypeEXT3␉␉= 0x83, // Linux␊ |
249 | ␉kPartitionTypeOSXBoot␉␉= 0xAB, // Mac OS X Boot partition␊ |
250 | ␉kPartitionTypeFreeBSD␉␉= 0xA5, // FreeBSD␊ |
251 | ␉kPartitionTypeOpenBSD␉␉= 0xA6, // OpenBSD␊ |
252 | ␉//kPartitionTypeNeXTSTEP␉= 0xA7 // NeXTSTEP␊ |
253 | ␉//kPartitionTypeNetBSD␉␉= 0xA9 // NetBSD␊ |
254 | ␉kPartitionTypeHFS␉␉= 0xAF, // Mac OS X␊ |
255 | ␉//kPartitionTypeSolaris␉␉= 0xBE,␉ // Solaris␊ |
256 | ␉kPartitionTypeBEFS␉␉= 0xEB, // BeOS BFS␊ |
257 | ␉//kPartitionTypeBeOS␉␉= 0xEB, // BeOS BFS␊ |
258 | ␉//kPartitionTypeSkyOS␉␉= 0xEC, // SkyOS␊ |
259 | };␊ |
260 | ␊ |
261 | //#define BIOS_DEV_TYPE(d)␉((d) & kBIOSDevTypeMask)␊ |
262 | #define BIOS_DEV_UNIT(bvr)␉((bvr)->biosdev - (bvr)->type)␊ |
263 | ␊ |
264 | // KernBootStruct device types.␊ |
265 | ␊ |
266 | enum␊ |
267 | {␊ |
268 | ␉DEV_SD = 0,␊ |
269 | ␉DEV_HD = 1,␊ |
270 | ␉DEV_FD = 2,␊ |
271 | ␉DEV_EN = 3␊ |
272 | };␊ |
273 | ␊ |
274 | /*␊ |
275 | * min/max Macros.␊ |
276 | * counting and rounding Macros.␊ |
277 | *␊ |
278 | * Azi: defined on <sys/param.h>,␊ |
279 | *␉␉i386/include/IOKit/IOLib.h (min/max), and others...␊ |
280 | *␊ |
281 | #ifndef MIN␊ |
282 | #define MIN(a,b) ( ((a) < (b)) ? (a) : (b) )␊ |
283 | #endif␊ |
284 | #ifndef MAX␊ |
285 | #define MAX(a,b) ( ((a) > (b)) ? (a) : (b) )␊ |
286 | #endif␊ |
287 | ␊ |
288 | #define round2(x, m)␉(((x) + (m / 2)) & ~(m - 1))␊ |
289 | #define roundup2(x, m)␉(((x) + m - 1) & ~(m - 1))*/␊ |
290 | ␊ |
291 | enum {␊ |
292 | ␉kNetworkDeviceType = kBIOSDevTypeNetwork,␊ |
293 | ␉kBlockDeviceType = kBIOSDevTypeHardDrive␊ |
294 | }; //gBootFileType_t;␊ |
295 | ␊ |
296 | enum␊ |
297 | {␊ |
298 | ␉kCursorTypeHidden = 0x0100,␊ |
299 | ␉kCursorTypeUnderline = 0x0607␊ |
300 | };␊ |
301 | ␊ |
302 | #endif /* !__LIBSAIO_SAIO_TYPES_H */␊ |
303 | |