Chameleon

Chameleon Svn Source Tree

Root/branches/azimutz/Chazi/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 "bios.h"
32#include "nbp_cmd.h"
33#include "bootargs.h"
34//Azi: shouldn't this be on disk.c ??
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
68boolcanOverride;// 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//Azi: 4K drive fails everytime I try...??
152// http://forum.voodooprojects.org/index.php/topic,568.msg9763.html#msg9763
153// MSDOS_CACHE_BLOCKSIZE ??????
154#define BPS 512 /* sector size of the device */
155#define F_READ 0x1 /* file opened for reading */
156#define F_WRITE 0x2 /* file opened for writing */
157#define F_ALLOC 0x4 /* buffer allocated */
158#define F_FILE 0x8 /* file instead of device */
159#define F_NBSF 0x10 /* no bad sector forwarding */
160#define F_SSI 0x40 /* set skip sector inhibit */
161#define F_MEM 0x80 /* memory instead of file or device */
162
163struct dirstuff {
164 char * dir_path; /* directory path */
165 long long dir_index; /* directory entry index */
166 BVRef dir_bvr; /* volume reference */
167};
168
169#define BVSTRLEN 32
170
171struct BootVolume {
172 BVRef next; /* list linkage pointer */
173 int biosdev; /* BIOS device number */
174 int type; /* device type (floppy, hd, network) */
175 unsigned int flags; /* attribute flags */
176 BVGetDescription description; /* BVGetDescription function */
177 int part_no; /* partition number (1 based) */
178 unsigned int part_boff; /* partition block offset */
179 unsigned int part_type; /* partition type */
180 unsigned int fs_boff; /* 1st block # of next read */
181 unsigned int fs_byteoff; /* Byte offset for read within block */
182 FSLoadFile fs_loadfile; /* FSLoadFile function */
183 FSReadFile fs_readfile; /* FSReadFile function */
184 FSGetDirEntry fs_getdirentry; /* FSGetDirEntry function */
185 FSGetFileBlock fs_getfileblock; /* FSGetFileBlock function */
186 FSGetUUID fs_getuuid; /* FSGetUUID function */
187 unsigned int bps; /* bytes per sector for this device */
188 char name[BVSTRLEN]; /* (name of partition) */
189 char type_name[BVSTRLEN]; /* (type of partition, eg. Apple_HFS) */
190 BVFree bv_free; /* BVFree function */
191 uint32_t modTime;
192 char label[BVSTRLEN]; /* partition volume label */
193 char altlabel[BVSTRLEN]; /* partition volume label */
194 bool filtered; /* newFilteredBVChain() will set to TRUE */
195 bool visible; /* will shown in the device list */
196};
197
198enum {
199kBVFlagPrimary = 0x01,
200kBVFlagNativeBoot = 0x02,
201kBVFlagForeignBoot = 0x04,
202kBVFlagBootable = 0x08,
203kBVFlagEFISystem = 0x10,
204kBVFlagBooter = 0x20,
205kBVFlagSystemVolume = 0x40
206};
207
208enum {
209 kBIOSDevTypeFloppy = 0x00,
210 kBIOSDevTypeHardDrive = 0x80,
211 kBIOSDevTypeNetwork = 0xE0,
212 kBIOSDevUnitMask = 0x0F,
213 kBIOSDevTypeMask = 0xF0,
214 kBIOSDevMask = 0xFF
215};
216
217enum {
218kPartitionTypeHFS = 0xAF,
219kPartitionTypeHPFS = 0x07,
220kPartitionTypeFAT16 = 0x06,
221kPartitionTypeFAT32 = 0x0c,
222kPartitionTypeEXT3 = 0x83
223};
224
225//#define BIOS_DEV_TYPE(d) ((d) & kBIOSDevTypeMask)
226#define BIOS_DEV_UNIT(bvr) ((bvr)->biosdev - (bvr)->type)
227
228/*
229 * KernBootStruct device types.
230 */
231enum {
232 DEV_SD = 0,
233 DEV_HD = 1,
234 DEV_FD = 2,
235 DEV_EN = 3
236};
237
238/*
239 * Macros for min/max.
240 *
241 * Azi: defined on <sys/param.h>; includes, check later...
242 */
243#ifndef MIN
244#defineMIN(a,b) ( ((a) < (b)) ? (a) : (b) )
245#endif
246#ifndef MAX
247#defineMAX(a,b) ( ((a) > (b)) ? (a) : (b) )
248#endif
249
250//Azi: not in use
251/*#defineround2(x, m)(((x) + (m / 2)) & ~(m - 1))
252#define roundup2(x, m) (((x) + m - 1) & ~(m - 1))
253
254#define MAKEKERNDEV(t, u, p) MAKEBOOTDEV(t, 0, 0, u, p)*/
255
256enum {
257 kNetworkDeviceType = kBIOSDevTypeNetwork,
258 kBlockDeviceType = kBIOSDevTypeHardDrive
259};// gBootFileType_t; - Kpatcher; still needed???
260
261enum {
262 kCursorTypeHidden = 0x0100,
263 kCursorTypeUnderline = 0x0607
264};
265
266#endif /* !__LIBSAIO_SAIO_TYPES_H */
267

Archive Download this file

Revision: 816