]> git.saurik.com Git - apple/boot.git/blob - i386/libsaio/saio_types.h
boot-132.tar.gz
[apple/boot.git] / 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 #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
41 typedef char BOOL;
42 #define NO 0
43 #define YES 1
44
45 typedef unsigned long entry_t;
46
47 typedef struct {
48 unsigned int sectors:8;
49 unsigned int heads:8;
50 unsigned int cylinders:16;
51 } compact_diskinfo_t;
52
53 struct driveParameters {
54 int cylinders;
55 int sectors;
56 int heads;
57 int totalDrives;
58 };
59
60
61 /*
62 * BIOS drive information.
63 */
64 struct boot_drive_info {
65 struct drive_params {
66 unsigned short buf_size;
67 unsigned short info_flags;
68 unsigned long phys_cyls;
69 unsigned long phys_heads;
70 unsigned long phys_spt;
71 unsigned long long phys_sectors;
72 unsigned short phys_nbps;
73 unsigned short dpte_offset;
74 unsigned short dpte_segment;
75 unsigned short key;
76 unsigned char path_len;
77 unsigned char reserved1;
78 unsigned short reserved2;
79 unsigned char bus_type[4];
80 unsigned char interface_type[8];
81 unsigned char interface_path[8];
82 unsigned char dev_path[8];
83 unsigned char reserved3;
84 unsigned char checksum;
85 } params __attribute__((packed));
86 struct drive_dpte {
87 unsigned short io_port_base;
88 unsigned short control_port_base;
89 unsigned char head_flags;
90 unsigned char vendor_info;
91 unsigned char irq : 4;
92 unsigned char irq_unused : 4;
93 unsigned char block_count;
94 unsigned char dma_channel : 4;
95 unsigned char dma_type : 4;
96 unsigned char pio_type : 4;
97 unsigned char pio_unused : 4;
98 unsigned short option_flags;
99 unsigned short reserved;
100 unsigned char revision;
101 unsigned char checksum;
102 } dpte __attribute__((packed));
103 } __attribute__((packed));
104 typedef struct boot_drive_info boot_drive_info_t;
105
106 struct driveInfo {
107 boot_drive_info_t di;
108 int uses_ebios;
109 int no_emulation;
110 int biosdev;
111 int valid;
112 };
113
114 typedef struct FinderInfo {
115 unsigned char data[16];
116 } FinderInfo;
117
118 struct BootVolume;
119 typedef struct BootVolume * BVRef;
120 typedef struct BootVolume * CICell;
121
122 typedef long (*FSInit)(CICell ih);
123 typedef long (*FSLoadFile)(CICell ih, char * filePath);
124 typedef long (*FSReadFile)(CICell ih, char *filePath, void *base, unsigned long offset, unsigned long length);
125 typedef long (*FSGetFileBlock)(CICell ih, char *filePath, unsigned long long *firstBlock);
126 typedef long (*FSGetDirEntry)(CICell ih, char * dirPath, long * dirIndex,
127 char ** name, long * flags, long * time,
128 FinderInfo * finderInfo, long * infoValid);
129 typedef long (* FSGetUUID)(CICell ih, char *uuidStr);
130 typedef void (*BVGetDescription)(CICell ih, char * str, long strMaxLen);
131
132 struct iob {
133 unsigned int i_flgs; /* see F_* below */
134 unsigned int i_offset; /* seek byte offset in file */
135 int i_filesize; /* size of file */
136 char * i_buf; /* file load address */
137 };
138
139 #define F_READ 0x1 /* file opened for reading */
140 #define F_WRITE 0x2 /* file opened for writing */
141 #define F_ALLOC 0x4 /* buffer allocated */
142 #define F_FILE 0x8 /* file instead of device */
143 #define F_NBSF 0x10 /* no bad sector forwarding */
144 #define F_SSI 0x40 /* set skip sector inhibit */
145 #define F_MEM 0x80 /* memory instead of file or device */
146
147 struct dirstuff {
148 char * dir_path; /* directory path */
149 long dir_index; /* directory entry index */
150 BVRef dir_bvr; /* volume reference */
151 };
152
153 #define BVSTRLEN 32
154
155 struct BootVolume {
156 BVRef next; /* list linkage pointer */
157 int biosdev; /* BIOS device number */
158 int type; /* device type (floppy, hd, network) */
159 unsigned int flags; /* attribute flags */
160 BVGetDescription description; /* BVGetDescription function */
161 int part_no; /* partition number (1 based) */
162 unsigned int part_boff; /* partition block offset */
163 unsigned int part_type; /* partition type */
164 unsigned int fs_boff; /* 1st block # of next read */
165 unsigned int fs_byteoff; /* Byte offset for read within block */
166 FSLoadFile fs_loadfile; /* FSLoadFile function */
167 FSReadFile fs_readfile; /* FSReadFile function */
168 FSGetDirEntry fs_getdirentry; /* FSGetDirEntry function */
169 FSGetFileBlock fs_getfileblock; /* FSGetFileBlock function */
170 FSGetUUID fs_getuuid; /* FSGetUUID function */
171 unsigned int bps; /* bytes per sector for this device */
172 char name[BVSTRLEN]; /* (name of partition) */
173 char type_name[BVSTRLEN]; /* (type of partition, eg. Apple_HFS) */
174
175 };
176
177 enum {
178 kBVFlagPrimary = 0x01,
179 kBVFlagNativeBoot = 0x02,
180 kBVFlagForeignBoot = 0x04
181 };
182
183 enum {
184 kBIOSDevTypeFloppy = 0x00,
185 kBIOSDevTypeHardDrive = 0x80,
186 kBIOSDevTypeNetwork = 0xE0,
187 kBIOSDevUnitMask = 0x0F,
188 kBIOSDevTypeMask = 0xF0,
189 kBIOSDevMask = 0xFF
190 };
191
192
193 //#define BIOS_DEV_TYPE(d) ((d) & kBIOSDevTypeMask)
194 #define BIOS_DEV_UNIT(bvr) ((bvr)->biosdev - (bvr)->type)
195
196 /*
197 * KernBootStruct device types.
198 */
199 enum {
200 DEV_SD = 0,
201 DEV_HD = 1,
202 DEV_FD = 2,
203 DEV_EN = 3
204 };
205
206 #ifndef max
207 #define max(a,b) ((a) > (b) ? (a) : (b))
208 #endif
209
210 #ifndef min
211 #define min(a,b) ((a) < (b) ? (a) : (b))
212 #endif
213
214 #define MAKEKERNDEV(t, u, p) MAKEBOOTDEV(t, 0, 0, u, p)
215
216 enum {
217 kNetworkDeviceType = kBIOSDevTypeNetwork,
218 kBlockDeviceType = kBIOSDevTypeHardDrive
219 } gBootFileType_t;
220
221 enum {
222 kCursorTypeHidden = 0x0100,
223 kCursorTypeUnderline = 0x0607
224 };
225
226 #endif /* !__LIBSAIO_SAIO_TYPES_H */