Chameleon

Chameleon Svn Source Tree

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

Archive Download this file

Revision: 1