Chameleon

Chameleon Svn Source Tree

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

Archive Download this file

Revision: 1824