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;
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 */
214boolOSisServer;/* 1 = OS X server , 0 = OS X client */
215boolOSisInstaller;/* 1 = OS X Install partition / recovery partition , 0 = OS X Install */
216
217};
218
219enum
220{
221kBVFlagZero= 0x00,
222kBVFlagPrimary= 0x01,
223kBVFlagNativeBoot= 0x02,
224kBVFlagForeignBoot= 0x04,
225kBVFlagBootable= 0x08,
226kBVFlagEFISystem= 0x10,
227kBVFlagBooter= 0x20,
228kBVFlagSystemVolume= 0x40,
229kBVFlagInstallVolume= 0x80
230};
231
232enum
233{
234kBIOSDevTypeFloppy= 0x00,
235kBIOSDevTypeHardDrive= 0x80,
236kBIOSDevTypeNetwork= 0xE0,
237kBIOSDevUnitMask= 0x0F,
238kBIOSDevTypeMask= 0xF0,
239kBIOSDevMask= 0xFF
240};
241
242enum
243{
244//KPartitionTypeFAT12= 0x01, // FAT12
245kPartitionTypeHPFS= 0x07, // Mac OS X
246kPartitionTypeFAT16= 0x06, // FAT16
247kPartitionTypeFAT32= 0x0C, // FAT32
248kPartitionTypeEXT3= 0x83, // Linux
249kPartitionTypeOSXBoot= 0xAB, // Mac OS X Boot partition
250kPartitionTypeFreeBSD= 0xA5, // FreeBSD
251kPartitionTypeOpenBSD= 0xA6, // OpenBSD
252//kPartitionTypeNeXTSTEP= 0xA7 // NeXTSTEP
253//kPartitionTypeNetBSD= 0xA9 // NetBSD
254kPartitionTypeHFS= 0xAF, // Mac OS X
255//kPartitionTypeSolaris= 0xBE, // Solaris
256kPartitionTypeBEFS= 0xEB, // BeOS BFS
257//kPartitionTypeBeOS= 0xEB, // BeOS BFS
258//kPartitionTypeSkyOS= 0xEC, // SkyOS
259};
260
261//#define BIOS_DEV_TYPE(d)((d) & kBIOSDevTypeMask)
262#define BIOS_DEV_UNIT(bvr)((bvr)->biosdev - (bvr)->type)
263
264// KernBootStruct device types.
265
266enum
267{
268DEV_SD = 0,
269DEV_HD = 1,
270DEV_FD = 2,
271DEV_EN = 3
272};
273
274/*
275 * min/max Macros.
276 * counting and rounding Macros.
277 *
278 * Azi: defined on <sys/param.h>,
279 *i386/include/IOKit/IOLib.h (min/max), and others...
280 *
281#ifndef MIN
282#define MIN(a,b) ( ((a) < (b)) ? (a) : (b) )
283#endif
284#ifndef MAX
285#define MAX(a,b) ( ((a) > (b)) ? (a) : (b) )
286#endif
287
288#define round2(x, m)(((x) + (m / 2)) & ~(m - 1))
289#define roundup2(x, m)(((x) + m - 1) & ~(m - 1))*/
290
291enum {
292kNetworkDeviceType = kBIOSDevTypeNetwork,
293kBlockDeviceType = kBIOSDevTypeHardDrive
294}; //gBootFileType_t;
295
296enum
297{
298kCursorTypeHidden = 0x0100,
299kCursorTypeUnderline = 0x0607
300};
301
302#endif /* !__LIBSAIO_SAIO_TYPES_H */
303

Archive Download this file

Revision: 2759