refactor: use cmake macros to do objcopy, install and tests
All checks were successful
Build nix packages / build-matrix (am-kernels) (push) Successful in 2m26s
Build nix packages / build-matrix (rv32Cross.am-kernels-nemu) (push) Successful in 2m23s
Build nix packages / build-matrix (rv32Cross.am-kernels-npc) (push) Successful in 2m21s

This commit is contained in:
xinyangli 2024-08-15 17:52:04 +08:00
parent f6c3a13e7f
commit 8630fe7667
Signed by: xin
SSH key fingerprint: SHA256:qZ/tzd8lYRtUFSrfBDBMcUqV4GHKxqeqRA3huItgvbk
12 changed files with 64 additions and 54 deletions

View file

@ -7,5 +7,5 @@ target_link_libraries(yield-os PRIVATE am-${ARCH} klib)
add_custom_command(TARGET yield-os
COMMAND ${CMAKE_OBJCOPY} ARGS -S --set-section-flags .bss=alloc,contents -O binary yield-os yield-os.bin)
install(TARGETS yield-os RUNTIME DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/am-kernels)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/yield-os.bin DESTINATION ${CMAKE_INSTALL_DATADIR}/am-kernels)
create_binary(yield-os)
install_target_and_binary(yield-os)

View file

@ -4,16 +4,20 @@
#define STACK_SIZE (4096 * 8)
typedef union {
uint8_t stack[STACK_SIZE];
struct { Context *cp; };
struct {
Context *cp;
};
} PCB;
static PCB pcb[2], pcb_boot, *current = &pcb_boot;
static void f(void *arg) {
while (1) {
for (int i = 0; i < 100; i++) {
putch("?AB"[(uintptr_t)arg > 2 ? 0 : (uintptr_t)arg]);
for (int volatile i = 0; i < 100000; i++) ;
for (int volatile i = 0; i < 100000; i++)
;
yield();
}
halt(0);
}
static Context *schedule(Event ev, Context *prev) {
@ -24,8 +28,8 @@ static Context *schedule(Event ev, Context *prev) {
int main() {
cte_init(schedule);
pcb[0].cp = kcontext((Area) { pcb[0].stack, &pcb[0] + 1 }, f, (void *)1L);
pcb[1].cp = kcontext((Area) { pcb[1].stack, &pcb[1] + 1 }, f, (void *)2L);
pcb[0].cp = kcontext((Area){pcb[0].stack, &pcb[0] + 1}, f, (void *)1L);
pcb[1].cp = kcontext((Area){pcb[1].stack, &pcb[1] + 1}, f, (void *)2L);
yield();
panic("Should not reach here!");
}