Chameleon

Chameleon Svn Source Tree

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