1 #ifndef __ASM_METAG_CORE_REG_H_ 2 #define __ASM_METAG_CORE_REG_H_ 3 4 #include <asm/metag_regs.h> 5 6 extern void core_reg_write(int unit, int reg, int thread, unsigned int val); 7 extern unsigned int core_reg_read(int unit, int reg, int thread); 8 9 /* 10 * These macros allow direct access from C to any register known to the 11 * assembler. Example candidates are TXTACTCYC, TXIDLECYC, and TXPRIVEXT. 12 */ 13 14 #define __core_reg_get(reg) ({ \ 15 unsigned int __grvalue; \ 16 asm volatile("MOV %0," #reg \ 17 : "=r" (__grvalue)); \ 18 __grvalue; \ 19 }) 20 21 #define __core_reg_set(reg, value) do { \ 22 unsigned int __srvalue = (value); \ 23 asm volatile("MOV " #reg ",%0" \ 24 : \ 25 : "r" (__srvalue)); \ 26 } while (0) 27 28 #define __core_reg_swap(reg, value) do { \ 29 unsigned int __srvalue = (value); \ 30 asm volatile("SWAP " #reg ",%0" \ 31 : "+r" (__srvalue)); \ 32 (value) = __srvalue; \ 33 } while (0) 34 35 #endif 36