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

Archive Download this file

Revision: 840