]> git.saurik.com Git - apple/boot.git/blob - i386/libsaio/saio_types.h
e78fc1a253e8c5b6ea6edf39a013e4641b643f84
[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
34 #if 0
35 #define DEBUG_DISK(x) printf x
36 #else
37 #define DEBUG_DISK(x)
38 #endif
39
40 typedef char BOOL;
41 #define NO 0
42 #define YES 1
43
44 typedef unsigned long entry_t;
45
46 typedef struct {
47 unsigned int sectors:8;
48 unsigned int heads:8;
49 unsigned int cylinders:16;
50 } compact_diskinfo_t;
51
52 struct driveParameters {
53 int cylinders;
54 int sectors;
55 int heads;
56 int totalDrives;
57 };
58
59 struct BootVolume;
60 typedef struct BootVolume * BVRef;
61 typedef struct BootVolume * CICell;
62
63 typedef long (*FSInit)(CICell ih);
64 typedef long (*FSLoadFile)(CICell ih, char * filePath);
65 typedef long (*FSGetDirEntry)(CICell ih, char * dirPath, long * dirIndex,
66 char ** name, long * flags, long * time);
67 typedef void (*BVGetDescription)(CICell ih, char * str, long strMaxLen);
68
69 struct iob {
70 unsigned int i_flgs; /* see F_* below */
71 unsigned int i_offset; /* seek byte offset in file */
72 int i_filesize; /* size of file */
73 char * i_buf; /* file load address */
74 };
75
76 #define F_READ 0x1 /* file opened for reading */
77 #define F_WRITE 0x2 /* file opened for writing */
78 #define F_ALLOC 0x4 /* buffer allocated */
79 #define F_FILE 0x8 /* file instead of device */
80 #define F_NBSF 0x10 /* no bad sector forwarding */
81 #define F_SSI 0x40 /* set skip sector inhibit */
82 #define F_MEM 0x80 /* memory instead of file or device */
83
84 struct dirstuff {
85 char * dir_path; /* directory path */
86 long dir_index; /* directory entry index */
87 BVRef dir_bvr; /* volume reference */
88 };
89
90 struct BootVolume {
91 BVRef next; /* list linkage pointer */
92 int biosdev; /* BIOS device number */
93 unsigned int flags; /* attribute flags */
94 BVGetDescription description; /* BVGetDescription function */
95 int part_no; /* partition number (1 based) */
96 unsigned int part_boff; /* partition block offset */
97 unsigned int part_type; /* partition type */
98 unsigned int fs_boff; /* 1st block # of next read */
99 FSLoadFile fs_loadfile; /* FSLoadFile function */
100 FSGetDirEntry fs_getdirentry; /* FSGetDirEntry function */
101 };
102
103 enum {
104 kBVFlagPrimary = 0x01,
105 kBVFlagNativeBoot = 0x02,
106 kBVFlagForeignBoot = 0x04
107 };
108
109 enum {
110 kBIOSDevTypeFloppy = 0x00,
111 kBIOSDevTypeHardDrive = 0x80,
112 kBIOSDevTypeNetwork = 0xE0,
113 kBIOSDevUnitMask = 0x0F,
114 kBIOSDevTypeMask = 0xF0,
115 kBIOSDevMask = 0xFF
116 };
117
118 #define BIOS_DEV_TYPE(d) ((d) & kBIOSDevTypeMask)
119 #define BIOS_DEV_UNIT(d) ((d) & kBIOSDevUnitMask)
120
121 /*
122 * KernBootStruct device types.
123 */
124 enum {
125 DEV_SD = 0,
126 DEV_HD = 1,
127 DEV_FD = 2,
128 DEV_EN = 3
129 };
130
131 #ifndef max
132 #define max(a,b) ((a) > (b) ? (a) : (b))
133 #endif
134
135 #ifndef min
136 #define min(a,b) ((a) < (b) ? (a) : (b))
137 #endif
138
139 #define MAKEKERNDEV(t, u, p) MAKEBOOTDEV(t, 0, 0, u, p)
140
141 #endif /* !__LIBSAIO_SAIO_TYPES_H */