Chameleon

Chameleon Svn Source Tree

Root/branches/meklort/i386/libsaio/saio_types.h

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

Archive Download this file

Revision: 429