Skip to content

Commit 7023f5b

Browse files
Merge branch 'contrib/github_pr_16040' into 'master'
refactor(xtensa): Rename specreg.h register macros (GitHub PR) Closes IDFGH-11606 and IDFGH-15386 See merge request espressif/esp-idf!39649
2 parents 0afcc02 + d0ceef2 commit 7023f5b

File tree

41 files changed

+824
-289
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+824
-289
lines changed

components/bootloader_support/src/esp32/bootloader_esp32.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ esp_err_t bootloader_init(void)
167167

168168
#if XCHAL_ERRATUM_572
169169
uint32_t memctl = XCHAL_CACHE_MEMCTL_DEFAULT;
170-
WSR(MEMCTL, memctl);
170+
WSR(XT_REG_MEMCTL, memctl);
171171
#endif // XCHAL_ERRATUM_572
172172

173173
// In RAM_APP, memory will be initialized in `call_start_cpu0`

components/bootloader_support/src/esp32s3/bootloader_esp32s3.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ esp_err_t bootloader_init(void)
144144

145145
#if XCHAL_ERRATUM_572
146146
uint32_t memctl = XCHAL_CACHE_MEMCTL_DEFAULT;
147-
WSR(MEMCTL, memctl);
147+
WSR(XT_REG_MEMCTL, memctl);
148148
#endif // XCHAL_ERRATUM_572
149149

150150
bootloader_ana_reset_config();

components/bt/controller/esp32/hli_vectors.S

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,17 @@ xt_highint4:
5757
wsr a0, CCOMPARE2
5858

5959
/* Enable Timer 2 interrupt */
60-
rsr a0, INTENABLE
60+
rsr a0, XT_REG_INTENABLE
6161
extui a0, a0, 16, 1
6262
bnez a0, 1f
6363
movi a0, 0
64-
xsr a0, INTENABLE /* disable all interrupts */
64+
xsr a0, XT_REG_INTENABLE /* disable all interrupts */
6565
/* And a0 with (1 << 16) for Timer 2 interrupt mask */
6666
addmi a0, a0, (1<<14)
6767
addmi a0, a0, (1<<14)
6868
addmi a0, a0, (1<<14)
6969
addmi a0, a0, (1<<14)
70-
wsr a0, INTENABLE /* Enable Timer 2 */
70+
wsr a0, XT_REG_INTENABLE /* Enable Timer 2 */
7171
1:
7272
#endif
7373

@@ -76,37 +76,37 @@ xt_highint4:
7676
s32i a1, a0, 4
7777
s32i a2, a0, 8
7878
s32i a3, a0, 12
79-
rsr a2, EXCSAVE_4 /* holds the value of a0 */
79+
rsr a2, XT_REG_EXCSAVE_4 /* holds the value of a0 */
8080
s32i a2, a0, 0
8181

8282
/* Save special registers */
8383
addi a0, a0, SPECREG_OFFSET
84-
rsr a2, WINDOWBASE
84+
rsr a2, XT_REG_WINDOWBASE
8585
s32i a2, a0, 0
86-
rsr a2, WINDOWSTART
86+
rsr a2, XT_REG_WINDOWSTART
8787
s32i a2, a0, 4
88-
rsr a2, SAR
88+
rsr a2, XT_REG_SAR
8989
s32i a2, a0, 8
90-
rsr a2, LBEG
90+
rsr a2, XT_REG_LBEG
9191
s32i a2, a0, 12
92-
rsr a2, LEND
92+
rsr a2, XT_REG_LEND
9393
s32i a2, a0, 16
94-
rsr a2, LCOUNT
94+
rsr a2, XT_REG_LCOUNT
9595
s32i a2, a0, 20
9696
rsr a2, EPC1
9797
s32i a2, a0, 24
9898

9999
#if CONFIG_ESP32_ECO3_CACHE_LOCK_FIX
100100
movi a0, 0
101-
xsr a0, INTENABLE /* disable all interrupts */
101+
xsr a0, XT_REG_INTENABLE /* disable all interrupts */
102102
movi a2, ~(1<<16)
103103
and a0, a2, a0
104-
wsr a0, INTENABLE
104+
wsr a0, XT_REG_INTENABLE
105105
#endif
106106

107107
/* disable exception mode, window overflow */
108108
movi a0, PS_INTLEVEL(5) | PS_EXCM
109-
wsr a0, PS
109+
wsr a0, XT_REG_PS
110110
rsync
111111

112112
/* Save the remaining physical registers.
@@ -153,12 +153,12 @@ xt_highint4:
153153
/* a0 still points to _l4_save_ctx */
154154

