-
Notifications
You must be signed in to change notification settings - Fork 919
Optimize stack management, fix preemption, and add automated QEMU testing for RISC-V32 port #513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
6dee013
85d0626
aad13e8
633629d
fedd124
ae13c5b
39ede67
a1b2457
4425c5b
fa9b870
ae2aa03
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| .tmp/ | ||
| _deps/ | ||
| build/ | ||
| build_qemu/ | ||
| Debug/ | ||
| CMakeFiles/ | ||
| CMakeScripts/ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -112,7 +112,7 @@ void tx_application_define(void *first_unused_memory) | |
|
|
||
| tx_thread_create(&thread_2, "thread 2", thread_2_entry, 2, | ||
| pointer, DEMO_STACK_SIZE, | ||
| 16, 16, 4, TX_AUTO_START); | ||
| 10, 10, 4, TX_AUTO_START); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why we need this? |
||
|
|
||
| /* Allocate the stack for thread 3. */ | ||
| tx_byte_allocate(&byte_pool_0, (VOID **) &pointer, DEMO_STACK_SIZE, TX_NO_WAIT); | ||
|
|
@@ -201,7 +201,7 @@ UINT status; | |
| thread_0_counter++; | ||
|
|
||
| /* Sleep for 10 ticks. */ | ||
| tx_thread_sleep(10); | ||
| tx_thread_sleep(1); | ||
|
|
||
| /* Set event flag 0 to wakeup thread 5. */ | ||
| status = tx_event_flags_set(&event_flags_0, 0x1, TX_OR); | ||
|
|
@@ -337,6 +337,7 @@ ULONG actual_flags; | |
| } | ||
| } | ||
|
|
||
| float fpu_test_val = 0.0f; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this can be moved to top after other #defines. |
||
|
|
||
| void thread_6_and_7_entry(ULONG thread_input) | ||
| { | ||
|
|
@@ -363,6 +364,9 @@ UINT status; | |
| if (status != TX_SUCCESS) | ||
| break; | ||
|
|
||
| /* FPU Test*/ | ||
| fpu_test_val += 1.1f; | ||
|
|
||
| /* Get the mutex again with suspension. This shows | ||
| that an owning thread may retrieve the mutex it | ||
| owns multiple times. */ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
|
|
||
| .section .text | ||
| .section .init | ||
| .align 4 | ||
| .global _start | ||
| .extern main | ||
|
|
@@ -11,7 +11,10 @@ _start: | |
| bne t0, zero, 1f | ||
| li x1, 0 | ||
| li x2, 0 | ||
| li x3, 0 | ||
| .option push | ||
| .option norelax | ||
| la gp, __global_pointer$ | ||
| .option pop | ||
|
Comment on lines
+14
to
+17
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. x3 register is missing. also I'm not sure why we need to change .text to .init. |
||
| li x4, 0 | ||
| li x5, 0 | ||
| li x6, 0 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |
| **************************************************************************/ | ||
|
|
||
| #include "csr.h" | ||
| #include "tx_port.h" | ||
|
|
||
| .section .text | ||
| .align 4 | ||
|
|
@@ -21,6 +22,7 @@ | |
| /* AUTHOR */ | ||
| /* */ | ||
| /* Akif Ejaz, 10xEngineers */ | ||
| /* Wei-Chen Lai, National Cheng Kung University */ | ||
| /* */ | ||
| /* DESCRIPTION */ | ||
| /* */ | ||
|
|
@@ -60,13 +62,13 @@ | |
| .extern trap_handler | ||
| .extern _tx_thread_context_restore | ||
| trap_entry: | ||
| #if defined(__riscv_float_abi_single) || defined(__riscv_float_abi_double) | ||
| addi sp, sp, -260 // Allocate space for all registers - with floating point enabled (65*4) | ||
| #if defined(__riscv_flen) && ((__riscv_flen == 32)||(__riscv_flen == 64)) | ||
| addi sp, sp, -65*REGBYTES // Allocate space for all registers - with floating point enabled | ||
| #else | ||
| addi sp, sp, -128 // Allocate space for all registers - without floating point enabled (32*4) | ||
| addi sp, sp, -32*REGBYTES // Allocate space for all registers - without floating point enabled | ||
| #endif | ||
|
|
||
| sw x1, 112(sp) // Store RA (28*4 = 112, because call will override ra [ra is a callee register in riscv]) | ||
| STORE x1, 28*REGBYTES(sp) // Store RA, 28*REGBYTES(because call will override ra [ra is a calle register in riscv]) | ||
|
Comment on lines
+65
to
+71
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here we intentionally used the hardcoded numbers, so we do not have to include .h file in .S files. |
||
|
|
||
| call _tx_thread_context_save | ||
|
|
||
|
|
@@ -133,6 +135,11 @@ _err: | |
| .extern board_init | ||
| _tx_initialize_low_level: | ||
|
|
||
| /* debug print | ||
| .section .rodata | ||
| debug_str_init: | ||
| .string "DEBUG : threadx/ports/risc-v32/gnu/example_build/qemu_virt/tx_initialize_low_level.S, _tx_initialize_low_level\n" | ||
| */ | ||
| .section .text | ||
|
|
||
| la t0, _tx_thread_system_stack_ptr | ||
|
|
@@ -155,6 +162,10 @@ _tx_initialize_low_level: | |
| addi sp, sp, -4 | ||
| sw ra, 0(sp) | ||
| call board_init | ||
| /* debug print | ||
| la a0, debug_str_init | ||
| call uart_puts | ||
| */ | ||
| lw ra, 0(sp) | ||
| addi sp, sp, 4 | ||
| la t0, trap_entry | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is port/ level cmake, lets move this under ports/riscv32/ if possible.