Skip to content

Commit bc5378f

Browse files
jcmvbkbcczankel
authored andcommitted
xtensa: reorganize SR referencing
- reference SRs by names where possible, not by numbers; - get rid of __stringify around SR names where possible; - remove unneeded SR names from asm/regs.h; - add SREG_ prefix to remaining SR names; Signed-off-by: Max Filippov <jcmvbkbc@gmail.com> Signed-off-by: Chris Zankel <chris@zankel.net>
1 parent f4349b6 commit bc5378f

20 files changed

Lines changed: 254 additions & 292 deletions

File tree

‎arch/xtensa/boot/boot-redboot/bootstrap.S‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,17 @@ _start:
5151
/* 'reset' window registers */
5252

5353
movi a4, 1
54-
wsr a4, PS
54+
wsr a4, ps
5555
rsync
5656

57-
rsr a5, WINDOWBASE
57+
rsr a5, windowbase
5858
ssl a5
5959
sll a4, a4
60-
wsr a4, WINDOWSTART
60+
wsr a4, windowstart
6161
rsync
6262

6363
movi a4, 0x00040000
64-
wsr a4, PS
64+
wsr a4, ps
6565
rsync
6666

6767
/* copy the loader to its address

‎arch/xtensa/include/asm/atomic.h‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ static inline void atomic_add(int i, atomic_t * v)
7373
"l32i %0, %2, 0 \n\t"
7474
"add %0, %0, %1 \n\t"
7575
"s32i %0, %2, 0 \n\t"
76-
"wsr a15, "__stringify(PS)" \n\t"
76+
"wsr a15, ps \n\t"
7777
"rsync \n"
7878
: "=&a" (vval)
7979
: "a" (i), "a" (v)
@@ -97,7 +97,7 @@ static inline void atomic_sub(int i, atomic_t *v)
9797
"l32i %0, %2, 0 \n\t"
9898
"sub %0, %0, %1 \n\t"
9999
"s32i %0, %2, 0 \n\t"
100-
"wsr a15, "__stringify(PS)" \n\t"
100+
"wsr a15, ps \n\t"
101101
"rsync \n"
102102
: "=&a" (vval)
103103
: "a" (i), "a" (v)
@@ -118,7 +118,7 @@ static inline int atomic_add_return(int i, atomic_t * v)
118118
"l32i %0, %2, 0 \n\t"
119119
"add %0, %0, %1 \n\t"
120120
"s32i %0, %2, 0 \n\t"
121-
"wsr a15, "__stringify(PS)" \n\t"
121+
"wsr a15, ps \n\t"
122122
"rsync \n"
123123
: "=&a" (vval)
124124
: "a" (i), "a" (v)
@@ -137,7 +137,7 @@ static inline int atomic_sub_return(int i, atomic_t * v)
137137
"l32i %0, %2, 0 \n\t"
138138
"sub %0, %0, %1 \n\t"
139139
"s32i %0, %2, 0 \n\t"
140-
"wsr a15, "__stringify(PS)" \n\t"
140+
"wsr a15, ps \n\t"
141141
"rsync \n"
142142
: "=&a" (vval)
143143
: "a" (i), "a" (v)
@@ -260,7 +260,7 @@ static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
260260
"xor %1, %4, %3 \n\t"
261261
"and %0, %0, %4 \n\t"
262262
"s32i %0, %2, 0 \n\t"
263-
"wsr a15, "__stringify(PS)" \n\t"
263+
"wsr a15, ps \n\t"
264264
"rsync \n"
265265
: "=&a" (vval), "=a" (mask)
266266
: "a" (v), "a" (all_f), "1" (mask)
@@ -277,7 +277,7 @@ static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
277277
"l32i %0, %2, 0 \n\t"
278278
"or %0, %0, %1 \n\t"
279279
"s32i %0, %2, 0 \n\t"
280-
"wsr a15, "__stringify(PS)" \n\t"
280+
"wsr a15, ps \n\t"
281281
"rsync \n"
282282
: "=&a" (vval)
283283
: "a" (mask), "a" (v)

‎arch/xtensa/include/asm/cacheflush.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ extern void copy_from_user_page(struct vm_area_struct*, struct page*,
165165
static inline u32 xtensa_get_cacheattr(void)
166166
{
167167
u32 r;
168-
asm volatile(" rsr %0, CACHEATTR" : "=a"(r));
168+
asm volatile(" rsr %0, cacheattr" : "=a"(r));
169169
return r;
170170
}
171171

‎arch/xtensa/include/asm/cmpxchg.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ __cmpxchg_u32(volatile int *p, int old, int new)
2727
"bne %0, %2, 1f \n\t"
2828
"s32i %3, %1, 0 \n\t"
2929
"1: \n\t"
30-
"wsr a15, "__stringify(PS)" \n\t"
30+
"wsr a15, ps \n\t"
3131
"rsync \n\t"
3232
: "=&a" (old)
3333
: "a" (p), "a" (old), "r" (new)
@@ -97,7 +97,7 @@ static inline unsigned long xchg_u32(volatile int * m, unsigned long val)
9797
__asm__ __volatile__("rsil a15, "__stringify(LOCKLEVEL)"\n\t"
9898
"l32i %0, %1, 0 \n\t"
9999
"s32i %2, %1, 0 \n\t"
100-
"wsr a15, "__stringify(PS)" \n\t"
100+
"wsr a15, ps \n\t"
101101
"rsync \n\t"
102102
: "=&a" (tmp)
103103
: "a" (m), "a" (val)

‎arch/xtensa/include/asm/coprocessor.h‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,10 @@
9494
#if XCHAL_HAVE_CP
9595

9696
#define RSR_CPENABLE(x) do { \
97-
__asm__ __volatile__("rsr %0," __stringify(CPENABLE) : "=a" (x)); \
97+
__asm__ __volatile__("rsr %0, cpenable" : "=a" (x)); \
9898
} while(0);
9999
#define WSR_CPENABLE(x) do { \
100-
__asm__ __volatile__("wsr %0," __stringify(CPENABLE) "; rsync" \
101-
:: "a" (x)); \
100+
__asm__ __volatile__("wsr %0, cpenable; rsync" :: "a" (x)); \
102101
} while(0);
103102

104103
#endif /* XCHAL_HAVE_CP */

