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

Archive Download this file

Revision: 2057