first user application

This commit is contained in:
2025-07-29 08:47:34 +03:00
parent 5dfff307df
commit 2a6266566a
6 changed files with 79 additions and 14 deletions

22
user.c Normal file
View File

@@ -0,0 +1,22 @@
#include "user.h"
extern char __stack_top[];
__attribute__((noreturn)) void exit(void) {
for(;;);
}
void putchar(char ch) {
// TODO
}
__attribute__((section(".text.start")))
__attribute__((naked))
void start(void) {
__asm__ __volatile__(
"mv sp, %[stack_top]\n"
"call main\n"
"call exit\n"
:: [stack_top] "r" (__stack_top)
);
}