Chameleon

Chameleon Svn Source Tree

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

Archive Download this file

Revision: 141