Chameleon

Chameleon Svn Source Tree

Root/branches/slice/i386/libsaio/saio_types.h

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

Archive Download this file

Revision: 676