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
139
140typedef struct FinderInfo
141{
142unsigned char data[16];
143} FinderInfo;
144
145
146structBootVolume;
147typedef struct BootVolume * BVRef;
148typedef struct BootVolume * CICell;
149
150typedef long (*FSInit)(CICell ih);
151typedef long (*FSLoadFile)(CICell ih, char * filePath);
152typedef long (*FSReadFile)(CICell ih, char *filePath, void *base, uint64_t offset, uint64_t length);
153typedef long (*FSGetFileBlock)(CICell ih, char *filePath, unsigned long long *firstBlock);
154typedef long (*FSGetDirEntry)(CICell ih, char * dirPath, long long * dirIndex,
155 char ** name, long * flags, long * time,
156 FinderInfo * finderInfo, long * infoValid);
157typedef long (*FSGetUUID)(CICell ih, char *uuidStr);
158typedef void (*BVGetDescription)(CICell ih, char * str, long strMaxLen);
159// Can be just pointed to free or a special free function
160typedef void (*BVFree)(CICell ih);
161
162struct iob
163{
164char * i_buf; /* file load address */
165unsigned int i_flgs; /* see F_* below */
166unsigned int i_offset; /* seek byte offset in file */
167int i_filesize; /* size of file */
168};
169
170#define BPS 512/* sector size of the device */
171#define F_READ 0x1/* file opened for reading */
172#define F_WRITE 0x2/* file opened for writing */
173#define F_ALLOC 0x4/* buffer allocated */
174#define F_FILE 0x8/* file instead of device */
175#define F_NBSF 0x10/* no bad sector forwarding */
176#define F_SSI 0x40/* set skip sector inhibit */
177#define F_MEM 0x80/* memory instead of file or device */
178
179struct dirstuff {
180char * dir_path;/* directory path */
181long long dir_index;/* directory entry index */
182BVRef dir_bvr; /* volume reference */
183};
184
185#define BVSTRLEN 32
186
187struct BootVolume
188{
189 BVRef next; /* list linkage pointer */
190 int biosdev; /* BIOS device number */
191 int type; /* device type (floppy, hd, network) */
192 unsigned int flags; /* attribute flags */
193 BVGetDescription description; /* BVGetDescription function */
194 int part_no; /* partition number (1 based) */
195 unsigned int part_boff; /* partition block offset */
196 unsigned int part_type; /* partition type */
197 unsigned int fs_boff; /* 1st block # of next read */
198 unsigned int fs_byteoff; /* Byte offset for read within block */
199 FSLoadFile fs_loadfile; /* FSLoadFile function */
200 FSReadFile fs_readfile; /* FSReadFile function */
201 FSGetDirEntry fs_getdirentry; /* FSGetDirEntry function */
202 FSGetFileBlock fs_getfileblock; /* FSGetFileBlock function */
203 FSGetUUID fs_getuuid; /* FSGetUUID function */
204 unsigned int bps; /* bytes per sector for this device */
205 char name[BVSTRLEN]; /* (name of partition) */
206 char type_name[BVSTRLEN]; /* (type of partition, eg. Apple_HFS) */
207 BVFree bv_free; /* BVFree function */
208 uint32_t modTime;
209 char label[BVSTRLEN]; /* partition volume label */
210 char altlabel[BVSTRLEN]; /* partition volume label */
211 bool filtered; /* newFilteredBVChain() will set to TRUE */
212 bool visible; /* will shown in the device list */
213 char OSVersion[8];
214 bool OSisServer; /* 1 = OS X server , 0 = OS X client */
215};
216
217enum
218{
219
220kBVFlagPrimary= 0x01,
221kBVFlagNativeBoot= 0x02,
222kBVFlagForeignBoot= 0x04,
223kBVFlagBootable= 0x08,
224kBVFlagEFISystem= 0x10,
225kBVFlagBooter= 0x20,
226kBVFlagSystemVolume= 0x40
227};
228
229enum
230{
231kBIOSDevTypeFloppy= 0x00,
232kBIOSDevTypeHardDrive= 0x80,
233kBIOSDevTypeNetwork= 0xE0,
234kBIOSDevUnitMask= 0x0F,
235kBIOSDevTypeMask= 0xF0,
236kBIOSDevMask= 0xFF
237};
238
239enum
240{
241kPartitionTypeHFS= 0xAF,
242kPartitionTypeHPFS= 0x07,
243kPartitionTypeFAT16= 0x06,
244kPartitionTypeFAT32= 0x0c,
245kPartitionTypeEXT3= 0x83,
246kPartitionTypeBEFS= 0xEB,
247kPartitionTypeFreeBSD= 0xa5,
248kPartitionTypeOpenBSD= 0xa6
249};
250
251//#define BIOS_DEV_TYPE(d)((d) & kBIOSDevTypeMask)
252#define BIOS_DEV_UNIT(bvr)((bvr)->biosdev - (bvr)->type)
253
254// KernBootStruct device types.
255
256enum
257{
258DEV_SD = 0,
259DEV_HD = 1,
260DEV_FD = 2,
261DEV_EN = 3
262};
263
264/*
265 * min/max Macros.
266 * counting and rounding Macros.
267 *
268 * Azi: defined on <sys/param.h>,
269 *i386/include/IOKit/IOLib.h (min/max), and others...
270 *
271#ifndef MIN
272#define MIN(a,b) ( ((a) < (b)) ? (a) : (b) )
273#endif
274#ifndef MAX
275#define MAX(a,b) ( ((a) > (b)) ? (a) : (b) )
276#endif
277
278#defineround2(x, m)(((x) + (m / 2)) & ~(m - 1))
279#define roundup2(x, m) (((x) + m - 1) & ~(m - 1))*/
280
281enum
282{
283kNetworkDeviceType = kBIOSDevTypeNetwork,
284kBlockDeviceType = kBIOSDevTypeHardDrive
285}; //gBootFileType_t;
286
287enum
288{
289kCursorTypeHidden = 0x0100,
290kCursorTypeUnderline = 0x0607
291};
292
293#endif /* !__LIBSAIO_SAIO_TYPES_H */
294

Archive Download this file

Revision: 2037