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