Chameleon

Chameleon Svn Source Tree

Root/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
60typedef struct Tag
61{
62longtype;
63char*string;
64uint8_t*data;
65longdataLen;
66longoffset;
67struct Tag *tag;
68struct Tag *tagNext;
69} 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 */
86typedef struct 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[16];
107unsigned char reserved3;
108unsigned char checksum;
109} params __attribute__((packed));
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 __attribute__((packed));
129} __attribute__((packed)) boot_drive_info_t;
130
131
132struct driveInfo
133{
134boot_drive_info_t di;
135
136int uses_ebios;
137int no_emulation;
138int biosdev;
139int valid;
140};
141
142
143typedef struct FinderInfo
144{
145unsigned char data[16];
146} FinderInfo;
147
148
149structBootVolume;
150typedef structBootVolume *BVRef;
151typedef structBootVolume *CICell;
152
153typedef long (*FSInit)(CICell ih);
154typedef long (*FSLoadFile)(CICell ih, char *filePath);
155typedef long (*FSReadFile)(CICell ih, char *filePath, void *base, uint64_t offset, uint64_t length);
156typedef long (*FSGetFileBlock)(CICell ih, char *filePath, unsigned long long *firstBlock);
157typedef long (*FSGetDirEntry)(CICell ih, char * dirPath, long long *dirIndex,
158 char **name, long * flags, u_int32_t *time,
159 FinderInfo *finderInfo, long *infoValid);
160typedef long (*FSGetUUID)(CICell ih, char *uuidStr);
161typedef void (*BVGetDescription)(CICell ih, char * str, long strMaxLen);
162// Can be just pointed to free or a special free function
163typedef void (*BVFree)(CICell ih);
164
165struct iob {
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 36 // changed from 32 to 36 due to gpt partition name length
188#define OSVERSTRLEN 9
189
190struct BootVolume {
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];/* alternate partition volume label */
213boolfiltered;/* newFilteredBVChain() will set to TRUE */
214boolvisible;/* will shown in the device list */
215charOSVersion[OSVERSTRLEN]; /* Null terminated string from '/System/Library/CoreServices/SystemVersion.plist/ProductVersion' e.g. "10.10.10" - hope will not reach e.g. 111.222.333 soon:) If so, OSVERSTRLEN 9 change to 12 */
216charOSFullVer[OSVERSTRLEN]; /* Null terminated string from '/System/Library/CoreServices/SystemVersion.plist/ProductVersion' */
217charOSBuildVer[OSVERSTRLEN];/* Null terminated string from '/System/Library/CoreServices/SystemVersion.plist/ProductBuildVersion' */
218boolOSisServer;/* 1 = OS X server , 0 = OS X client */
219boolOSisInstaller;/* 1 = OS X Installer */
220boolOSisMacOSXUpgrade;/* 1 = OS X Installer Upgrade */
221boolOSisOSXUpgrade;/* 1 = OS X Installer Upgrade */
222boolOSisRecovery;/* 1 = Recovery HD partition */
223};
224
225enum
226{
227kBVFlagZero= 0x00,
228kBVFlagPrimary= 0x01,
229kBVFlagNativeBoot= 0x02,
230kBVFlagForeignBoot= 0x04,
231kBVFlagBootable= 0x08,
232kBVFlagEFISystem= 0x10,
233kBVFlagBooter= 0x20,
234kBVFlagSystemVolume= 0x40,
235kBVFlagInstallVolume= 0x80
236};
237
238enum
239{
240kBIOSDevTypeFloppy= 0x00,
241kBIOSDevTypeHardDrive= 0x80,
242kBIOSDevTypeNetwork= 0xE0,
243kBIOSDevUnitMask= 0x0F,
244kBIOSDevTypeMask= 0xF0,
245kBIOSDevMask= 0xFF
246};
247
248enum
249{
250//KPartitionTypeFAT12= 0x01, // FAT12
251kPartitionTypeHPFS= 0x07, // Mac OS X
252kPartitionTypeFAT16= 0x06, // FAT16
253kPartitionTypeFAT32= 0x0C, // FAT32
254kPartitionTypeEXT3= 0x83, // Linux
255kPartitionTypeOSXBoot= 0xAB, // Mac OS X Boot partition
256kPartitionTypeFreeBSD= 0xA5, // FreeBSD
257kPartitionTypeOpenBSD= 0xA6, // OpenBSD
258//kPartitionTypeNeXTSTEP= 0xA7 // NeXTSTEP
259//kPartitionTypeNetBSD= 0xA9 // NetBSD
260kPartitionTypeHFS= 0xAF, // Mac OS X
261//kPartitionTypeSolaris= 0xBE, // Solaris
262kPartitionTypeBEFS= 0xEB, // BeOS BFS
263//kPartitionTypeBeOS= 0xEB, // BeOS BFS
264//kPartitionTypeSkyOS= 0xEC, // SkyOS
265};
266
267//#define BIOS_DEV_TYPE(d)((d) & kBIOSDevTypeMask)
268#define BIOS_DEV_UNIT(bvr)((bvr)->biosdev - (bvr)->type)
269
270// KernBootStruct device types.
271
272enum
273{
274DEV_SD = 0,
275DEV_HD = 1,
276DEV_FD = 2,
277DEV_EN = 3
278};
279
280/*
281 * min/max Macros.
282 * counting and rounding Macros.
283 *
284 * Azi: defined on <sys/param.h>,
285 *i386/include/IOKit/IOLib.h (min/max), and others...
286 *
287#ifndef MIN
288#define MIN(a,b) ( ((a) < (b)) ? (a) : (b) )
289#endif
290#ifndef MAX
291#define MAX(a,b) ( ((a) > (b)) ? (a) : (b) )
292#endif
293
294#define round2(x, m)(((x) + (m / 2)) & ~(m - 1))
295#define roundup2(x, m)(((x) + m - 1) & ~(m - 1))*/
296
297enum {
298kNetworkDeviceType = kBIOSDevTypeNetwork,
299kBlockDeviceType = kBIOSDevTypeHardDrive
300}; //gBootFileType_t;
301
302enum
303{
304kCursorTypeHidden = 0x0100,
305kCursorTypeUnderline = 0x0607
306};
307
308#endif /* !__LIBSAIO_SAIO_TYPES_H */
309

Archive Download this file

Revision: 2887