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 | struct driveParameters␊ |
52 | {␊ |
53 | ␉int cylinders;␊ |
54 | ␉int sectors;␊ |
55 | ␉int heads;␊ |
56 | ␉int totalDrives;␊ |
57 | };␊ |
58 | ␊ |
59 | struct Tag {␊ |
60 | ␉long␉␉type;␊ |
61 | ␉char␉ *string;␊ |
62 | ␉long␉␉offset;␊ |
63 | ␉struct Tag *tag;␊ |
64 | ␉struct Tag *tagNext;␊ |
65 | };␊ |
66 | typedef struct Tag Tag, *TagPtr;␊ |
67 | ␊ |
68 | /*␊ |
69 | * Max size fo config data array, in bytes.␊ |
70 | */␊ |
71 | #define IO_CONFIG_DATA_SIZE␉␉40960 // was 4096 // was 163840␊ |
72 | ␊ |
73 | typedef struct {␊ |
74 | ␉char␉plist[IO_CONFIG_DATA_SIZE];␉// 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 | struct driveInfo␊ |
129 | {␊ |
130 | ␉boot_drive_info_t di;␊ |
131 | ␊ |
132 | ␉int uses_ebios;␊ |
133 | ␉int no_emulation;␊ |
134 | ␉int biosdev;␊ |
135 | ␉int valid;␊ |
136 | };␊ |
137 | ␊ |
138 | typedef struct FinderInfo␊ |
139 | {␊ |
140 | ␉unsigned char data[16];␊ |
141 | } FinderInfo;␊ |
142 | ␊ |
143 | ␊ |
144 | struct␉␉BootVolume;␊ |
145 | typedef struct BootVolume * BVRef;␊ |
146 | typedef struct BootVolume * CICell;␊ |
147 | ␊ |
148 | typedef long (*FSInit)(CICell ih);␊ |
149 | typedef long (*FSLoadFile)(CICell ih, char * filePath);␊ |
150 | typedef long (*FSReadFile)(CICell ih, char *filePath, void *base, uint64_t offset, uint64_t length);␊ |
151 | typedef long (*FSGetFileBlock)(CICell ih, char *filePath, unsigned long long *firstBlock);␊ |
152 | typedef long (*FSGetDirEntry)(CICell ih, char * dirPath, long long * dirIndex,␊ |
153 | ␉␉␉␉␉␉␉ char ** name, long * flags, long * time,␊ |
154 | ␉␉␉␉␉␉␉ FinderInfo * finderInfo, long * infoValid);␊ |
155 | typedef long (*FSGetUUID)(CICell ih, char *uuidStr);␊ |
156 | typedef void (*BVGetDescription)(CICell ih, char * str, long strMaxLen);␊ |
157 | // Can be just pointed to free or a special free function␊ |
158 | typedef void (*BVFree)(CICell ih);␊ |
159 | ␊ |
160 | struct iob {␊ |
161 | ␉char * i_buf; /* file load address */␊ |
162 | ␉unsigned int i_flgs; /* see F_* below */␊ |
163 | ␉unsigned int i_offset; /* seek byte offset in file */␊ |
164 | ␉int i_filesize; /* size of file */␊ |
165 | };␊ |
166 | ␊ |
167 | #define BPS␉ 512␉␉␉␉/* sector size of the device */␊ |
168 | #define F_READ␉ 0x1␉␉␉␉/* file opened for reading */␊ |
169 | #define F_WRITE␉ 0x2␉␉␉␉/* file opened for writing */␊ |
170 | #define F_ALLOC␉ 0x4␉␉␉␉/* buffer allocated */␊ |
171 | #define F_FILE␉ 0x8␉␉␉␉/* file instead of device */␊ |
172 | #define F_NBSF␉ 0x10␉␉␉␉/* no bad sector forwarding */␊ |
173 | #define F_SSI␉ 0x40␉␉␉␉/* set skip sector inhibit */␊ |
174 | #define F_MEM␉ 0x80␉␉␉␉/* memory instead of file or device */␊ |
175 | ␊ |
176 | struct dirstuff {␊ |
177 | ␉char *␉␉ dir_path;␉␉/* directory path */␊ |
178 | ␉long long␉ dir_index;␉␉/* directory entry index */␊ |
179 | ␉BVRef␉␉ dir_bvr;␉␉/* volume reference */␊ |
180 | };␊ |
181 | ␊ |
182 | #define BVSTRLEN 32␊ |
183 | ␊ |
184 | struct BootVolume {␊ |
185 | ␉BVRef␉␉␉next;␉␉␉/* list linkage pointer */␊ |
186 | ␉int␉␉␉biosdev;␉␉/* BIOS device number */␊ |
187 | ␉int␉␉␉type;␉␉␉/* device type (floppy, hd, network) */␊ |
188 | ␉unsigned int␉␉flags;␉␉␉/* attribute flags */␊ |
189 | ␉BVGetDescription␉description;␉␉/* BVGetDescription function */␊ |
190 | ␉int␉␉␉part_no;␉␉/* partition number (1 based) */␊ |
191 | ␉unsigned int␉␉part_boff;␉␉/* partition block offset */␊ |
192 | ␉unsigned int␉␉part_type;␉␉/* partition type */␊ |
193 | ␉unsigned int␉␉fs_boff;␉␉/* 1st block # of next read */␊ |
194 | ␉unsigned int␉␉fs_byteoff;␉␉/* Byte offset for read within block */␊ |
195 | ␉FSLoadFile␉␉fs_loadfile;␉␉/* FSLoadFile function */␊ |
196 | ␉FSReadFile␉␉fs_readfile;␉␉/* FSReadFile function */␊ |
197 | ␉FSGetDirEntry␉␉fs_getdirentry;␉␉/* FSGetDirEntry function */␊ |
198 | ␉FSGetFileBlock␉␉fs_getfileblock;␉/* FSGetFileBlock function */␊ |
199 | ␉FSGetUUID␉␉fs_getuuid;␉␉/* FSGetUUID function */␊ |
200 | ␉unsigned int␉␉bps;␉␉␉/* bytes per sector for this device */␊ |
201 | ␉char␉␉␉name[BVSTRLEN];␉␉/* (name of partition) */␊ |
202 | ␉char␉␉␉type_name[BVSTRLEN];␉/* (type of partition, eg. Apple_HFS) */␊ |
203 | ␉BVFree␉␉␉bv_free;␉␉/* BVFree function */␊ |
204 | ␉uint32_t␉␉modTime;␊ |
205 | ␉char␉␉␉label[BVSTRLEN];␉/* partition volume label */␊ |
206 | ␉char␉␉␉altlabel[BVSTRLEN];␉/* partition volume label */␊ |
207 | ␉bool␉␉␉filtered;␉␉/* newFilteredBVChain() will set to TRUE */␊ |
208 | ␉bool␉␉␉visible;␉␉/* will shown in the device list */␊ |
209 | ␉char␉␉␉OSVersion[8];␊ |
210 | ␉bool␉␉␉OSisServer;␉␉/* 1 = OS X server , 0 = OS X client */␊ |
211 | ␉bool␉␉␉OSisInstaller;␉␉/* 1 = OS X Install partition / recover partition , 0 = OS X Install */␊ |
212 | ␊ |
213 | };␊ |
214 | ␊ |
215 | enum␊ |
216 | {␊ |
217 | ␉kBVFlagPrimary␉␉␉= 0x01,␊ |
218 | ␉kBVFlagNativeBoot␉␉= 0x02,␊ |
219 | ␉kBVFlagForeignBoot␉␉= 0x04,␊ |
220 | ␉kBVFlagBootable␉␉␉= 0x08,␊ |
221 | ␉kBVFlagEFISystem␉␉= 0x10,␊ |
222 | ␉kBVFlagBooter␉␉␉= 0x20,␊ |
223 | ␉kBVFlagSystemVolume␉␉= 0x40,␊ |
224 | ␉kBVFlagInstallVolume␉␉= 0x80␊ |
225 | };␊ |
226 | ␊ |
227 | enum␊ |
228 | {␊ |
229 | ␉kBIOSDevTypeFloppy␉␉= 0x00,␊ |
230 | ␉kBIOSDevTypeHardDrive␉␉= 0x80,␊ |
231 | ␉kBIOSDevTypeNetwork␉␉= 0xE0,␊ |
232 | ␉kBIOSDevUnitMask␉␉= 0x0F,␊ |
233 | ␉kBIOSDevTypeMask␉␉= 0xF0,␊ |
234 | ␉kBIOSDevMask␉␉␉= 0xFF␊ |
235 | };␊ |
236 | ␊ |
237 | enum␊ |
238 | {␊ |
239 | ␉//KPartitionTypeFAT12␉␉= 0x01, // FAT12␊ |
240 | ␉kPartitionTypeHPFS␉␉= 0x07, // Mac OS X␊ |
241 | ␉kPartitionTypeFAT16␉␉= 0x06, // FAT16␊ |
242 | ␉kPartitionTypeFAT32␉␉= 0x0C, // FAT32␊ |
243 | ␉kPartitionTypeEXT3␉␉= 0x83, // Linux␊ |
244 | ␉kPartitionTypeOSXBoot␉␉= 0xAB, // Mac OS X Boot partition␊ |
245 | ␉kPartitionTypeFreeBSD␉␉= 0xA5, // FreeBSD␊ |
246 | ␉kPartitionTypeOpenBSD␉␉= 0xA6, // OpenBSD␊ |
247 | ␉//kPartitionTypeNeXTSTEP␉= 0xA7 // NeXTSTEP␊ |
248 | ␉//kPartitionTypeNetBSD␉␉= 0xA9 // NetBSD␊ |
249 | ␉kPartitionTypeHFS␉␉= 0xAF, // Mac OS X␊ |
250 | ␉//kPartitionTypeSolaris␉␉= 0xBE,␉ // Solaris␊ |
251 | ␉kPartitionTypeBEFS␉␉= 0xEB, // BeOS BFS␊ |
252 | ␉//kPartitionTypeBeOS␉␉= 0xEB, // BeOS BFS␊ |
253 | ␉//kPartitionTypeSkyOS␉␉= 0xEC, // SkyOS␊ |
254 | };␊ |
255 | ␊ |
256 | //#define BIOS_DEV_TYPE(d)␉((d) & kBIOSDevTypeMask)␊ |
257 | #define BIOS_DEV_UNIT(bvr)␉((bvr)->biosdev - (bvr)->type)␊ |
258 | ␊ |
259 | // KernBootStruct device types.␊ |
260 | ␊ |
261 | enum␊ |
262 | {␊ |
263 | ␉DEV_SD = 0,␊ |
264 | ␉DEV_HD = 1,␊ |
265 | ␉DEV_FD = 2,␊ |
266 | ␉DEV_EN = 3␊ |
267 | };␊ |
268 | ␊ |
269 | /*␊ |
270 | * min/max Macros.␊ |
271 | * counting and rounding Macros.␊ |
272 | *␊ |
273 | * Azi: defined on <sys/param.h>,␊ |
274 | *␉␉i386/include/IOKit/IOLib.h (min/max), and others...␊ |
275 | *␊ |
276 | #ifndef MIN␊ |
277 | #define MIN(a,b) ( ((a) < (b)) ? (a) : (b) )␊ |
278 | #endif␊ |
279 | #ifndef MAX␊ |
280 | #define MAX(a,b) ( ((a) > (b)) ? (a) : (b) )␊ |
281 | #endif␊ |
282 | ␊ |
283 | #define round2(x, m)␉(((x) + (m / 2)) & ~(m - 1))␊ |
284 | #define roundup2(x, m)␉(((x) + m - 1) & ~(m - 1))*/␊ |
285 | ␊ |
286 | enum {␊ |
287 | ␉kNetworkDeviceType = kBIOSDevTypeNetwork,␊ |
288 | ␉kBlockDeviceType = kBIOSDevTypeHardDrive␊ |
289 | }; //gBootFileType_t;␊ |
290 | ␊ |
291 | enum␊ |
292 | {␊ |
293 | ␉kCursorTypeHidden = 0x0100,␊ |
294 | ␉kCursorTypeUnderline = 0x0607␊ |
295 | };␊ |
296 | ␊ |
297 | #endif /* !__LIBSAIO_SAIO_TYPES_H */␊ |
298 | |