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
60struct Tag {
61longtype;
62char *string;
63longoffset;
64struct Tag *tag;
65struct Tag *tagNext;
66};
67typedef struct Tag 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 {
75charplist[IO_CONFIG_DATA_SIZE];// buffer for plist
76TagPtrdictionary;// buffer for xml dictionary
77boolcanOverride;// flag to mark a dictionary can be overriden
78} config_file_t;
79
80/*
81 * BIOS drive information.
82 */
83struct boot_drive_info
84{
85struct drive_params
86{
87unsigned short buf_size;
88unsigned short info_flags;
89unsigned long phys_cyls;
90unsigned long phys_heads;
91unsigned long phys_spt;
92unsigned long long phys_sectors;
93unsigned short phys_nbps;
94unsigned short dpte_offset;
95unsigned short dpte_segment;
96unsigned short key;
97unsigned char path_len;
98unsigned char reserved1;
99unsigned short reserved2;
100unsigned char bus_type[4];
101unsigned char interface_type[8];
102unsigned char interface_path[8];
103unsigned char dev_path[16];
104unsigned char reserved3;
105unsigned char checksum;
106} params;
107
108struct drive_dpte
109{
110unsigned short io_port_base;
111unsigned short control_port_base;
112unsigned char head_flags;
113unsigned char vendor_info;
114unsigned char irq : 4;
115unsigned char irq_unused : 4;
116unsigned char block_count;
117unsigned char dma_channel : 4;
118unsigned char dma_type : 4;
119unsigned char pio_type : 4;
120unsigned char pio_unused : 4;
121unsigned short option_flags;
122unsigned short reserved;
123unsigned char revision;
124unsigned char checksum;
125 } dpte;
126} __attribute__((packed));
127typedef struct boot_drive_info 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{
221kBVFlagPrimary= 0x01,
222kBVFlagNativeBoot= 0x02,
223kBVFlagForeignBoot= 0x04,
224kBVFlagBootable= 0x08,
225kBVFlagEFISystem= 0x10,
226kBVFlagBooter= 0x20,
227kBVFlagSystemVolume= 0x40,
228kBVFlagInstallVolume= 0x80
229};
230
231enum
232{
233kBIOSDevTypeFloppy= 0x00,
234kBIOSDevTypeHardDrive= 0x80,
235kBIOSDevTypeNetwork= 0xE0,
236kBIOSDevUnitMask= 0x0F,
237kBIOSDevTypeMask= 0xF0,
238kBIOSDevMask= 0xFF
239};
240
241enum
242{
243//KPartitionTypeFAT12= 0x01, // FAT12
244kPartitionTypeHPFS= 0x07, // Mac OS X
245kPartitionTypeFAT16= 0x06, // FAT16
246kPartitionTypeFAT32= 0x0C, // FAT32
247kPartitionTypeEXT3= 0x83, // Linux
248kPartitionTypeOSXBoot= 0xAB, // Mac OS X Boot partition
249kPartitionTypeFreeBSD= 0xA5, // FreeBSD
250kPartitionTypeOpenBSD= 0xA6, // OpenBSD
251//kPartitionTypeNeXTSTEP= 0xA7 // NeXTSTEP
252//kPartitionTypeNetBSD= 0xA9 // NetBSD
253kPartitionTypeHFS= 0xAF, // Mac OS X
254//kPartitionTypeSolaris= 0xBE, // Solaris
255kPartitionTypeBEFS= 0xEB, // BeOS BFS
256//kPartitionTypeBeOS= 0xEB, // BeOS BFS
257//kPartitionTypeSkyOS= 0xEC, // SkyOS
258};
259
260//#define BIOS_DEV_TYPE(d)((d) & kBIOSDevTypeMask)
261#define BIOS_DEV_UNIT(bvr)((bvr)->biosdev - (bvr)->type)
262
263// KernBootStruct device types.
264
265enum
266{
267DEV_SD = 0,
268DEV_HD = 1,
269DEV_FD = 2,
270DEV_EN = 3
271};
272
273/*
274 * min/max Macros.
275 * counting and rounding Macros.
276 *
277 * Azi: defined on <sys/param.h>,
278 *i386/include/IOKit/IOLib.h (min/max), and others...
279 *
280#ifndef MIN
281#define MIN(a,b) ( ((a) < (b)) ? (a) : (b) )
282#endif
283#ifndef MAX
284#define MAX(a,b) ( ((a) > (b)) ? (a) : (b) )
285#endif
286
287#define round2(x, m)(((x) + (m / 2)) & ~(m - 1))
288#define roundup2(x, m)(((x) + m - 1) & ~(m - 1))*/
289
290enum {
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: 2683