1 |
/* |
2 |
* macos_util.h - MacOS definitions/utility functions |
3 |
* |
4 |
* Basilisk II (C) 1997-1999 Christian Bauer |
5 |
* |
6 |
* This program is free software; you can redistribute it and/or modify |
7 |
* it under the terms of the GNU General Public License as published by |
8 |
* the Free Software Foundation; either version 2 of the License, or |
9 |
* (at your option) any later version. |
10 |
* |
11 |
* This program is distributed in the hope that it will be useful, |
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
* GNU General Public License for more details. |
15 |
* |
16 |
* You should have received a copy of the GNU General Public License |
17 |
* along with this program; if not, write to the Free Software |
18 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 |
*/ |
20 |
|
21 |
#ifndef MACOS_UTIL_H |
22 |
#define MACOS_UTIL_H |
23 |
|
24 |
|
25 |
/* |
26 |
* Queues |
27 |
*/ |
28 |
|
29 |
enum { // Queue types |
30 |
dummyType = 0, |
31 |
vType = 1, |
32 |
ioQType = 2, |
33 |
drvQType = 3, |
34 |
evType = 4, |
35 |
fsQType = 5, |
36 |
sIQType = 6, |
37 |
dtQType = 7, |
38 |
nmType = 8 |
39 |
}; |
40 |
|
41 |
enum { // QElem struct |
42 |
qLink = 0, |
43 |
qType = 4, |
44 |
qData = 6 |
45 |
}; |
46 |
|
47 |
enum { // QHdr struct |
48 |
qFlags = 0, |
49 |
qHead = 2, |
50 |
qTail = 6 |
51 |
}; |
52 |
|
53 |
|
54 |
/* |
55 |
* Definitions for Device Manager |
56 |
*/ |
57 |
|
58 |
// Error codes |
59 |
enum { |
60 |
noErr = 0, |
61 |
controlErr = -17, |
62 |
statusErr = -18, |
63 |
readErr = -19, |
64 |
writErr = -20, |
65 |
badUnitErr = -21, |
66 |
unitEmptyErr = -22, |
67 |
openErr = -23, |
68 |
closErr = -24, |
69 |
abortErr = -27, |
70 |
notOpenErr = -28, |
71 |
dskFulErr = -34, |
72 |
nsvErr = -35, |
73 |
ioErr = -36, |
74 |
bdNamErr = -37, |
75 |
fnOpnErr = -38, |
76 |
eofErr = -39, |
77 |
posErr = -40, |
78 |
tmfoErr = -42, |
79 |
fnfErr = -43, |
80 |
wPrErr = -44, |
81 |
fLckdErr = -45, |
82 |
fBsyErr = -47, |
83 |
dupFNErr = -48, |
84 |
paramErr = -50, |
85 |
rfNumErr = -51, |
86 |
permErr = -54, |
87 |
nsDrvErr = -56, |
88 |
extFSErr = -58, |
89 |
noDriveErr = -64, |
90 |
offLinErr = -65, |
91 |
noNybErr = -66, |
92 |
noAdrMkErr = -67, |
93 |
dataVerErr = -68, |
94 |
badCksmErr = -69, |
95 |
badBtSlpErr = -70, |
96 |
noDtaMkErr = -71, |
97 |
badDCksum = -72, |
98 |
badDBtSlp = -73, |
99 |
wrUnderrun = -74, |
100 |
cantStepErr = -75, |
101 |
tk0BadErr = -76, |
102 |
initIWMErr = -77, |
103 |
twoSideErr = -78, |
104 |
spdAdjErr = -79, |
105 |
seekErr = -80, |
106 |
sectNFErr = -81, |
107 |
fmt1Err = -82, |
108 |
fmt2Err = -83, |
109 |
verErr = -84, |
110 |
memFullErr = -108, |
111 |
dirNFErr = -120 |
112 |
}; |
113 |
|
114 |
// Misc constants |
115 |
enum { |
116 |
goodbye = -1, |
117 |
|
118 |
ioInProgress = 1, |
119 |
aRdCmd = 2, |
120 |
aWrCmd = 3, |
121 |
asyncTrpBit = 10, |
122 |
noQueueBit = 9, |
123 |
|
124 |
dReadEnable = 0, |
125 |
dWritEnable = 1, |
126 |
dCtlEnable = 2, |
127 |
dStatEnable = 3, |
128 |
dNeedGoodBye = 4, |
129 |
dNeedTime = 5, |
130 |
dNeedLock = 6, |
131 |
|
132 |
dOpened = 5, |
133 |
dRAMBased = 6, |
134 |
drvrActive = 7, |
135 |
|
136 |
rdVerify = 64, |
137 |
|
138 |
fsCurPerm = 0, |
139 |
fsRdPerm = 1, |
140 |
fsWrPerm = 2, |
141 |
fsRdWrPerm = 3, |
142 |
fsRdWrShPerm = 4, |
143 |
|
144 |
fsAtMark = 0, |
145 |
fsFromStart = 1, |
146 |
fsFromLEOF = 2, |
147 |
fsFromMark = 3, |
148 |
|
149 |
sony = 0, |
150 |
hard20 = 1 |
151 |
}; |
152 |
|
153 |
enum { // Large volume constants |
154 |
kWidePosOffsetBit = 8, |
155 |
kMaximumBlocksIn4GB = 0x007fffff |
156 |
}; |
157 |
|
158 |
enum { // IOParam struct |
159 |
ioTrap = 6, |
160 |
ioCmdAddr = 8, |
161 |
ioCompletion = 12, |
162 |
ioResult = 16, |
163 |
ioNamePtr = 18, |
164 |
ioVRefNum = 22, |
165 |
ioRefNum = 24, |
166 |
ioVersNum = 26, |
167 |
ioPermssn = 27, |
168 |
ioMisc = 28, |
169 |
ioBuffer = 32, |
170 |
ioReqCount = 36, |
171 |
ioActCount = 40, |
172 |
ioPosMode = 44, |
173 |
ioPosOffset = 46, |
174 |
ioWPosOffset = 46, // Wide positioning offset when ioPosMode has kWidePosOffsetBit set |
175 |
SIZEOF_IOParam = 50 |
176 |
}; |
177 |
|
178 |
enum { // CntrlParam struct |
179 |
csCode = 26, |
180 |
csParam = 28 |
181 |
}; |
182 |
|
183 |
enum { // DrvSts struct |
184 |
dsTrack = 0, |
185 |
dsWriteProt = 2, |
186 |
dsDiskInPlace = 3, |
187 |
dsInstalled = 4, |
188 |
dsSides = 5, |
189 |
dsQLink = 6, |
190 |
dsQType = 10, |
191 |
dsQDrive = 12, |
192 |
dsQRefNum = 14, |
193 |
dsQFSID = 16, |
194 |
dsTwoSideFmt = 18, |
195 |
dsNewIntf = 19, |
196 |
dsDiskErrs = 20, |
197 |
dsMFMDrive = 22, |
198 |
dsMFMDisk = 23, |
199 |
dsTwoMegFmt = 24 |
200 |
}; |
201 |
|
202 |
enum { // DrvSts2 struct |
203 |
dsDriveSize = 18, |
204 |
dsDriveS1 = 20, |
205 |
dsDriveType = 22, |
206 |
dsDriveManf = 24, |
207 |
dsDriveChar = 26, |
208 |
dsDriveMisc = 28, |
209 |
SIZEOF_DrvSts = 30 |
210 |
}; |
211 |
|
212 |
enum { // DCtlEntry struct |
213 |
dCtlDriver = 0, |
214 |
dCtlFlags = 4, |
215 |
dCtlQHdr = 6, |
216 |
dCtlPosition = 16, |
217 |
dCtlStorage = 20, |
218 |
dCtlRefNum = 24, |
219 |
dCtlCurTicks = 26, |
220 |
dCtlWindow = 30, |
221 |
dCtlDelay = 34, |
222 |
dCtlEMask = 36, |
223 |
dCtlMenu = 38, |
224 |
dCtlSlot = 40, |
225 |
dCtlSlotId = 41, |
226 |
dCtlDevBase = 42, |
227 |
dCtlOwner = 46, |
228 |
dCtlExtDev = 50, |
229 |
dCtlFillByte = 51, |
230 |
dCtlNodeID = 52 |
231 |
}; |
232 |
|
233 |
|
234 |
/* |
235 |
* Definitions for Deferred Task Manager |
236 |
*/ |
237 |
|
238 |
enum { // DeferredTask struct |
239 |
dtFlags = 6, |
240 |
dtAddr = 8, |
241 |
dtParam = 12, |
242 |
dtReserved = 16 |
243 |
}; |
244 |
|
245 |
|
246 |
// Functions |
247 |
extern void EnqueueMac(uint32 elem, uint32 list); // Enqueue QElem in list |
248 |
extern int FindFreeDriveNumber(int num); // Find first free drive number, starting at "num" |
249 |
extern void MountVolume(void *fh); // Mount volume with given file handle (see sys.h) |
250 |
extern bool HasMacStarted(void); // Test if basic MacOS initializations are done |
251 |
extern void FileDiskLayout(loff_t size, uint8 *data, loff_t &start_byte, loff_t &real_size); // Calculate disk image file layout given file size and first 256 data bytes |
252 |
|
253 |
#endif |