Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions ports/risc-v64/gnu/inc/tx_port.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions ports/risc-v64/gnu/src/tx_thread_context_restore.S
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,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. */
Expand Down Expand Up @@ -256,7 +256,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)
Expand Down Expand Up @@ -411,7 +411,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

Expand Down Expand Up @@ -494,14 +494,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


/* } */
Expand Down
2 changes: 1 addition & 1 deletion ports/risc-v64/gnu/src/tx_thread_context_save.S
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,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 */
Expand Down
10 changes: 5 additions & 5 deletions ports/risc-v64/gnu/src/tx_thread_schedule.S
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,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; */
Expand All @@ -118,8 +118,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

Expand Down
4 changes: 2 additions & 2 deletions ports/risc-v64/gnu/src/tx_thread_stack_build.S
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
/* } */
10 changes: 5 additions & 5 deletions ports/risc-v64/gnu/src/tx_thread_system_return.S
Original file line number Diff line number Diff line change
Expand Up @@ -173,24 +173,24 @@ _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

/* Save time-slice for the thread and clear the current time-slice. */
/* _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:
Expand Down
8 changes: 4 additions & 4 deletions ports/risc-v64/gnu/src/tx_timer_interrupt.S
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand All @@ -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) */
Expand Down