]> git.saurik.com Git - apple/boot.git/blob - i386/libsaio/saio_types.h
a7e9edbd72ff3b09b55494f223b13af573106eac
[apple/boot.git] / i386 / libsaio / saio_types.h
1 /*
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25 /* Useful types. */
26
27 #ifndef __LIBSAIO_SAIO_TYPES_H
28 #define __LIBSAIO_SAIO_TYPES_H
29
30 #include <sys/reboot.h>
31 #include <sys/types.h>
32 #include "bios.h"
33 #include "nbp_cmd.h"
34 #include <pexpert/i386/boot.h>
35
36 #if DEBUG
37 #define DEBUG_DISK(x) printf x
38 #else
39 #define DEBUG_DISK(x)
40 #endif
41
42 typedef char BOOL;
43 #define NO 0
44 #define YES 1
45
46 typedef unsigned long entry_t;
47
48 typedef struct {
49 unsigned int sectors:8;
50 unsigned int heads:8;
51 unsigned int cylinders:16;
52 } compact_diskinfo_t;
53
54 struct driveParameters {
55 int cylinders;
56 int sectors;
57 int heads;
58 int totalDrives;
59 };
60
61 struct driveInfo {
62 boot_drive_info_t di;
63 int uses_ebios;
64 int no_emulation;
65 int biosdev;
66 int valid;
67 };
68
69
70 struct BootVolume;
71 typedef struct BootVolume * BVRef;
72 typedef struct BootVolume * CICell;
73
74 typedef long (*FSInit)(CICell ih);
75 typedef long (*FSLoadFile)(CICell ih, char * filePath);
76 typedef long (*FSGetDirEntry)(CICell ih, char * dirPath, long * dirIndex,
77 char ** name, long * flags, long * time);
78 typedef void (*BVGetDescription)(CICell ih, char * str, long strMaxLen);
79
80 struct iob {
81 unsigned int i_flgs; /* see F_* below */
82 unsigned int i_offset; /* seek byte offset in file */
83 int i_filesize; /* size of file */
84 char * i_buf; /* file load address */
85 };
86
87 #define F_READ 0x1 /* file opened for reading */
88 #define F_WRITE 0x2 /* file opened for writing */
89 #define F_ALLOC 0x4 /* buffer allocated */
90 #define F_FILE 0x8 /* file instead of device */
91 #define F_NBSF 0x10 /* no bad sector forwarding */
92 #define F_SSI 0x40 /* set skip sector inhibit */
93 #define F_MEM 0x80 /* memory instead of file or device */
94
95 struct dirstuff {
96 char * dir_path; /* directory path */
97 long dir_index; /* directory entry index */
98 BVRef dir_bvr; /* volume reference */
99 };
100
101 #define BVSTRLEN 32
102
103 struct BootVolume {
104 BVRef next; /* list linkage pointer */
105 int biosdev; /* BIOS device number */
106 int type; /* device type (floppy, hd, network) */
107 unsigned int flags; /* attribute flags */
108 BVGetDescription description; /* BVGetDescription function */
109 int part_no; /* partition number (1 based) */
110 unsigned int part_boff; /* partition block offset */
111 unsigned int part_type; /* partition type */
112 unsigned int fs_boff; /* 1st block # of next read */
113 FSLoadFile fs_loadfile; /* FSLoadFile function */
114 FSGetDirEntry fs_getdirentry; /* FSGetDirEntry function */
115 unsigned int bps; /* bytes per sector for this device */
116 char name[BVSTRLEN]; /* (name of partition) */
117 char type_name[BVSTRLEN]; /* (type of partition, eg. Apple_HFS) */
118
119 };
120
121 enum {
122 kBVFlagPrimary = 0x01,
123 kBVFlagNativeBoot = 0x02,
124 kBVFlagForeignBoot = 0x04
125 };
126
127 enum {
128 kBIOSDevTypeFloppy = 0x00,
129 kBIOSDevTypeHardDrive = 0x80,
130 kBIOSDevTypeNetwork = 0xE0,
131 kBIOSDevUnitMask = 0x0F,
132 kBIOSDevTypeMask = 0xF0,
133 kBIOSDevMask = 0xFF
134 };
135
136 //#define BIOS_DEV_TYPE(d) ((d) & kBIOSDevTypeMask)
137 #define BIOS_DEV_UNIT(bvr) ((bvr)->biosdev - (bvr)->type)
138
139 /*
140 * KernBootStruct device types.
141 */
142 enum {
143 DEV_SD = 0,
144 DEV_HD = 1,
145 DEV_FD = 2,
146 DEV_EN = 3
147 };
148
149 #ifndef max
150 #define max(a,b) ((a) > (b) ? (a) : (b))
151 #endif
152
153 #ifndef min
154 #define min(a,b) ((a) < (b) ? (a) : (b))
155 #endif
156
157 #define MAKEKERNDEV(t, u, p) MAKEBOOTDEV(t, 0, 0, u, p)
158
159 enum {
160 kNetworkDeviceType = kBIOSDevTypeNetwork,
161 kBlockDeviceType = kBIOSDevTypeHardDrive
162 } gBootFileType_t;
163
164 #endif /* !__LIBSAIO_SAIO_TYPES_H */