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