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