155155
/* Can clear WINDOWSTART now, all registers are saved */
156-
rsr a2, WINDOWBASE
156+
rsr a2, XT_REG_WINDOWBASE
157157
/* WINDOWSTART = (1 << WINDOWBASE) */
158158
movi a3, 1
159159
ssl a2
160160
sll a3, a3
161-
wsr a3, WINDOWSTART
161+
wsr a3, XT_REG_WINDOWSTART
162162

163163
_highint4_stack_switch:
164164
movi a0, 0
@@ -169,7 +169,7 @@ _highint4_stack_switch:
169169

170170
/* Set up PS for C, disable all interrupts except NMI and debug, and clear EXCM. */
171171
movi a6, PS_INTLEVEL(4) | PS_UM | PS_WOE
172-
wsr a6, PS
172+
wsr a6, XT_REG_PS
173173
rsync
174174

175175
/* Call C handler */
@@ -180,21 +180,21 @@ _highint4_stack_switch:
180180

181181
/* Done with C handler; re-enable exception mode, disabling window overflow */
182182
movi a2, PS_INTLEVEL(5) | PS_EXCM /* TOCHECK */
183-
wsr a2, PS
183+
wsr a2, XT_REG_PS
184184
rsync
185185

186186
/* Restore the special registers.
187187
* WINDOWSTART will be restored near the end.
188188
*/
189189
movi a0, _l4_save_ctx + SPECREG_OFFSET
190190
l32i a2, a0, 8
191-
wsr a2, SAR
191+
wsr a2, XT_REG_SAR
192192
l32i a2, a0, 12
193-
wsr a2, LBEG
193+
wsr a2, XT_REG_LBEG
194194
l32i a2, a0, 16
195-
wsr a2, LEND
195+
wsr a2, XT_REG_LEND
196196
l32i a2, a0, 20
197-
wsr a2, LCOUNT
197+
wsr a2, XT_REG_LCOUNT
198198
l32i a2, a0, 24
199199
wsr a2, EPC1
200200

@@ -247,12 +247,12 @@ _highint4_stack_switch:
247247
movi a0, _l4_save_ctx
248248

249249
l32i a2, a0, SPECREG_OFFSET + 4
250-
wsr a2, WINDOWSTART
250+
wsr a2, XT_REG_WINDOWSTART
251251

252252
l32i a1, a0, 4
253253
l32i a2, a0, 8
254254
l32i a3, a0, 12
255-
rsr a0, EXCSAVE_4 /* holds the value of a0 before the interrupt handler */
255+
rsr a0, XT_REG_EXCSAVE_4 /* holds the value of a0 before the interrupt handler */
256256

257257
/* Return from the interrupt, restoring PS from EPS_4 */
258258
rfi 4

components/esp_gdbstub/src/port/xtensa/gdbstub-entry.S

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ esp_gdbstub_int:
2424
#if XCHAL_HAVE_WINDOWED
2525
s32e a0, sp, -12 /* for debug backtrace */
2626
#endif
27-
rsr a0, PS /* save interruptee's PS */
27+
rsr a0, XT_REG_PS /* save interruptee's PS */
2828
s32i a0, sp, XT_STK_PS
29-
rsr a0, EPC_1 /* save interruptee's PC */
29+
rsr a0, XT_REG_EPC_1 /* save interruptee's PC */
3030
s32i a0, sp, XT_STK_PC
3131
#if XCHAL_HAVE_WINDOWED
3232
s32e a0, sp, -16 /* for debug backtrace */
@@ -35,21 +35,21 @@ esp_gdbstub_int:
3535
s32i a13, sp, XT_STK_A13 /* A13 to have already been saved */
3636

3737
/* Save exc cause and vaddr into exception frame */
38-
rsr a0, EXCCAUSE
38+
rsr a0, XT_REG_EXCCAUSE
3939
s32i a0, sp, XT_STK_EXCCAUSE
40-
rsr a0, EXCVADDR
40+
rsr a0, XT_REG_EXCVADDR
4141
s32i a0, sp, XT_STK_EXCVADDR
4242

4343

4444
/* _xt_context_save seems to save the current a0, but we need the interuptees a0. Fix this. */
45-
rsr a0, EXCSAVE_1 /* save interruptee's a0 */
45+
rsr a0, XT_REG_EXCSAVE_1 /* save interruptee's a0 */
4646

4747
s32i a0, sp, XT_STK_A0
4848

4949
/* Save context pointer as input parameter */
5050
rsr a6, excsave1
5151

52-
rsr a3, EPS
52+
rsr a3, XT_REG_EPS
5353
s32i a3, sp, XT_STK_PS // store PS to the ps place
5454
movi a3, gdbstub_handle_uart_int
5555
callx0 a3

