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 * Keys used in system Boot.plist
47 */
48#define kGraphicsModeKey"Graphics Mode"
49#define kTextModeKey"Text Mode"
50#define kQuietBootKey"Quiet Boot"
51#define kKernelFlagsKey"Kernel Flags"
52#define kMKextCacheKey"MKext Cache"
53#define kKernelNameKey"Kernel"
54#define kKernelCacheKey "Kernel Cache"
55#define kUseKernelCache "UseKernelCache"
56#define kBootDeviceKey"Boot Device"
57#define kTimeoutKey"Timeout"
58#define kRootDeviceKey"rd"
59#define kBootUUIDKey"boot-uuid"
60#define kHelperRootUUIDKey"Root UUID"
61#define kPlatformKey"platform"
62#define kCDROMPromptKey"CD-ROM Prompt"
63#define kCDROMOptionKey"CD-ROM Option Key"
64#define kRescanPromptKey"Rescan Prompt"
65#define kRescanKey "Rescan"
66#define kScanSingleDriveKey"Scan Single Drive"
67#define kInsantMenuKey"Instant Menu"
68#define kDefaultKernel"mach_kernel"
69#define kWaitForKeypressKey"Wait"
70/* AsereBLN: added the other keys */
71
72#define kProductVersion"ProductVersion"/* boot.c */
73#define karch"arch"/* boot.c */
74#define kDeviceProperties"device-properties"/* device_inject.c */
75#define kHidePartition"Hide Partition"/* disk.c */
76#define kRenamePartition"Rename Partition"/* disk.c */
77#define kSMBIOSKey"SMBIOS"/* fake_efi.c */
78#define kSystemID"SystemId"/* fake_efi.c */
79#define kSystemType"SystemType"/* fake_efi.c */
80#define kPCIRootUID"PCIRootUID"/* pci_root.c */
81#define kDefaultPartition"Default Partition"/* sys.c */
82
83#define PLATFORM_NAME_LEN 64
84#define ROOT_PATH_LEN 256
85
86#define DEFAULT_SCREEN_WIDTH 1024
87#define DEFAULT_SCREEN_HEIGHT 768
88
89/*
90 * Max size fo config data array, in bytes.
91 */
92#define IO_CONFIG_DATA_SIZE40960 // was 4096 // was 163840
93
94#define rand_tab_len 100
95
96struct ran_obj {
97int tab[rand_tab_len];
98int rmin;
99int n;
100};
101
102typedef struct tm_t
103{
104 int tm_sec ; /* seconds after minute [0-61] (61 allows for 2 leap-seconds)*/
105 int tm_min ; /* minutes after hour [0-59] */
106 int tm_hour ; /* hours after midnight [0-23] */
107 int tm_mday ; /* day of the month [1-31] */
108 int tm_mon ; /* month of year [0-11] */
109 int tm_year ; /* current year-1900 */
110
111}tm_t;
112
113typedef unsigned long entry_t;
114
115typedef struct {
116 unsigned int sectors:8;
117 unsigned int heads:8;
118 unsigned int cylinders:16;
119} compact_diskinfo_t;
120
121struct driveParameters {
122 int cylinders;
123 int sectors;
124 int heads;
125 int totalDrives;
126};
127
128struct Tag {
129long type;
130char *string;
131long offset;
132struct Tag *tag;
133struct Tag *tagNext;
134};
135typedef struct Tag Tag, *TagPtr;
136
137typedef struct {
138charplist[IO_CONFIG_DATA_SIZE];// buffer for plist
139TagPtrdictionary;// buffer for xml dictionary
140bool canOverride; // flag to mark a dictionary can be overriden
141} config_file_t;
142
143/*
144 * BIOS drive information.
145 */
146struct boot_drive_info {
147 struct drive_params {
148unsigned short buf_size;
149unsigned short info_flags;
150unsigned long phys_cyls;
151unsigned long phys_heads;
152unsigned long phys_spt;
153unsigned long long phys_sectors;
154unsigned short phys_nbps;
155unsigned short dpte_offset;
156unsigned short dpte_segment;
157unsigned short key;
158unsigned char path_len;
159unsigned char reserved1;
160unsigned short reserved2;
161unsigned char bus_type[4];
162unsigned char interface_type[8];
163unsigned char interface_path[8];
164unsigned char dev_path[8];
165unsigned char reserved3;
166unsigned char checksum;
167 } params __attribute__((packed));
168 struct drive_dpte {
169unsigned short io_port_base;
170unsigned short control_port_base;
171unsigned char head_flags;
172unsigned char vendor_info;
173unsigned char irq : 4;
174unsigned char irq_unused : 4;
175unsigned char block_count;
176unsigned char dma_channel : 4;
177unsigned char dma_type : 4;
178unsigned char pio_type : 4;
179unsigned char pio_unused : 4;
180unsigned short option_flags;
181unsigned short reserved;
182unsigned char revision;
183unsigned char checksum;
184 } dpte __attribute__((packed));
185} __attribute__((packed));
186typedef struct boot_drive_info boot_drive_info_t;
187
188struct driveInfo {
189 boot_drive_info_t di;
190 int uses_ebios;
191 int no_emulation;
192 int biosdev;
193 int valid;
194};
195
196typedef struct FinderInfo {
197 unsigned char data[16];
198} FinderInfo;
199
200struct BootVolume;
201typedef struct BootVolume * BVRef;
202typedef struct BootVolume * CICell;
203
204typedef long (*FSInit)(CICell ih);
205typedef long (*FSLoadFile)(CICell ih, char * filePath);
206typedef long (*FSReadFile)(CICell ih, char *filePath, void *base, uint64_t offset, uint64_t length);
207typedef long (*FSGetFileBlock)(CICell ih, char *filePath, unsigned long long *firstBlock);
208typedef long (*FSGetDirEntry)(CICell ih, char * dirPath, long long * dirIndex,
209 char ** name, long * flags, long * time,
210 FinderInfo * finderInfo, long * infoValid);
211typedef long (*FSGetUUID)(CICell ih, char *uuidStr);
212typedef void (*BVGetDescription)(CICell ih, char * str, long strMaxLen);
213// Can be just pointed to free or a special free function
214typedef void (*BVFree)(CICell ih);
215
216struct iob {
217 unsigned int i_flgs; /* see F_* below */
218 unsigned int i_offset; /* seek byte offset in file */
219 int i_filesize; /* size of file */
220 char * i_buf; /* file load address */
221};
222
223#define BPS 512 /* sector size of the device */
224#define F_READ 0x1 /* file opened for reading */
225#define F_WRITE 0x2 /* file opened for writing */
226#define F_ALLOC 0x4 /* buffer allocated */
227#define F_FILE 0x8 /* file instead of device */
228#define F_NBSF 0x10 /* no bad sector forwarding */
229#define F_SSI 0x40 /* set skip sector inhibit */
230#define F_MEM 0x80 /* memory instead of file or device */
231
232struct dirstuff {
233 char * dir_path; /* directory path */
234 long long dir_index; /* directory entry index */
235 BVRef dir_bvr; /* volume reference */
236};
237
238#define BVSTRLEN 32
239
240struct BootVolume {
241 BVRef next; /* list linkage pointer */
242 int biosdev; /* BIOS device number */
243 int type; /* device type (floppy, hd, network) */
244 unsigned int flags; /* attribute flags */
245 BVGetDescription description; /* BVGetDescription function */
246 int part_no; /* partition number (1 based) */
247 unsigned int part_boff; /* partition block offset */
248 unsigned int part_type; /* partition type */
249 unsigned int fs_boff; /* 1st block # of next read */
250 unsigned int fs_byteoff; /* Byte offset for read within block */
251 FSLoadFile fs_loadfile; /* FSLoadFile function */
252 FSReadFile fs_readfile; /* FSReadFile function */
253 FSGetDirEntry fs_getdirentry; /* FSGetDirEntry function */
254 FSGetFileBlock fs_getfileblock; /* FSGetFileBlock function */
255 FSGetUUID fs_getuuid; /* FSGetUUID function */
256 unsigned int bps; /* bytes per sector for this device */
257 char name[BVSTRLEN]; /* (name of partition) */
258 char type_name[BVSTRLEN]; /* (type of partition, eg. Apple_HFS) */
259 BVFree bv_free; /* BVFree function */
260 uint32_t modTime;
261 char label[BVSTRLEN]; /* partition volume label */
262 char altlabel[BVSTRLEN]; /* partition volume label */
263 bool filtered; /* newFilteredBVChain() will set to TRUE */
264 bool visible; /* will shown in the device list */
265 char OSVersion[8];
266 bool kernelfound; /* mach_kernel found in default location, currently only /mach_kernel is supported */
267 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 */
268};
269
270enum {
271 kBVFlagPrimary = 0x01,
272 kBVFlagNativeBoot = 0x02,
273 kBVFlagForeignBoot = 0x04,
274 kBVFlagBootable = 0x08,
275 kBVFlagEFISystem = 0x10,
276#ifdef BOOT_HELPER_SUPPORT
277 kBVFlagBooter = 0x20,
278#endif
279 kBVFlagSystemVolume = 0x40
280};
281
282enum {
283 kBIOSDevTypeFloppy = 0x00,
284 kBIOSDevTypeHardDrive = 0x80,
285 kBIOSDevTypeNetwork = 0xE0,
286 kBIOSDevUnitMask = 0x0F,
287 kBIOSDevTypeMask = 0xF0,
288 kBIOSDevMask = 0xFF
289};
290
291enum {
292
293kPartitionTypeHFS = 0xAF,
294kPartitionTypeHPFS = 0x07,
295kPartitionTypeFAT16 = 0x06,
296kPartitionTypeFAT32 = 0x0c,
297kPartitionTypeEXT3 = 0x83,
298kPartitionTypeFreeBSD = 0xa5,
299kPartitionTypeOpenBSD = 0xa6,
300kPartitionTypeBEFS = 0xEB
301};
302
303//#define BIOS_DEV_TYPE(d) ((d) & kBIOSDevTypeMask)
304#define BIOS_DEV_UNIT(bvr) ((bvr)->biosdev - (bvr)->type)
305
306#ifndef max
307#define max(a,b) ((a) > (b) ? (a) : (b))
308#endif
309
310#ifndef min
311#define min(a,b) ((a) < (b) ? (a) : (b))
312#endif
313
314#defineround2(x, m)(((x) + (m / 2)) & ~(m - 1))
315#define roundup2(x, m) (((x) + m - 1) & ~(m - 1))
316
317#define MAKEKERNDEV(t, u, p) MAKEBOOTDEV(t, 0, 0, u, p)
318
319enum {
320 kNetworkDeviceType = kBIOSDevTypeNetwork,
321 kBlockDeviceType = kBIOSDevTypeHardDrive
322};
323
324enum {
325 kCursorTypeHidden = 0x0100,
326 kCursorTypeUnderline = 0x0607
327};
328
329#endif /* !__LIBSAIO_SAIO_TYPES_H */
330

Archive Download this file

Revision: 1840