ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/include/cpu_emulation.h
(Generate patch)

Comparing SheepShaver/src/include/cpu_emulation.h (file contents):
Revision 1.5 by gbeauche, 2003-10-12T05:44:13Z vs.
Revision 1.14 by gbeauche, 2004-11-13T14:09:16Z

# Line 1 | Line 1
1   /*
2   *  cpu_emulation.h - Definitions for CPU emulation and Mac memory access
3   *
4 < *  SheepShaver (C) 1997-2002 Christian Bauer and Marc Hellwig
4 > *  SheepShaver (C) 1997-2004 Christian Bauer and Marc Hellwig
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# Line 27 | Line 27
27   */
28  
29   // Constants
30 < const uint32 ROM_BASE = 0x40800000;                     // Base address of ROM
31 < const uint32 ROM_SIZE = 0x00400000;                     // Size of ROM file
32 < const uint32 ROM_AREA_SIZE = 0x500000;          // Size of ROM area
33 < const uint32 ROM_END = ROM_BASE + ROM_SIZE;     // End of ROM
34 < const uint32 DR_CACHE_BASE = 0x69000000;        // Address of DR cache
35 < const uint32 DR_CACHE_SIZE = 0x80000;           // Size of DR Cache
36 < const uint32 SHEEP_BASE = 0x60000000;           // Address of SheepShaver data
37 < const uint32 SHEEP_SIZE = 0x40000;                      // Size of SheepShaver data
38 <
39 < const uint32 KERNEL_DATA_BASE = 0x68ffe000;     // Address of Kernel Data
40 < const uint32 KERNEL_DATA2_BASE = 0x5fffe000;// Alternate address of Kernel Data
41 < const uint32 KERNEL_AREA_SIZE = 0x2000;         // Size of Kernel Data area
30 > const uintptr ROM_BASE = 0x40800000;                    // Base address of ROM
31 > const uint32  ROM_SIZE = 0x400000;                              // Size of ROM file
32 > const uint32  ROM_AREA_SIZE = 0x500000;                 // Size of ROM area
33 > const uintptr ROM_END = ROM_BASE + ROM_SIZE;    // End of ROM
34 > const uintptr DR_EMULATOR_BASE = 0x68070000;    // Address of DR emulator code
35 > const uint32  DR_EMULATOR_SIZE = 0x10000;               // Size of DR emulator code
36 > const uintptr DR_CACHE_BASE = 0x69000000;               // Address of DR cache
37 > const uint32  DR_CACHE_SIZE = 0x80000;                  // Size of DR Cache
38 >
39 > const uintptr KERNEL_DATA_BASE = 0x68ffe000;    // Address of Kernel Data
40 > const uintptr KERNEL_DATA2_BASE = 0x5fffe000;   // Alternate address of Kernel Data
41 > const uint32  KERNEL_AREA_SIZE = 0x2000;                // Size of Kernel Data area
42  
43   // MacOS 68k Emulator Data
44   struct EmulatorData {
# Line 54 | Line 54 | struct KernelData {
54   // RAM and ROM pointers (allocated and set by main_*.cpp)
55   extern uint32 RAMBase;                  // Base address of Mac RAM
56   extern uint32 RAMSize;                  // Size address of Mac RAM
57 < extern uint32 SheepStack1Base;  // SheepShaver first alternate stack base
58 < extern uint32 SheepStack2Base;  // SheepShaver second alternate stack base
59 < extern uint32 SheepThunksBase;  // SheepShaver thunks base
57 > extern uint8 *RAMBaseHost;              // Base address of Mac RAM (host address space)
58 > extern uint8 *ROMBaseHost;              // Base address of Mac ROM (host address space)
59  
60   // Mac memory access functions
61 + #if EMULATED_PPC
62 + #include "cpu/vm.hpp"
63 + static inline uint32 ReadMacInt8(uint32 addr) {return vm_read_memory_1(addr);}
64 + static inline void WriteMacInt8(uint32 addr, uint32 v) {vm_write_memory_1(addr, v);}
65 + static inline uint32 ReadMacInt16(uint32 addr) {return vm_read_memory_2(addr);}
66 + static inline void WriteMacInt16(uint32 addr, uint32 v) {vm_write_memory_2(addr, v);}
67 + static inline uint32 ReadMacInt32(uint32 addr) {return vm_read_memory_4(addr);}
68 + static inline void WriteMacInt32(uint32 addr, uint32 v) {vm_write_memory_4(addr, v);}
69 + static inline uint64 ReadMacInt64(uint32 addr) {return vm_read_memory_8(addr);}
70 + static inline void WriteMacInt64(uint32 addr, uint64 v) {vm_write_memory_8(addr, v);}
71 + static inline uint32 Host2MacAddr(uint8 *addr) {return vm_do_get_virtual_address(addr);}
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;}
86 < #endif
86 > static inline uint32 Host2MacAddr(uint8 *addr) {return (uint32)addr;}
87   static inline uint8 *Mac2HostAddr(uint32 addr) {return (uint8 *)addr;}
88   static inline void *Mac_memset(uint32 addr, int c, size_t n) {return memset(Mac2HostAddr(addr), c, n);}
89   static inline void *Mac2Host_memcpy(void *dest, uint32 src, size_t n) {return memcpy(dest, Mac2HostAddr(src), n);}
90   static inline void *Host2Mac_memcpy(uint32 dest, const void *src, size_t n) {return memcpy(Mac2HostAddr(dest), src, n);}
91   static inline void *Mac2Mac_memcpy(uint32 dest, uint32 src, size_t n) {return memcpy(Mac2HostAddr(dest), Mac2HostAddr(src), n);}
92 + #endif
93  
94  
95   /*
96   *  680x0 and PPC emulation
97   */
98  
99 + // 68k procedure helper to write a big endian 16-bit word
100 + #ifdef WORDS_BIGENDIAN
101 + #define PW(W) W
102 + #else
103 + #define PW(X) ((((X) >> 8) & 0xff) | (((X) & 0xff) << 8))
104 + #endif
105 +
106 + // PowerPC procedure helper to write a big-endian 32-bit word
107 + #ifdef WORDS_BIGENDIAN
108 + #define PL(X) X
109 + #else
110 + #define PL(X)                                                                                                   \
111 +     ((((X) & 0xff000000) >> 24) | (((X) & 0x00ff0000) >>  8) | \
112 +      (((X) & 0x0000ff00) <<  8) | (((X) & 0x000000ff) << 24))
113 + #endif
114 +
115   struct M68kRegisters;
116   extern void Execute68k(uint32, M68kRegisters *r);                       // Execute 68k subroutine from EMUL_OP routine, must be ended with RTS
117   extern void Execute68kTrap(uint16 trap, M68kRegisters *r);      // Execute 68k A-Trap from EMUL_OP routine
118   #if EMULATED_PPC
119   extern void FlushCodeCache(uintptr start, uintptr end);         // Invalidate emulator caches
95 extern void ExecuteNative(int selector);                                        // Execute native code from EMUL_OP routine (real mode switch)
96 #else
97 extern void ExecutePPC(void (*func)(void));                                     // Execute PPC code from EMUL_OP routine (real mode switch)
120   #endif
121 + extern void ExecuteNative(int selector);                                        // Execute native code from EMUL_OP routine (real mode switch)
122  
123   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines