Use BUILD_SHEEPSHAVER_PROCEDURE to allocate static procedures into the

SheepShaver globals. Fix build of sheepshaver_glue.cpp without JIT.
This commit is contained in:
gbeauche 2004-11-22 22:04:38 +00:00
parent 7be8af917c
commit 114f5ff6c7
4 changed files with 47 additions and 35 deletions

View File

@ -267,12 +267,13 @@ void EmulOp(M68kRegisters *r, uint32 pc, int selector)
#endif
// Patch DebugStr()
static const uint16 proc[] = {
PW(M68K_EMUL_OP_DEBUG_STR),
PW(0x4e74), // rtd #4
PW(0x0004)
static const uint8 proc_template[] = {
M68K_EMUL_OP_DEBUG_STR >> 8, M68K_EMUL_OP_DEBUG_STR,
0x4e, 0x74, // rtd #4
0x00, 0x04
};
WriteMacInt32(0x1dfc, Host2MacAddr((uint8 *)proc));
BUILD_SHEEPSHAVER_PROCEDURE(proc);
WriteMacInt32(0x1dfc, proc);
break;
}

View File

@ -166,6 +166,11 @@ static inline uint32 SheepProc(const uint8 *proc, uint32 proc_size)
return mac_proc;
}
#define BUILD_SHEEPSHAVER_PROCEDURE(PROC) \
static uint32 PROC = 0; \
if (PROC == 0) \
PROC = SheepProc(PROC##_template, sizeof(PROC##_template))
class SheepVar
{
uint32 m_base;

View File

@ -42,6 +42,9 @@
#include <stdio.h>
#include <stdlib.h>
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif
#ifdef USE_SDL_VIDEO
#include <SDL_events.h>
@ -180,9 +183,10 @@ public:
// Execute MacOS/PPC code
uint32 execute_macos_code(uint32 tvect, int nargs, uint32 const *args);
#if PPC_ENABLE_JIT
// Compile one instruction
virtual int compile1(codegen_context_t & cg_context);
#endif
// Resource manager thunk
void get_resource(uint32 old_get_resource);
@ -318,9 +322,9 @@ void sheepshaver_cpu::execute_sheep(uint32 opcode)
}
// Compile one instruction
#if PPC_ENABLE_JIT
int sheepshaver_cpu::compile1(codegen_context_t & cg_context)
{
#if PPC_ENABLE_JIT
const instr_info_t *ii = cg_context.instr_info;
if (ii->mnemo != PPC_I(SHEEP))
return COMPILE_FAILURE;
@ -466,9 +470,8 @@ int sheepshaver_cpu::compile1(codegen_context_t & cg_context)
}
}
return status;
#endif
return COMPILE_FAILURE;
}
#endif
// CPU context to preserve on interrupt
sheepshaver_cpu::interrupt_context::interrupt_context(sheepshaver_cpu *_cpu, const char *_where)
@ -1045,7 +1048,7 @@ void sheepshaver_cpu::handle_interrupt(void)
M68kRegisters r;
uint32 old_r25 = ReadMacInt32(XLM_68K_R25); // Save interrupt level
WriteMacInt32(XLM_68K_R25, 0x21); // Execute with interrupt level 1
static const uint8 proc[] = {
static const uint8 proc_template[] = {
0x3f, 0x3c, 0x00, 0x00, // move.w #$0000,-(sp) (fake format word)
0x48, 0x7a, 0x00, 0x0a, // pea @1(pc) (return address)
0x40, 0xe7, // move sr,-(sp) (saved SR)
@ -1053,7 +1056,8 @@ void sheepshaver_cpu::handle_interrupt(void)
0x4e, 0xd0, // jmp (a0)
M68K_RTS >> 8, M68K_RTS & 0xff // @1
};
Execute68k(Host2MacAddr((uint8 *)proc), &r);
BUILD_SHEEPSHAVER_PROCEDURE(proc);
Execute68k(proc, &r);
WriteMacInt32(XLM_68K_R25, old_r25); // Restore interrupt level
#else
// Only update cursor

View File

@ -181,45 +181,47 @@ void *FindLibSymbol(char *lib_str, char *sym_str)
M68kRegisters r;
// Find shared library
static const uint16 proc1[] = {
PW(0x558f), // subq.l #2,a7
PW(0x2f08), // move.l a0,-(a7)
PW(0x2f3c), PW(0x7077), PW(0x7063), // move.l #'pwpc',-(a7)
PW(0x2f3c), PW(0x0000), PW(0x0001), // move.l #kReferenceCFrag,-(a7)
PW(0x2f09), // move.l a1,-(a7)
PW(0x2f0a), // move.l a2,-(a7)
PW(0x2f0b), // move.l a3,-(a7)
PW(0x3f3c), PW(0x0001), // (GetSharedLibrary)
PW(0xaa5a), // CFMDispatch
PW(0x301f), // move.w (a7)+,d0
PW(M68K_RTS)
static const uint8 proc1_template[] = {
0x55, 0x8f, // subq.l #2,a7
0x2f, 0x08, // move.l a0,-(a7)
0x2f, 0x3c, 0x70, 0x77, 0x70, 0x63, // move.l #'pwpc',-(a7)
0x2f, 0x3c, 0x00, 0x00, 0x00, 0x01, // move.l #kReferenceCFrag,-(a7)
0x2f, 0x09, // move.l a1,-(a7)
0x2f, 0x0a, // move.l a2,-(a7)
0x2f, 0x0b, // move.l a3,-(a7)
0x3f, 0x3c, 0x00, 0x01, // (GetSharedLibrary)
0xaa, 0x5a, // CFMDispatch
0x30, 0x1f, // move.w (a7)+,d0
M68K_RTS >> 8, M68K_RTS
};
BUILD_SHEEPSHAVER_PROCEDURE(proc1);
r.a[0] = lib.addr();
r.a[1] = conn_id.addr();
r.a[2] = main_addr.addr();
r.a[3] = err.addr();
Execute68k(Host2MacAddr((uint8 *)proc1), &r);
Execute68k(proc1, &r);
D(bug(" GetSharedLibrary: ret %d, connection ID %ld, main %p\n", (int16)r.d[0], conn_id.value(), main_addr.value()));
if (r.d[0])
return NULL;
// Find symbol
static const uint16 proc2[] = {
PW(0x558f), // subq.l #2,a7
PW(0x2f00), // move.l d0,-(a7)
PW(0x2f08), // move.l a0,-(a7)
PW(0x2f09), // move.l a1,-(a7)
PW(0x2f0a), // move.l a2,-(a7)
PW(0x3f3c), PW(0x0005), // (FindSymbol)
PW(0xaa5a), // CFMDispatch
PW(0x301f), // move.w (a7)+,d0
PW(M68K_RTS)
static const uint8 proc2_template[] = {
0x55, 0x8f, // subq.l #2,a7
0x2f, 0x00, // move.l d0,-(a7)
0x2f, 0x08, // move.l a0,-(a7)
0x2f, 0x09, // move.l a1,-(a7)
0x2f, 0x0a, // move.l a2,-(a7)
0x3f, 0x3c, 0x00, 0x05, // (FindSymbol)
0xaa, 0x5a, // CFMDispatch
0x30, 0x1f, // move.w (a7)+,d0
M68K_RTS >> 8, M68K_RTS
};
BUILD_SHEEPSHAVER_PROCEDURE(proc2);
r.d[0] = conn_id.value();
r.a[0] = sym.addr();
r.a[1] = sym_addr.addr();
r.a[2] = sym_class.addr();
Execute68k(Host2MacAddr((uint8 *)proc2), &r);
Execute68k(proc2, &r);
D(bug(" FindSymbol1: ret %d, sym_addr %p, sym_class %ld\n", (int16)r.d[0], sym_addr.value(), sym_class.value()));
//!! CloseConnection()?
if (r.d[0])