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#define kAcpiMethod"Acpi2Method"// 2 (= method 2) for some machines that may hang on acpi 2 (aka acpi 64 bit) detection (replace the old kUnsafeACPI "UnsafeACPI")
83
84#define PLATFORM_NAME_LEN 64
85#define ROOT_PATH_LEN 256
86
87#define DEFAULT_SCREEN_WIDTH 1024
88#define DEFAULT_SCREEN_HEIGHT 768
89
90/*
91 * Max size fo config data array, in bytes.
92 */
93#define IO_CONFIG_DATA_SIZE40960 // was 4096 // was 163840
94
95struct tm {
96inttm_sec;/* seconds after the minute [0-60] */
97inttm_min;/* minutes after the hour [0-59] */
98inttm_hour;/* hours since midnight [0-23] */
99inttm_mday;/* day of the month [1-31] */
100inttm_mon;/* months since January [0-11] */
101inttm_year;/* years since 1900 */
102inttm_wday;/* days since Sunday [0-6] */
103inttm_yday;/* days since January 1 [0-365] */
104inttm_isdst;/* Daylight Savings Time flag */
105longtm_gmtoff;/* offset from CUT in seconds */
106char*tm_zone;/* timezone abbreviation */
107};
108
109/** System time structure */
110struct timeval {
111time_t tv_sec; /**< Seconds */
112suseconds_t tv_usec; /**< Microseconds */
113};
114
115typedef struct tm_t
116{
117 int tm_sec ; /* seconds after minute [0-61] (61 allows for 2 leap-seconds)*/
118 int tm_min ; /* minutes after hour [0-59] */
119 int tm_hour ; /* hours after midnight [0-23] */
120 int tm_mday ; /* day of the month [1-31] */
121 int tm_mon ; /* month of year [0-11] */
122 int tm_year ; /* current year-1900 */
123
124}tm_t;
125
126typedef unsigned long entry_t;
127
128typedef struct {
129 unsigned int sectors:8;
130 unsigned int heads:8;
131 unsigned int cylinders:16;
132} compact_diskinfo_t;
133
134struct driveParameters {
135 int cylinders;
136 int sectors;
137 int heads;
138 int totalDrives;
139};
140
141struct Tag {
142long type;
143char *string;
144long offset;
145struct Tag *tag;
146struct Tag *tagNext;
147};
148typedef struct Tag Tag, *TagPtr;
149
150typedef struct {
151charplist[IO_CONFIG_DATA_SIZE];// buffer for plist
152TagPtrdictionary;// buffer for xml dictionary
153bool canOverride; // flag to mark a dictionary can be overriden
154} config_file_t;
155
156/*
157 * BIOS drive information.
158 */
159struct boot_drive_info {
160 struct drive_params {
161unsigned short buf_size;
162unsigned short info_flags;
163unsigned long phys_cyls;
164unsigned long phys_heads;
165unsigned long phys_spt;
166unsigned long long phys_sectors;
167unsigned short phys_nbps;
168unsigned short dpte_offset;
169unsigned short dpte_segment;
170unsigned short key;
171unsigned char path_len;
172unsigned char reserved1;
173unsigned short reserved2;
174unsigned char bus_type[4];
175unsigned char interface_type[8];
176unsigned char interface_path[8];
177unsigned char dev_path[8];
178unsigned char reserved3;
179unsigned char checksum;
180 } params __attribute__((packed));
181 struct drive_dpte {
182unsigned short io_port_base;
183unsigned short control_port_base;
184unsigned char head_flags;
185unsigned char vendor_info;
186unsigned char irq : 4;
187unsigned char irq_unused : 4;
188unsigned char block_count;
189unsigned char dma_channel : 4;
190unsigned char dma_type : 4;
191unsigned char pio_type : 4;
192unsigned char pio_unused : 4;
193unsigned short option_flags;
194unsigned short reserved;
195unsigned char revision;
196unsigned char checksum;
197 } dpte __attribute__((packed));
198} __attribute__((packed));
199typedef struct boot_drive_info boot_drive_info_t;
200
201struct driveInfo {
202 boot_drive_info_t di;
203 int uses_ebios;
204 int no_emulation;
205 int biosdev;
206 int valid;
207};
208
209typedef struct FinderInfo {
210 unsigned char data[16];
211} FinderInfo;
212
213struct BootVolume;
214typedef struct BootVolume * BVRef;
215typedef struct BootVolume * CICell;
216
217typedef long (*FSInit)(CICell ih);
218typedef long (*FSLoadFile)(CICell ih, char * filePath);
219typedef long (*FSReadFile)(CICell ih, char *filePath, void *base, uint64_t offset, uint64_t length);
220typedef long (*FSGetFileBlock)(CICell ih, char *filePath, unsigned long long *firstBlock);
221typedef long (*FSGetDirEntry)(CICell ih, char * dirPath, long long * dirIndex,
222 char ** name, long * flags, long * time,
223 FinderInfo * finderInfo, long * infoValid);
224typedef long (*FSGetUUID)(CICell ih, char *uuidStr);
225typedef void (*BVGetDescription)(CICell ih, char * str, long strMaxLen);
226// Can be just pointed to free or a special free function
227typedef void (*BVFree)(CICell ih);
228
229struct iob {
230 unsigned int i_flgs; /* see F_* below */
231 unsigned int i_offset; /* seek byte offset in file */
232 int i_filesize; /* size of file */
233 char * i_buf; /* file load address */
234};
235
236#define BPS 512 /* sector size of the device */
237#define F_READ 0x1 /* file opened for reading */
238#define F_WRITE 0x2 /* file opened for writing */
239#define F_ALLOC 0x4 /* buffer allocated */
240#define F_FILE 0x8 /* file instead of device */
241#define F_NBSF 0x10 /* no bad sector forwarding */
242#define F_SSI 0x40 /* set skip sector inhibit */
243#define F_MEM 0x80 /* memory instead of file or device */
244
245struct dirstuff {
246 char * dir_path; /* directory path */
247 long long dir_index; /* directory entry index */
248 BVRef dir_bvr; /* volume reference */
249};
250
251#define BVSTRLEN 32
252
253struct BootVolume {
254 BVRef next; /* list linkage pointer */
255 int biosdev; /* BIOS device number */
256 int type; /* device type (floppy, hd, network) */
257 unsigned int flags; /* attribute flags */
258 BVGetDescription description; /* BVGetDescription function */
259 int part_no; /* partition number (1 based) */
260 unsigned int part_boff; /* partition block offset */
261 unsigned int part_type; /* partition type */
262 unsigned int fs_boff; /* 1st block # of next read */
263 unsigned int fs_byteoff; /* Byte offset for read within block */
264 FSLoadFile fs_loadfile; /* FSLoadFile function */
265 FSReadFile fs_readfile; /* FSReadFile function */
266 FSGetDirEntry fs_getdirentry; /* FSGetDirEntry function */
267 FSGetFileBlock fs_getfileblock; /* FSGetFileBlock function */
268 FSGetUUID fs_getuuid; /* FSGetUUID function */
269 unsigned int bps; /* bytes per sector for this device */
270 char name[BVSTRLEN]; /* (name of partition) */
271 char type_name[BVSTRLEN]; /* (type of partition, eg. Apple_HFS) */
272 BVFree bv_free; /* BVFree function */
273 uint32_t modTime;
274 char label[BVSTRLEN]; /* partition volume label */
275 char altlabel[BVSTRLEN]; /* partition volume label */
276 bool filtered; /* newFilteredBVChain() will set to TRUE */
277 bool visible; /* will shown in the device list */
278 char OSVersion[8];
279 bool kernelfound; /* mach_kernel found in default location, currently only /mach_kernel is supported */
280 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 */
281};
282
283enum {
284 kBVFlagPrimary = 0x01,
285 kBVFlagNativeBoot = 0x02,
286 kBVFlagForeignBoot = 0x04,
287 kBVFlagBootable = 0x08,
288 kBVFlagEFISystem = 0x10,
289#ifdef BOOT_HELPER_SUPPORT
290 kBVFlagBooter = 0x20,
291#endif
292 kBVFlagSystemVolume = 0x40
293};
294
295enum {
296 kBIOSDevTypeFloppy = 0x00,
297 kBIOSDevTypeHardDrive = 0x80,
298 kBIOSDevTypeNetwork = 0xE0,
299 kBIOSDevUnitMask = 0x0F,
300 kBIOSDevTypeMask = 0xF0,
301 kBIOSDevMask = 0xFF
302};
303
304enum {
305
306kPartitionTypeHFS = 0xAF,
307kPartitionTypeHPFS = 0x07,
308kPartitionTypeFAT16 = 0x06,
309kPartitionTypeFAT32 = 0x0c,
310kPartitionTypeEXT3 = 0x83,
311kPartitionTypeFreeBSD = 0xa5,
312kPartitionTypeOpenBSD = 0xa6,
313kPartitionTypeBEFS = 0xEB
314};
315
316//#define BIOS_DEV_TYPE(d) ((d) & kBIOSDevTypeMask)
317#define BIOS_DEV_UNIT(bvr) ((bvr)->biosdev - (bvr)->type)
318
319#ifndef max
320#define max(a,b) ((a) > (b) ? (a) : (b))
321#endif
322
323#ifndef min
324#define min(a,b) ((a) < (b) ? (a) : (b))
325#endif
326
327#defineround2(x, m)(((x) + (m / 2)) & ~(m - 1))
328#define roundup2(x, m) (((x) + m - 1) & ~(m - 1))
329
330#define MAKEKERNDEV(t, u, p) MAKEBOOTDEV(t, 0, 0, u, p)
331
332enum {
333 kNetworkDeviceType = kBIOSDevTypeNetwork,
334 kBlockDeviceType = kBIOSDevTypeHardDrive
335};
336
337enum {
338 kCursorTypeHidden = 0x0100,
339 kCursorTypeUnderline = 0x0607
340};
341
342#endif /* !__LIBSAIO_SAIO_TYPES_H */
343

Archive Download this file

Revision: 1984