Chameleon

Chameleon Svn Source Tree

Root/branches/ErmaC/Enoch_Modules/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/*
72 * Max size fo config data array, in bytes.
73 */
74#define IO_CONFIG_DATA_SIZE40960 // was 4096 // was 163840
75
76typedef struct
77{
78charplist[IO_CONFIG_DATA_SIZE];// buffer for plist
79TagPtrdictionary; // buffer for xml dictionary
80boolcanOverride;// flag to mark a dictionary can be overriden
81} config_file_t;
82
83/*
84 * BIOS drive information.
85 */
86struct boot_drive_info
87{
88struct drive_params
89{
90unsigned short buf_size;
91unsigned short info_flags;
92unsigned long phys_cyls;
93unsigned long phys_heads;
94unsigned long phys_spt;
95unsigned long long phys_sectors;
96unsigned short phys_nbps;
97unsigned short dpte_offset;
98unsigned short dpte_segment;
99unsigned short key;
100unsigned char path_len;
101unsigned char reserved1;
102unsigned short reserved2;
103unsigned char bus_type[4];
104unsigned char interface_type[8];
105unsigned char interface_path[8];
106unsigned char dev_path[8];
107unsigned char reserved3;
108unsigned char checksum;
109} params;
110
111struct drive_dpte
112{
113unsigned short io_port_base;
114unsigned short control_port_base;
115unsigned char head_flags;
116unsigned char vendor_info;
117unsigned char irq : 4;
118unsigned char irq_unused : 4;
119unsigned char block_count;
120unsigned char dma_channel : 4;
121unsigned char dma_type : 4;
122unsigned char pio_type : 4;
123unsigned char pio_unused : 4;
124unsigned short option_flags;
125unsigned short reserved;
126unsigned char revision;
127unsigned char checksum;
128 } dpte;
129} __attribute__((packed));
130typedef struct boot_drive_info boot_drive_info_t;
131
132
133struct driveInfo
134{
135boot_drive_info_t di;
136
137int uses_ebios;
138int no_emulation;
139int biosdev;
140int valid;
141};
142
143
144typedef struct FinderInfo
145{
146unsigned char data[16];
147} FinderInfo;
148
149
150structBootVolume;
151typedef struct BootVolume * BVRef;
152typedef struct BootVolume * CICell;
153
154typedef long (*FSInit)(CICell ih);
155typedef long (*FSLoadFile)(CICell ih, char * filePath);
156typedef long (*FSReadFile)(CICell ih, char *filePath, void *base, uint64_t offset, uint64_t length);
157typedef long (*FSGetFileBlock)(CICell ih, char *filePath, unsigned long long *firstBlock);
158typedef long (*FSGetDirEntry)(CICell ih, char * dirPath, long long * dirIndex,
159 char ** name, long * flags, long * time,
160 FinderInfo * finderInfo, long * infoValid);
161typedef long (*FSGetUUID)(CICell ih, char *uuidStr);
162typedef void (*BVGetDescription)(CICell ih, char * str, long strMaxLen);
163// Can be just pointed to free or a special free function
164typedef void (*BVFree)(CICell ih);
165
166struct iob
167{
168char * i_buf; /* file load address */
169unsigned int i_flgs; /* see F_* below */
170unsigned int i_offset; /* seek byte offset in file */
171int i_filesize; /* size of file */
172};
173
174#define BPS 512/* sector size of the device */
175#define F_READ 0x1/* file opened for reading */
176#define F_WRITE 0x2/* file opened for writing */
177#define F_ALLOC 0x4/* buffer allocated */
178#define F_FILE 0x8/* file instead of device */
179#define F_NBSF 0x10/* no bad sector forwarding */
180#define F_SSI 0x40/* set skip sector inhibit */
181#define F_MEM 0x80/* memory instead of file or device */
182
183struct dirstuff {
184char * dir_path;/* directory path */
185long long dir_index;/* directory entry index */
186BVRef dir_bvr;/* volume reference */
187};
188
189#define BVSTRLEN 32
190
191struct BootVolume
192{
193BVRefnext;/* list linkage pointer */
194intbiosdev;/* BIOS device number */
195inttype;/* device type (floppy, hd, network) */
196unsigned intflags;/* attribute flags */
197BVGetDescriptiondescription;/* BVGetDescription function */
198intpart_no;/* partition number (1 based) */
199unsigned intpart_boff;/* partition block offset */
200unsigned intpart_type;/* partition type */
201unsigned intfs_boff;/* 1st block # of next read */
202unsigned intfs_byteoff;/* Byte offset for read within block */
203FSLoadFilefs_loadfile;/* FSLoadFile function */
204FSReadFilefs_readfile;/* FSReadFile function */
205FSGetDirEntryfs_getdirentry;/* FSGetDirEntry function */
206FSGetFileBlockfs_getfileblock;/* FSGetFileBlock function */
207FSGetUUIDfs_getuuid;/* FSGetUUID function */
208unsigned intbps;/* bytes per sector for this device */
209charname[BVSTRLEN];/* (name of partition) */
210chartype_name[BVSTRLEN];/* (type of partition, eg. Apple_HFS) */
211BVFreebv_free;/* BVFree function */
212uint32_tmodTime;
213charlabel[BVSTRLEN];/* partition volume label */
214charaltlabel[BVSTRLEN];/* partition volume label */
215boolfiltered;/* newFilteredBVChain() will set to TRUE */
216boolvisible;/* will shown in the device list */
217charOSVersion[8];
218boolOSisServer;/* 1 = OS X server , 0 = OS X client */
219boolOSisInstaller;/* 1 = OS X Install partition / recover partition , 0 = OS X Install */
220
221};
222
223enum
224{
225kBVFlagPrimary= 0x01,
226kBVFlagNativeBoot= 0x02,
227kBVFlagForeignBoot= 0x04,
228kBVFlagBootable= 0x08,
229kBVFlagEFISystem= 0x10,
230kBVFlagBooter= 0x20,
231kBVFlagSystemVolume= 0x40
232};
233
234enum
235{
236kBIOSDevTypeFloppy= 0x00,
237kBIOSDevTypeHardDrive= 0x80,
238kBIOSDevTypeNetwork= 0xE0,
239kBIOSDevUnitMask= 0x0F,
240kBIOSDevTypeMask= 0xF0,
241kBIOSDevMask= 0xFF
242};
243
244enum
245{
246kPartitionTypeHFS= 0xAF, // Mac OS X
247kPartitionTypeHPFS= 0x07, // Mac OS X
248//KPartitionTypeFAT12= 0x01, // FAT12
249kPartitionTypeFAT16= 0x06, // FAT16
250kPartitionTypeFAT32= 0x0c, // FAT32
251kPartitionTypeEXT3= 0x83, // Linux
252kPartitionTypeBEFS= 0xEB, // BeOS BFS
253kPartitionTypeFreeBSD= 0xa5, // FreeBSD
254kPartitionTypeOpenBSD= 0xa6 // OpenBSD
255//kPartitionTypeBeOS= 0xeb, // BeOS BFS
256//kPartitionTypeSkyOS= 0xec, // SkyOS
257};
258
259//#define BIOS_DEV_TYPE(d)((d) & kBIOSDevTypeMask)
260#define BIOS_DEV_UNIT(bvr)((bvr)->biosdev - (bvr)->type)
261
262// KernBootStruct device types.
263
264enum
265{
266DEV_SD = 0,
267DEV_HD = 1,
268DEV_FD = 2,
269DEV_EN = 3
270};
271
272/*
273 * min/max Macros.
274 * counting and rounding Macros.
275 *
276 * Azi: defined on <sys/param.h>,
277 *i386/include/IOKit/IOLib.h (min/max), and others...
278 *
279#ifndef MIN
280#define MIN(a,b) ( ((a) < (b)) ? (a) : (b) )
281#endif
282#ifndef MAX
283#define MAX(a,b) ( ((a) > (b)) ? (a) : (b) )
284#endif
285
286#defineround2(x, m)(((x) + (m / 2)) & ~(m - 1))
287#define roundup2(x, m) (((x) + m - 1) & ~(m - 1))*/
288
289enum
290{
291kNetworkDeviceType = kBIOSDevTypeNetwork,
292kBlockDeviceType = kBIOSDevTypeHardDrive
293}; //gBootFileType_t;
294
295enum
296{
297kCursorTypeHidden = 0x0100,
298kCursorTypeUnderline = 0x0607
299};
300
301#endif /* !__LIBSAIO_SAIO_TYPES_H */
302

Archive Download this file

Revision: 2238