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 <pexpert/i386/boot.h>
38#include "bootLion.h"
39
40#if DEBUG
41#define DEBUG_DISK(x) printf x
42#else
43#define DEBUG_DISK(x)
44#endif
45
46typedef unsigned long entry_t;
47
48typedef struct {
49 unsigned int sectors:8;
50 unsigned int heads:8;
51 unsigned int cylinders:16;
52} compact_diskinfo_t;
53
54struct driveParameters {
55 int cylinders;
56 int sectors;
57 int heads;
58 int totalDrives;
59};
60
61struct Tag {
62long type;
63char *string;
64long offset;
65struct Tag *tag;
66struct Tag *tagNext;
67};
68typedef struct Tag Tag, *TagPtr;
69
70typedef struct {
71charplist[4096];// buffer for plist
72TagPtrdictionary;// buffer for xml dictionary
73bool canOverride; // flag to mark a dictionary can be overriden
74} config_file_t;
75
76/*
77 * BIOS drive information.
78 */
79struct boot_drive_info {
80 struct drive_params {
81unsigned short buf_size;
82unsigned short info_flags;
83unsigned long phys_cyls;
84unsigned long phys_heads;
85unsigned long phys_spt;
86unsigned long long phys_sectors;
87unsigned short phys_nbps;
88unsigned short dpte_offset;
89unsigned short dpte_segment;
90unsigned short key;
91unsigned char path_len;
92unsigned char reserved1;
93unsigned short reserved2;
94unsigned char bus_type[4];
95unsigned char interface_type[8];
96unsigned char interface_path[8];
97unsigned char dev_path[8];
98unsigned char reserved3;
99unsigned char checksum;
100 } params __attribute__((packed));
101 struct drive_dpte {
102unsigned short io_port_base;
103unsigned short control_port_base;
104unsigned char head_flags;
105unsigned char vendor_info;
106unsigned char irq : 4;
107unsigned char irq_unused : 4;
108unsigned char block_count;
109unsigned char dma_channel : 4;
110unsigned char dma_type : 4;
111unsigned char pio_type : 4;
112unsigned char pio_unused : 4;
113unsigned short option_flags;
114unsigned short reserved;
115unsigned char revision;
116unsigned char checksum;
117 } dpte __attribute__((packed));
118} __attribute__((packed));
119typedef struct boot_drive_info boot_drive_info_t;
120
121struct driveInfo {
122 boot_drive_info_t di;
123 int uses_ebios;
124 int no_emulation;
125 int biosdev;
126 int valid;
127};
128
129typedef struct FinderInfo {
130 unsigned char data[16];
131} FinderInfo;
132
133struct BootVolume;
134typedef struct BootVolume * BVRef;
135typedef struct BootVolume * CICell;
136
137typedef long (*FSInit)(CICell ih);
138typedef long (*FSLoadFile)(CICell ih, char * filePath);
139typedef long (*FSReadFile)(CICell ih, char *filePath, void *base, uint64_t offset, uint64_t length);
140typedef long (*FSGetFileBlock)(CICell ih, char *filePath, unsigned long long *firstBlock);
141typedef long (*FSGetDirEntry)(CICell ih, char * dirPath, long long * dirIndex,
142 char ** name, long * flags, long * time,
143 FinderInfo * finderInfo, long * infoValid);
144typedef long (*FSGetUUID)(CICell ih, char *uuidStr);
145typedef void (*BVGetDescription)(CICell ih, char * str, long strMaxLen);
146// Can be just pointed to free or a special free function
147typedef void (*BVFree)(CICell ih);
148
149struct iob {
150 unsigned int i_flgs; /* see F_* below */
151 unsigned int i_offset; /* seek byte offset in file */
152 int i_filesize; /* size of file */
153 char * i_buf; /* file load address */
154};
155
156#define BPS 512 /* sector size of the device */
157#define F_READ 0x1 /* file opened for reading */
158#define F_WRITE 0x2 /* file opened for writing */
159#define F_ALLOC 0x4 /* buffer allocated */
160#define F_FILE 0x8 /* file instead of device */
161#define F_NBSF 0x10 /* no bad sector forwarding */
162#define F_SSI 0x40 /* set skip sector inhibit */
163#define F_MEM 0x80 /* memory instead of file or device */
164
165struct dirstuff {
166 char * dir_path; /* directory path */
167 long long dir_index; /* directory entry index */
168 BVRef dir_bvr; /* volume reference */
169};
170
171#define BVSTRLEN 32
172
173struct BootVolume {
174 BVRef next; /* list linkage pointer */
175 int biosdev; /* BIOS device number */
176 int type; /* device type (floppy, hd, network) */
177 unsigned int flags; /* attribute flags */
178 BVGetDescription description; /* BVGetDescription function */
179 int part_no; /* partition number (1 based) */
180 unsigned int part_boff; /* partition block offset */
181 unsigned int part_type; /* partition type */
182 unsigned int fs_boff; /* 1st block # of next read */
183 unsigned int fs_byteoff; /* Byte offset for read within block */
184 FSLoadFile fs_loadfile; /* FSLoadFile function */
185 FSReadFile fs_readfile; /* FSReadFile function */
186 FSGetDirEntry fs_getdirentry; /* FSGetDirEntry function */
187 FSGetFileBlock fs_getfileblock; /* FSGetFileBlock function */
188 FSGetUUID fs_getuuid; /* FSGetUUID function */
189 unsigned int bps; /* bytes per sector for this device */
190 char name[BVSTRLEN]; /* (name of partition) */
191 char type_name[BVSTRLEN]; /* (type of partition, eg. Apple_HFS) */
192 BVFree bv_free; /* BVFree function */
193 uint32_t modTime;
194 char label[BVSTRLEN]; /* partition volume label */
195 char altlabel[BVSTRLEN]; /* partition volume label */
196 bool filtered; /* newFilteredBVChain() will set to TRUE */
197 bool visible; /* will shown in the device list */
198};
199
200enum {
201 kBVFlagPrimary = 0x01,
202 kBVFlagNativeBoot = 0x02,
203 kBVFlagForeignBoot = 0x04,
204 kBVFlagBootable = 0x08,
205 kBVFlagEFISystem = 0x10,
206#ifdef BOOT_HELPER_SUPPORT
207 kBVFlagBooter = 0x20,
208#endif
209 kBVFlagSystemVolume = 0x40
210};
211
212enum {
213 kBIOSDevTypeFloppy = 0x00,
214 kBIOSDevTypeHardDrive = 0x80,
215 kBIOSDevTypeNetwork = 0xE0,
216 kBIOSDevUnitMask = 0x0F,
217 kBIOSDevTypeMask = 0xF0,
218 kBIOSDevMask = 0xFF
219};
220
221enum {
222
223kPartitionTypeHFS = 0xAF,
224kPartitionTypeHPFS = 0x07,
225kPartitionTypeFAT16 = 0x06,
226kPartitionTypeFAT32 = 0x0c,
227kPartitionTypeEXT3 = 0x83,
228kPartitionTypeFreeBSD = 0xa5,
229kPartitionTypeOpenBSD = 0xa6,
230};
231
232//#define BIOS_DEV_TYPE(d) ((d) & kBIOSDevTypeMask)
233#define BIOS_DEV_UNIT(bvr) ((bvr)->biosdev - (bvr)->type)
234
235/*
236 * KernBootStruct device types.
237 */
238/*
239enum {
240 DEV_SD = 0,
241 DEV_HD = 1,
242 DEV_FD = 2,
243 DEV_EN = 3
244};
245*/
246#ifndef max
247#define max(a,b) ((a) > (b) ? (a) : (b))
248#endif
249
250#ifndef min
251#define min(a,b) ((a) < (b) ? (a) : (b))
252#endif
253
254#defineround2(x, m)(((x) + (m / 2)) & ~(m - 1))
255#define roundup2(x, m) (((x) + m - 1) & ~(m - 1))
256
257#define MAKEKERNDEV(t, u, p) MAKEBOOTDEV(t, 0, 0, u, p)
258
259enum {
260 kNetworkDeviceType = kBIOSDevTypeNetwork,
261 kBlockDeviceType = kBIOSDevTypeHardDrive
262};
263
264enum {
265 kCursorTypeHidden = 0x0100,
266 kCursorTypeUnderline = 0x0607
267};
268
269#endif /* !__LIBSAIO_SAIO_TYPES_H */
270

Archive Download this file

Revision: 789