ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/include/macos_util.h
Revision: 1.11
Committed: 2001-02-02T20:52:59Z (23 years, 10 months ago) by cebix
Content type: text/plain
Branch: MAIN
CVS Tags: snapshot-17022001, snapshot-29052001, release-0_9-1
Changes since 1.10: +1 -1 lines
Log Message:
- bumped version number to 0.9
- updated copyright dates

File Contents

# Content
1 /*
2 * macos_util.h - MacOS definitions/utility functions
3 *
4 * Basilisk II (C) 1997-2001 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 #include "cpu_emulation.h"
25
26
27 /*
28 * Queues
29 */
30
31 enum { // Queue types
32 dummyType = 0,
33 vType = 1,
34 ioQType = 2,
35 drvQType = 3,
36 evType = 4,
37 fsQType = 5,
38 sIQType = 6,
39 dtQType = 7,
40 nmType = 8
41 };
42
43 enum { // QElem struct
44 qLink = 0,
45 qType = 4,
46 qData = 6
47 };
48
49 enum { // QHdr struct
50 qFlags = 0,
51 qHead = 2,
52 qTail = 6
53 };
54
55
56 /*
57 * Definitions for Device Manager
58 */
59
60 // Error codes
61 enum {
62 noErr = 0,
63 controlErr = -17,
64 statusErr = -18,
65 readErr = -19,
66 writErr = -20,
67 badUnitErr = -21,
68 unitEmptyErr = -22,
69 openErr = -23,
70 closErr = -24,
71 abortErr = -27,
72 notOpenErr = -28,
73 dskFulErr = -34,
74 nsvErr = -35,
75 ioErr = -36,
76 bdNamErr = -37,
77 fnOpnErr = -38,
78 eofErr = -39,
79 posErr = -40,
80 tmfoErr = -42,
81 fnfErr = -43,
82 wPrErr = -44,
83 fLckdErr = -45,
84 fBsyErr = -47,
85 dupFNErr = -48,
86 paramErr = -50,
87 rfNumErr = -51,
88 permErr = -54,
89 nsDrvErr = -56,
90 extFSErr = -58,
91 noDriveErr = -64,
92 offLinErr = -65,
93 noNybErr = -66,
94 noAdrMkErr = -67,
95 dataVerErr = -68,
96 badCksmErr = -69,
97 badBtSlpErr = -70,
98 noDtaMkErr = -71,
99 badDCksum = -72,
100 badDBtSlp = -73,
101 wrUnderrun = -74,
102 cantStepErr = -75,
103 tk0BadErr = -76,
104 initIWMErr = -77,
105 twoSideErr = -78,
106 spdAdjErr = -79,
107 seekErr = -80,
108 sectNFErr = -81,
109 fmt1Err = -82,
110 fmt2Err = -83,
111 verErr = -84,
112 memFullErr = -108,
113 dirNFErr = -120
114 };
115
116 // Misc constants
117 enum {
118 goodbye = -1,
119
120 ioInProgress = 1,
121 aRdCmd = 2,
122 aWrCmd = 3,
123 asyncTrpBit = 10,
124 noQueueBit = 9,
125
126 dReadEnable = 0,
127 dWritEnable = 1,
128 dCtlEnable = 2,
129 dStatEnable = 3,
130 dNeedGoodBye = 4,
131 dNeedTime = 5,
132 dNeedLock = 6,
133
134 dOpened = 5,
135 dRAMBased = 6,
136 drvrActive = 7,
137
138 rdVerify = 64,
139
140 fsCurPerm = 0,
141 fsRdPerm = 1,
142 fsWrPerm = 2,
143 fsRdWrPerm = 3,
144 fsRdWrShPerm = 4,
145
146 fsAtMark = 0,
147 fsFromStart = 1,
148 fsFromLEOF = 2,
149 fsFromMark = 3,
150
151 sony = 0,
152 hard20 = 1
153 };
154
155 enum { // Large volume constants
156 kWidePosOffsetBit = 8,
157 kMaximumBlocksIn4GB = 0x007fffff
158 };
159
160 enum { // IOParam struct
161 ioTrap = 6,
162 ioCmdAddr = 8,
163 ioCompletion = 12,
164 ioResult = 16,
165 ioNamePtr = 18,
166 ioVRefNum = 22,
167 ioRefNum = 24,
168 ioVersNum = 26,
169 ioPermssn = 27,
170 ioMisc = 28,
171 ioBuffer = 32,
172 ioReqCount = 36,
173 ioActCount = 40,
174 ioPosMode = 44,
175 ioPosOffset = 46,
176 ioWPosOffset = 46, // Wide positioning offset when ioPosMode has kWidePosOffsetBit set
177 SIZEOF_IOParam = 50
178 };
179
180 enum { // CntrlParam struct
181 csCode = 26,
182 csParam = 28
183 };
184
185 enum { // DrvSts struct
186 dsTrack = 0,
187 dsWriteProt = 2,
188 dsDiskInPlace = 3,
189 dsInstalled = 4,
190 dsSides = 5,
191 dsQLink = 6,
192 dsQType = 10,
193 dsQDrive = 12,
194 dsQRefNum = 14,
195 dsQFSID = 16,
196 dsTwoSideFmt = 18,
197 dsNewIntf = 19,
198 dsDiskErrs = 20,
199 dsMFMDrive = 22,
200 dsMFMDisk = 23,
201 dsTwoMegFmt = 24
202 };
203
204 enum { // DrvSts2 struct
205 dsDriveSize = 18,
206 dsDriveS1 = 20,
207 dsDriveType = 22,
208 dsDriveManf = 24,
209 dsDriveChar = 26,
210 dsDriveMisc = 28,
211 SIZEOF_DrvSts = 30
212 };
213
214 enum { // DCtlEntry struct
215 dCtlDriver = 0,
216 dCtlFlags = 4,
217 dCtlQHdr = 6,
218 dCtlPosition = 16,
219 dCtlStorage = 20,
220 dCtlRefNum = 24,
221 dCtlCurTicks = 26,
222 dCtlWindow = 30,
223 dCtlDelay = 34,
224 dCtlEMask = 36,
225 dCtlMenu = 38,
226 dCtlSlot = 40,
227 dCtlSlotId = 41,
228 dCtlDevBase = 42,
229 dCtlOwner = 46,
230 dCtlExtDev = 50,
231 dCtlFillByte = 51,
232 dCtlNodeID = 52
233 };
234
235
236 /*
237 * Definitions for Deferred Task Manager
238 */
239
240 enum { // DeferredTask struct
241 dtFlags = 6,
242 dtAddr = 8,
243 dtParam = 12,
244 dtReserved = 16
245 };
246
247
248 // Definitions for DebugUtil() Selector
249 enum {
250 duDebuggerGetMax = 0,
251 duDebuggerEnter = 1,
252 duDebuggerExit = 2,
253 duDebuggerPoll = 3,
254 duGetPageState = 4,
255 duPageFaultFatal = 5,
256 duDebuggerLockMemory = 6,
257 duDebuggerUnlockMemory = 7,
258 duEnterSupervisorMode = 8
259 };
260
261 // Functions
262 extern void EnqueueMac(uint32 elem, uint32 list); // Enqueue QElem in list
263 extern int FindFreeDriveNumber(int num); // Find first free drive number, starting at "num"
264 extern void MountVolume(void *fh); // Mount volume with given file handle (see sys.h)
265 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
266 extern uint32 DebugUtil(uint32 Selector); // DebugUtil() Replacement
267
268 // Construct four-character-code
269 #define FOURCC(a,b,c,d) (((uint32)(a) << 24) | ((uint32)(b) << 16) | ((uint32)(c) << 8) | (uint32)(d))
270
271 // Emulator identification codes (4 and 2 characters)
272 const uint32 EMULATOR_ID_4 = 0x62617369; // 'basi'
273 const uint16 EMULATOR_ID_2 = 0x6261; // 'ba'
274
275 // Test if basic MacOS initializations (of the ROM) are done
276 static inline bool HasMacStarted(void)
277 {
278 return ReadMacInt32(0xcfc) == FOURCC('W','L','S','C'); // Mac warm start flag
279 }
280
281 #endif