]> git.saurik.com Git - apple/boot.git/blob - i386/libsaio/saio_types.h
237249fc3e68130c44d05eaf5f88c43893f8091b
[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 * Portions Copyright (c) 1999 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 1.1 (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 struct driveInfo {
61 boot_drive_info_t di;
62 int uses_ebios;
63 int no_emulation;
64 int biosdev;
65 int valid;
66 };
67
68
69 struct BootVolume;
70 typedef struct BootVolume * BVRef;
71 typedef struct BootVolume * CICell;
72
73 typedef long (*FSInit)(CICell ih);
74 typedef long (*FSLoadFile)(CICell ih, char * filePath);
75 typedef long (*FSGetDirEntry)(CICell ih, char * dirPath, long * dirIndex,
76 char ** name, long * flags, long * time);
77 typedef void (*BVGetDescription)(CICell ih, char * str, long strMaxLen);
78
79 struct iob {
80 unsigned int i_flgs; /* see F_* below */
81 unsigned int i_offset; /* seek byte offset in file */
82 int i_filesize; /* size of file */
83 char * i_buf; /* file load address */
84 };
85
86 #define F_READ 0x1 /* file opened for reading */
87 #define F_WRITE 0x2 /* file opened for writing */
88 #define F_ALLOC 0x4 /* buffer allocated */
89 #define F_FILE 0x8 /* file instead of device */
90 #define F_NBSF 0x10 /* no bad sector forwarding */
91 #define F_SSI 0x40 /* set skip sector inhibit */
92 #define F_MEM 0x80 /* memory instead of file or device */
93
94 struct dirstuff {
95 char * dir_path; /* directory path */
96 long dir_index; /* directory entry index */
97 BVRef dir_bvr; /* volume reference */
98 };
99
100 #define BVSTRLEN 32
101
102 struct BootVolume {
103 BVRef next; /* list linkage pointer */
104 int biosdev; /* BIOS device number */
105 int type; /* device type (floppy, hd, network) */
106 unsigned int flags; /* attribute flags */
107 BVGetDescription description; /* BVGetDescription function */
108 int part_no; /* partition number (1 based) */
109 unsigned int part_boff; /* partition block offset */
110 unsigned int part_type; /* partition type */
111 unsigned int fs_boff; /* 1st block # of next read */
112 FSLoadFile fs_loadfile; /* FSLoadFile function */
113 FSGetDirEntry fs_getdirentry; /* FSGetDirEntry function */
114 unsigned int bps; /* bytes per sector for this device */
115 char name[BVSTRLEN]; /* (name of partition) */
116 char type_name[BVSTRLEN]; /* (type of partition, eg. Apple_HFS) */
117
118 };
119
120 enum {
121 kBVFlagPrimary = 0x01,
122 kBVFlagNativeBoot = 0x02,
123 kBVFlagForeignBoot = 0x04
124 };
125
126 enum {
127 kBIOSDevTypeFloppy = 0x00,
128 kBIOSDevTypeHardDrive = 0x80,
129 kBIOSDevTypeNetwork = 0xE0,
130 kBIOSDevUnitMask = 0x0F,
131 kBIOSDevTypeMask = 0xF0,
132 kBIOSDevMask = 0xFF
133 };
134
135 //#define BIOS_DEV_TYPE(d) ((d) & kBIOSDevTypeMask)
136 #define BIOS_DEV_UNIT(bvr) ((bvr)->biosdev - (bvr)->type)
137
138 /*
139 * KernBootStruct device types.
140 */
141 enum {
142 DEV_SD = 0,
143 DEV_HD = 1,
144 DEV_FD = 2,
145 DEV_EN = 3
146 };
147
148 #ifndef max
149 #define max(a,b) ((a) > (b) ? (a) : (b))
150 #endif
151
152 #ifndef min
153 #define min(a,b) ((a) < (b) ? (a) : (b))
154 #endif
155
156 #define MAKEKERNDEV(t, u, p) MAKEBOOTDEV(t, 0, 0, u, p)
157
158 enum {
159 kNetworkDeviceType = kBIOSDevTypeNetwork,
160 kBlockDeviceType = kBIOSDevTypeHardDrive
161 } gBootFileType_t;
162
163 #endif /* !__LIBSAIO_SAIO_TYPES_H */