Chameleon

Chameleon Svn Source Tree

Root/branches/Chimera/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
51struct driveParameters
52{
53int cylinders;
54int sectors;
55int heads;
56int totalDrives;
57};
58
59struct Tag {
60longtype;
61char *string;
62longoffset;
63struct Tag *tag;
64struct Tag *tagNext;
65};
66typedef struct Tag Tag, *TagPtr;
67
68/*
69 * Max size fo config data array, in bytes.
70 */
71#define IO_CONFIG_DATA_SIZE40960 // was 4096 // was 163840
72
73typedef struct {
74charplist[IO_CONFIG_DATA_SIZE];// 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
128struct driveInfo
129{
130boot_drive_info_t di;
131
132int uses_ebios;
133int no_emulation;
134int biosdev;
135int valid;
136};
137
138typedef struct FinderInfo
139{
140unsigned char data[16];
141} FinderInfo;
142
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 {
161char * i_buf; /* file load address */
162unsigned int i_flgs; /* see F_* below */
163unsigned int i_offset; /* seek byte offset in file */
164int i_filesize; /* size of file */
165};
166
167#define BPS 512/* sector size of the device */
168#define F_READ 0x1/* file opened for reading */
169#define F_WRITE 0x2/* file opened for writing */
170#define F_ALLOC 0x4/* buffer allocated */
171#define F_FILE 0x8/* file instead of device */
172#define F_NBSF 0x10/* no bad sector forwarding */
173#define F_SSI 0x40/* set skip sector inhibit */
174#define F_MEM 0x80/* memory instead of file or device */
175
176struct dirstuff {
177char * dir_path;/* directory path */
178long long dir_index;/* directory entry index */
179BVRef dir_bvr;/* volume reference */
180};
181
182#define BVSTRLEN 32
183
184struct BootVolume {
185BVRefnext;/* list linkage pointer */
186intbiosdev;/* BIOS device number */
187inttype;/* device type (floppy, hd, network) */
188unsigned intflags;/* attribute flags */
189BVGetDescriptiondescription;/* BVGetDescription function */
190intpart_no;/* partition number (1 based) */
191unsigned intpart_boff;/* partition block offset */
192unsigned intpart_type;/* partition type */
193unsigned intfs_boff;/* 1st block # of next read */
194unsigned intfs_byteoff;/* Byte offset for read within block */
195FSLoadFilefs_loadfile;/* FSLoadFile function */
196FSReadFilefs_readfile;/* FSReadFile function */
197FSGetDirEntryfs_getdirentry;/* FSGetDirEntry function */
198FSGetFileBlockfs_getfileblock;/* FSGetFileBlock function */
199FSGetUUIDfs_getuuid;/* FSGetUUID function */
200unsigned intbps;/* bytes per sector for this device */
201charname[BVSTRLEN];/* (name of partition) */
202chartype_name[BVSTRLEN];/* (type of partition, eg. Apple_HFS) */
203BVFreebv_free;/* BVFree function */
204uint32_tmodTime;
205charlabel[BVSTRLEN];/* partition volume label */
206charaltlabel[BVSTRLEN];/* partition volume label */
207boolfiltered;/* newFilteredBVChain() will set to TRUE */
208boolvisible;/* will shown in the device list */
209charOSVersion[8];
210boolOSisServer;/* 1 = OS X server , 0 = OS X client */
211boolOSisInstaller;/* 1 = OS X Install partition / recover partition , 0 = OS X Install */
212
213};
214
215enum
216{
217kBVFlagPrimary= 0x01,
218kBVFlagNativeBoot= 0x02,
219kBVFlagForeignBoot= 0x04,
220kBVFlagBootable= 0x08,
221kBVFlagEFISystem= 0x10,
222kBVFlagBooter= 0x20,
223kBVFlagSystemVolume= 0x40,
224kBVFlagInstallVolume= 0x80
225};
226
227enum
228{
229kBIOSDevTypeFloppy= 0x00,
230kBIOSDevTypeHardDrive= 0x80,
231kBIOSDevTypeNetwork= 0xE0,
232kBIOSDevUnitMask= 0x0F,
233kBIOSDevTypeMask= 0xF0,
234kBIOSDevMask= 0xFF
235};
236
237enum
238{
239//KPartitionTypeFAT12= 0x01, // FAT12
240kPartitionTypeHPFS= 0x07, // Mac OS X
241kPartitionTypeFAT16= 0x06, // FAT16
242kPartitionTypeFAT32= 0x0C, // FAT32
243kPartitionTypeEXT3= 0x83, // Linux
244kPartitionTypeOSXBoot= 0xAB, // Mac OS X Boot partition
245kPartitionTypeFreeBSD= 0xA5, // FreeBSD
246kPartitionTypeOpenBSD= 0xA6, // OpenBSD
247//kPartitionTypeNeXTSTEP= 0xA7 // NeXTSTEP
248//kPartitionTypeNetBSD= 0xA9 // NetBSD
249kPartitionTypeHFS= 0xAF, // Mac OS X
250//kPartitionTypeSolaris= 0xBE, // Solaris
251kPartitionTypeBEFS= 0xEB, // BeOS BFS
252//kPartitionTypeBeOS= 0xEB, // BeOS BFS
253//kPartitionTypeSkyOS= 0xEC, // SkyOS
254};
255
256//#define BIOS_DEV_TYPE(d)((d) & kBIOSDevTypeMask)
257#define BIOS_DEV_UNIT(bvr)((bvr)->biosdev - (bvr)->type)
258
259// KernBootStruct device types.
260
261enum
262{
263DEV_SD = 0,
264DEV_HD = 1,
265DEV_FD = 2,
266DEV_EN = 3
267};
268
269/*
270 * min/max Macros.
271 * counting and rounding Macros.
272 *
273 * Azi: defined on <sys/param.h>,
274 *i386/include/IOKit/IOLib.h (min/max), and others...
275 *
276#ifndef MIN
277#define MIN(a,b) ( ((a) < (b)) ? (a) : (b) )
278#endif
279#ifndef MAX
280#define MAX(a,b) ( ((a) > (b)) ? (a) : (b) )
281#endif
282
283#define round2(x, m)(((x) + (m / 2)) & ~(m - 1))
284#define roundup2(x, m)(((x) + m - 1) & ~(m - 1))*/
285
286enum {
287kNetworkDeviceType = kBIOSDevTypeNetwork,
288kBlockDeviceType = kBIOSDevTypeHardDrive
289}; //gBootFileType_t;
290
291enum
292{
293kCursorTypeHidden = 0x0100,
294kCursorTypeUnderline = 0x0607
295};
296
297#endif /* !__LIBSAIO_SAIO_TYPES_H */
298

Archive Download this file

Revision: 2658