Reverted ULONG to be 4 bytes long, fixing missaligment issue in the current port (#534)

* Reverted RISCV-64 port

* Fixed wrong load/store instructions used
This commit is contained in:
Christos Papadopoulos
2026-05-25 16:12:33 -04:00
committed by GitHub
parent c7d4b2f228
commit 5b1b740a66
7 changed files with 28 additions and 27 deletions
+4 -3
View File
@@ -77,15 +77,16 @@ typedef char CHAR;
typedef unsigned char UCHAR;
typedef int INT;
typedef unsigned int UINT;
typedef long LONG;
typedef unsigned long ULONG;
typedef int LONG;
typedef unsigned int ULONG;
typedef unsigned long long ULONG64;
typedef short SHORT;
typedef unsigned short USHORT;
#define ULONG64_DEFINED
#endif /* __ASSEMBLER__ */
#define ALIGN_TYPE_DEFINED
typedef unsigned long long ALIGN_TYPE;
/* Define the priority levels for ThreadX. Legal values range
@@ -78,9 +78,9 @@ _tx_thread_context_restore:
{ */
la t0, _tx_thread_system_state // Pickup addr of nested interrupt count
ld t1, 0(t0) // Pickup nested interrupt count
lw t1, 0(t0) // Pickup nested interrupt count
addi t1, t1, -1 // Decrement the nested interrupt counter
sd t1, 0(t0) // Store new nested count
sw t1, 0(t0) // Store new nested count
beqz t1, _tx_thread_not_nested_restore // If 0, not nested restore
/* Interrupts are nested. */
@@ -283,7 +283,7 @@ _tx_thread_no_preempt_restore:
/* Pickup the saved stack pointer. */
/* sp = _tx_thread_current_ptr -> tx_thread_stack_ptr; */
ld sp, 16(t1) // Switch back to thread's stack
ld sp, 8(t1) // Switch back to thread's stack
/* Recover floating point registers. */
#if defined(__riscv_float_abi_single)
@@ -460,7 +460,7 @@ _tx_thread_preempt_restore:
/* Instead of directly activating the thread again, ensure we save the
entire stack frame by saving the remaining registers. */
ld t0, 16(t1) // Pickup thread's stack pointer
ld t0, 8(t1) // Pickup thread's stack pointer
ori t3, zero, 1 // Build interrupt stack type
sd t3, 0(t0) // Store stack type
@@ -543,14 +543,14 @@ _tx_thread_preempt_restore:
{ */
la t0, _tx_timer_time_slice // Pickup time slice variable address
ld t2, 0(t0) // Pickup time slice
lw t2, 0(t0) // Pickup time slice
beqz t2, _tx_thread_dont_save_ts // If 0, skip time slice processing
/* _tx_thread_current_ptr -> tx_thread_time_slice = _tx_timer_time_slice
_tx_timer_time_slice = 0; */
sd t2, 48(t1) // Save current time slice
sd x0, 0(t0) // Clear global time slice
sw t2, 36(t1) // Save current time slice
sw x0, 0(t0) // Clear global time slice
/* } */
@@ -312,7 +312,7 @@ _tx_thread_not_nested_save:
la t1, _tx_thread_current_ptr // Pickup current thread pointer address
ld t1, 0(t1) // Pickup current thread pointer
sd sp, 16(t1) // Save stack pointer
sd sp, 8(t1) // Save stack pointer
#ifdef TX_ENABLE_EXECUTION_CHANGE_NOTIFY
/* _tx_execution_isr_enter is called with thread stack pointer */
+5 -5
View File
@@ -113,10 +113,10 @@ _tx_thread_schedule_loop:
/* Increment the run count for this thread. */
/* _tx_thread_current_ptr -> tx_thread_run_count++; */
ld t2, 8(t1) // Pickup run count
ld t3, 48(t1) // Pickup time slice value
lw t2, 4(t1) // Pickup run count
lw t3, 36(t1) // Pickup time slice value
addi t2, t2, 1 // Increment run count
sd t2, 8(t1) // Store new run count
sw t2, 4(t1) // Store new run count
/* Setup time-slice, if present. */
/* _tx_timer_time_slice = _tx_thread_current_ptr -> tx_thread_time_slice; */
@@ -126,8 +126,8 @@ _tx_thread_schedule_loop:
/* Switch to the thread's stack. */
/* SP = _tx_thread_execute_ptr -> tx_thread_stack_ptr; */
ld sp, 16(t1) // Switch to thread's stack
sd t3, 0(t2) // Store new time-slice
ld sp, 8(t1) // Switch to thread's stack
sw t3, 0(t2) // Store new time-slice
#ifdef TX_ENABLE_EXECUTION_CHANGE_NOTIFY
@@ -140,7 +140,7 @@ If vector extension support:
Stack Bottom: (higher memory address) */
ld t0, 32(a0) // Pickup end of stack area
ld t0, 24(a0) // Pickup end of stack area
li t1, ~15 // Build 16-byte alignment mask
and t0, t0, t1 // Make sure 16-byte alignment
@@ -258,6 +258,6 @@ vector_clear_done:
/* Setup stack pointer. */
/* thread_ptr -> tx_thread_stack_ptr = t0; */
sd t0, 16(a0) // Save stack pointer in thread's
sd t0, 8(a0) // Save stack pointer in thread's
ret // control block and return
/* } */
@@ -183,15 +183,15 @@ _tx_thread_system_return:
/* _tx_thread_current_ptr -> tx_thread_stack_ptr = SP;
SP = _tx_thread_system_stack_ptr; */
sd sp, 16(t1) // Save stack pointer
ld sp, 0(t2) // Switch to system stack
sd sp, 8(t1) // Save stack pointer
ld sp, 0(t2) // Switch to system stack
/* Determine if the time-slice is active. */
/* if (_tx_timer_time_slice)
{ */
la t4, _tx_timer_time_slice // Pickup time slice variable addr
ld t3, 0(t4) // Pickup time slice value
lw t3, 0(t4) // Pickup time slice value
la t2, _tx_thread_schedule // Pickup address of scheduling loop
beqz t3, _tx_thread_dont_save_ts // If no time-slice, don't save it
@@ -199,8 +199,8 @@ _tx_thread_system_return:
/* _tx_thread_current_ptr -> tx_thread_time_slice = _tx_timer_time_slice;
_tx_timer_time_slice = 0; */
sd t3, 48(t1) // Save current time-slice for thread
sd zero, 0(t4) // Clear time-slice variable
sw t3, 36(t1) // Save current time-slice for thread
sw zero, 0(t4) // Clear time-slice variable
/* } */
_tx_thread_dont_save_ts:
+4 -4
View File
@@ -66,11 +66,11 @@ _tx_timer_interrupt:
/* _tx_timer_system_clock++; */
la t0, _tx_timer_system_clock // Pickup address of system clock
ld t1, 0(t0) // Pickup system clock
lw t1, 0(t0) // Pickup system clock
la t2, _tx_timer_time_slice // Pickup address of time slice
ld t3, 0(t2) // Pickup time slice
lw t3, 0(t2) // Pickup time slice
addi t1, t1, 1 // Increment system clock
sd t1, 0(t0) // Store new system clock
sw t1, 0(t0) // Store new system clock
li t6, 0 // Clear local expired flag
/* Test for time-slice expiration. */
@@ -83,7 +83,7 @@ _tx_timer_interrupt:
/* Decrement the time_slice. */
/* _tx_timer_time_slice--; */
sd t3, 0(t2) // Store new time slice
sw t3, 0(t2) // Store new time slice
/* Check for expiration. */
/* if (_tx_timer_time_slice == 0) */