Root/
Source at commit 418 created 13 years 10 months ago. By azimutz, Trunk it, revs 413 --> 416. | |
---|---|
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 * 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 F_READ 0x1 /* file opened for reading */␊ |
151 | #define F_WRITE 0x2 /* file opened for writing */␊ |
152 | #define F_ALLOC 0x4 /* buffer allocated */␊ |
153 | #define F_FILE 0x8 /* file instead of device */␊ |
154 | #define F_NBSF 0x10 /* no bad sector forwarding */␊ |
155 | #define F_SSI 0x40 /* set skip sector inhibit */␊ |
156 | #define F_MEM 0x80 /* memory instead of file or device */␊ |
157 | ␊ |
158 | struct dirstuff {␊ |
159 | char * dir_path; /* directory path */␊ |
160 | long dir_index; /* directory entry index */␊ |
161 | BVRef dir_bvr; /* volume reference */␊ |
162 | };␊ |
163 | ␊ |
164 | #define BVSTRLEN 32␊ |
165 | ␊ |
166 | struct BootVolume {␊ |
167 | BVRef next; /* list linkage pointer */␊ |
168 | int biosdev; /* BIOS device number */␊ |
169 | int type; /* device type (floppy, hd, network) */␊ |
170 | unsigned int flags; /* attribute flags */␊ |
171 | BVGetDescription description; /* BVGetDescription function */␊ |
172 | int part_no; /* partition number (1 based) */␊ |
173 | unsigned int part_boff; /* partition block offset */␊ |
174 | unsigned int part_type; /* partition type */␊ |
175 | unsigned int fs_boff; /* 1st block # of next read */␊ |
176 | unsigned int fs_byteoff; /* Byte offset for read within block */␊ |
177 | FSLoadFile fs_loadfile; /* FSLoadFile function */␊ |
178 | FSReadFile fs_readfile; /* FSReadFile function */␊ |
179 | FSGetDirEntry fs_getdirentry; /* FSGetDirEntry function */␊ |
180 | FSGetFileBlock fs_getfileblock; /* FSGetFileBlock function */␊ |
181 | FSGetUUID fs_getuuid; /* FSGetUUID function */␊ |
182 | unsigned int bps; /* bytes per sector for this device */␊ |
183 | char name[BVSTRLEN]; /* (name of partition) */␊ |
184 | char type_name[BVSTRLEN]; /* (type of partition, eg. Apple_HFS) */␊ |
185 | BVFree bv_free; /* BVFree function */␊ |
186 | uint32_t modTime;␊ |
187 | char␉␉␉ label[BVSTRLEN]; /* partition volume label */␊ |
188 | char␉␉␉ altlabel[BVSTRLEN]; /* partition volume label */␊ |
189 | bool filtered; /* newFilteredBVChain() will set to TRUE */␊ |
190 | bool visible; /* will shown in the device list */␊ |
191 | };␊ |
192 | ␊ |
193 | enum {␊ |
194 | kBVFlagPrimary = 0x01,␊ |
195 | kBVFlagNativeBoot = 0x02,␊ |
196 | kBVFlagForeignBoot = 0x04,␊ |
197 | kBVFlagBootable = 0x08,␊ |
198 | kBVFlagEFISystem = 0x10,␊ |
199 | kBVFlagBooter = 0x20,␊ |
200 | kBVFlagSystemVolume = 0x40␊ |
201 | };␊ |
202 | ␊ |
203 | enum {␊ |
204 | kBIOSDevTypeFloppy = 0x00,␊ |
205 | kBIOSDevTypeHardDrive = 0x80,␊ |
206 | kBIOSDevTypeNetwork = 0xE0,␊ |
207 | kBIOSDevUnitMask = 0x0F,␊ |
208 | kBIOSDevTypeMask = 0xF0,␊ |
209 | kBIOSDevMask = 0xFF␊ |
210 | };␊ |
211 | ␊ |
212 | enum {␊ |
213 | ␉␊ |
214 | ␉kPartitionTypeHFS␉ = 0xAF,␊ |
215 | ␉kPartitionTypeHPFS = 0x07,␊ |
216 | ␉kPartitionTypeFAT16 = 0x06,␊ |
217 | ␉kPartitionTypeFAT32 = 0x0c,␊ |
218 | ␉kPartitionTypeEXT3 = 0x83,␊ |
219 | };␊ |
220 | ␊ |
221 | //#define BIOS_DEV_TYPE(d) ((d) & kBIOSDevTypeMask)␊ |
222 | #define BIOS_DEV_UNIT(bvr) ((bvr)->biosdev - (bvr)->type)␊ |
223 | ␊ |
224 | /*␊ |
225 | * KernBootStruct device types.␊ |
226 | */␊ |
227 | enum {␊ |
228 | DEV_SD = 0,␊ |
229 | DEV_HD = 1,␊ |
230 | DEV_FD = 2,␊ |
231 | DEV_EN = 3␊ |
232 | };␊ |
233 | ␊ |
234 | #ifndef max␊ |
235 | #define max(a,b) ((a) > (b) ? (a) : (b))␊ |
236 | #endif␊ |
237 | ␊ |
238 | #ifndef min␊ |
239 | #define min(a,b) ((a) < (b) ? (a) : (b))␊ |
240 | #endif␊ |
241 | ␊ |
242 | #define␉round2(x, m)␉(((x) + (m / 2)) & ~(m - 1))␊ |
243 | #define roundup2(x, m) (((x) + m - 1) & ~(m - 1))␊ |
244 | ␊ |
245 | #define MAKEKERNDEV(t, u, p) MAKEBOOTDEV(t, 0, 0, u, p)␊ |
246 | ␊ |
247 | enum {␊ |
248 | kNetworkDeviceType = kBIOSDevTypeNetwork,␊ |
249 | kBlockDeviceType = kBIOSDevTypeHardDrive␊ |
250 | };␊ |
251 | ␊ |
252 | enum {␊ |
253 | kCursorTypeHidden = 0x0100,␊ |
254 | kCursorTypeUnderline = 0x0607␊ |
255 | };␊ |
256 | ␊ |
257 | #endif /* !__LIBSAIO_SAIO_TYPES_H */␊ |
258 |