diff options
author | Benji Dial <benji6283@gmail.com> | 2020-09-06 00:48:07 -0400 |
---|---|---|
committer | Benji Dial <benji6283@gmail.com> | 2020-09-06 00:48:07 -0400 |
commit | e8c6577617bffa4402c07c7aa20e3c24f03c1c20 (patch) | |
tree | 2fb9230b62d2344a44453117de9e656892219788 /src/user/init/main.c | |
parent | 7ff724fe8f709440da9c730fdb8dcbaa4f989ed5 (diff) | |
download | portland-os-e8c6577617bffa4402c07c7aa20e3c24f03c1c20.tar.gz |
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
Diffstat (limited to 'src/user/init/main.c')
-rw-r--r-- | src/user/init/main.c | 29 |
1 files changed, 21 insertions, 8 deletions
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 <pland.h> -#include <canyo/file.h> +#include <knob/user.h> +#include <knob/file.h> +#include <knob/heap.h> 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"); } |