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
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 struct BootVolume * BVRef;
149typedef struct BootVolume * 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 32
186
187struct BootVolume {
188BVRefnext;/* list linkage pointer */
189intbiosdev;/* BIOS device number */
190inttype;/* device type (floppy, hd, network) */
191unsigned intflags;/* attribute flags */
192BVGetDescriptiondescription;/* BVGetDescription function */
193intpart_no;/* partition number (1 based) */
194unsigned intpart_boff;/* partition block offset */
195unsigned intpart_type;/* partition type */
196unsigned intfs_boff;/* 1st block # of next read */
197unsigned intfs_byteoff;/* Byte offset for read within block */
198FSLoadFilefs_loadfile;/* FSLoadFile function */
199FSReadFilefs_readfile;/* FSReadFile function */
200FSGetDirEntryfs_getdirentry;/* FSGetDirEntry function */
201FSGetFileBlockfs_getfileblock;/* FSGetFileBlock function */
202FSGetUUIDfs_getuuid;/* FSGetUUID function */
203unsigned intbps;/* bytes per sector for this device */
204charname[BVSTRLEN];/* (name of partition) */
205chartype_name[BVSTRLEN];/* (type of partition, eg. Apple_HFS) */
206BVFreebv_free;/* BVFree function */
207uint32_tmodTime;
208charlabel[BVSTRLEN];/* partition volume label */
209charaltlabel[BVSTRLEN];/* partition volume label */
210boolfiltered;/* newFilteredBVChain() will set to TRUE */
211boolvisible;/* will shown in the device list */
212charOSVersion[8];
213boolOSisServer;/* 1 = OS X server , 0 = OS X client */
214boolOSisInstaller;/* 1 = OS X Install partition / recover partition , 0 = OS X Install */
215
216};
217
218enum
219{
220kBVFlagPrimary= 0x01,
221kBVFlagNativeBoot= 0x02,
222kBVFlagForeignBoot= 0x04,
223kBVFlagBootable= 0x08,
224kBVFlagEFISystem= 0x10,
225kBVFlagBooter= 0x20,
226kBVFlagSystemVolume= 0x40,
227kBVFlagInstallVolume= 0x80
228};
229
230enum
231{
232kBIOSDevTypeFloppy= 0x00,
233kBIOSDevTypeHardDrive= 0x80,
234kBIOSDevTypeNetwork= 0xE0,
235kBIOSDevUnitMask= 0x0F,
236kBIOSDevTypeMask= 0xF0,
237kBIOSDevMask= 0xFF
238};
239
240enum
241{
242//KPartitionTypeFAT12= 0x01, // FAT12
243kPartitionTypeHPFS= 0x07, // Mac OS X
244kPartitionTypeFAT16= 0x06, // FAT16
245kPartitionTypeFAT32= 0x0C, // FAT32
246kPartitionTypeEXT3= 0x83, // Linux
247kPartitionTypeOSXBoot= 0xAB, // Mac OS X Boot partition
248kPartitionTypeFreeBSD= 0xA5, // FreeBSD
249kPartitionTypeOpenBSD= 0xA6, // OpenBSD
250//kPartitionTypeNeXTSTEP= 0xA7 // NeXTSTEP
251//kPartitionTypeNetBSD= 0xA9 // NetBSD
252kPartitionTypeHFS= 0xAF, // Mac OS X
253//kPartitionTypeSolaris= 0xBE, // Solaris
254kPartitionTypeBEFS= 0xEB, // BeOS BFS
255//kPartitionTypeBeOS= 0xEB, // BeOS BFS
256//kPartitionTypeSkyOS= 0xEC, // SkyOS
257};
258
259//#define BIOS_DEV_TYPE(d)((d) & kBIOSDevTypeMask)
260#define BIOS_DEV_UNIT(bvr)((bvr)->biosdev - (bvr)->type)
261
262// KernBootStruct device types.
263
264enum
265{
266DEV_SD = 0,
267DEV_HD = 1,
268DEV_FD = 2,
269DEV_EN = 3
270};
271
272/*
273 * min/max Macros.
274 * counting and rounding Macros.
275 *
276 * Azi: defined on <sys/param.h>,
277 *i386/include/IOKit/IOLib.h (min/max), and others...
278 *
279#ifndef MIN
280#define MIN(a,b) ( ((a) < (b)) ? (a) : (b) )
281#endif
282#ifndef MAX
283#define MAX(a,b) ( ((a) > (b)) ? (a) : (b) )
284#endif
285
286#define round2(x, m)(((x) + (m / 2)) & ~(m - 1))
287#define roundup2(x, m)(((x) + m - 1) & ~(m - 1))*/
288
289enum {
290kNetworkDeviceType = kBIOSDevTypeNetwork,
291kBlockDeviceType = kBIOSDevTypeHardDrive
292}; //gBootFileType_t;
293
294enum
295{
296kCursorTypeHidden = 0x0100,
297kCursorTypeUnderline = 0x0607
298};
299
300#endif /* !__LIBSAIO_SAIO_TYPES_H */
301

Archive Download this file

Revision: 2525