components/esp_gdbstub/src/port/xtensa/gdbstub_xtensa.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <string.h>
88
#include "esp_gdbstub_common.h"
99
#include "soc/soc_memory_layout.h"
10-
#include "xtensa/config/specreg.h"
10+
#include "xtensa/config/xt_specreg.h"
1111
#include "sdkconfig.h"
1212
#include "esp_cpu.h"
1313
#include "esp_ipc_isr.h"
@@ -35,8 +35,8 @@ static void update_regfile_common(esp_gdbstub_gdb_regfile_t *dst)
3535
}
3636
dst->windowbase = 0;
3737
dst->windowstart = 0x1;
38-
RSR(CONFIGID0, dst->configid0);
39-
RSR(CONFIGID1, dst->configid1);
38+
RSR(XT_REG_CONFIGID0, dst->configid0);
39+
RSR(XT_REG_CONFIGID1, dst->configid1);
4040
}
4141

4242
#if XCHAL_HAVE_FP
@@ -111,7 +111,7 @@ void esp_gdbstub_frame_to_regfile(const esp_gdbstub_frame_t *frame, esp_gdbstub_
111111
current_tcb_ptr = pxCurrentTCBs[esp_cpu_get_core_id()];
112112
#endif
113113
uint32_t cp_enabled;
114-
RSR(CPENABLE, cp_enabled);
114+
RSR(XT_REG_CPENABLE, cp_enabled);
115115

116116
// Check if the co-processor is enabled
117117
if (cp_enabled) {
@@ -182,7 +182,7 @@ void esp_gdbstub_tcb_frame_to_regfile(dummy_tcb_t *tcb, esp_gdbstub_gdb_regfile_
182182
#endif
183183

184184
uint32_t cp_enabled;
185-
RSR(CPENABLE, cp_enabled);
185+
RSR(XT_REG_CPENABLE, cp_enabled);
186186

187187
void *current_tcb_ptr = tcb;
188188
uint32_t *current_fpu_ptr = NULL;
@@ -309,8 +309,8 @@ void esp_gdbstub_stall_other_cpus_end(void)
309309
* */
310310
void esp_gdbstub_clear_step(void)
311311
{
312-
WSR(ICOUNT, 0);
313-
WSR(ICOUNTLEVEL, 0);
312+
WSR(XT_REG_ICOUNT, 0);
313+
WSR(XT_REG_ICOUNTLEVEL, 0);
314314
}
315315

316316
/** @brief GDB do step
@@ -326,8 +326,8 @@ void esp_gdbstub_do_step( esp_gdbstub_frame_t *frame)
326326
level &= 0x7;
327327
level += 1;
328328

329-
WSR(ICOUNTLEVEL, level);
330-
WSR(ICOUNT, -2);
329+
WSR(XT_REG_ICOUNTLEVEL, level);
330+
WSR(XT_REG_ICOUNT, -2);
331331
}
332332

333333
/** @brief GDB trigger other CPU
@@ -364,7 +364,7 @@ void esp_gdbstub_set_register(esp_gdbstub_frame_t *frame, uint32_t reg_index, ui
364364
#if XCHAL_HAVE_FP
365365
void *ptr1;
366366
uint32_t cp_enabled;
367-
RSR(CPENABLE, cp_enabled);
367+
RSR(XT_REG_CPENABLE, cp_enabled);
368368
if (cp_enabled != 0) {
369369
if (reg_index == 87) {
370370
asm volatile ("lsi f0, %0, 0" :: "a" (ptr0));

components/esp_gdbstub/src/port/xtensa/xt_debugexception.S

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ _xt_panic_gdbstub:
2222
s32i a0, sp, XT_STK_EXIT
2323
s32i a0, sp, XT_STK_A0
2424

25-
rsr a0, PS /* save interruptee's PS */
25+
rsr a0, XT_REG_PS /* save interruptee's PS */
2626
s32i a0, sp, XT_STK_PS
27-
rsr a0, EPC_1 /* save interruptee's PC */
27+
rsr a0, XT_REG_EPC_1 /* save interruptee's PC */
2828
s32i a0, sp, XT_STK_PC
2929
call0 _xt_context_save /* Save full context*/
3030
addi a7, sp, XT_STK_FRMSZ
@@ -33,29 +33,29 @@ _xt_panic_gdbstub:
3333
s32i a13, sp, XT_STK_A13
3434

3535
/* Save exc cause and vaddr into exception frame */
36-
rsr a0, EXCCAUSE
36+
rsr a0, XT_REG_EXCCAUSE
3737
s32i a0, sp, XT_STK_EXCCAUSE
38-
rsr a0, EXCVADDR
38+
rsr a0, XT_REG_EXCVADDR
3939
s32i a0, sp, XT_STK_EXCVADDR
4040

4141
/* _xt_context_save seems to save the current a0, but we need the interuptees a0. Fix this. */
42-
rsr a0, EXCSAVE_1 /* save interruptee's a0 */
42+
rsr a0, XT_REG_EXCSAVE_1 /* save interruptee's a0 */
4343

4444
/* Set up PS for C, disable all interrupts except NMI and debug, and clear EXCM. */
4545
movi a0, PS_INTLEVEL(5) | PS_UM | PS_WOE
46-
wsr a0, PS
46+
wsr a0, XT_REG_PS
4747

4848
//Call gdbstub handler
4949

50-
rsr a0,(EPC + XCHAL_DEBUGLEVEL)
50+
rsr a0,(XT_REG_EPC + XCHAL_DEBUGLEVEL)
5151
s32i a0, sp, XT_STK_PC
5252
mov a6, sp
53-
rsr a9, EPS_6
53+
rsr a9, XT_REG_EPS_6
5454
s32i a9, sp, XT_STK_PS // store PS to the ps place
5555
movi a11, gdbstub_handle_debug_int
5656
callx4 a11 /* Call interrupt handler */
5757
l32i a0, sp, XT_STK_PC
58-
wsr a0,(EPC + XCHAL_DEBUGLEVEL)
58+
wsr a0,(XT_REG_EPC + XCHAL_DEBUGLEVEL)
5959
call0 _xt_context_restore /* Restore full context*/
6060
l32i a12, sp, XT_STK_A12
6161
l32i a13, sp, XT_STK_A13

components/esp_hw_support/test_apps/esp_hw_support_unity_tests/main/test_dport.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,11 +307,11 @@ TEST_CASE("test for DPORT access performance", "[esp32]")
307307
static uint32_t start, end;
308308

309309
#define BENCHMARK_START() do { \
310-
RSR(CCOUNT, start); \
310+
RSR(XT_REG_CCOUNT, start); \
311311
} while(0)
312312

313313
#define BENCHMARK_END(OPERATION) do { \
314-
RSR(CCOUNT, end); \
314+
RSR(XT_REG_CCOUNT, end); \
315315
printf("%s took %"PRIu32" cycles/op (%"PRIu32" cycles for %d ops)\n", \
316316
OPERATION, (end - start)/REPEAT_OPS, \
317317
(end - start), REPEAT_OPS); \

components/esp_hw_support/test_apps/esp_hw_support_unity_tests/main/test_dport_xt_highint5.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ xt_highint5:
4040
wsr a0, CCOMPARE2
4141
esync
4242

43-
rsr a0, EXCSAVE_5 // restore a0
43+
rsr a0, XT_REG_EXCSAVE_5 // restore a0
4444
rfi 5
4545

4646

@@ -74,7 +74,7 @@ xt_highint5:
7474
l32i a4, a0, L5_INTR_A4_OFFSET
7575
rsync
7676
.L_xt_highint5_exit:
77-
rsr a0, EXCSAVE_5 // restore a0
77+
rsr a0, XT_REG_EXCSAVE_5 // restore a0
7878
rfi 5
7979

8080
/* The linker has no reason to link in this file; all symbols it exports are already defined

components/esp_hw_support/test_apps/esp_hw_support_unity_tests/main/test_fp.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,13 @@ float IRAM_ATTR test_fp_benchmark_fp_divide(int counts, unsigned *cycles)
215215
{
216216
float f = MAXFLOAT;
217217
uint32_t before, after;
218-
RSR(CCOUNT, before);
218+
RSR(XT_REG_CCOUNT, before);
219219

220220
for (int i = 0; i < counts; i++) {
221221
f /= 1.000432f;
222222
}
223223

224-
RSR(CCOUNT, after);
224+
RSR(XT_REG_CCOUNT, after);
225225
*cycles = (after - before) / counts;
226226

227227
return f;
@@ -254,13 +254,13 @@ float IRAM_ATTR test_fp_benchmark_fp_sqrt(int counts, unsigned *cycles)
254254
{
255255
float f = MAXFLOAT;
256256
uint32_t before, after;
257-
RSR(CCOUNT, before);
257+
RSR(XT_REG_CCOUNT, before);
258258

259259
for (int i = 0; i < counts; i++) {
260260
f = sqrtf(f);
261261
}
262262

263-
RSR(CCOUNT, after);
263+
RSR(XT_REG_CCOUNT, after);
264264
*cycles = (after - before) / counts;
265265

266266
return f;

0 commit comments

Comments
 (0)