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

Archive Download this file

Revision: HEAD