Chameleon

Chameleon Svn Source Tree

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

Archive Download this file

Revision: 2004