| 29 |
#include "name_registry.h" |
#include "name_registry.h" |
| 30 |
#include "serial.h" |
#include "serial.h" |
| 31 |
#include "ether.h" |
#include "ether.h" |
| 32 |
|
#include "macos_util.h" |
| 33 |
|
|
| 34 |
|
|
| 35 |
/* NativeOp instruction format: |
/* NativeOp instruction format: |
| 42 |
#define POWERPC_NATIVE_OP(LR, OP) \ |
#define POWERPC_NATIVE_OP(LR, OP) \ |
| 43 |
(POWERPC_EMUL_OP | ((LR) << 11) | (((uint32)OP) << 6) | 2) |
(POWERPC_EMUL_OP | ((LR) << 11) | (((uint32)OP) << 6) | 2) |
| 44 |
|
|
| 45 |
// Return the fake PowerPC opcode to handle specified native code |
/* |
| 46 |
|
* Return the fake PowerPC opcode to handle specified native code |
| 47 |
|
*/ |
| 48 |
|
|
| 49 |
#if EMULATED_PPC |
#if EMULATED_PPC |
| 50 |
uint32 NativeOpcode(int selector) |
uint32 NativeOpcode(int selector) |
| 51 |
{ |
{ |
| 88 |
} |
} |
| 89 |
#endif |
#endif |
| 90 |
|
|
| 91 |
// NativeOp -> { TVECT, function base } mappings |
|
| 92 |
|
/* |
| 93 |
|
* Initialize the thunks system |
| 94 |
|
*/ |
| 95 |
|
|
| 96 |
struct native_op_t { |
struct native_op_t { |
| 97 |
uint32 tvect; |
uint32 tvect; |
| 98 |
uint32 func; |
uint32 func; |
| 99 |
}; |
}; |
| 100 |
static native_op_t native_op[NATIVE_OP_MAX]; |
static native_op_t native_op[NATIVE_OP_MAX]; |
| 101 |
|
|
|
// Initialize the thunks system |
|
| 102 |
bool ThunksInit(void) |
bool ThunksInit(void) |
| 103 |
{ |
{ |
| 104 |
#if EMULATED_PPC |
#if EMULATED_PPC |
| 127 |
#else |
#else |
| 128 |
#error "FIXME: define NativeOp for your platform" |
#error "FIXME: define NativeOp for your platform" |
| 129 |
#endif |
#endif |
| 130 |
|
DEFINE_NATIVE_OP(NATIVE_PATCH_NAME_REGISTRY, DoPatchNameRegistry); |
| 131 |
|
DEFINE_NATIVE_OP(NATIVE_VIDEO_INSTALL_ACCEL, VideoInstallAccel); |
| 132 |
|
DEFINE_NATIVE_OP(NATIVE_VIDEO_VBL, VideoVBL); |
| 133 |
|
DEFINE_NATIVE_OP(NATIVE_VIDEO_DO_DRIVER_IO, VideoDoDriverIO); |
| 134 |
|
DEFINE_NATIVE_OP(NATIVE_ETHER_IRQ, EtherIRQ); |
| 135 |
|
DEFINE_NATIVE_OP(NATIVE_ETHER_INIT, InitStreamModule); |
| 136 |
|
DEFINE_NATIVE_OP(NATIVE_ETHER_TERM, TerminateStreamModule); |
| 137 |
|
DEFINE_NATIVE_OP(NATIVE_ETHER_OPEN, ether_open); |
| 138 |
|
DEFINE_NATIVE_OP(NATIVE_ETHER_CLOSE, ether_close); |
| 139 |
|
DEFINE_NATIVE_OP(NATIVE_ETHER_WPUT, ether_wput); |
| 140 |
|
DEFINE_NATIVE_OP(NATIVE_ETHER_RSRV, ether_rsrv); |
| 141 |
DEFINE_NATIVE_OP(NATIVE_SERIAL_NOTHING, SerialNothing); |
DEFINE_NATIVE_OP(NATIVE_SERIAL_NOTHING, SerialNothing); |
| 142 |
DEFINE_NATIVE_OP(NATIVE_SERIAL_OPEN, SerialOpen); |
DEFINE_NATIVE_OP(NATIVE_SERIAL_OPEN, SerialOpen); |
| 143 |
DEFINE_NATIVE_OP(NATIVE_SERIAL_PRIME_IN, SerialPrimeIn); |
DEFINE_NATIVE_OP(NATIVE_SERIAL_PRIME_IN, SerialPrimeIn); |
| 151 |
return true; |
return true; |
| 152 |
} |
} |
| 153 |
|
|
| 154 |
// Return the native function descriptor (TVECT) |
|
| 155 |
|
/* |
| 156 |
|
* Return the native function descriptor (TVECT) |
| 157 |
|
*/ |
| 158 |
|
|
| 159 |
uint32 NativeTVECT(int selector) |
uint32 NativeTVECT(int selector) |
| 160 |
{ |
{ |
| 161 |
assert(selector < NATIVE_OP_MAX); |
assert(selector < NATIVE_OP_MAX); |
| 162 |
const uint32 tvect = native_op[selector].tvect; |
const uint32 tvect = native_op[selector].tvect; |
| 163 |
assert(tvect != 0); |
assert(tvect != 0); |
| 164 |
return native_op[selector].tvect; |
return tvect; |
| 165 |
} |
} |
| 166 |
|
|
| 167 |
// Return the native function address |
|
| 168 |
|
/* |
| 169 |
|
* Return the native function address |
| 170 |
|
*/ |
| 171 |
|
|
| 172 |
uint32 NativeFunction(int selector) |
uint32 NativeFunction(int selector) |
| 173 |
{ |
{ |
| 174 |
assert(selector < NATIVE_OP_MAX); |
assert(selector < NATIVE_OP_MAX); |
| 175 |
const uint32 func = native_op[selector].func; |
const uint32 func = native_op[selector].func; |
| 176 |
assert(func != 0); |
assert(func != 0); |
| 177 |
return native_op[selector].func; |
return func; |
| 178 |
|
} |
| 179 |
|
|
| 180 |
|
|
| 181 |
|
/* |
| 182 |
|
* Execute native code from EMUL_OP routine (real mode switch) |
| 183 |
|
*/ |
| 184 |
|
|
| 185 |
|
void ExecuteNative(int selector) |
| 186 |
|
{ |
| 187 |
|
SheepRoutineDescriptor desc(0, NativeTVECT(selector)); |
| 188 |
|
M68kRegisters r; |
| 189 |
|
Execute68k(desc.addr(), &r); |
| 190 |
} |
} |