feat(kernel): linker and source code

This commit is contained in:
2026-01-26 00:52:13 +01:00
parent 7367da52fb
commit 12f6e05a4e
2 changed files with 77 additions and 0 deletions

28
src/kernel.c Normal file
View File

@@ -0,0 +1,28 @@
typedef unsigned char u8;
typedef unsigned int u32;
typedef u32 size_t;
extern char __bss[], __bss_end[], __stack_top[];
void *memset(void *buf, char c, size_t n) {
u8 *p = (u8 *)buf;
while (n--) {
*p++ = c;
}
return buf;
}
void kernel_main(void) {
memset(__bss, 0, __bss_end - __bss);
for (;;)
;
}
__attribute__((section(".text.boot"))) __attribute__((naked)) void boot(void) {
__asm__ __volatile__("mv sp, %[stack_top]\n"
"j kernel_main\n"
:
: [stack_top] "r"(__stack_top));
}