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