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 | ␊ |
61 | struct Tag␊ |
62 | {␊ |
63 | ␉long␉␉type;␊ |
64 | ␉char␉ *string;␊ |
65 | ␉long␉␉offset;␊ |
66 | ␉struct Tag *tag;␊ |
67 | ␉struct Tag *tagNext;␊ |
68 | };␊ |
69 | typedef struct Tag Tag, *TagPtr;␊ |
70 | ␊ |
71 | ␊ |
72 | typedef struct␊ |
73 | {␊ |
74 | ␉char␉plist[16384];␉// buffer for plist␊ |
75 | ␉TagPtr␉dictionary; // buffer for xml dictionary␊ |
76 | ␉bool␉canOverride;␉// flag to mark a dictionary can be overriden␊ |
77 | } config_file_t;␊ |
78 | ␊ |
79 | /*␊ |
80 | * BIOS drive information.␊ |
81 | */␊ |
82 | struct boot_drive_info␊ |
83 | {␊ |
84 | ␉struct drive_params␊ |
85 | ␉{␊ |
86 | ␉unsigned short buf_size;␊ |
87 | ␉unsigned short info_flags;␊ |
88 | ␉unsigned long phys_cyls;␊ |
89 | ␉unsigned long phys_heads;␊ |
90 | ␉unsigned long phys_spt;␊ |
91 | ␉unsigned long long phys_sectors;␊ |
92 | ␉unsigned short phys_nbps;␊ |
93 | ␉unsigned short dpte_offset;␊ |
94 | ␉unsigned short dpte_segment;␊ |
95 | ␉unsigned short key;␊ |
96 | ␉unsigned char path_len;␊ |
97 | ␉unsigned char reserved1;␊ |
98 | ␉unsigned short reserved2;␊ |
99 | ␉unsigned char bus_type[4];␊ |
100 | ␉unsigned char interface_type[8];␊ |
101 | ␉unsigned char interface_path[8];␊ |
102 | ␉unsigned char dev_path[8];␊ |
103 | ␉unsigned char reserved3;␊ |
104 | ␉unsigned char checksum;␊ |
105 | ␉} params;␊ |
106 | ␊ |
107 | ␉struct drive_dpte␊ |
108 | ␉{␊ |
109 | ␉unsigned short io_port_base;␊ |
110 | ␉unsigned short control_port_base;␊ |
111 | ␉unsigned char head_flags;␊ |
112 | ␉unsigned char vendor_info;␊ |
113 | ␉unsigned char irq : 4;␊ |
114 | ␉unsigned char irq_unused : 4;␊ |
115 | ␉unsigned char block_count;␊ |
116 | ␉unsigned char dma_channel : 4;␊ |
117 | ␉unsigned char dma_type␉ : 4;␊ |
118 | ␉unsigned char pio_type␉ : 4;␊ |
119 | ␉unsigned char pio_unused : 4;␊ |
120 | ␉unsigned short option_flags;␊ |
121 | ␉unsigned short reserved;␊ |
122 | ␉unsigned char revision;␊ |
123 | ␉unsigned char checksum;␊ |
124 | } dpte;␊ |
125 | } __attribute__((packed));␊ |
126 | typedef struct boot_drive_info boot_drive_info_t;␊ |
127 | ␊ |
128 | ␊ |
129 | struct driveInfo␊ |
130 | {␊ |
131 | ␉boot_drive_info_t di;␊ |
132 | ␊ |
133 | ␉int uses_ebios;␊ |
134 | ␉int no_emulation;␊ |
135 | ␉int biosdev;␊ |
136 | ␉int valid;␊ |
137 | };␊ |
138 | ␊ |
139 | ␊ |
140 | typedef struct FinderInfo␊ |
141 | {␊ |
142 | ␉unsigned char data[16];␊ |
143 | } FinderInfo;␊ |
144 | ␊ |
145 | ␊ |
146 | struct␉␉BootVolume;␊ |
147 | typedef struct BootVolume * BVRef;␊ |
148 | typedef struct BootVolume * CICell;␊ |
149 | ␊ |
150 | typedef long (*FSInit)(CICell ih);␊ |
151 | typedef long (*FSLoadFile)(CICell ih, char * filePath);␊ |
152 | typedef long (*FSReadFile)(CICell ih, char *filePath, void *base, uint64_t offset, uint64_t length);␊ |
153 | typedef long (*FSGetFileBlock)(CICell ih, char *filePath, unsigned long long *firstBlock);␊ |
154 | typedef long (*FSGetDirEntry)(CICell ih, char * dirPath, long long * dirIndex,␊ |
155 | ␉␉␉␉␉␉␉ char ** name, long * flags, long * time,␊ |
156 | ␉␉␉␉␉␉␉ FinderInfo * finderInfo, long * infoValid);␊ |
157 | typedef long (*FSGetUUID)(CICell ih, char *uuidStr);␊ |
158 | typedef void (*BVGetDescription)(CICell ih, char * str, long strMaxLen);␊ |
159 | // Can be just pointed to free or a special free function␊ |
160 | typedef void (*BVFree)(CICell ih);␊ |
161 | ␊ |
162 | struct iob␊ |
163 | {␊ |
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 32␊ |
186 | ␊ |
187 | struct BootVolume␊ |
188 | {␊ |
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]; /* partition volume label */␊ |
211 | bool filtered; /* newFilteredBVChain() will set to TRUE */␊ |
212 | bool visible; /* will shown in the device list */␊ |
213 | char␉␉␉ OSVersion[8];␊ |
214 | bool␉␉␉ OSisServer; /* 1 = OS X server , 0 = OS X client */␊ |
215 | };␊ |
216 | ␊ |
217 | enum␊ |
218 | {␊ |
219 | ␊ |
220 | ␉kBVFlagPrimary␉␉␉= 0x01,␊ |
221 | ␉kBVFlagNativeBoot␉␉= 0x02,␊ |
222 | ␉kBVFlagForeignBoot␉␉= 0x04,␊ |
223 | ␉kBVFlagBootable␉␉␉= 0x08,␊ |
224 | ␉kBVFlagEFISystem␉␉= 0x10,␊ |
225 | ␉kBVFlagBooter␉␉␉= 0x20,␊ |
226 | ␉kBVFlagSystemVolume␉␉= 0x40␊ |
227 | };␊ |
228 | ␊ |
229 | enum␊ |
230 | {␊ |
231 | ␉kBIOSDevTypeFloppy␉␉= 0x00,␊ |
232 | ␉kBIOSDevTypeHardDrive␉␉= 0x80,␊ |
233 | ␉kBIOSDevTypeNetwork␉␉= 0xE0,␊ |
234 | ␉kBIOSDevUnitMask␉␉= 0x0F,␊ |
235 | ␉kBIOSDevTypeMask␉␉= 0xF0,␊ |
236 | ␉kBIOSDevMask␉␉␉= 0xFF␊ |
237 | };␊ |
238 | ␊ |
239 | enum␊ |
240 | {␊ |
241 | ␉kPartitionTypeHFS␉␉= 0xAF,␊ |
242 | ␉kPartitionTypeHPFS␉␉= 0x07,␊ |
243 | ␉kPartitionTypeFAT16␉␉= 0x06,␊ |
244 | ␉kPartitionTypeFAT32␉␉= 0x0c,␊ |
245 | ␉kPartitionTypeEXT3␉␉= 0x83,␊ |
246 | ␉kPartitionTypeBEFS␉␉= 0xEB,␊ |
247 | ␉kPartitionTypeFreeBSD␉␉= 0xa5,␊ |
248 | ␉kPartitionTypeOpenBSD␉␉= 0xa6␊ |
249 | };␊ |
250 | ␊ |
251 | //#define BIOS_DEV_TYPE(d)␉((d) & kBIOSDevTypeMask)␊ |
252 | #define BIOS_DEV_UNIT(bvr)␉((bvr)->biosdev - (bvr)->type)␊ |
253 | ␊ |
254 | // KernBootStruct device types.␊ |
255 | ␊ |
256 | enum␊ |
257 | {␊ |
258 | ␉DEV_SD = 0,␊ |
259 | ␉DEV_HD = 1,␊ |
260 | ␉DEV_FD = 2,␊ |
261 | ␉DEV_EN = 3␊ |
262 | };␊ |
263 | ␊ |
264 | /*␊ |
265 | * min/max Macros.␊ |
266 | * counting and rounding Macros.␊ |
267 | *␊ |
268 | * Azi: defined on <sys/param.h>,␊ |
269 | *␉␉i386/include/IOKit/IOLib.h (min/max), and others...␊ |
270 | *␊ |
271 | #ifndef MIN␊ |
272 | #define MIN(a,b) ( ((a) < (b)) ? (a) : (b) )␊ |
273 | #endif␊ |
274 | #ifndef MAX␊ |
275 | #define MAX(a,b) ( ((a) > (b)) ? (a) : (b) )␊ |
276 | #endif␊ |
277 | ␊ |
278 | #define␉round2(x, m)␉(((x) + (m / 2)) & ~(m - 1))␊ |
279 | #define roundup2(x, m) (((x) + m - 1) & ~(m - 1))*/␊ |
280 | ␊ |
281 | enum␊ |
282 | {␊ |
283 | ␉kNetworkDeviceType = kBIOSDevTypeNetwork,␊ |
284 | ␉kBlockDeviceType = kBIOSDevTypeHardDrive␊ |
285 | }; //gBootFileType_t;␊ |
286 | ␊ |
287 | enum␊ |
288 | {␊ |
289 | ␉kCursorTypeHidden = 0x0100,␊ |
290 | ␉kCursorTypeUnderline = 0x0607␊ |
291 | };␊ |
292 | ␊ |
293 | #endif /* !__LIBSAIO_SAIO_TYPES_H */␊ |
294 | |