Chameleon

Chameleon Svn Source Tree

Root/branches/rewrite/i386/libsaio/saio_types.h

Source at commit 1076 created 9 years 11 days ago.
By meklort, Removed disk code + fs code from libsaio. Moved modulesystem to within /modules/ folder
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 "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 {
44unsigned int sectors:8;
45unsigned int heads:8;
46unsigned int cylinders:16;
47} compact_diskinfo_t;
48
49struct driveParameters {
50int cylinders;
51int sectors;
52int heads;
53int totalDrives;
54};
55
56struct Tag {
57longtype;
58char *string;
59longoffset;
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 {
75struct 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;
96struct 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 {
117boot_drive_info_t di;
118int uses_ebios;
119int no_emulation;
120int biosdev;
121int valid;
122};
123
124typedef struct FinderInfo {
125unsigned 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 {
145unsigned int i_flgs;/* see F_* below */
146unsigned int i_offset;/* seek byte offset in file */
147int i_filesize;/* size of file */
148char * 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 {
161char * dir_path;/* directory path */
162long long dir_index;/* directory entry index */
163BVRef dir_bvr;/* volume reference */
164};
165
166#define BVSTRLEN 32
167
168struct BootVolume {
169BVRef next; /* list linkage pointer */
170int biosdev; /* BIOS device number */
171int type; /* device type (floppy, hd, network) */
172unsigned int flags; /* attribute flags */
173BVGetDescription description; /* BVGetDescription function */
174int part_no; /* partition number (1 based) */
175unsigned int part_boff; /* partition block offset */
176unsigned int part_type; /* partition type */
177unsigned int fs_boff; /* 1st block # of next read */
178unsigned int fs_byteoff; /* Byte offset for read within block */
179FSLoadFile fs_loadfile; /* FSLoadFile function */
180FSReadFile fs_readfile; /* FSReadFile function */
181FSGetDirEntry fs_getdirentry; /* FSGetDirEntry function */
182FSGetFileBlock fs_getfileblock; /* FSGetFileBlock function */
183FSGetUUID fs_getuuid; /* FSGetUUID function */
184unsigned int bps; /* bytes per sector for this device */
185char name[BVSTRLEN]; /* (name of partition) */
186char type_name[BVSTRLEN]; /* (type of partition, eg. Apple_HFS) */
187BVFree bv_free; /* BVFree function */
188uint32_t modTime;
189char label[BVSTRLEN]; /* partition volume label */
190char altlabel[BVSTRLEN]; /* partition volume label */
191bool filtered; /* newFilteredBVChain() will set to TRUE */
192bool visible; /* will shown in the device list */
193};
194
195enum {
196kBVFlagPrimary= 0x01,
197kBVFlagNativeBoot= 0x02,
198kBVFlagForeignBoot= 0x04,
199kBVFlagBootable= 0x08,
200kBVFlagEFISystem= 0x10,
201kBVFlagBooter= 0x20,
202kBVFlagSystemVolume= 0x40
203};
204
205enum {
206kBIOSDevTypeFloppy= 0x00,
207kBIOSDevTypeHardDrive= 0x80,
208kBIOSDevTypeNetwork= 0xE0,
209kBIOSDevUnitMask= 0x0F,
210kBIOSDevTypeMask= 0xF0,
211kBIOSDevMask= 0xFF
212};
213
214enum {
215kPartitionTypeHFS= 0xAF,
216kPartitionTypeHPFS= 0x07,
217kPartitionTypeFAT16= 0x06,
218kPartitionTypeFAT32= 0x0c,
219kPartitionTypeEXT3= 0x83
220};
221
222//#define BIOS_DEV_TYPE(d)((d) & kBIOSDevTypeMask)
223#define BIOS_DEV_UNIT(bvr)((bvr)->biosdev - (bvr)->type)
224
225/*
226 * KernBootStruct device types.
227 */
228enum {
229DEV_SD = 0,
230DEV_HD = 1,
231DEV_FD = 2,
232DEV_EN = 3
233};
234
235/*
236 * min/max Macros.
237 * counting and rounding Macros.
238 *
239 * Azi: defined on <sys/param.h>,
240 *i386/include/IOKit/IOLib.h (min/max), and others...
241 *
242#ifndef MIN
243#define MIN(a,b) ( ((a) < (b)) ? (a) : (b) )
244#endif
245#ifndef MAX
246#define MAX(a,b) ( ((a) > (b)) ? (a) : (b) )
247#endif
248
249#define round2(x, m)(((x) + (m / 2)) & ~(m - 1))
250#define roundup2(x, m)(((x) + m - 1) & ~(m - 1))*/
251
252enum {
253kNetworkDeviceType = kBIOSDevTypeNetwork,
254kBlockDeviceType = kBIOSDevTypeHardDrive
255}; //gBootFileType_t;
256
257enum {
258kCursorTypeHidden = 0x0100,
259kCursorTypeUnderline = 0x0607
260};
261
262#endif /* !__LIBSAIO_SAIO_TYPES_H */
263

Archive Download this file

Revision: 1076