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