Skip to content

Commit 633629d

Browse files
committed
feat: add RISC-V QEMU demo support and fix assembly implementation
1 parent aad13e8 commit 633629d

7 files changed

Lines changed: 178220 additions & 12 deletions

File tree

CMakeLists.txt

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,33 @@ set(CPACK_SOURCE_IGNORE_FILES
6969
".*~$"
7070
)
7171
set(CPACK_VERBATIM_VARIABLES YES)
72-
include(CPack)
72+
include(CPack)
73+
74+
# Enable the QEMU Virt demo application (Target: kernel.elf)
75+
set(QEMU_DEMO_DIR ${CMAKE_CURRENT_LIST_DIR}/ports/risc-v32/gnu/example_build/qemu_virt)
76+
77+
add_executable(kernel.elf
78+
${QEMU_DEMO_DIR}/demo_threadx.c
79+
${QEMU_DEMO_DIR}/entry.s
80+
${QEMU_DEMO_DIR}/uart.c
81+
${QEMU_DEMO_DIR}/plic.c
82+
${QEMU_DEMO_DIR}/hwtimer.c
83+
${QEMU_DEMO_DIR}/trap.c
84+
${QEMU_DEMO_DIR}/board.c
85+
${QEMU_DEMO_DIR}/tx_initialize_low_level.S
86+
)
87+
88+
target_link_libraries(kernel.elf PRIVATE threadx)
89+
90+
target_include_directories(kernel.elf PRIVATE
91+
${CMAKE_CURRENT_LIST_DIR}/common/inc
92+
${CMAKE_CURRENT_LIST_DIR}/ports/${THREADX_ARCH}/${THREADX_TOOLCHAIN}/inc
93+
${QEMU_DEMO_DIR}
94+
)
95+
96+
# Linker options
97+
target_link_options(kernel.elf PRIVATE
98+
-T${QEMU_DEMO_DIR}/link.lds
99+
-nostartfiles
100+
-Wl,-Map=kernel.map
101+
)

ports/risc-v32/gnu/example_build/qemu_virt/entry.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
.section .text
2+
.section .init
33
.align 4
44
.global _start
55
.extern main

ports/risc-v32/gnu/example_build/qemu_virt/link.lds

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ SECTIONS
88
* where qemu's -kernel jumps.
99
*/
1010
. = 0x80000000;
11+
12+
.init : {
13+
KEEP (*(.init))
14+
}
1115

1216
.text : {
1317
*(.text .text.*)

0 commit comments

Comments
 (0)