From e8c6577617bffa4402c07c7aa20e3c24f03c1c20 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Sun, 6 Sep 2020 00:48:07 -0400 Subject: program loading, others big kernel additions: paging, elf loading, separate kernel and user page allocation it now properly loads and runs sd0:bin/init.elf still need to determine which disk was booted from, and start the init on that disk --- src/user/init/main.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'src/user/init') diff --git a/src/user/init/main.c b/src/user/init/main.c index 002fd92..9a411e7 100644 --- a/src/user/init/main.c +++ b/src/user/init/main.c @@ -1,16 +1,29 @@ -#include -#include +#include +#include +#include void main() { - fs_handle f = fs_open("sys/startup.rc"); + tell_user_sz("\n\nThis is a userland program.\n"); + + tell_user_sz("Opening sd0:TEST.TXT.\n"); + struct file *f = open_file("sd0:TEST.TXT"); if (!f) { - vga_printsz("Couldn't open sys/startup.rc\n"); + tell_user_sz("Failed to open.\n"); return; } - uint8_t line_buffer[128]; - while (read_line(f, 128, line_buffer)) - plef_run(line_buffer); + tell_user_sz("Length: "); + uint32_t size = file_size(f); + tell_user_n(size); + tell_user_sz(" bytes\n\nContents:\n"); + + char *buf = get_block(size + 1); + read_from_file(f, size, buf); + buf[size] = '\0'; + + close_file(f); + + tell_user_sz(buf); - fs_close(f); + tell_user_sz("\n\nGoodbye!\n"); } -- cgit v1.2.3