am-tests,microbench,yield-os: CMake support

This commit is contained in:
xinyangli 2024-08-13 20:24:57 +08:00
parent 02b38e7b44
commit 0b911f75ce
Signed by: xin
SSH key fingerprint: SHA256:qZ/tzd8lYRtUFSrfBDBMcUqV4GHKxqeqRA3huItgvbk
13 changed files with 496 additions and 14 deletions

View file

@ -0,0 +1 @@
add_subdirectory(src)

View file

@ -0,0 +1,24 @@
add_executable(am-tests
tests/audio/audio-data.S
tests/audio.c
tests/devscan.c
tests/hello.c
tests/intr.c
tests/keyboard.c
tests/mp.c
tests/rtc.c
tests/video.c
tests/vm.c
main.c
)
# set_property(SOURCE tests/audio/audio-data.S APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/tests/audio/little-star.pcm)
target_include_directories(am-tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../include)
target_link_libraries(am-tests PRIVATE am-${ARCH} klib npcgcc)
# -- Extract binary file from ELF
add_custom_command(TARGET am-tests
COMMAND ${CMAKE_OBJCOPY} ARGS -S --set-section-flags .bss=alloc,contents -O binary am-tests am-tests.bin)
install(TARGETS am-tests RUNTIME DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/am-kernels)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/am-tests.bin DESTINATION ${CMAKE_INSTALL_DATADIR}/am-kernels)

View file

@ -2,5 +2,5 @@
.global audio_payload, audio_payload_end
.p2align 3
audio_payload:
.incbin "src/tests/audio/little-star.pcm"
.incbin "little-star.pcm"
audio_payload_end:

View file

@ -2,6 +2,6 @@
void hello() {
for (int i = 0; i < 10; i ++) {
putstr("Hello, AM World @ " __ISA__ "\n");
putstr("Hello, AM World @ " "__ISA__" "\n");
}
}

View file

@ -1,15 +1,19 @@
#include <amtest.h>
Context *simple_trap(Event ev, Context *ctx) {
switch(ev.event) {
case EVENT_IRQ_TIMER:
putch('t'); break;
case EVENT_IRQ_IODEV:
putch('d'); break;
case EVENT_YIELD:
putch('y'); break;
default:
panic("Unhandled event"); break;
switch (ev.event) {
case EVENT_IRQ_TIMER:
putch('t');
break;
case EVENT_IRQ_IODEV:
putch('d');
break;
case EVENT_YIELD:
putch('y');
break;
default:
panic("Unhandled event");
break;
}
return ctx;
}
@ -20,7 +24,8 @@ void hello_intr() {
io_read(AM_INPUT_CONFIG);
iset(1);
while (1) {
for (volatile int i = 0; i < 10000000; i++) ;
for (volatile int i = 0; i < 10000000; i++)
;
yield();
}
}