--- previous/src/cpu/mmu_common.h 2018/04/24 19:29:02 1.1 +++ previous/src/cpu/mmu_common.h 2018/04/24 19:33:45 1.1.1.4 @@ -1,8 +1,11 @@ +#ifndef UAE_MMU_COMMON_H +#define UAE_MMU_COMMON_H -#ifndef MMU_COMMON_H -#define MMU_COMMON_H +#define MMUDEBUG 0 +#define MMUINSDEBUG 0 +#define MMUDEBUGMISC 0 -#if 0 +#ifdef __cplusplus struct m68k_exception { int prb; m68k_exception (int exc) : prb (exc) {} @@ -14,22 +17,22 @@ struct m68k_exception { #define CATCH(var) catch(m68k_exception var) #define THROW(n) throw m68k_exception(n) #define THROW_AGAIN(var) throw - +#define ENDTRY #else /* we are in plain C, just use a stack of long jumps */ #include -extern jmp_buf __exbuf; +extern sigjmp_buf __exbuf; extern int __exvalue; -#define TRY(DUMMY) __exvalue=setjmp(__exbuf); \ +#define TRY(DUMMY) __exvalue=sigsetjmp(__exbuf, 0); \ if (__exvalue==0) { __pushtry(&__exbuf); -#define CATCH(x) __poptry(); } else { fprintf(stderr,"Gotcha! %d %s in %d\n",__exvalue,__FILE__,__LINE__); +#define CATCH(x) __poptry(); } else {m68k_exception x=__exvalue; x=x; #define ENDTRY __poptry();} -#define THROW(x) if (__is_catched()) {fprintf(stderr,"Longjumping %s in %d\n",__FILE__,__LINE__);longjmp(__exbuf,x);} -#define THROW_AGAIN(var) if (__is_catched()) longjmp(*__poptry(),__exvalue) +#define THROW(x) if (__is_catched()) {siglongjmp(__exbuf,x);} +#define THROW_AGAIN(var) if (__is_catched()) siglongjmp(*__poptry(),__exvalue) #define SAVE_EXCEPTION #define RESTORE_EXCEPTION -jmp_buf* __poptry(void); -void __pushtry(jmp_buf *j); +sigjmp_buf* __poptry(void); +void __pushtry(sigjmp_buf *j); int __is_catched(void); typedef int m68k_exception; @@ -37,14 +40,44 @@ typedef int m68k_exception; #endif /* special status word (access error stack frame) */ -/* this is only valid for 68040 */ -/* TODO: correctly handle SSW on 68030 */ +/* 68060 */ +#define MMU_FSLW_MA 0x08000000 +#define MMU_FSLW_LK 0x02000000 +#define MMU_FSLW_R 0x01000000 +#define MMU_FSLW_W 0x00800000 +#define MMU_FSLW_SIZE_L 0x00000000 /* Note: wrong in mc68060 manual! */ +#define MMU_FSLW_SIZE_B 0x00200000 +#define MMU_FSLW_SIZE_W 0x00400000 +#define MMU_FSLW_SIZE_D 0x00600000 +#define MMU_FSLW_TT 0x00180000 +#define MMU_FSLW_TT_N 0x00000000 /* Normal access */ +#define MMU_FSLW_TT_16 0x00080000 /* MOVE16 */ +#define MMU_FSLW_TM 0x00070000 /* = function code */ +#define MMU_FSLW_IO 0x00008000 +#define MMU_FSLW_PBE 0x00004000 +#define MMU_FSLW_SBE 0x00002000 +#define MMU_FSLW_PTA 0x00001000 +#define MMU_FSLW_PTB 0x00000800 +#define MMU_FSLW_IL 0x00000400 +#define MMU_FSLW_PF 0x00000200 +#define MMU_FSLW_SP 0x00000100 +#define MMU_FSLW_WP 0x00000080 +#define MMU_FSLW_TWE 0x00000040 +#define MMU_FSLW_RE 0x00000020 +#define MMU_FSLW_WE 0x00000010 +#define MMU_FSLW_TTR 0x00000008 +#define MMU_FSLW_BPE 0x00000004 +#define MMU_FSLW_SEE 0x00000001 +/* 68040 */ #define MMU_SSW_TM 0x0007 #define MMU_SSW_TT 0x0018 +#define MMU_SSW_TT1 0x0010 +#define MMU_SSW_TT0 0x0008 #define MMU_SSW_SIZE 0x0060 #define MMU_SSW_SIZE_B 0x0020 #define MMU_SSW_SIZE_W 0x0040 #define MMU_SSW_SIZE_L 0x0000 +#define MMU_SSW_SIZE_CL 0x0060 #define MMU_SSW_RW 0x0100 #define MMU_SSW_LK 0x0200 #define MMU_SSW_ATC 0x0400 @@ -53,7 +86,7 @@ typedef int m68k_exception; #define MMU_SSW_CT 0x2000 #define MMU_SSW_CU 0x4000 #define MMU_SSW_CP 0x8000 - +/* 68030 */ #define MMU030_SSW_FC 0x8000 #define MMU030_SSW_FB 0x4000 #define MMU030_SSW_RC 0x2000 @@ -62,19 +95,26 @@ typedef int m68k_exception; #define MMU030_SSW_RM 0x0080 #define MMU030_SSW_RW 0x0040 #define MMU030_SSW_SIZE_MASK 0x0030 -#define MMU030_SSW_SIZE_B 0x0010 /* correct ? */ -#define MMU030_SSW_SIZE_W 0x0020 /* correct ? */ -#define MMU030_SSW_SIZE_L 0x0000 /* correct ? */ +#define MMU030_SSW_SIZE_B 0x0010 +#define MMU030_SSW_SIZE_W 0x0020 +#define MMU030_SSW_SIZE_L 0x0000 #define MMU030_SSW_FC_MASK 0x0007 -#define ALWAYS_INLINE __inline +#define ALWAYS_INLINE inline // take care of 2 kinds of alignement, bus size and page -static inline bool is_unaligned(uaecptr addr, int size) +#if 1 +static ALWAYS_INLINE bool is_unaligned(uaecptr addr, int size) { - return unlikely((addr & (size - 1)) && (addr ^ (addr + size - 1)) & 0x1000); + return unlikely((addr & (size - 1)) && (addr ^ (addr + size - 1)) & regs.mmu_page_size); } +#else +static ALWAYS_INLINE bool is_unaligned(uaecptr addr, int size) +{ + return (addr & (size - 1)); +} +#endif static ALWAYS_INLINE void phys_put_long(uaecptr addr, uae_u32 l) { @@ -101,4 +141,4 @@ static ALWAYS_INLINE uae_u32 phys_get_by return byteget (addr); } -#endif +#endif /* UAE_MMU_COMMON_H */