#define __write_64bit_c0_register(register, sel, value) \
do { \
if (sizeof(unsigned long) == 4) \
__write_64bit_c0_split(register, sel, value); \
else if (sel == 0) \
__asm__ __volatile__( \
".set\tmips3\n\t" \
"dmtc0\t%z0, " #register "\n\t" \
".set\tmips0" \
: : "Jr" (value)); \
else \
__asm__ __volatile__( \
".set\tmips64\n\t" \
"dmtc0\t%z0, " #register ", " #sel "\n\t" \
".set\tmips0" \
: : "Jr" (value)); \
} while(0);
////////////////////////////////
#define __write_32bit_c0_register(register, sel, value) \
do { \
if (sel == 0) \
__asm__ __volatile__( \
"mtc0\t%z0, " #register "\n\t" \
: : "Jr" ((unsigned int)(value))); \
else \
__asm__ __volatile__( \
".set\tmips32\n\t" \
"mtc0\t%z0, " #register ", " #sel "\n\t" \
".set\tmips0" \
: : "Jr" ((unsigned int)(value))); \
} while (0)
/////////////////////////////
#define __read_32bit_c0_register(source, sel) \
({ int __res; \
if (sel == 0) \
__asm__ __volatile__( \
"mfc0\t%0, " #source "\n\t" \
: "=r" (__res)); \
else \
__asm__ __volatile__( \
".set\tmips32\n\t" \
"mfc0\t%0, " #source ", " #sel "\n\t" \
".set\tmips0\n\t" \
: "=r" (__res)); \
__res; \
})
/////////////////////////////////
#define __read_64bit_c0_register(source, sel) \
({ unsigned long long __res; \
if (sizeof(unsigned long) == 4) \
__res = __read_64bit_c0_split(source, sel); \
else if (sel == 0) \
__asm__ __volatile__( \
".set\tmips3\n\t" \
"dmfc0\t%0, " #source "\n\t" \
".set\tmips0" \
: "=r" (__res)); \
else \
__asm__ __volatile__( \
".set\tmips64\n\t" \
"dmfc0\t%0, " #source ", " #sel "\n\t" \
".set\tmips0" \
: "=r" (__res)); \
__res; \
})
/////////////////////////////////
void write_32bit_c0_watchhi0(unsigned int value)
{
__asm__ __volatile__( \
"mtc0\t%z0, $19\n\t" \
: : "Jr" ((unsigned int)(value)));
}
int read_32bit_c0_watchhi0(void)
{
int __res;
__asm__ __volatile__( \
"mfc0\t%0, $19\n\t" \
: "=r" (__res));
return__res;
}
int read_64bit_c0_watchlo0(void)
{
unsigned long __res;
__asm__ __volatile__( \
".set\tmips3\n\t" \
"dmfc0\t%0, $18\n\t" \
".set\tmips0" \
: "=r" (__res));
return __res;
}
void write_64bit_c0_watchlo0(unsigned long addr)
{
__asm__ __volatile__( \
".set\tmips3\n\t" \
"dmtc0\t%z0, $18\n\t" \
".set\tmips0" \
: : "Jr" (addr)); \
}
/////////////////////////////////
阅读(1534) | 评论(0) | 转发(0) |