Root/
Source at commit 1302 created 12 years 7 months ago. By meklort, Clean up libsaio | |
---|---|
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 <sys/param.h>␊ |
32 | #include "bios.h"␊ |
33 | #include "bootargs.h"␊ |
34 | ␊ |
35 | #if DEBUG␊ |
36 | #define DEBUG_DISK(x) printf x␊ |
37 | #else␊ |
38 | #define DEBUG_DISK(x)␊ |
39 | #endif␊ |
40 | ␊ |
41 | typedef unsigned long entry_t;␊ |
42 | ␊ |
43 | typedef struct {␊ |
44 | ␉unsigned int sectors:8;␊ |
45 | ␉unsigned int heads:8;␊ |
46 | ␉unsigned int cylinders:16;␊ |
47 | } compact_diskinfo_t;␊ |
48 | ␊ |
49 | struct driveParameters {␊ |
50 | ␉int cylinders;␊ |
51 | ␉int sectors;␊ |
52 | ␉int heads;␊ |
53 | ␉int totalDrives;␊ |
54 | };␊ |
55 | ␊ |
56 | struct Tag {␊ |
57 | ␉long␉␉type;␊ |
58 | ␉char␉ *string;␊ |
59 | ␉long␉␉offset;␊ |
60 | ␉struct Tag *tag;␊ |
61 | ␉struct Tag *tagNext;␊ |
62 | };␊ |
63 | typedef struct Tag Tag, *TagPtr;␊ |
64 | ␊ |
65 | ␊ |
66 | typedef struct FinderInfo {␊ |
67 | ␉unsigned char data[16];␊ |
68 | } FinderInfo;␊ |
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 (*FSReadFile)(CICell ih, char *filePath, void *base, uint64_t offset, uint64_t length);␊ |
77 | typedef long (*FSGetFileBlock)(CICell ih, char *filePath, unsigned long long *firstBlock);␊ |
78 | typedef long (*FSGetDirEntry)(CICell ih, char * dirPath, long long * dirIndex,␊ |
79 | ␉␉␉␉␉␉␉ char ** name, long * flags, long * time,␊ |
80 | ␉␉␉␉␉␉␉ FinderInfo * finderInfo, long * infoValid);␊ |
81 | typedef long (*FSGetUUID)(CICell ih, char *uuidStr);␊ |
82 | typedef void (*BVGetDescription)(CICell ih, char * str, long strMaxLen);␊ |
83 | // Can be just pointed to free or a special free function␊ |
84 | typedef void (*BVFree)(CICell ih);␊ |
85 | ␊ |
86 | struct iob {␊ |
87 | ␉unsigned int i_flgs;␉␉␉/* see F_* below */␊ |
88 | ␉unsigned int i_offset;␉␉/* seek byte offset in file */␊ |
89 | ␉int␉␉␉ i_filesize;␉␉/* size of file */␊ |
90 | ␉char *␉␉ i_buf;␉␉␉/* file load address */␊ |
91 | };␊ |
92 | ␊ |
93 | #define BPS␉␉ 512␉␉␉␉/* sector size of the device */␊ |
94 | #define F_READ␉ 0x1␉␉␉␉/* file opened for reading */␊ |
95 | #define F_WRITE␉ 0x2␉␉␉␉/* file opened for writing */␊ |
96 | #define F_ALLOC␉ 0x4␉␉␉␉/* buffer allocated */␊ |
97 | #define F_FILE␉ 0x8␉␉␉␉/* file instead of device */␊ |
98 | #define F_NBSF␉ 0x10␉␉␉␉/* no bad sector forwarding */␊ |
99 | #define F_SSI␉ 0x40␉␉␉␉/* set skip sector inhibit */␊ |
100 | #define F_MEM␉ 0x80␉␉␉␉/* memory instead of file or device */␊ |
101 | ␊ |
102 | struct dirstuff {␊ |
103 | ␉char *␉␉ dir_path;␉␉/* directory path */␊ |
104 | ␉long long␉ dir_index;␉␉/* directory entry index */␊ |
105 | ␉BVRef␉␉ dir_bvr;␉␉␉/* volume reference */␊ |
106 | };␊ |
107 | ␊ |
108 | #define BVSTRLEN 32␊ |
109 | ␊ |
110 | enum {␊ |
111 | ␉kBVFlagPrimary␉␉␉= 0x01,␊ |
112 | ␉kBVFlagNativeBoot␉␉= 0x02,␊ |
113 | ␉kBVFlagForeignBoot␉␉= 0x04,␊ |
114 | ␉kBVFlagBootable␉␉␉= 0x08,␊ |
115 | ␉kBVFlagEFISystem␉␉= 0x10,␊ |
116 | ␉kBVFlagBooter␉␉␉= 0x20,␊ |
117 | ␉kBVFlagSystemVolume␉␉= 0x40␊ |
118 | };␊ |
119 | ␊ |
120 | enum {␊ |
121 | ␉kBIOSDevTypeFloppy␉␉= 0x00,␊ |
122 | ␉kBIOSDevTypeHardDrive␉= 0x80,␊ |
123 | ␉kBIOSDevTypeNetwork␉␉= 0xE0,␊ |
124 | ␉kBIOSDevUnitMask␉␉= 0x0F,␊ |
125 | ␉kBIOSDevTypeMask␉␉= 0xF0,␊ |
126 | ␉kBIOSDevMask␉␉␉= 0xFF␊ |
127 | };␊ |
128 | ␊ |
129 | enum {␊ |
130 | ␉kPartitionTypeHFS␉␉= 0xAF,␊ |
131 | ␉kPartitionTypeHPFS␉␉= 0x07,␊ |
132 | ␉kPartitionTypeFAT16␉␉= 0x06,␊ |
133 | ␉kPartitionTypeFAT32␉␉= 0x0c,␊ |
134 | ␉kPartitionTypeEXT3␉␉= 0x83␊ |
135 | };␊ |
136 | ␊ |
137 | //#define BIOS_DEV_TYPE(d)␉((d) & kBIOSDevTypeMask)␊ |
138 | #define BIOS_DEV_UNIT(bvr)␉((bvr)->biosdev - (bvr)->type)␊ |
139 | ␊ |
140 | /*␊ |
141 | * KernBootStruct device types.␊ |
142 | */␊ |
143 | enum {␊ |
144 | ␉DEV_SD = 0,␊ |
145 | ␉DEV_HD = 1,␊ |
146 | ␉DEV_FD = 2,␊ |
147 | ␉DEV_EN = 3␊ |
148 | };␊ |
149 | ␊ |
150 | /*␊ |
151 | * min/max Macros.␊ |
152 | * counting and rounding Macros.␊ |
153 | *␊ |
154 | * Azi: defined on <sys/param.h>,␊ |
155 | *␉␉i386/include/IOKit/IOLib.h (min/max), and others...␊ |
156 | *␊ |
157 | #ifndef MIN␊ |
158 | #define MIN(a,b) ( ((a) < (b)) ? (a) : (b) )␊ |
159 | #endif␊ |
160 | #ifndef MAX␊ |
161 | #define MAX(a,b) ( ((a) > (b)) ? (a) : (b) )␊ |
162 | #endif␊ |
163 | ␊ |
164 | #define round2(x, m)␉(((x) + (m / 2)) & ~(m - 1))␊ |
165 | #define roundup2(x, m)␉(((x) + m - 1) & ~(m - 1))*/␊ |
166 | ␊ |
167 | enum {␊ |
168 | ␉kNetworkDeviceType = kBIOSDevTypeNetwork,␊ |
169 | ␉kBlockDeviceType = kBIOSDevTypeHardDrive␊ |
170 | }; //gBootFileType_t;␊ |
171 | ␊ |
172 | enum {␊ |
173 | ␉kCursorTypeHidden␉ = 0x0100,␊ |
174 | ␉kCursorTypeUnderline = 0x0607␊ |
175 | };␊ |
176 | ␊ |
177 | #endif /* !__LIBSAIO_SAIO_TYPES_H */␊ |
178 |