You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: portable/IAR/RISC-V/portASM.s
+27-21Lines changed: 27 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -107,35 +107,35 @@ definitions. */
107
107
CODE
108
108
109
109
portUPDATE_MTIMER_COMPARE_REGISTER MACRO
110
-
load_x t0, pullMachineTimerCompareRegister /* Load address of compare register into t0. */
111
-
load_x t1, pullNextTime /* Load the address of ullNextTime into t1. */
110
+
load_x a0, pullMachineTimerCompareRegister /* Load address of compare register into a0. */
111
+
load_x a1, pullNextTime /* Load the address of ullNextTime into a1. */
112
112
113
113
#if( __riscv_xlen == 32 )
114
114
115
115
/* Update the 64-bit mtimer compare match value in two 32-bit writes. */
116
-
li t4, -1
117
-
lw t2, 0(t1) /* Load the low word of ullNextTime into t2. */
118
-
lw t3, 4(t1) /* Load the high word of ullNextTime into t3. */
119
-
sw t4, 0(t0) /* Low word no smaller than old value to start with - will be overwritten below. */
120
-
sw t3, 4(t0) /* Store high word of ullNextTime into compare register. No smaller than new value. */
121
-
sw t2, 0(t0) /* Store low word of ullNextTime into compare register. */
116
+
li a4, -1
117
+
lw a2, 0(a1) /* Load the low word of ullNextTime into a2. */
118
+
lw a3, 4(a1) /* Load the high word of ullNextTime into a3. */
119
+
sw a4, 0(a0) /* Low word no smaller than old value to start with - will be overwritten below. */
120
+
sw a3, 4(a0) /* Store high word of ullNextTime into compare register. No smaller than new value. */
121
+
sw a2, 0(a0) /* Store low word of ullNextTime into compare register. */
122
122
lw t0, uxTimerIncrementsForOneTick /* Load the value of ullTimerIncrementForOneTick into t0 (could this be optimized by storing in an array next to pullNextTime?). */
123
-
addt4, t0, t2 /* Add the low word of ullNextTime to the timer increments for one tick (assumes timer increment for one tick fits in 32-bits). */
124
-
sltu t5, t4, t2 /* See if the sum of low words overflowed (what about the zero case?). */
125
-
addt6, t3, t5 /* Add overflow to high word of ullNextTime. */
126
-
sw t4, 0(t1) /* Store new low word of ullNextTime. */
127
-
sw t6, 4(t1) /* Store new high word of ullNextTime. */
123
+
adda4, t0, a2 /* Add the low word of ullNextTime to the timer increments for one tick (assumes timer increment for one tick fits in 32-bits). */
124
+
sltu t1, a4, a2 /* See if the sum of low words overflowed (what about the zero case?). */
125
+
addt2, a3, t1 /* Add overflow to high word of ullNextTime. */
126
+
sw a4, 0(a1) /* Store new low word of ullNextTime. */
127
+
sw t2, 4(a1) /* Store new high word of ullNextTime. */
128
128
129
129
#endif /* __riscv_xlen == 32 */
130
130
131
131
#if( __riscv_xlen == 64 )
132
132
133
133
/* Update the 64-bit mtimer compare match value. */
134
-
ld t2, 0(t1) /* Load ullNextTime into t2. */
135
-
sd t2, 0(t0) /* Store ullNextTime into compare register. */
134
+
ld t2, 0(a1) /* Load ullNextTime into t2. */
135
+
sd t2, 0(a0) /* Store ullNextTime into compare register. */
136
136
ld t0, uxTimerIncrementsForOneTick /* Load the value of ullTimerIncrementForOneTick into t0 (could this be optimized by storing in an array next to pullNextTime?). */
137
137
add t4, t0, t2 /* Add ullNextTime to the timer increments for one tick. */
csrr t0, CSR_MSTATUS/* Obtain current mstatus value. */
208
+
csrr t0, CSR_MSTATUS/* Obtain current mstatus value. */
209
209
andi t0, t0, ~0x8 /* Ensure interrupts are disabled when the stack is restored within an ISR. Required when a task is created after the schedulre has been started, otherwise interrupts would be disabled anyway. */
210
210
addi t1, x0, 0x188 /* Generate the value 0x1880, which are the MPIE and MPP bits to set in mstatus. */
211
211
slli t1, t1, 4
@@ -215,9 +215,13 @@ pxPortInitialiseStack:
215
215
store_x t0, 0(a0) /* mstatus onto the stack. */
216
216
addi a0, a0, -portWORD_SIZE /* Space for critical nesting count. */
217
217
store_x x0, 0(a0) /* Critical nesting count starts at 0 for every task. */
218
-
addi a0, a0, -(22 * portWORD_SIZE) /* Space for registers x11-x31. */
218
+
#ifdef __riscv_32e
219
+
addi a0, a0, -(6 * portWORD_SIZE) /* Space for registers x10-15. */
220
+
#else
221
+
addi a0, a0, -(22 * portWORD_SIZE) /* Space for registers x10-x31. */
222
+
#endif
219
223
store_x a2, 0(a0) /* Task parameters (pvParameters parameter) goes into register X10/a0 on the stack. */
220
-
addi a0, a0, -(6 * portWORD_SIZE) /* Space for registers x5-x9. */
224
+
addi a0, a0, -(6 * portWORD_SIZE) /* Space for registers x5-x9 + taskReturnAddress. */
221
225
load_x t0, xTaskReturnAddress
222
226
store_x t0, 0(a0) /* Return address onto the stack. */
223
227
addi t0, x0, portasmADDITIONAL_CONTEXT_SIZE /* The number of chip specific additional registers. */
@@ -250,6 +254,7 @@ xPortStartFirstTask:
250
254
load_x x13, 10 * portWORD_SIZE( sp ) /* a3 */
251
255
load_x x14, 11 * portWORD_SIZE( sp ) /* a4 */
252
256
load_x x15, 12 * portWORD_SIZE( sp ) /* a5 */
257
+
#ifndef __riscv_32e
253
258
load_x x16, 13 * portWORD_SIZE( sp ) /* a6 */
254
259
load_x x17, 14 * portWORD_SIZE( sp ) /* a7 */
255
260
load_x x18, 15 * portWORD_SIZE( sp ) /* s2 */
@@ -266,12 +271,13 @@ xPortStartFirstTask:
266
271
load_x x29, 26 * portWORD_SIZE( sp ) /* t4 */
267
272
load_x x30, 27 * portWORD_SIZE( sp ) /* t5 */
268
273
load_x x31, 28 * portWORD_SIZE( sp ) /* t6 */
274
+
#endif
269
275
270
-
load_x x5, 29 * portWORD_SIZE( sp ) /* Obtain xCriticalNesting value for this task from task's stack. */
276
+
load_x x5, portCRITICAL_NESTING_OFFSET * portWORD_SIZE( sp ) /* Obtain xCriticalNesting value for this task from task's stack. */
271
277
load_x x6, pxCriticalNesting /* Load the address of xCriticalNesting into x6. */
272
278
store_x x5, 0( x6 ) /* Restore the critical nesting value for this task. */
0 commit comments