refactor: use cmake macros to do objcopy, install and tests
All checks were successful
All checks were successful
This commit is contained in:
parent
f6c3a13e7f
commit
8630fe7667
12 changed files with 64 additions and 54 deletions
|
@ -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)
|
||||
|
|
|
@ -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!");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue