Chameleon Applications

Chameleon Applications Svn Source Tree

Root/branches/iFabio/Chameleon/i386/libsaio/saio_types.h

Source at commit 307 created 12 years 11 months ago.
By ifabio, merge changes from trunk (929). Also merge the module changes from Azimutz branche (fix compile error) Also edited the info.plist into AHCIPortInjector.kext: http://forum.voodooprojects.org/index.php/topic,1170.0.html
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 "bios.h"
32#include "nbp_cmd.h"
33#include "bootargs.h"
34
35#if DEBUG
36#define DEBUG_DISK(x) printf x
37#else
38#define DEBUG_DISK(x)
39#endif
40
41typedef unsigned long entry_t;
42
43typedef struct {
44 unsigned int sectors:8;
45 unsigned int heads:8;
46 unsigned int cylinders:16;
47} compact_diskinfo_t;
48
49struct driveParameters {
50 int cylinders;
51 int sectors;
52 int heads;
53 int totalDrives;
54};
55
56struct Tag {
57long type;
58char *string;
59long offset;
60struct Tag *tag;
61struct Tag *tagNext;
62};
63typedef struct Tag Tag, *TagPtr;
64
65typedef struct {
66charplist[4096];// buffer for plist
67TagPtrdictionary;// buffer for xml dictionary
68bool canOverride; // flag to mark a dictionary can be overriden
69} config_file_t;
70
71/*
72 * BIOS drive information.
73 */
74struct boot_drive_info {
75 struct drive_params {
76unsigned short buf_size;
77unsigned short info_flags;
78unsigned long phys_cyls;
79unsigned long phys_heads;
80unsigned long phys_spt;
81unsigned long long phys_sectors;
82unsigned short phys_nbps;
83unsigned short dpte_offset;
84unsigned short dpte_segment;
85unsigned short key;
86unsigned char path_len;
87unsigned char reserved1;
88unsigned short reserved2;
89unsigned char bus_type[4];
90unsigned char interface_type[8];
91unsigned char interface_path[8];
92unsigned char dev_path[8];
93unsigned char reserved3;
94unsigned char checksum;
95 } params;
96 struct drive_dpte {
97unsigned short io_port_base;
98unsigned short control_port_base;
99unsigned char head_flags;
100unsigned char vendor_info;
101unsigned char irq : 4;
102unsigned char irq_unused : 4;
103unsigned char block_count;
104unsigned char dma_channel : 4;
105unsigned char dma_type : 4;
106unsigned char pio_type : 4;
107unsigned char pio_unused : 4;
108unsigned short option_flags;
109unsigned short reserved;
110unsigned char revision;
111unsigned char checksum;
112 } dpte;
113} __attribute__((packed));
114typedef struct boot_drive_info boot_drive_info_t;
115
116struct driveInfo {
117 boot_drive_info_t di;
118 int uses_ebios;
119 int no_emulation;
120 int biosdev;
121 int valid;
122};
123
124typedef struct FinderInfo {
125 unsigned char data[16];
126} FinderInfo;
127
128struct BootVolume;
129typedef struct BootVolume * BVRef;
130typedef struct BootVolume * CICell;
131
132typedef long (*FSInit)(CICell ih);
133typedef long (*FSLoadFile)(CICell ih, char * filePath);
134typedef long (*FSReadFile)(CICell ih, char *filePath, void *base, uint64_t offset, uint64_t length);
135typedef long (*FSGetFileBlock)(CICell ih, char *filePath, unsigned long long *firstBlock);
136typedef long (*FSGetDirEntry)(CICell ih, char * dirPath, long long * dirIndex,
137 char ** name, long * flags, long * time,
138 FinderInfo * finderInfo, long * infoValid);
139typedef long (*FSGetUUID)(CICell ih, char *uuidStr);
140typedef void (*BVGetDescription)(CICell ih, char * str, long strMaxLen);
141// Can be just pointed to free or a special free function
142typedef void (*BVFree)(CICell ih);
143
144struct iob {
145 unsigned int i_flgs; /* see F_* below */
146 unsigned int i_offset; /* seek byte offset in file */
147 int i_filesize; /* size of file */
148 char * i_buf; /* file load address */
149};
150
151#define BPS 512 /* sector size of the device */
152#define F_READ 0x1 /* file opened for reading */
153#define F_WRITE 0x2 /* file opened for writing */
154#define F_ALLOC 0x4 /* buffer allocated */
155#define F_FILE 0x8 /* file instead of device */
156#define F_NBSF 0x10 /* no bad sector forwarding */
157#define F_SSI 0x40 /* set skip sector inhibit */
158#define F_MEM 0x80 /* memory instead of file or device */
159
160struct dirstuff {
161 char * dir_path; /* directory path */
162 long long dir_index; /* directory entry index */
163 BVRef dir_bvr; /* volume reference */
164};
165
166#define BVSTRLEN 32
167
168struct BootVolume {
169 BVRef next; /* list linkage pointer */
170 int biosdev; /* BIOS device number */
171 int type; /* device type (floppy, hd, network) */
172 unsigned int flags; /* attribute flags */
173 BVGetDescription description; /* BVGetDescription function */
174 int part_no; /* partition number (1 based) */
175 unsigned int part_boff; /* partition block offset */
176 unsigned int part_type; /* partition type */
177 unsigned int fs_boff; /* 1st block # of next read */
178 unsigned int fs_byteoff; /* Byte offset for read within block */
179 FSLoadFile fs_loadfile; /* FSLoadFile function */
180 FSReadFile fs_readfile; /* FSReadFile function */
181 FSGetDirEntry fs_getdirentry; /* FSGetDirEntry function */
182 FSGetFileBlock fs_getfileblock; /* FSGetFileBlock function */
183 FSGetUUID fs_getuuid; /* FSGetUUID function */
184 unsigned int bps; /* bytes per sector for this device */
185 char name[BVSTRLEN]; /* (name of partition) */
186 char type_name[BVSTRLEN]; /* (type of partition, eg. Apple_HFS) */
187 BVFree bv_free; /* BVFree function */
188 uint32_t modTime;
189 char label[BVSTRLEN]; /* partition volume label */
190 char altlabel[BVSTRLEN]; /* partition volume label */
191 bool filtered; /* newFilteredBVChain() will set to TRUE */
192 bool visible; /* will shown in the device list */
193};
194
195enum {
196 kBVFlagPrimary = 0x01,
197 kBVFlagNativeBoot = 0x02,
198 kBVFlagForeignBoot = 0x04,
199 kBVFlagBootable = 0x08,
200 kBVFlagEFISystem = 0x10,
201 kBVFlagBooter = 0x20,
202 kBVFlagSystemVolume = 0x40
203};
204
205enum {
206 kBIOSDevTypeFloppy = 0x00,
207 kBIOSDevTypeHardDrive = 0x80,
208 kBIOSDevTypeNetwork = 0xE0,
209 kBIOSDevUnitMask = 0x0F,
210 kBIOSDevTypeMask = 0xF0,
211 kBIOSDevMask = 0xFF
212};
213
214enum {
215
216kPartitionTypeHFS = 0xAF,
217kPartitionTypeHPFS = 0x07,
218kPartitionTypeFAT16 = 0x06,
219kPartitionTypeFAT32 = 0x0c,
220kPartitionTypeEXT3 = 0x83,
221kPartitionTypeBEFS = 0xEB,
222kPartitionTypeFreeBSD = 0xa5,
223kPartitionTypeOpenBSD = 0xa6,
224};
225
226//#define BIOS_DEV_TYPE(d) ((d) & kBIOSDevTypeMask)
227#define BIOS_DEV_UNIT(bvr) ((bvr)->biosdev - (bvr)->type)
228
229/*
230 * KernBootStruct device types.
231 */
232enum {
233 DEV_SD = 0,
234 DEV_HD = 1,
235 DEV_FD = 2,
236 DEV_EN = 3
237};
238
239#ifndef max
240#define max(a,b) ((a) > (b) ? (a) : (b))
241#endif
242
243#ifndef min
244#define min(a,b) ((a) < (b) ? (a) : (b))
245#endif
246
247#defineround2(x, m)(((x) + (m / 2)) & ~(m - 1))
248#define roundup2(x, m) (((x) + m - 1) & ~(m - 1))
249
250#define MAKEKERNDEV(t, u, p) MAKEBOOTDEV(t, 0, 0, u, p)
251
252enum {
253 kNetworkDeviceType = kBIOSDevTypeNetwork,
254 kBlockDeviceType = kBIOSDevTypeHardDrive
255}; //gBootFileType_t;
256
257enum {
258 kCursorTypeHidden = 0x0100,
259 kCursorTypeUnderline = 0x0607
260};
261
262#endif /* !__LIBSAIO_SAIO_TYPES_H */
263

Archive Download this file

Revision: 307