|
|
1.1 root 1:
2: #ifndef MMU_COMMON_H
3: #define MMU_COMMON_H
4:
1.1.1.2 ! root 5: #define MMUDEBUG 0
! 6: #define MMUINSDEBUG 0
! 7: #define MMUDEBUGMISC 0
! 8:
! 9: //#ifdef _MSC_VER
! 10: //#define unlikely(x) x
! 11: //#define likely(x) x
! 12: //#endif
! 13: #if __GNUC__ >= 3
! 14: # define likely(x) __builtin_expect (!!(x), 1)
! 15: # define unlikely(x) __builtin_expect (!!(x), 0)
! 16: #else
! 17: # define likely(x) (x)
! 18: # define unlikely(x) (x)
! 19: #endif
! 20:
! 21: #ifdef __cplusplus
1.1 root 22: struct m68k_exception {
23: int prb;
24: m68k_exception (int exc) : prb (exc) {}
25: operator int() { return prb; }
26: };
27: #define SAVE_EXCEPTION
28: #define RESTORE_EXCEPTION
29: #define TRY(var) try
30: #define CATCH(var) catch(m68k_exception var)
31: #define THROW(n) throw m68k_exception(n)
32: #define THROW_AGAIN(var) throw
1.1.1.2 ! root 33: #define ENDTRY
1.1 root 34: #else
35: /* we are in plain C, just use a stack of long jumps */
36: #include <setjmp.h>
37: extern jmp_buf __exbuf;
38: extern int __exvalue;
39: #define TRY(DUMMY) __exvalue=setjmp(__exbuf); \
40: if (__exvalue==0) { __pushtry(&__exbuf);
1.1.1.2 ! root 41: #define CATCH(x) __poptry(); } else {
1.1 root 42: #define ENDTRY __poptry();}
1.1.1.2 ! root 43: #define THROW(x) if (__is_catched()) {longjmp(__exbuf,x);}
1.1 root 44: #define THROW_AGAIN(var) if (__is_catched()) longjmp(*__poptry(),__exvalue)
45: #define SAVE_EXCEPTION
46: #define RESTORE_EXCEPTION
47: jmp_buf* __poptry(void);
48: void __pushtry(jmp_buf *j);
49: int __is_catched(void);
50:
51: typedef int m68k_exception;
52:
53: #endif
54:
55: /* special status word (access error stack frame) */
1.1.1.2 ! root 56: /* 68060 */
! 57: #define MMU_FSLW_MA 0x08000000
! 58: #define MMU_FSLW_LK 0x02000000
! 59: #define MMU_FSLW_R 0x01000000
! 60: #define MMU_FSLW_W 0x00800000
! 61: #define MMU_FSLW_SIZE_L 0x00000000 /* Note: wrong in mc68060 manual! */
! 62: #define MMU_FSLW_SIZE_B 0x00200000
! 63: #define MMU_FSLW_SIZE_W 0x00400000
! 64: #define MMU_FSLW_SIZE_D 0x00600000
! 65: #define MMU_FSLW_TT 0x00180000
! 66: #define MMU_FSLW_TT_N 0x00000000 /* Normal access */
! 67: #define MMU_FSLW_TT_16 0x00080000 /* MOVE16 */
! 68: #define MMU_FSLW_TM 0x00070000 /* = function code */
! 69: #define MMU_FSLW_IO 0x00008000
! 70: #define MMU_FSLW_PBE 0x00004000
! 71: #define MMU_FSLW_SBE 0x00002000
! 72: #define MMU_FSLW_PTA 0x00001000
! 73: #define MMU_FSLW_PTB 0x00000800
! 74: #define MMU_FSLW_IL 0x00000400
! 75: #define MMU_FSLW_PF 0x00000200
! 76: #define MMU_FSLW_SP 0x00000100
! 77: #define MMU_FSLW_WP 0x00000080
! 78: #define MMU_FSLW_TWE 0x00000040
! 79: #define MMU_FSLW_RE 0x00000020
! 80: #define MMU_FSLW_WE 0x00000010
! 81: #define MMU_FSLW_TTR 0x00000008
! 82: #define MMU_FSLW_BPE 0x00000004
! 83: #define MMU_FSLW_SEE 0x00000001
! 84: /* 68040 */
1.1 root 85: #define MMU_SSW_TM 0x0007
86: #define MMU_SSW_TT 0x0018
1.1.1.2 ! root 87: #define MMU_SSW_TT1 0x0010
! 88: #define MMU_SSW_TT0 0x0008
1.1 root 89: #define MMU_SSW_SIZE 0x0060
90: #define MMU_SSW_SIZE_B 0x0020
91: #define MMU_SSW_SIZE_W 0x0040
92: #define MMU_SSW_SIZE_L 0x0000
1.1.1.2 ! root 93: #define MMU_SSW_SIZE_CL 0x0060
1.1 root 94: #define MMU_SSW_RW 0x0100
95: #define MMU_SSW_LK 0x0200
96: #define MMU_SSW_ATC 0x0400
97: #define MMU_SSW_MA 0x0800
98: #define MMU_SSW_CM 0x1000
99: #define MMU_SSW_CT 0x2000
100: #define MMU_SSW_CU 0x4000
101: #define MMU_SSW_CP 0x8000
1.1.1.2 ! root 102: /* 68030 */
1.1 root 103: #define MMU030_SSW_FC 0x8000
104: #define MMU030_SSW_FB 0x4000
105: #define MMU030_SSW_RC 0x2000
106: #define MMU030_SSW_RB 0x1000
107: #define MMU030_SSW_DF 0x0100
108: #define MMU030_SSW_RM 0x0080
109: #define MMU030_SSW_RW 0x0040
110: #define MMU030_SSW_SIZE_MASK 0x0030
1.1.1.2 ! root 111: #define MMU030_SSW_SIZE_B 0x0010
! 112: #define MMU030_SSW_SIZE_W 0x0020
! 113: #define MMU030_SSW_SIZE_L 0x0000
1.1 root 114: #define MMU030_SSW_FC_MASK 0x0007
115:
116:
117: #define ALWAYS_INLINE __inline
118:
119: // take care of 2 kinds of alignement, bus size and page
1.1.1.2 ! root 120: #if 1
1.1 root 121: static inline bool is_unaligned(uaecptr addr, int size)
122: {
1.1.1.2 ! root 123: return unlikely((addr & (size - 1)) && (addr ^ (addr + size - 1)) & regs.mmu_page_size);
1.1 root 124: }
1.1.1.2 ! root 125: #else
! 126: static inline bool is_unaligned(uaecptr addr, int size)
! 127: {
! 128: return (addr & (size - 1));
! 129: }
! 130: #endif
1.1 root 131:
132: static ALWAYS_INLINE void phys_put_long(uaecptr addr, uae_u32 l)
133: {
134: longput(addr, l);
135: }
136: static ALWAYS_INLINE void phys_put_word(uaecptr addr, uae_u32 w)
137: {
138: wordput(addr, w);
139: }
140: static ALWAYS_INLINE void phys_put_byte(uaecptr addr, uae_u32 b)
141: {
142: byteput(addr, b);
143: }
144: static ALWAYS_INLINE uae_u32 phys_get_long(uaecptr addr)
145: {
146: return longget (addr);
147: }
148: static ALWAYS_INLINE uae_u32 phys_get_word(uaecptr addr)
149: {
150: return wordget (addr);
151: }
152: static ALWAYS_INLINE uae_u32 phys_get_byte(uaecptr addr)
153: {
154: return byteget (addr);
155: }
156:
157: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.