89 |
|
|
90 |
|
// From rsrc_patches.cpp |
91 |
|
extern "C" void check_load_invoc(uint32 type, int16 id, uint32 h); |
92 |
+ |
extern "C" void named_check_load_invoc(uint32 type, uint32 name, uint32 h); |
93 |
|
|
94 |
|
// PowerPC EmulOp to exit from emulation looop |
95 |
|
const uint32 POWERPC_EXEC_RETURN = POWERPC_EMUL_OP | 1; |
178 |
|
|
179 |
|
// Make sure the SIGSEGV handler can access CPU registers |
180 |
|
friend sigsegv_return_t sigsegv_handler(sigsegv_address_t, sigsegv_address_t); |
180 |
– |
|
181 |
– |
// Memory allocator returning areas aligned on 16-byte boundaries |
182 |
– |
void *operator new(size_t size); |
183 |
– |
void operator delete(void *p); |
181 |
|
}; |
182 |
|
|
186 |
– |
// Memory allocator returning areas aligned on 16-byte boundaries |
187 |
– |
void *sheepshaver_cpu::operator new(size_t size) |
188 |
– |
{ |
189 |
– |
void *p; |
190 |
– |
|
191 |
– |
#if defined(HAVE_POSIX_MEMALIGN) |
192 |
– |
if (posix_memalign(&p, 16, size) != 0) |
193 |
– |
throw std::bad_alloc(); |
194 |
– |
#elif defined(HAVE_MEMALIGN) |
195 |
– |
p = memalign(16, size); |
196 |
– |
#elif defined(HAVE_VALLOC) |
197 |
– |
p = valloc(size); // page-aligned! |
198 |
– |
#else |
199 |
– |
/* XXX: handle padding ourselves */ |
200 |
– |
p = malloc(size); |
201 |
– |
#endif |
202 |
– |
|
203 |
– |
return p; |
204 |
– |
} |
205 |
– |
|
206 |
– |
void sheepshaver_cpu::operator delete(void *p) |
207 |
– |
{ |
208 |
– |
#if defined(HAVE_MEMALIGN) || defined(HAVE_VALLOC) |
209 |
– |
#if defined(__GLIBC__) |
210 |
– |
// this is known to work only with GNU libc |
211 |
– |
free(p); |
212 |
– |
#endif |
213 |
– |
#else |
214 |
– |
free(p); |
215 |
– |
#endif |
216 |
– |
} |
217 |
– |
|
183 |
|
sheepshaver_cpu::sheepshaver_cpu() |
184 |
|
: powerpc_cpu(enable_jit_p()) |
185 |
|
{ |
228 |
|
for (int i = 0; i < 7; i++) |
229 |
|
r68.a[i] = gpr(16 + i); |
230 |
|
r68.a[7] = gpr(1); |
231 |
< |
uint32 saved_cr = get_cr() & CR_field<2>::mask(); |
231 |
> |
uint32 saved_cr = get_cr() & 0xff9fffff; // mask_operand::compute(11, 8) |
232 |
|
uint32 saved_xer = get_xer(); |
233 |
|
EmulOp(&r68, gpr(24), emul_op); |
234 |
|
set_cr(saved_cr); |
344 |
|
dg.gen_invoke_T0_T1_T2((void (*)(uint32, uint32, uint32))check_load_invoc); |
345 |
|
status = COMPILE_CODE_OK; |
346 |
|
break; |
347 |
+ |
case NATIVE_NAMED_CHECK_LOAD_INVOC: |
348 |
+ |
dg.gen_load_T0_GPR(3); |
349 |
+ |
dg.gen_load_T1_GPR(4); |
350 |
+ |
dg.gen_load_T2_GPR(5); |
351 |
+ |
dg.gen_invoke_T0_T1_T2((void (*)(uint32, uint32, uint32))named_check_load_invoc); |
352 |
+ |
status = COMPILE_CODE_OK; |
353 |
+ |
break; |
354 |
|
#endif |
355 |
|
case NATIVE_BITBLT: |
356 |
|
dg.gen_load_T0_GPR(3); |
768 |
|
#error "FIXME: You don't have the capability to skip instruction within signal handlers" |
769 |
|
#endif |
770 |
|
|
771 |
< |
printf("SIGSEGV\n"); |
772 |
< |
printf(" pc %p\n", fault_instruction); |
773 |
< |
printf(" ea %p\n", fault_address); |
771 |
> |
fprintf(stderr, "SIGSEGV\n"); |
772 |
> |
fprintf(stderr, " pc %p\n", fault_instruction); |
773 |
> |
fprintf(stderr, " ea %p\n", fault_address); |
774 |
|
dump_registers(); |
775 |
|
ppc_cpu->dump_log(); |
776 |
|
enter_mon(); |
834 |
|
#endif |
835 |
|
|
836 |
|
delete ppc_cpu; |
837 |
+ |
ppc_cpu = NULL; |
838 |
|
} |
839 |
|
|
840 |
|
#if PPC_ENABLE_JIT && PPC_REENTRANT_JIT |
882 |
|
|
883 |
|
void TriggerInterrupt(void) |
884 |
|
{ |
885 |
+ |
idle_resume(); |
886 |
|
#if 0 |
887 |
|
WriteMacInt32(0x16a, ReadMacInt32(0x16a) + 1); |
888 |
|
#else |
903 |
|
if (int32(ReadMacInt32(XLM_IRQ_NEST)) > 0) |
904 |
|
return; |
905 |
|
|
906 |
< |
// Increment interrupt counter |
906 |
> |
// Update interrupt count |
907 |
|
#if EMUL_TIME_STATS |
908 |
|
interrupt_count++; |
909 |
|
#endif |
979 |
|
} |
980 |
|
} |
981 |
|
|
1008 |
– |
static void get_resource(void); |
1009 |
– |
static void get_1_resource(void); |
1010 |
– |
static void get_ind_resource(void); |
1011 |
– |
static void get_1_ind_resource(void); |
1012 |
– |
static void r_get_resource(void); |
1013 |
– |
|
982 |
|
// Execute NATIVE_OP routine |
983 |
|
void sheepshaver_cpu::execute_native_op(uint32 selector) |
984 |
|
{ |
1000 |
|
case NATIVE_VIDEO_DO_DRIVER_IO: |
1001 |
|
gpr(3) = (int32)(int16)VideoDoDriverIO(gpr(3), gpr(4), gpr(5), gpr(6), gpr(7)); |
1002 |
|
break; |
1003 |
+ |
case NATIVE_ETHER_AO_GET_HWADDR: |
1004 |
+ |
AO_get_ethernet_address(gpr(3)); |
1005 |
+ |
break; |
1006 |
+ |
case NATIVE_ETHER_AO_ADD_MULTI: |
1007 |
+ |
AO_enable_multicast(gpr(3)); |
1008 |
+ |
break; |
1009 |
+ |
case NATIVE_ETHER_AO_DEL_MULTI: |
1010 |
+ |
AO_disable_multicast(gpr(3)); |
1011 |
+ |
break; |
1012 |
+ |
case NATIVE_ETHER_AO_SEND_PACKET: |
1013 |
+ |
AO_transmit_packet(gpr(3)); |
1014 |
+ |
break; |
1015 |
|
case NATIVE_ETHER_IRQ: |
1016 |
|
EtherIRQ(); |
1017 |
|
break; |
1072 |
|
break; |
1073 |
|
} |
1074 |
|
case NATIVE_GET_RESOURCE: |
1075 |
+ |
get_resource(ReadMacInt32(XLM_GET_RESOURCE)); |
1076 |
+ |
break; |
1077 |
|
case NATIVE_GET_1_RESOURCE: |
1078 |
+ |
get_resource(ReadMacInt32(XLM_GET_1_RESOURCE)); |
1079 |
+ |
break; |
1080 |
|
case NATIVE_GET_IND_RESOURCE: |
1081 |
+ |
get_resource(ReadMacInt32(XLM_GET_IND_RESOURCE)); |
1082 |
+ |
break; |
1083 |
|
case NATIVE_GET_1_IND_RESOURCE: |
1084 |
< |
case NATIVE_R_GET_RESOURCE: { |
1085 |
< |
typedef void (*GetResourceCallback)(void); |
1086 |
< |
static const GetResourceCallback get_resource_callbacks[] = { |
1087 |
< |
::get_resource, |
1102 |
< |
::get_1_resource, |
1103 |
< |
::get_ind_resource, |
1104 |
< |
::get_1_ind_resource, |
1105 |
< |
::r_get_resource |
1106 |
< |
}; |
1107 |
< |
get_resource_callbacks[selector - NATIVE_GET_RESOURCE](); |
1084 |
> |
get_resource(ReadMacInt32(XLM_GET_1_IND_RESOURCE)); |
1085 |
> |
break; |
1086 |
> |
case NATIVE_R_GET_RESOURCE: |
1087 |
> |
get_resource(ReadMacInt32(XLM_R_GET_RESOURCE)); |
1088 |
|
break; |
1109 |
– |
} |
1089 |
|
case NATIVE_MAKE_EXECUTABLE: |
1090 |
|
MakeExecutable(0, gpr(4), gpr(5)); |
1091 |
|
break; |
1092 |
|
case NATIVE_CHECK_LOAD_INVOC: |
1093 |
|
check_load_invoc(gpr(3), gpr(4), gpr(5)); |
1094 |
|
break; |
1095 |
+ |
case NATIVE_NAMED_CHECK_LOAD_INVOC: |
1096 |
+ |
named_check_load_invoc(gpr(3), gpr(4), gpr(5)); |
1097 |
+ |
break; |
1098 |
|
default: |
1099 |
|
printf("FATAL: NATIVE_OP called with bogus selector %d\n", selector); |
1100 |
|
QuitEmulator(); |
1181 |
|
const uint32 args[] = { arg1, arg2, arg3, arg4, arg5, arg6, arg7 }; |
1182 |
|
return ppc_cpu->execute_macos_code(tvect, sizeof(args)/sizeof(args[0]), args); |
1183 |
|
} |
1202 |
– |
|
1203 |
– |
/* |
1204 |
– |
* Resource Manager thunks |
1205 |
– |
*/ |
1206 |
– |
|
1207 |
– |
void get_resource(void) |
1208 |
– |
{ |
1209 |
– |
ppc_cpu->get_resource(ReadMacInt32(XLM_GET_RESOURCE)); |
1210 |
– |
} |
1211 |
– |
|
1212 |
– |
void get_1_resource(void) |
1213 |
– |
{ |
1214 |
– |
ppc_cpu->get_resource(ReadMacInt32(XLM_GET_1_RESOURCE)); |
1215 |
– |
} |
1216 |
– |
|
1217 |
– |
void get_ind_resource(void) |
1218 |
– |
{ |
1219 |
– |
ppc_cpu->get_resource(ReadMacInt32(XLM_GET_IND_RESOURCE)); |
1220 |
– |
} |
1221 |
– |
|
1222 |
– |
void get_1_ind_resource(void) |
1223 |
– |
{ |
1224 |
– |
ppc_cpu->get_resource(ReadMacInt32(XLM_GET_1_IND_RESOURCE)); |
1225 |
– |
} |
1226 |
– |
|
1227 |
– |
void r_get_resource(void) |
1228 |
– |
{ |
1229 |
– |
ppc_cpu->get_resource(ReadMacInt32(XLM_R_GET_RESOURCE)); |
1230 |
– |
} |