Root/
Source at commit 1083 created 13 years 1 month ago. By meklort, add GetDriveInfo | |
---|---|
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 "bootargs.h"␊ |
34 | ␊ |
35 | #if DEBUG␊ |
36 | #define DEBUG_DISK(x) printf x␊ |
37 | #else␊ |
38 | #define DEBUG_DISK(x)␊ |
39 | #endif␊ |
40 | ␊ |
41 | typedef unsigned long entry_t;␊ |
42 | ␊ |
43 | typedef struct {␊ |
44 | ␉unsigned int sectors:8;␊ |
45 | ␉unsigned int heads:8;␊ |
46 | ␉unsigned int cylinders:16;␊ |
47 | } compact_diskinfo_t;␊ |
48 | ␊ |
49 | struct driveParameters {␊ |
50 | ␉int cylinders;␊ |
51 | ␉int sectors;␊ |
52 | ␉int heads;␊ |
53 | ␉int totalDrives;␊ |
54 | };␊ |
55 | ␊ |
56 | struct Tag {␊ |
57 | ␉long␉␉type;␊ |
58 | ␉char␉ *string;␊ |
59 | ␉long␉␉offset;␊ |
60 | ␉struct Tag *tag;␊ |
61 | ␉struct Tag *tagNext;␊ |
62 | };␊ |
63 | typedef struct Tag Tag, *TagPtr;␊ |
64 | ␊ |
65 | typedef struct {␊ |
66 | ␉char␉plist[4096];␉// buffer for plist␊ |
67 | ␉TagPtr␉dictionary;␉␉// buffer for xml dictionary␊ |
68 | ␉bool␉canOverride;␉// flag to mark a dictionary can be overriden␊ |
69 | } config_file_t;␊ |
70 | ␊ |
71 | typedef struct FinderInfo {␊ |
72 | ␉unsigned char data[16];␊ |
73 | } FinderInfo;␊ |
74 | ␊ |
75 | struct␉␉ BootVolume;␊ |
76 | typedef struct BootVolume * BVRef;␊ |
77 | typedef struct BootVolume * CICell;␊ |
78 | ␊ |
79 | typedef long (*FSInit)(CICell ih);␊ |
80 | typedef long (*FSLoadFile)(CICell ih, char * filePath);␊ |
81 | typedef long (*FSReadFile)(CICell ih, char *filePath, void *base, uint64_t offset, uint64_t length);␊ |
82 | typedef long (*FSGetFileBlock)(CICell ih, char *filePath, unsigned long long *firstBlock);␊ |
83 | typedef long (*FSGetDirEntry)(CICell ih, char * dirPath, long long * dirIndex,␊ |
84 | ␉␉␉␉␉␉␉ char ** name, long * flags, long * time,␊ |
85 | ␉␉␉␉␉␉␉ FinderInfo * finderInfo, long * infoValid);␊ |
86 | typedef long (*FSGetUUID)(CICell ih, char *uuidStr);␊ |
87 | typedef void (*BVGetDescription)(CICell ih, char * str, long strMaxLen);␊ |
88 | // Can be just pointed to free or a special free function␊ |
89 | typedef void (*BVFree)(CICell ih);␊ |
90 | ␊ |
91 | struct iob {␊ |
92 | ␉unsigned int i_flgs;␉␉␉/* see F_* below */␊ |
93 | ␉unsigned int i_offset;␉␉/* seek byte offset in file */␊ |
94 | ␉int␉␉␉ i_filesize;␉␉/* size of file */␊ |
95 | ␉char *␉␉ i_buf;␉␉␉/* file load address */␊ |
96 | };␊ |
97 | ␊ |
98 | #define BPS␉␉ 512␉␉␉␉/* sector size of the device */␊ |
99 | #define F_READ␉ 0x1␉␉␉␉/* file opened for reading */␊ |
100 | #define F_WRITE␉ 0x2␉␉␉␉/* file opened for writing */␊ |
101 | #define F_ALLOC␉ 0x4␉␉␉␉/* buffer allocated */␊ |
102 | #define F_FILE␉ 0x8␉␉␉␉/* file instead of device */␊ |
103 | #define F_NBSF␉ 0x10␉␉␉␉/* no bad sector forwarding */␊ |
104 | #define F_SSI␉ 0x40␉␉␉␉/* set skip sector inhibit */␊ |
105 | #define F_MEM␉ 0x80␉␉␉␉/* memory instead of file or device */␊ |
106 | ␊ |
107 | struct dirstuff {␊ |
108 | ␉char *␉␉ dir_path;␉␉/* directory path */␊ |
109 | ␉long long␉ dir_index;␉␉/* directory entry index */␊ |
110 | ␉BVRef␉␉ dir_bvr;␉␉␉/* volume reference */␊ |
111 | };␊ |
112 | ␊ |
113 | #define BVSTRLEN 32␊ |
114 | ␊ |
115 | struct BootVolume {␊ |
116 | ␉BVRef␉␉␉ next;␉␉␉ /* list linkage pointer */␊ |
117 | ␉int␉␉␉␉ biosdev;␉␉ /* BIOS device number */␊ |
118 | ␉int␉␉␉␉ type;␉␉␉ /* device type (floppy, hd, network) */␊ |
119 | ␉unsigned int␉ flags;␉␉␉ /* attribute flags */␊ |
120 | ␉BVGetDescription description;␉ /* BVGetDescription function */␊ |
121 | ␉int␉␉␉␉ part_no;␉␉ /* partition number (1 based) */␊ |
122 | ␉unsigned int␉ part_boff;␉␉ /* partition block offset */␊ |
123 | ␉unsigned int␉ part_type;␉␉ /* partition type */␊ |
124 | ␉unsigned int␉ fs_boff;␉␉ /* 1st block # of next read */␊ |
125 | ␉unsigned int␉ fs_byteoff;␉ /* Byte offset for read within block */␊ |
126 | ␉FSLoadFile␉␉ fs_loadfile;␉ /* FSLoadFile function */␊ |
127 | ␉FSReadFile␉␉ fs_readfile;␉ /* FSReadFile function */␊ |
128 | ␉FSGetDirEntry␉ fs_getdirentry; /* FSGetDirEntry function */␊ |
129 | ␉FSGetFileBlock␉ fs_getfileblock; /* FSGetFileBlock function */␊ |
130 | ␉FSGetUUID␉␉ fs_getuuid;␉ /* FSGetUUID function */␊ |
131 | ␉unsigned int␉ bps;␉␉␉ /* bytes per sector for this device */␊ |
132 | ␉char␉␉␉ name[BVSTRLEN]; /* (name of partition) */␊ |
133 | ␉char␉␉␉ type_name[BVSTRLEN]; /* (type of partition, eg. Apple_HFS) */␊ |
134 | ␉BVFree␉␉␉ bv_free;␉␉ /* BVFree function */␊ |
135 | ␉uint32_t␉␉ modTime;␊ |
136 | ␉char␉␉␉ label[BVSTRLEN]; /* partition volume label */␊ |
137 | ␉char␉␉␉ altlabel[BVSTRLEN]; /* partition volume label */␊ |
138 | ␉bool␉␉␉ filtered;␉␉ /* newFilteredBVChain() will set to TRUE */␊ |
139 | ␉bool␉␉␉ visible;␉␉ /* will shown in the device list */␊ |
140 | };␊ |
141 | ␊ |
142 | enum {␊ |
143 | ␉kBVFlagPrimary␉␉␉= 0x01,␊ |
144 | ␉kBVFlagNativeBoot␉␉= 0x02,␊ |
145 | ␉kBVFlagForeignBoot␉␉= 0x04,␊ |
146 | ␉kBVFlagBootable␉␉␉= 0x08,␊ |
147 | ␉kBVFlagEFISystem␉␉= 0x10,␊ |
148 | ␉kBVFlagBooter␉␉␉= 0x20,␊ |
149 | ␉kBVFlagSystemVolume␉␉= 0x40␊ |
150 | };␊ |
151 | ␊ |
152 | enum {␊ |
153 | ␉kBIOSDevTypeFloppy␉␉= 0x00,␊ |
154 | ␉kBIOSDevTypeHardDrive␉= 0x80,␊ |
155 | ␉kBIOSDevTypeNetwork␉␉= 0xE0,␊ |
156 | ␉kBIOSDevUnitMask␉␉= 0x0F,␊ |
157 | ␉kBIOSDevTypeMask␉␉= 0xF0,␊ |
158 | ␉kBIOSDevMask␉␉␉= 0xFF␊ |
159 | };␊ |
160 | ␊ |
161 | enum {␊ |
162 | ␉kPartitionTypeHFS␉␉= 0xAF,␊ |
163 | ␉kPartitionTypeHPFS␉␉= 0x07,␊ |
164 | ␉kPartitionTypeFAT16␉␉= 0x06,␊ |
165 | ␉kPartitionTypeFAT32␉␉= 0x0c,␊ |
166 | ␉kPartitionTypeEXT3␉␉= 0x83␊ |
167 | };␊ |
168 | ␊ |
169 | //#define BIOS_DEV_TYPE(d)␉((d) & kBIOSDevTypeMask)␊ |
170 | #define BIOS_DEV_UNIT(bvr)␉((bvr)->biosdev - (bvr)->type)␊ |
171 | ␊ |
172 | /*␊ |
173 | * KernBootStruct device types.␊ |
174 | */␊ |
175 | enum {␊ |
176 | ␉DEV_SD = 0,␊ |
177 | ␉DEV_HD = 1,␊ |
178 | ␉DEV_FD = 2,␊ |
179 | ␉DEV_EN = 3␊ |
180 | };␊ |
181 | ␊ |
182 | /*␊ |
183 | * min/max Macros.␊ |
184 | * counting and rounding Macros.␊ |
185 | *␊ |
186 | * Azi: defined on <sys/param.h>,␊ |
187 | *␉␉i386/include/IOKit/IOLib.h (min/max), and others...␊ |
188 | *␊ |
189 | #ifndef MIN␊ |
190 | #define MIN(a,b) ( ((a) < (b)) ? (a) : (b) )␊ |
191 | #endif␊ |
192 | #ifndef MAX␊ |
193 | #define MAX(a,b) ( ((a) > (b)) ? (a) : (b) )␊ |
194 | #endif␊ |
195 | ␊ |
196 | #define round2(x, m)␉(((x) + (m / 2)) & ~(m - 1))␊ |
197 | #define roundup2(x, m)␉(((x) + m - 1) & ~(m - 1))*/␊ |
198 | ␊ |
199 | enum {␊ |
200 | ␉kNetworkDeviceType = kBIOSDevTypeNetwork,␊ |
201 | ␉kBlockDeviceType = kBIOSDevTypeHardDrive␊ |
202 | }; //gBootFileType_t;␊ |
203 | ␊ |
204 | enum {␊ |
205 | ␉kCursorTypeHidden␉ = 0x0100,␊ |
206 | ␉kCursorTypeUnderline = 0x0607␊ |
207 | };␊ |
208 | ␊ |
209 | #endif /* !__LIBSAIO_SAIO_TYPES_H */␊ |
210 |