1 #ifndef __PROCESSOR_H__ 2 #define __PROCESSOR_H__ 7 #define __stringify(rn) #rn 8 #define ATTRIBUTE_ALIGN(v) __attribute__((aligned(v))) 10 #define STACK_ALIGN(type, name, cnt, alignment) u8 _al__##name[((sizeof(type)*(cnt)) + (alignment) + (((sizeof(type)*(cnt))%(alignment)) > 0 ? ((alignment) - ((sizeof(type)*(cnt))%(alignment))) : 0))]; \ 11 type *name = (type*)(((u32)(_al__##name)) + ((alignment) - (((u32)(_al__##name))&((alignment)-1)))) 13 #define _sync() asm volatile("sync") 14 #define _nop() asm volatile("nop") 15 #define ppcsync() asm volatile("sc") 16 #define ppchalt() ({ \ 17 asm volatile("sync"); \ 19 asm volatile("nop"); \ 20 asm volatile("li 3,0"); \ 21 asm volatile("nop"); \ 25 #define mfpvr() ({register u32 _rval; \ 26 asm volatile("mfpvr %0" : "=r"(_rval)); _rval;}) 28 #define mfdcr(_rn) ({register u32 _rval; \ 29 asm volatile("mfdcr %0," __stringify(_rn) \ 30 : "=r" (_rval)); _rval;}) 31 #define mtdcr(rn, val) asm volatile("mtdcr " __stringify(rn) ",%0" : : "r" (val)) 33 #define mfmsr() ({register u32 _rval; \ 34 asm volatile("mfmsr %0" : "=r" (_rval)); _rval;}) 35 #define mtmsr(val) asm volatile("mtmsr %0" : : "r" (val)) 37 #define mfdec() ({register u32 _rval; \ 38 asm volatile("mfdec %0" : "=r" (_rval)); _rval;}) 39 #define mtdec(_val) asm volatile("mtdec %0" : : "r" (_val)) 42 ({ register u32 _rval = 0; \ 43 asm volatile("mfspr %0," __stringify(_rn) \ 48 #define mtspr(_rn, _val) asm volatile("mtspr " __stringify(_rn) ",%0" : : "r" (_val)) 50 #define mfwpar() mfspr(WPAR) 51 #define mtwpar(_val) mtspr(WPAR,_val) 53 #define mfmmcr0() mfspr(MMCR0) 54 #define mtmmcr0(_val) mtspr(MMCR0,_val) 55 #define mfmmcr1() mfspr(MMCR1) 56 #define mtmmcr1(_val) mtspr(MMCR1,_val) 58 #define mfpmc1() mfspr(PMC1) 59 #define mtpmc1(_val) mtspr(PMC1,_val) 60 #define mfpmc2() mfspr(PMC2) 61 #define mtpmc2(_val) mtspr(PMC2,_val) 62 #define mfpmc3() mfspr(PMC3) 63 #define mtpmc3(_val) mtspr(PMC3,_val) 64 #define mfpmc4() mfspr(PMC4) 65 #define mtpmc4(_val) mtspr(PMC4,_val) 67 #define mfhid0() mfspr(HID0) 68 #define mthid0(_val) mtspr(HID0,_val) 69 #define mfhid1() mfspr(HID1) 70 #define mthid1(_val) mtspr(HID1,_val) 71 #define mfhid2() mfspr(HID2) 72 #define mthid2(_val) mtspr(HID2,_val) 73 #define mfhid4() mfspr(HID4) 74 #define mthid4(_val) mtspr(HID4,_val) 76 #define __lhbrx(base,index) \ 77 ({ register u16 res; \ 78 __asm__ volatile ("lhbrx %0,%1,%2" : "=r"(res) : "b%"(index), "r"(base) : "memory"); \ 81 #define __lwbrx(base,index) \ 82 ({ register u32 res; \ 83 __asm__ volatile ("lwbrx %0,%1,%2" : "=r"(res) : "b%"(index), "r"(base) : "memory"); \ 86 #define __sthbrx(base,index,value) \ 87 __asm__ volatile ("sthbrx %0,%1,%2" : : "r"(value), "b%"(index), "r"(base) : "memory") 89 #define __stwbrx(base,index,value) \ 90 __asm__ volatile ("stwbrx %0,%1,%2" : : "r"(value), "b%"(index), "r"(base) : "memory") 92 #define cntlzw(_val) ({register u32 _rval; \ 93 asm volatile("cntlzw %0, %1" : "=r"((_rval)) : "r"((_val))); _rval;}) 95 #define _CPU_MSR_GET( _msr_value ) \ 98 asm volatile ("mfmsr %0" : "=&r" ((_msr_value)) : "0" ((_msr_value))); \ 101 #define _CPU_MSR_SET( _msr_value ) \ 102 { asm volatile ("mtmsr %0" : "=&r" ((_msr_value)) : "0" ((_msr_value))); } 104 #define _CPU_ISR_Enable() \ 105 { register u32 _val = 0; \ 106 __asm__ __volatile__ ( \ 108 "ori %0,%0,0x8000\n" \ 110 : "=&r" ((_val)) : "0" ((_val)) \ 114 #define _CPU_ISR_Disable( _isr_cookie ) \ 115 { register u32 _disable_mask = 0; \ 117 __asm__ __volatile__ ( \ 119 "rlwinm %1,%0,0,17,15\n" \ 121 "extrwi %0,%0,1,16" \ 122 : "=&r" ((_isr_cookie)), "=&r" ((_disable_mask)) \ 123 : "0" ((_isr_cookie)), "1" ((_disable_mask)) \ 127 #define _CPU_ISR_Restore( _isr_cookie ) \ 128 { register u32 _enable_mask = 0; \ 129 __asm__ __volatile__ ( \ 133 " ori %1,%1,0x8000\n" \ 136 : "=r"((_isr_cookie)),"=&r" ((_enable_mask)) \ 137 : "0"((_isr_cookie)),"1" ((_enable_mask)) \ 141 #define _CPU_ISR_Flash( _isr_cookie ) \ 142 { register u32 _flash_mask = 0; \ 143 __asm__ __volatile__ ( \ 147 " ori %1,%1,0x8000\n" \ 149 " rlwinm %1,%1,0,17,15\n" \ 152 : "=r" ((_isr_cookie)), "=&r" ((_flash_mask)) \ 153 : "0" ((_isr_cookie)), "1" ((_flash_mask)) \ 157 #define _CPU_FPR_Enable() \ 158 { register u32 _val = 0; \ 159 asm volatile ("mfmsr %0; ori %0,%0,0x2000; mtmsr %0" : \ 160 "=&r" (_val) : "0" (_val));\ 163 #define _CPU_FPR_Disable() \ 164 { register u32 _val = 0; \ 165 asm volatile ("mfmsr %0; rlwinm %0,%0,0,19,17; mtmsr %0" : \ 166 "=&r" (_val) : "0" (_val));\ 204 asm volatile(
"lwz %0,0(%1) ; sync" :
"=r"(
x) :
"b"(0xc0000000 |
addr));
210 asm(
"stw %0,0(%1) ; eieio" : :
"r"(
x),
"b"(0xc0000000 |
addr));
221 asm volatile(
"lhz %0,0(%1) ; sync" :
"=r"(
x) :
"b"(0xc0000000 |
addr));
227 asm(
"sth %0,0(%1) ; eieio" : :
"r"(
x),
"b"(0xc0000000 |
addr));
233 asm volatile(
"lbz %0,0(%1) ; sync" :
"=r"(
x) :
"b"(0xc0000000 |
addr));
239 asm(
"stb %0,0(%1) ; eieio" : :
"r"(
x),
"b"(0xc0000000 |
addr));
244 asm(
"stfs %0,0(%1) ; eieio" : :
"f"(
x),
"b"(0xc0000000 |
addr));
GLuint GLfloat * val
Definition: glext.h:7847
static u16 bswap16(u16 val)
Definition: processor.h:173
float f32
Definition: gctypes.h:43
#define __lwbrx(base, index)
Definition: processor.h:81
static void writef32(u32 addr, f32 x)
Definition: processor.h:242
static void write32(u32 addr, u32 x)
Definition: processor.h:208
static void write8(u32 addr, u8 x)
Definition: processor.h:237
static void mask32(u32 addr, u32 clear, u32 set)
Definition: processor.h:213
uint16_t u16
16bit unsigned integer
Definition: gctypes.h:18
static u64 bswap64(u64 val)
Definition: processor.h:185
#define __lhbrx(base, index)
Definition: processor.h:76
GLenum const GLvoid * addr
Definition: glext.h:10528
GLint GLint GLint GLint GLint x
Definition: glext.h:6295
static u32 bswap32(u32 val)
Definition: processor.h:179
static u32 read32(u32 addr)
Definition: processor.h:201
uint64_t u64
64bit unsigned integer
Definition: gctypes.h:20
static u16 read16(u32 addr)
Definition: processor.h:218
uint8_t u8
8bit unsigned integer
Definition: gctypes.h:17
uint32_t u32
32bit unsigned integer
Definition: gctypes.h:19
static void write16(u32 addr, u16 x)
Definition: processor.h:225
static u8 read8(u32 addr)
Definition: processor.h:230