Skip to content

Commit 5910de8

Browse files
authored
Merge pull request #506 from akifejaz/qemu-examples
Updated the QEMU examples to match the new RV port format
2 parents 33610aa + cd101d9 commit 5910de8

File tree

3 files changed

+16
-25
lines changed

3 files changed

+16
-25
lines changed

ports/risc-v32/gnu/example_build/qemu_virt/tx_initialize_low_level.S

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
**************************************************************************/
1010

1111
#include "csr.h"
12-
#include "tx_port.h"
1312

1413
.section .text
1514
.align 4
@@ -67,12 +66,12 @@
6766
.extern _tx_thread_context_restore
6867
trap_entry:
6968
#if defined(__riscv_float_abi_single) || defined(__riscv_float_abi_double)
70-
addi sp, sp, -65*REGBYTES // Allocate space for all registers - with floating point enabled
69+
addi sp, sp, -260 // Allocate space for all registers - with floating point enabled (65*4)
7170
#else
72-
addi sp, sp, -32*REGBYTES // Allocate space for all registers - without floating point enabled
71+
addi sp, sp, -128 // Allocate space for all registers - without floating point enabled (32*4)
7372
#endif
7473

75-
STORE x1, 28*REGBYTES(sp) // Store RA, 28*REGBYTES(because call will override ra [ra is a calle register in riscv])
74+
sw x1, 112(sp) // Store RA (28*4 = 112, because call will override ra [ra is a callee register in riscv])
7675

7776
call _tx_thread_context_save
7877

@@ -139,11 +138,6 @@ _err:
139138
.extern board_init
140139
_tx_initialize_low_level:
141140

142-
/* debug print
143-
.section .rodata
144-
debug_str_init:
145-
.string "DEBUG : threadx/ports/risc-v32/gnu/example_build/qemu_virt/tx_initialize_low_level.S, _tx_initialize_low_level\n"
146-
*/
147141
.section .text
148142

149143
la t0, _tx_thread_system_stack_ptr
@@ -166,10 +160,6 @@ debug_str_init:
166160
addi sp, sp, -4
167161
sw ra, 0(sp)
168162
call board_init
169-
/* debug print
170-
la a0, debug_str_init
171-
call uart_puts
172-
*/
173163
lw ra, 0(sp)
174164
addi sp, sp, 4
175165
la t0, trap_entry

ports/risc-v64/gnu/example_build/qemu_virt/demo_threadx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include "tx_api.h"
66
#include "uart.h"
77
#define DEMO_STACK_SIZE 1024
8-
#define DEMO_BYTE_POOL_SIZE 9120
8+
#define DEMO_BYTE_POOL_SIZE 9180
99
#define DEMO_BLOCK_POOL_SIZE 100
1010
#define DEMO_QUEUE_SIZE 100
1111

ports/risc-v64/gnu/example_build/qemu_virt/tx_initialize_low_level.S

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
**************************************************************************/
1010

1111
#include "csr.h"
12-
#include "tx_port.h"
1312

1413
.section .text
1514
.align 4
@@ -67,12 +66,12 @@
6766
.extern _tx_thread_context_restore
6867
trap_entry:
6968
#if defined(__riscv_float_abi_single) || defined(__riscv_float_abi_double)
70-
addi sp, sp, -65*REGBYTES // Allocate space for all registers - with floating point enabled
69+
addi sp, sp, -520 // Allocate space for all registers - with floating point enabled (65*8)
7170
#else
72-
addi sp, sp, -32*REGBYTES // Allocate space for all registers - without floating point enabled
71+
addi sp, sp, -256 // Allocate space for all registers - without floating point enabled (32*8)
7372
#endif
7473

75-
STORE x1, 28*REGBYTES(sp) // Store RA, 28*REGBYTES(because call will override ra [ra is a calle register in riscv])
74+
sd x1, 224(sp) // Store RA (28*8 = 224, because call will override ra [ra is a callee register in riscv])
7675

7776
call _tx_thread_context_save
7877

@@ -138,19 +137,21 @@ _err:
138137
.extern _end
139138
.extern board_init
140139
_tx_initialize_low_level:
141-
sd sp, _tx_thread_system_stack_ptr, t0 // Save system stack pointer
140+
la t0, _tx_thread_system_stack_ptr
141+
sd sp, 0(t0) // Save system stack pointer
142142

143-
la t0, _end // Pickup first free address
144-
sd t0, _tx_initialize_unused_memory, t1 // Save unused memory address
143+
la t0, _end // Pickup first free address
144+
la t1, _tx_initialize_unused_memory
145+
sd t0, 0(t1) // Save unused memory address
145146
li t0, MSTATUS_MIE
146-
csrrc zero, mstatus, t0 // clear MSTATUS_MIE bit
147+
csrrc zero, mstatus, t0 // clear MSTATUS_MIE bit
147148
li t0, (MSTATUS_MPP_M | MSTATUS_MPIE )
148-
csrrs zero, mstatus, t0 // set MSTATUS_MPP, MPIE bit
149+
csrrs zero, mstatus, t0 // set MSTATUS_MPP, MPIE bit
149150
li t0, (MIE_MTIE | MIE_MSIE | MIE_MEIE)
150-
csrrs zero, mie, t0 // set mie
151+
csrrs zero, mie, t0 // set mie
151152
#ifdef __riscv_flen
152153
li t0, MSTATUS_FS
153-
csrrs zero, mstatus, t0 // set MSTATUS_FS bit to open f/d isa in riscv
154+
csrrs zero, mstatus, t0 // set MSTATUS_FS bit to open f/d isa in riscv
154155
fscsr x0
155156
#endif
156157
addi sp, sp, -8

0 commit comments

Comments
 (0)