59 |
|
extern uint32 SheepThunksBase; // SheepShaver thunks base |
60 |
|
|
61 |
|
// Mac memory access functions |
62 |
+ |
#if EMULATED_PPC |
63 |
+ |
#include "cpu/vm.hpp" |
64 |
+ |
static inline uint32 ReadMacInt8(uint32 addr) {return vm_read_memory_1(addr);} |
65 |
+ |
static inline void WriteMacInt8(uint32 addr, uint32 v) {vm_write_memory_1(addr, v);} |
66 |
+ |
static inline uint32 ReadMacInt16(uint32 addr) {return vm_read_memory_2(addr);} |
67 |
+ |
static inline void WriteMacInt16(uint32 addr, uint32 v) {vm_write_memory_2(addr, v);} |
68 |
+ |
static inline uint32 ReadMacInt32(uint32 addr) {return vm_read_memory_4(addr);} |
69 |
+ |
static inline void WriteMacInt32(uint32 addr, uint32 v) {vm_write_memory_4(addr, v);} |
70 |
+ |
static inline uint64 ReadMacInt64(uint32 addr) {return vm_read_memory_8(addr);} |
71 |
+ |
static inline void WriteMacInt64(uint32 addr, uint64 v) {vm_write_memory_8(addr, v);} |
72 |
+ |
static inline uint8 *Mac2HostAddr(uint32 addr) {return vm_do_get_real_address(addr);} |
73 |
+ |
static inline void *Mac_memset(uint32 addr, int c, size_t n) {return vm_memset(addr, c, n);} |
74 |
+ |
static inline void *Mac2Host_memcpy(void *dest, uint32 src, size_t n) {return vm_memcpy(dest, src, n);} |
75 |
+ |
static inline void *Host2Mac_memcpy(uint32 dest, const void *src, size_t n) {return vm_memcpy(dest, src, n);} |
76 |
+ |
static inline void *Mac2Mac_memcpy(uint32 dest, uint32 src, size_t n) {return vm_memcpy(dest, src, n);} |
77 |
+ |
#else |
78 |
|
static inline uint32 ReadMacInt8(uint32 addr) {return *(uint8 *)addr;} |
79 |
|
static inline void WriteMacInt8(uint32 addr, uint32 b) {*(uint8 *)addr = b;} |
64 |
– |
#ifdef __i386__ |
65 |
– |
static inline uint32 ReadMacInt16(uint32 addr) {uint32 retval; __asm__ ("movzwl %w1,%k0\n\tshll $16,%k0\n\tbswapl %k0\n" : "=&r" (retval) : "m" (*(uint16 *)addr) : "cc"); return retval;} |
66 |
– |
static inline uint32 ReadMacInt32(uint32 addr) {uint32 retval; __asm__ ("bswap %0" : "=r" (retval) : "0" (*(uint32 *)addr) : "cc"); return retval;} |
67 |
– |
static inline uint64 ReadMacInt64(uint32 addr) {return ((uint64)ReadMacInt32(addr) << 32) | ReadMacInt32(addr + 4);} |
68 |
– |
static inline void WriteMacInt16(uint32 addr, uint32 w) {__asm__ ("bswapl %0" : "=&r" (w) : "0" (w << 16) : "cc"); *(uint16 *)addr = w;} |
69 |
– |
static inline void WriteMacInt32(uint32 addr, uint32 l) {__asm__ ("bswap %0" : "=r" (l) : "0" (l) : "cc"); *(uint32 *)addr = l;} |
70 |
– |
static inline void WriteMacInt64(uint32 addr, uint64 ll) {WriteMacInt32(addr, ll >> 32); WriteMacInt32(addr, ll);} |
71 |
– |
#else |
80 |
|
static inline uint32 ReadMacInt16(uint32 addr) {return *(uint16 *)addr;} |
81 |
|
static inline uint32 ReadMacInt32(uint32 addr) {return *(uint32 *)addr;} |
82 |
|
static inline uint64 ReadMacInt64(uint32 addr) {return *(uint64 *)addr;} |
83 |
|
static inline void WriteMacInt16(uint32 addr, uint32 w) {*(uint16 *)addr = w;} |
84 |
|
static inline void WriteMacInt32(uint32 addr, uint32 l) {*(uint32 *)addr = l;} |
85 |
|
static inline void WriteMacInt64(uint32 addr, uint64 ll) {*(uint64 *)addr = ll;} |
78 |
– |
#endif |
86 |
|
static inline uint8 *Mac2HostAddr(uint32 addr) {return (uint8 *)addr;} |
87 |
|
static inline void *Mac_memset(uint32 addr, int c, size_t n) {return memset(Mac2HostAddr(addr), c, n);} |
88 |
|
static inline void *Mac2Host_memcpy(void *dest, uint32 src, size_t n) {return memcpy(dest, Mac2HostAddr(src), n);} |
89 |
|
static inline void *Host2Mac_memcpy(uint32 dest, const void *src, size_t n) {return memcpy(Mac2HostAddr(dest), src, n);} |
90 |
|
static inline void *Mac2Mac_memcpy(uint32 dest, uint32 src, size_t n) {return memcpy(Mac2HostAddr(dest), Mac2HostAddr(src), n);} |
91 |
+ |
#endif |
92 |
|
|
93 |
|
|
94 |
|
/* |
99 |
|
extern void Execute68k(uint32, M68kRegisters *r); // Execute 68k subroutine from EMUL_OP routine, must be ended with RTS |
100 |
|
extern void Execute68kTrap(uint16 trap, M68kRegisters *r); // Execute 68k A-Trap from EMUL_OP routine |
101 |
|
#if EMULATED_PPC |
102 |
+ |
extern void FlushCodeCache(uintptr start, uintptr end); // Invalidate emulator caches |
103 |
|
extern void ExecuteNative(int selector); // Execute native code from EMUL_OP routine (real mode switch) |
104 |
|
#else |
105 |
|
extern void ExecutePPC(void (*func)(void)); // Execute PPC code from EMUL_OP routine (real mode switch) |