‎arch/xtensa/include/asm/delay.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ static inline void __delay(unsigned long loops)
2727
static __inline__ u32 xtensa_get_ccount(void)
2828
{
2929
u32 ccount;
30-
asm volatile ("rsr %0, 234; # CCOUNT\n" : "=r" (ccount));
30+
asm volatile ("rsr %0, ccount\n" : "=r" (ccount));
3131
return ccount;
3232
}
3333

‎arch/xtensa/include/asm/irqflags.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
static inline unsigned long arch_local_save_flags(void)
1717
{
1818
unsigned long flags;
19-
asm volatile("rsr %0,"__stringify(PS) : "=a" (flags));
19+
asm volatile("rsr %0, ps" : "=a" (flags));
2020
return flags;
2121
}
2222

@@ -41,7 +41,7 @@ static inline void arch_local_irq_enable(void)
4141

4242
static inline void arch_local_irq_restore(unsigned long flags)
4343
{
44-
asm volatile("wsr %0, "__stringify(PS)" ; rsync"
44+
asm volatile("wsr %0, ps; rsync"
4545
:: "a" (flags) : "memory");
4646
}
4747

‎arch/xtensa/include/asm/mmu_context.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ extern unsigned long asid_cache;
5151

5252
static inline void set_rasid_register (unsigned long val)
5353
{
54-
__asm__ __volatile__ (" wsr %0, "__stringify(RASID)"\n\t"
54+
__asm__ __volatile__ (" wsr %0, rasid\n\t"
5555
" isync\n" : : "a" (val));
5656
}
5757

5858
static inline unsigned long get_rasid_register (void)
5959
{
6060
unsigned long tmp;
61-
__asm__ __volatile__ (" rsr %0,"__stringify(RASID)"\n\t" : "=a" (tmp));
61+
__asm__ __volatile__ (" rsr %0, rasid\n\t" : "=a" (tmp));
6262
return tmp;
6363
}
6464

‎arch/xtensa/include/asm/regs.h‎

Lines changed: 9 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -27,52 +27,15 @@
2727

2828
/* Special registers. */
2929

30-
#define LBEG 0
31-
#define LEND 1
32-
#define LCOUNT 2
33-
#define SAR 3
34-
#define BR 4
35-
#define SCOMPARE1 12
36-
#define ACCHI 16
37-
#define ACCLO 17
38-
#define MR 32
39-
#define WINDOWBASE 72
40-
#define WINDOWSTART 73
41-
#define PTEVADDR 83
42-
#define RASID 90
43-
#define ITLBCFG 91
44-
#define DTLBCFG 92
45-
#define IBREAKENABLE 96
46-
#define DDR 104
47-
#define IBREAKA 128
48-
#define DBREAKA 144
49-
#define DBREAKC 160
50-
#define EPC 176
51-
#define EPC_1 177
52-
#define DEPC 192
53-
#define EPS 192
54-
#define EPS_1 193
55-
#define EXCSAVE 208
56-
#define EXCSAVE_1 209
57-
#define INTERRUPT 226
58-
#define INTENABLE 228
59-
#define PS 230
60-
#define THREADPTR 231
61-
#define EXCCAUSE 232
62-
#define DEBUGCAUSE 233
63-
#define CCOUNT 234
64-
#define PRID 235
65-
#define ICOUNT 236
66-
#define ICOUNTLEVEL 237
67-
#define EXCVADDR 238
68-
#define CCOMPARE 240
69-
#define MISC_SR 244
70-
71-
/* Special names for read-only and write-only interrupt registers. */
72-
73-
#define INTREAD 226
74-
#define INTSET 226
75-
#define INTCLEAR 227
30+
#define SREG_MR 32
31+
#define SREG_IBREAKA 128
32+
#define SREG_DBREAKA 144
33+
#define SREG_DBREAKC 160
34+
#define SREG_EPC 176
35+
#define SREG_EPS 192
36+
#define SREG_EXCSAVE 208
37+
#define SREG_CCOMPARE 240
38+
#define SREG_MISC 244
7639

7740
/* EXCCAUSE register fields */
7841

‎arch/xtensa/include/asm/timex.h‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ extern cycles_t cacheflush_time;
6363
* Register access.
6464
*/
6565

66-
#define WSR_CCOUNT(r) asm volatile ("wsr %0,"__stringify(CCOUNT) :: "a" (r))
67-
#define RSR_CCOUNT(r) asm volatile ("rsr %0,"__stringify(CCOUNT) : "=a" (r))
68-
#define WSR_CCOMPARE(x,r) asm volatile ("wsr %0,"__stringify(CCOMPARE)"+"__stringify(x) :: "a"(r))
69-
#define RSR_CCOMPARE(x,r) asm volatile ("rsr %0,"__stringify(CCOMPARE)"+"__stringify(x) : "=a"(r))
66+
#define WSR_CCOUNT(r) asm volatile ("wsr %0, ccount" :: "a" (r))
67+
#define RSR_CCOUNT(r) asm volatile ("rsr %0, ccount" : "=a" (r))
68+
#define WSR_CCOMPARE(x,r) asm volatile ("wsr %0,"__stringify(SREG_CCOMPARE)"+"__stringify(x) :: "a"(r))
69+
#define RSR_CCOMPARE(x,r) asm volatile ("rsr %0,"__stringify(SREG_CCOMPARE)"+"__stringify(x) : "=a"(r))
7070

7171
static inline unsigned long get_ccount (void)
7272
{

0 commit comments

Comments
 (0)