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

Archive Download this file

Revision: 2118