1 |
/* |
2 |
* $Id$ |
3 |
* |
4 |
* macos_util_macosx.h - Work around clashes with the enums in <CarbonCore/OSUtils.h> |
5 |
* Based on: |
6 |
* |
7 |
* macos_util.h - MacOS definitions/utility functions |
8 |
* |
9 |
* Basilisk II (C) 1997-2002 Christian Bauer |
10 |
* |
11 |
* This program is free software; you can redistribute it and/or modify |
12 |
* it under the terms of the GNU General Public License as published by |
13 |
* the Free Software Foundation; either version 2 of the License, or |
14 |
* (at your option) any later version. |
15 |
* |
16 |
* This program is distributed in the hope that it will be useful, |
17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19 |
* GNU General Public License for more details. |
20 |
* |
21 |
* You should have received a copy of the GNU General Public License |
22 |
* along with this program; if not, write to the Free Software |
23 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
24 |
*/ |
25 |
|
26 |
#ifndef MACOS_UTIL_H |
27 |
#define MACOS_UTIL_H |
28 |
|
29 |
#include "cpu_emulation.h" |
30 |
|
31 |
#import <CarbonCore/OSUtils.h> |
32 |
|
33 |
/* |
34 |
* Queues |
35 |
*/ |
36 |
|
37 |
enum { // QElem struct |
38 |
qLink = 0, |
39 |
qType = 4, |
40 |
qData = 6 |
41 |
}; |
42 |
|
43 |
enum { // QHdr struct |
44 |
qFlags = 0, |
45 |
qHead = 2, |
46 |
qTail = 6 |
47 |
}; |
48 |
|
49 |
|
50 |
/* |
51 |
* Definitions for Device Manager |
52 |
*/ |
53 |
|
54 |
// Misc constants |
55 |
|
56 |
enum { // IOParam struct |
57 |
ioTrap = 6, |
58 |
ioCmdAddr = 8, |
59 |
ioCompletion = 12, |
60 |
ioResult = 16, |
61 |
ioNamePtr = 18, |
62 |
ioVRefNum = 22, |
63 |
ioRefNum = 24, |
64 |
ioVersNum = 26, |
65 |
ioPermssn = 27, |
66 |
ioMisc = 28, |
67 |
ioBuffer = 32, |
68 |
ioReqCount = 36, |
69 |
ioActCount = 40, |
70 |
ioPosMode = 44, |
71 |
ioPosOffset = 46, |
72 |
ioWPosOffset = 46, // Wide positioning offset when ioPosMode has kWidePosOffsetBit set |
73 |
SIZEOF_IOParam = 50 |
74 |
}; |
75 |
|
76 |
enum { // CntrlParam struct |
77 |
csCode = 26, |
78 |
csParam = 28 |
79 |
}; |
80 |
|
81 |
enum { // DrvSts struct |
82 |
dsTrack = 0, |
83 |
dsWriteProt = 2, |
84 |
dsDiskInPlace = 3, |
85 |
dsInstalled = 4, |
86 |
dsSides = 5, |
87 |
dsQLink = 6, |
88 |
dsQType = 10, |
89 |
dsQDrive = 12, |
90 |
dsQRefNum = 14, |
91 |
dsQFSID = 16, |
92 |
dsTwoSideFmt = 18, |
93 |
dsNewIntf = 19, |
94 |
dsDiskErrs = 20, |
95 |
dsMFMDrive = 22, |
96 |
dsMFMDisk = 23, |
97 |
dsTwoMegFmt = 24 |
98 |
}; |
99 |
|
100 |
enum { // DrvSts2 struct |
101 |
dsDriveSize = 18, |
102 |
dsDriveS1 = 20, |
103 |
dsDriveType = 22, |
104 |
dsDriveManf = 24, |
105 |
dsDriveChar = 26, |
106 |
dsDriveMisc = 28, |
107 |
SIZEOF_DrvSts = 30 |
108 |
}; |
109 |
|
110 |
enum { // DCtlEntry struct |
111 |
dCtlDriver = 0, |
112 |
dCtlFlags = 4, |
113 |
dCtlQHdr = 6, |
114 |
dCtlPosition = 16, |
115 |
dCtlStorage = 20, |
116 |
dCtlRefNum = 24, |
117 |
dCtlCurTicks = 26, |
118 |
dCtlWindow = 30, |
119 |
dCtlDelay = 34, |
120 |
dCtlEMask = 36, |
121 |
dCtlMenu = 38, |
122 |
dCtlSlot = 40, |
123 |
dCtlSlotId = 41, |
124 |
dCtlDevBase = 42, |
125 |
dCtlOwner = 46, |
126 |
dCtlExtDev = 50, |
127 |
dCtlFillByte = 51, |
128 |
dCtlNodeID = 52 |
129 |
}; |
130 |
|
131 |
|
132 |
/* |
133 |
* Definitions for Deferred Task Manager |
134 |
*/ |
135 |
|
136 |
enum { // DeferredTask struct |
137 |
dtFlags = 6, |
138 |
dtAddr = 8, |
139 |
dtParam = 12, |
140 |
dtReserved = 16 |
141 |
}; |
142 |
|
143 |
|
144 |
// Definitions for DebugUtil() Selector |
145 |
enum { |
146 |
duDebuggerGetMax = 0, |
147 |
duDebuggerEnter = 1, |
148 |
duDebuggerExit = 2, |
149 |
duDebuggerPoll = 3, |
150 |
duGetPageState = 4, |
151 |
duPageFaultFatal = 5, |
152 |
duDebuggerLockMemory = 6, |
153 |
duDebuggerUnlockMemory = 7, |
154 |
duEnterSupervisorMode = 8 |
155 |
}; |
156 |
|
157 |
// Functions |
158 |
extern void EnqueueMac(uint32 elem, uint32 list); // Enqueue QElem in list |
159 |
extern int FindFreeDriveNumber(int num); // Find first free drive number, starting at "num" |
160 |
extern void MountVolume(void *fh); // Mount volume with given file handle (see sys.h) |
161 |
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 |
162 |
extern uint32 DebugUtil(uint32 Selector); // DebugUtil() Replacement |
163 |
extern uint32 TimeToMacTime(time_t t); // Convert time_t value to MacOS time |
164 |
|
165 |
// Construct four-character-code |
166 |
#define FOURCC(a,b,c,d) (((uint32)(a) << 24) | ((uint32)(b) << 16) | ((uint32)(c) << 8) | (uint32)(d)) |
167 |
|
168 |
// Emulator identification codes (4 and 2 characters) |
169 |
const uint32 EMULATOR_ID_4 = 0x62617369; // 'basi' |
170 |
const uint16 EMULATOR_ID_2 = 0x6261; // 'ba' |
171 |
|
172 |
// Test if basic MacOS initializations (of the ROM) are done |
173 |
static inline bool HasMacStarted(void) |
174 |
{ |
175 |
return ReadMacInt32(0xcfc) == FOURCC('W','L','S','C'); // Mac warm start flag |
176 |
} |
177 |
|
178 |
#endif |