Chameleon

Chameleon Svn Source Tree

Root/branches/ErmaC/Enoch/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;
64longoffset;
65struct Tag *tag;
66struct Tag *tagNext;
67} 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 */
84typedef struct 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[16];
105unsigned char reserved3;
106unsigned char checksum;
107} params __attribute__((packed));
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 __attribute__((packed));
127} __attribute__((packed)) boot_drive_info_t;
128
129
130struct driveInfo
131{
132boot_drive_info_t di;
133
134int uses_ebios;
135int no_emulation;
136int biosdev;
137int valid;
138};
139
140
141typedef struct FinderInfo
142{
143unsigned char data[16];
144} FinderInfo;
145
146
147structBootVolume;
148typedef structBootVolume *BVRef;
149typedef structBootVolume *CICell;
150
151typedef long (*FSInit)(CICell ih);
152typedef long (*FSLoadFile)(CICell ih, char *filePath);
153typedef long (*FSReadFile)(CICell ih, char *filePath, void *base, uint64_t offset, uint64_t length);
154typedef long (*FSGetFileBlock)(CICell ih, char *filePath, unsigned long long *firstBlock);
155typedef long (*FSGetDirEntry)(CICell ih, char * dirPath, long long *dirIndex,
156 char **name, long * flags, u_int32_t *time,
157 FinderInfo *finderInfo, long *infoValid);
158typedef long (*FSGetUUID)(CICell ih, char *uuidStr);
159typedef void (*BVGetDescription)(CICell ih, char * str, long strMaxLen);
160// Can be just pointed to free or a special free function
161typedef void (*BVFree)(CICell ih);
162
163struct iob {
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 36 // changed from 32 to 36 due to gpt partition name length
186#define OSVERSTRLEN 9
187
188struct BootVolume {
189BVRefnext;/* list linkage pointer */
190intbiosdev;/* BIOS device number */
191inttype;/* device type (floppy, hd, network) */
192unsigned intflags;/* attribute flags */
193BVGetDescriptiondescription;/* BVGetDescription function */
194intpart_no;/* partition number (1 based) */
195unsigned intpart_boff;/* partition block offset */
196unsigned intpart_type;/* partition type */
197unsigned intfs_boff;/* 1st block # of next read */
198unsigned intfs_byteoff;/* Byte offset for read within block */
199FSLoadFilefs_loadfile;/* FSLoadFile function */
200FSReadFilefs_readfile;/* FSReadFile function */
201FSGetDirEntryfs_getdirentry;/* FSGetDirEntry function */
202FSGetFileBlockfs_getfileblock;/* FSGetFileBlock function */
203FSGetUUIDfs_getuuid;/* FSGetUUID function */
204unsigned intbps;/* bytes per sector for this device */
205charname[BVSTRLEN];/* (name of partition) */
206chartype_name[BVSTRLEN];/* (type of partition, eg. Apple_HFS) */
207BVFreebv_free;/* BVFree function */
208uint32_tmodTime;
209charlabel[BVSTRLEN];/* partition volume label */
210charaltlabel[BVSTRLEN];/* alternate partition volume label */
211boolfiltered;/* newFilteredBVChain() will set to TRUE */
212boolvisible;/* will shown in the device list */
213charOSVersion[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 */
214charOSFullVer[OSVERSTRLEN]; /* Null terminated string from '/System/Library/CoreServices/SystemVersion.plist/ProductVersion' */
215boolOSisServer;/* 1 = OS X server , 0 = OS X client */
216boolOSisInstaller;/* 1 = OS X Install partition / recovery partition , 0 = OS X Install */
217
218};
219
220enum
221{
222kBVFlagZero= 0x00,
223kBVFlagPrimary= 0x01,
224kBVFlagNativeBoot= 0x02,
225kBVFlagForeignBoot= 0x04,
226kBVFlagBootable= 0x08,
227kBVFlagEFISystem= 0x10,
228kBVFlagBooter= 0x20,
229kBVFlagSystemVolume= 0x40,
230kBVFlagInstallVolume= 0x80
231};
232
233enum
234{
235kBIOSDevTypeFloppy= 0x00,
236kBIOSDevTypeHardDrive= 0x80,
237kBIOSDevTypeNetwork= 0xE0,
238kBIOSDevUnitMask= 0x0F,
239kBIOSDevTypeMask= 0xF0,
240kBIOSDevMask= 0xFF
241};
242
243enum
244{
245//KPartitionTypeFAT12= 0x01, // FAT12
246kPartitionTypeHPFS= 0x07, // Mac OS X
247kPartitionTypeFAT16= 0x06, // FAT16
248kPartitionTypeFAT32= 0x0C, // FAT32
249kPartitionTypeEXT3= 0x83, // Linux
250kPartitionTypeOSXBoot= 0xAB, // Mac OS X Boot partition
251kPartitionTypeFreeBSD= 0xA5, // FreeBSD
252kPartitionTypeOpenBSD= 0xA6, // OpenBSD
253//kPartitionTypeNeXTSTEP= 0xA7 // NeXTSTEP
254//kPartitionTypeNetBSD= 0xA9 // NetBSD
255kPartitionTypeHFS= 0xAF, // Mac OS X
256//kPartitionTypeSolaris= 0xBE, // Solaris
257kPartitionTypeBEFS= 0xEB, // BeOS BFS
258//kPartitionTypeBeOS= 0xEB, // BeOS BFS
259//kPartitionTypeSkyOS= 0xEC, // SkyOS
260};
261
262//#define BIOS_DEV_TYPE(d)((d) & kBIOSDevTypeMask)
263#define BIOS_DEV_UNIT(bvr)((bvr)->biosdev - (bvr)->type)
264
265// KernBootStruct device types.
266
267enum
268{
269DEV_SD = 0,
270DEV_HD = 1,
271DEV_FD = 2,
272DEV_EN = 3
273};
274
275/*
276 * min/max Macros.
277 * counting and rounding Macros.
278 *
279 * Azi: defined on <sys/param.h>,
280 *i386/include/IOKit/IOLib.h (min/max), and others...
281 *
282#ifndef MIN
283#define MIN(a,b) ( ((a) < (b)) ? (a) : (b) )
284#endif
285#ifndef MAX
286#define MAX(a,b) ( ((a) > (b)) ? (a) : (b) )
287#endif
288
289#define round2(x, m)(((x) + (m / 2)) & ~(m - 1))
290#define roundup2(x, m)(((x) + m - 1) & ~(m - 1))*/
291
292enum {
293kNetworkDeviceType = kBIOSDevTypeNetwork,
294kBlockDeviceType = kBIOSDevTypeHardDrive
295}; //gBootFileType_t;
296
297enum
298{
299kCursorTypeHidden = 0x0100,
300kCursorTypeUnderline = 0x0607
301};
302
303#endif /* !__LIBSAIO_SAIO_TYPES_H */
304

Archive Download this file

Revision: 2759