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