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 *
5 * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
6 * Reserved. This file contains Original Code and/or Modifications of
7 * Original Code as defined in and that are subject to the Apple Public
8 * Source License Version 2.0 (the "License"). You may not use this file
9 * except in compliance with the License. Please obtain a copy of the
10 * License at http://www.apple.com/publicsource and read it before using
11 * this file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
18 * License for the specific language governing rights and limitations
19 * under the License.
20 *
21 */
22/* Useful types. */
23
24#ifndef __LIBSAIO_SAIO_TYPES_H
25#define __LIBSAIO_SAIO_TYPES_H
26
27#include <sys/reboot.h>
28#include <sys/types.h>
29#include <sys/param.h>
30#include "bios.h"
31#include "nbp_cmd.h"
32#include "bootargs.h"
33
34#if DEBUG
35#define DEBUG_DISK(x) printf x
36#else
37#define DEBUG_DISK(x)
38#endif
39
40typedef unsigned long entry_t;
41
42typedef struct
43{
44unsigned int sectors:8;
45unsigned int heads:8;
46unsigned int cylinders:16;
47} compact_diskinfo_t;
48
49
50struct driveParameters
51{
52int cylinders;
53int sectors;
54int heads;
55int totalDrives;
56};
57
58
59struct Tag
60{
61longtype;
62char *string;
63longoffset;
64struct Tag *tag;
65struct Tag *tagNext;
66};
67typedef struct Tag Tag, *TagPtr;
68
69/*
70 * Max size fo config data array, in bytes.
71 */
72#define IO_CONFIG_DATA_SIZE40960 // was 4096 // was 163840
73
74typedef struct
75{
76charplist[IO_CONFIG_DATA_SIZE];// buffer for plist
77TagPtrdictionary; // buffer for xml dictionary
78boolcanOverride;// flag to mark a dictionary can be overriden
79} config_file_t;
80
81/*
82 * BIOS drive information.
83 */
84struct boot_drive_info
85{
86struct drive_params
87{
88unsigned short buf_size;
89unsigned short info_flags;
90unsigned long phys_cyls;
91unsigned long phys_heads;
92unsigned long phys_spt;
93unsigned long long phys_sectors;
94unsigned short phys_nbps;
95unsigned short dpte_offset;
96unsigned short dpte_segment;
97unsigned short key;
98unsigned char path_len;
99unsigned char reserved1;
100unsigned short reserved2;
101unsigned char bus_type[4];
102unsigned char interface_type[8];
103unsigned char interface_path[8];
104unsigned char dev_path[8];
105unsigned char reserved3;
106unsigned char checksum;
107} params;
108
109struct drive_dpte
110{
111unsigned short io_port_base;
112unsigned short control_port_base;
113unsigned char head_flags;
114unsigned char vendor_info;
115unsigned char irq : 4;
116unsigned char irq_unused : 4;
117unsigned char block_count;
118unsigned char dma_channel : 4;
119unsigned char dma_type : 4;
120unsigned char pio_type : 4;
121unsigned char pio_unused : 4;
122unsigned short option_flags;
123unsigned short reserved;
124unsigned char revision;
125unsigned char checksum;
126 } dpte;
127} __attribute__((packed));
128typedef struct boot_drive_info boot_drive_info_t;
129
130
131struct driveInfo
132{
133boot_drive_info_t di;
134
135int uses_ebios;
136int no_emulation;
137int biosdev;
138int valid;
139};
140
141
142typedef struct FinderInfo
143{
144unsigned char data[16];
145} FinderInfo;
146
147
148structBootVolume;
149typedef struct BootVolume * BVRef;
150typedef struct BootVolume * CICell;
151
152typedef long (*FSInit)(CICell ih);
153typedef long (*FSLoadFile)(CICell ih, char * filePath);
154typedef long (*FSReadFile)(CICell ih, char *filePath, void *base, uint64_t offset, uint64_t length);
155typedef long (*FSGetFileBlock)(CICell ih, char *filePath, unsigned long long *firstBlock);
156typedef long (*FSGetDirEntry)(CICell ih, char * dirPath, long long * dirIndex,
157 char ** name, long * flags, long * time,
158 FinderInfo * finderInfo, long * infoValid);
159typedef long (*FSGetUUID)(CICell ih, char *uuidStr);
160typedef void (*BVGetDescription)(CICell ih, char * str, long strMaxLen);
161// Can be just pointed to free or a special free function
162typedef void (*BVFree)(CICell ih);
163
164struct iob
165{
166char * i_buf; /* file load address */
167unsigned int i_flgs; /* see F_* below */
168unsigned int i_offset; /* seek byte offset in file */
169int i_filesize; /* size of file */
170};
171
172#define BPS 512/* sector size of the device */
173#define F_READ 0x1/* file opened for reading */
174#define F_WRITE 0x2/* file opened for writing */
175#define F_ALLOC 0x4/* buffer allocated */
176#define F_FILE 0x8/* file instead of device */
177#define F_NBSF 0x10/* no bad sector forwarding */
178#define F_SSI 0x40/* set skip sector inhibit */
179#define F_MEM 0x80/* memory instead of file or device */
180
181struct dirstuff {
182char * dir_path;/* directory path */
183long long dir_index;/* directory entry index */
184BVRef dir_bvr;/* volume reference */
185};
186
187#define BVSTRLEN 32
188
189struct BootVolume
190{
191BVRefnext;/* list linkage pointer */
192intbiosdev;/* BIOS device number */
193inttype;/* device type (floppy, hd, network) */
194unsigned intflags;/* attribute flags */
195BVGetDescriptiondescription;/* BVGetDescription function */
196intpart_no;/* partition number (1 based) */
197unsigned intpart_boff;/* partition block offset */
198unsigned intpart_type;/* partition type */
199unsigned intfs_boff;/* 1st block # of next read */
200unsigned intfs_byteoff;/* Byte offset for read within block */
201FSLoadFilefs_loadfile;/* FSLoadFile function */
202FSReadFilefs_readfile;/* FSReadFile function */
203FSGetDirEntryfs_getdirentry;/* FSGetDirEntry function */
204FSGetFileBlockfs_getfileblock;/* FSGetFileBlock function */
205FSGetUUIDfs_getuuid;/* FSGetUUID function */
206unsigned intbps;/* bytes per sector for this device */
207charname[BVSTRLEN];/* (name of partition) */
208chartype_name[BVSTRLEN];/* (type of partition, eg. Apple_HFS) */
209BVFreebv_free;/* BVFree function */
210uint32_tmodTime;
211charlabel[BVSTRLEN];/* partition volume label */
212charaltlabel[BVSTRLEN];/* partition volume label */
213boolfiltered;/* newFilteredBVChain() will set to TRUE */
214boolvisible;/* will shown in the device list */
215charOSVersion[8];
216boolOSisServer;/* 1 = OS X server , 0 = OS X client */
217boolOSisInstaller;/* 1 = OS X Install partition / recover partition , 0 = OS X Install */
218
219};
220
221enum
222{
223kBVFlagPrimary= 0x01,
224kBVFlagNativeBoot= 0x02,
225kBVFlagForeignBoot= 0x04,
226kBVFlagBootable= 0x08,
227kBVFlagEFISystem= 0x10,
228kBVFlagBooter= 0x20,
229kBVFlagSystemVolume= 0x40
230};
231
232enum
233{
234kBIOSDevTypeFloppy= 0x00,
235kBIOSDevTypeHardDrive= 0x80,
236kBIOSDevTypeNetwork= 0xE0,
237kBIOSDevUnitMask= 0x0F,
238kBIOSDevTypeMask= 0xF0,
239kBIOSDevMask= 0xFF
240};
241
242enum
243{
244kPartitionTypeHFS= 0xAF,
245kPartitionTypeHPFS= 0x07,
246kPartitionTypeFAT16= 0x06,
247kPartitionTypeFAT32= 0x0c,
248kPartitionTypeEXT3= 0x83,
249kPartitionTypeBEFS= 0xEB,
250kPartitionTypeFreeBSD= 0xa5,
251kPartitionTypeOpenBSD= 0xa6
252};
253
254//#define BIOS_DEV_TYPE(d)((d) & kBIOSDevTypeMask)
255#define BIOS_DEV_UNIT(bvr)((bvr)->biosdev - (bvr)->type)
256
257// KernBootStruct device types.
258
259enum
260{
261DEV_SD = 0,
262DEV_HD = 1,
263DEV_FD = 2,
264DEV_EN = 3
265};
266
267/*
268 * min/max Macros.
269 * counting and rounding Macros.
270 *
271 * Azi: defined on <sys/param.h>,
272 *i386/include/IOKit/IOLib.h (min/max), and others...
273 *
274#ifndef MIN
275#define MIN(a,b) ( ((a) < (b)) ? (a) : (b) )
276#endif
277#ifndef MAX
278#define MAX(a,b) ( ((a) > (b)) ? (a) : (b) )
279#endif
280
281#defineround2(x, m)(((x) + (m / 2)) & ~(m - 1))
282#define roundup2(x, m) (((x) + m - 1) & ~(m - 1))*/
283
284enum
285{
286kNetworkDeviceType = kBIOSDevTypeNetwork,
287kBlockDeviceType = kBIOSDevTypeHardDrive
288}; //gBootFileType_t;
289
290enum
291{
292kCursorTypeHidden = 0x0100,
293kCursorTypeUnderline = 0x0607
294};
295
296#endif /* !__LIBSAIO_SAIO_TYPES_H */
297

Archive Download this file

Revision: 2111