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 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
67bool canOverride; // flag to mark a dictionary can be overriden
68} config_file_t;
69
70/*
71 * BIOS drive information.
72 */
73struct boot_drive_info {
74 struct drive_params {
75unsigned short buf_size;
76unsigned short info_flags;
77unsigned long phys_cyls;
78unsigned long phys_heads;
79unsigned long phys_spt;
80unsigned long long phys_sectors;
81unsigned short phys_nbps;
82unsigned short dpte_offset;
83unsigned short dpte_segment;
84unsigned short key;
85unsigned char path_len;
86unsigned char reserved1;
87unsigned short reserved2;
88unsigned char bus_type[4];
89unsigned char interface_type[8];
90unsigned char interface_path[8];
91unsigned char dev_path[8];
92unsigned char reserved3;
93unsigned char checksum;
94 } params __attribute__((packed));
95 struct drive_dpte {
96unsigned short io_port_base;
97unsigned short control_port_base;
98unsigned char head_flags;
99unsigned char vendor_info;
100unsigned char irq : 4;
101unsigned char irq_unused : 4;
102unsigned char block_count;
103unsigned char dma_channel : 4;
104unsigned char dma_type : 4;
105unsigned char pio_type : 4;
106unsigned char pio_unused : 4;
107unsigned short option_flags;
108unsigned short reserved;
109unsigned char revision;
110unsigned char checksum;
111 } dpte __attribute__((packed));
112} __attribute__((packed));
113typedef struct boot_drive_info boot_drive_info_t;
114
115struct driveInfo {
116 boot_drive_info_t di;
117 int uses_ebios;
118 int no_emulation;
119 int biosdev;
120 int valid;
121};
122
123typedef struct FinderInfo {
124 unsigned char data[16];
125} FinderInfo;
126
127struct BootVolume;
128typedef struct BootVolume * BVRef;
129typedef struct BootVolume * CICell;
130
131typedef long (*FSInit)(CICell ih);
132typedef long (*FSLoadFile)(CICell ih, char * filePath);
133typedef long (*FSReadFile)(CICell ih, char *filePath, void *base, uint64_t offset, uint64_t length);
134typedef long (*FSGetFileBlock)(CICell ih, char *filePath, unsigned long long *firstBlock);
135typedef long (*FSGetDirEntry)(CICell ih, char * dirPath, long long * dirIndex,
136 char ** name, long * flags, long * time,
137 FinderInfo * finderInfo, long * infoValid);
138typedef long (* FSGetUUID)(CICell ih, char *uuidStr);
139typedef void (*BVGetDescription)(CICell ih, char * str, long strMaxLen);
140// Can be just pointed to free or a special free function
141typedef void (*BVFree)(CICell ih);
142
143struct 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
159struct 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
167struct 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
194enum {
195 kBVFlagPrimary = 0x01,
196 kBVFlagNativeBoot = 0x02,
197 kBVFlagForeignBoot = 0x04,
198 kBVFlagBootable = 0x08,
199 kBVFlagEFISystem = 0x10,
200 kBVFlagBooter = 0x20,
201 kBVFlagSystemVolume = 0x40
202};
203
204enum {
205 kBIOSDevTypeFloppy = 0x00,
206 kBIOSDevTypeHardDrive = 0x80,
207 kBIOSDevTypeNetwork = 0xE0,
208 kBIOSDevUnitMask = 0x0F,
209 kBIOSDevTypeMask = 0xF0,
210 kBIOSDevMask = 0xFF
211};
212
213enum {
214
215kPartitionTypeHFS = 0xAF,
216kPartitionTypeHPFS = 0x07,
217kPartitionTypeFAT16 = 0x06,
218kPartitionTypeFAT32 = 0x0c,
219kPartitionTypeEXT3 = 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 */
228enum {
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#defineround2(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
248enum {
249 kNetworkDeviceType = kBIOSDevTypeNetwork,
250 kBlockDeviceType = kBIOSDevTypeHardDrive
251} gBootFileType_t;
252
253enum {
254 kCursorTypeHidden = 0x0100,
255 kCursorTypeUnderline = 0x0607
256};
257
258#endif /* !__LIBSAIO_SAIO_TYPES_H */
259

Archive Download this file

Revision: 367