diff options
author | Matthew Sotoudeh <matthewsot@outlook.com> | 2022-05-10 21:59:56 -0700 |
---|---|---|
committer | Matthew Sotoudeh <matthewsot@outlook.com> | 2022-05-10 21:59:56 -0700 |
commit | 33cb209e04e89d2a84cb8cdb7e5ba60f31798e2f (patch) | |
tree | cf067c2e0465c6c1d0e2fccb3f04e0d87e8708ca | |
parent | 804f600df9cb0af1e5523ba91452d30cc0daf397 (diff) |
verify that exo actually works when things are 'really' picmatthew-exo-pic
-rw-r--r-- | kern/kern.c | 12 | ||||
-rw-r--r-- | libc/tinyprintf.c | 25 | ||||
-rw-r--r-- | libc/tinyprintf.h | 2 |
3 files changed, 24 insertions, 15 deletions
diff --git a/kern/kern.c b/kern/kern.c index a1ea749..1ff5382 100644 --- a/kern/kern.c +++ b/kern/kern.c @@ -42,16 +42,20 @@ static void unmap_low_pages() { for (uintptr_t pa = (uintptr_t) &__code_start__; pa < (uintptr_t) &__code_end__; pa += page_size) { vm_unmap(pa); } +#if 0 // map heap extern char __heap_start__; for (uintptr_t pa = (uintptr_t) &__heap_start__; pa < heap_end; pa += page_size) { vm_unmap(pa); } +#endif // map uart, gpio, watchdog timer vm_unmap(0x20100000); +#if 0 for (unsigned i = 0; i < 64; i++) { vm_unmap(0x20200000 + page_size * i); } +#endif sys_prefetch_flush(); sys_flush_btb(); sys_clean_and_invalidate_cache(); @@ -71,8 +75,12 @@ void kernel_start() { vm_enable(); jump_to_ka(); - /* unmap_low_pages(); */ + unmap_low_pages(); + + printf("Hello, World!\n"); + + reboot(); - printf("kernel booted\n"); + // printf("kernel booted\n"); return; } diff --git a/libc/tinyprintf.c b/libc/tinyprintf.c index a7a528d..e6cfc73 100644 --- a/libc/tinyprintf.c +++ b/libc/tinyprintf.c @@ -21,6 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "tinyprintf.h" +void uart_putc(void* p, char c); + /* * Configuration */ @@ -188,7 +190,8 @@ static char a2u(char ch, const char** src, int base, unsigned int* nump) { return ch; } -static void putchw(void* putp, putcf putf, struct param* p) { +#define putf uart_putc +static void putchw(void* putp, struct param* p) { char ch; int n = p->width; char* bf = p->bf; @@ -239,7 +242,7 @@ static void putchw(void* putp, putcf putf, struct param* p) { } } -void tfp_format(void* putp, putcf putf, const char* fmt, va_list va) { +void tfp_format(void* putp, const char* fmt, va_list va) { struct param p; #ifdef PRINTF_LONG_SUPPORT char bf[23]; /* long = 64b on some architectures */ @@ -339,7 +342,7 @@ void tfp_format(void* putp, putcf putf, const char* fmt, va_list va) { else #endif ui2a(va_arg(va, unsigned int), &p); - putchw(putp, putf, &p); + putchw(putp, &p); break; case 'd': case 'i': @@ -355,7 +358,7 @@ void tfp_format(void* putp, putcf putf, const char* fmt, va_list va) { else #endif i2a(va_arg(va, int), &p); - putchw(putp, putf, &p); + putchw(putp, &p); break; #ifdef SIZEOF_POINTER case 'p': @@ -383,19 +386,19 @@ void tfp_format(void* putp, putcf putf, const char* fmt, va_list va) { else #endif ui2a(va_arg(va, unsigned int), &p); - putchw(putp, putf, &p); + putchw(putp, &p); break; case 'o': p.base = 8; ui2a(va_arg(va, unsigned int), &p); - putchw(putp, putf, &p); + putchw(putp, &p); break; case 'c': putf(putp, (char) (va_arg(va, int))); break; case 's': p.bf = va_arg(va, char*); - putchw(putp, putf, &p); + putchw(putp, &p); p.bf = bf; break; case '%': @@ -409,18 +412,16 @@ abort:; } #if TINYPRINTF_DEFINE_TFP_PRINTF -static putcf stdout_putf; static void* stdout_putp; void init_printf(void* putp, putcf putf) { - stdout_putf = putf; stdout_putp = putp; } void tfp_printf(char* fmt, ...) { va_list va; va_start(va, fmt); - tfp_format(stdout_putp, stdout_putf, fmt, va); + tfp_format(stdout_putp, fmt, va); va_end(va); } #endif @@ -448,7 +449,7 @@ int tfp_vsnprintf(char* str, size_t size, const char* format, va_list ap) { data.dest = str; data.dest_capacity = size - 1; data.num_chars = 0; - tfp_format(&data, _vsnprintf_putcf, format, ap); + tfp_format(&data, format, ap); if (data.num_chars < data.dest_capacity) data.dest[data.num_chars] = '\0'; @@ -482,7 +483,7 @@ int tfp_vsprintf(char* str, const char* format, va_list ap) { struct _vsprintf_putcf_data data; data.dest = str; data.num_chars = 0; - tfp_format(&data, _vsprintf_putcf, format, ap); + tfp_format(&data, format, ap); data.dest[data.num_chars] = '\0'; return data.num_chars; } diff --git a/libc/tinyprintf.h b/libc/tinyprintf.h index d61ea96..70c38aa 100644 --- a/libc/tinyprintf.h +++ b/libc/tinyprintf.h @@ -154,7 +154,7 @@ typedef void (*putcf)(void*, char); The 'tfp_printf' and 'tfp_sprintf' functions simply define their own callback and pass to it the right 'putp' it is expecting. */ -void tfp_format(void* putp, putcf putf, const char* fmt, va_list va); +void tfp_format(void* putp, const char* fmt, va_list va); #if TINYPRINTF_DEFINE_TFP_SPRINTF int tfp_vsnprintf(char* str, size_t size, const char* fmt, va_list ap); |