feat: added UART support with a basic kprint in kernel

wip: DTB
This commit is contained in:
karina
2026-04-20 16:20:31 +04:00
parent ef9aa56d11
commit 635052c8dc
8 changed files with 158 additions and 13 deletions
+10
View File
@@ -0,0 +1,10 @@
#include "bootinfo.h"
#include <stdint.h>
static inline void mmio_write32(uintptr_t addr, uint32_t val) {
*(volatile uint32_t *)addr = val;
}
static inline uint32_t mmio_read32(uintptr_t addr) {
return *(volatile uint32_t *)addr;
}
+36
View File
@@ -0,0 +1,36 @@
#include <stddef.h>
#include <stdint.h>
void* memmove(void* dest, const void* src, unsigned long n) {
unsigned char* d = (unsigned char*)dest;
const unsigned char* s = (const unsigned char*)src;
if (d < s) {
while (n--) *d++ = *s++;
} else {
d += n; s += n;
while (n--) *--d = *--s;
}
return dest;
}
void* memcpy(void* dest, const void* src, unsigned long n) {
return memmove(dest, src, n);
}
void* memset(void* dest, int c, unsigned long n) {
unsigned char* d = (unsigned char*)dest;
while (n--) *d++ = (unsigned char)c;
return dest;
}
// Stack protection
long __stack_chk_guard = (long)0xDEADBEEFCAFEBABEULL;
void __stack_chk_fail(void) { while (1); }
// Swift runtime allocator stubs — should never be called in embedded mode
int posix_memalign(void** ptr, unsigned long align, unsigned long size) {
(void)ptr; (void)align; (void)size;
while (1);
}
void free(void* ptr) { (void)ptr; }