From 46007d2598b7aef13895b21669cfb6f24272e5fe Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Mon, 27 Apr 2020 23:13:36 +0200 Subject: Minor but important fixes in processing --- CMakeLists.txt | 2 +- src/kernel/fs/elf.c | 4 ++-- src/kernel/kernel.c | 3 +++ src/kernel/tasks/process.h | 2 +- src/userspace/linker.ld | 21 +++++++++++++-------- 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 14436e4..ff06f04 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,7 +55,7 @@ add_custom_command( add_executable(user ${user_sources}) target_include_directories(user PUBLIC "src/userspace/") set_target_properties(user PROPERTIES OUTPUT_NAME "${CMAKE_CURRENT_SOURCE_DIR}/build/user.o") -target_link_libraries(kernel PRIVATE "-T ${CMAKE_CURRENT_SOURCE_DIR}/src/userspace/linker.ld") +target_link_libraries(user PRIVATE "-T ${CMAKE_CURRENT_SOURCE_DIR}/src/userspace/linker.ld") # Dependencies add_dependencies(kernel resources user) diff --git a/src/kernel/fs/elf.c b/src/kernel/fs/elf.c index aea191b..ec22d77 100644 --- a/src/kernel/fs/elf.c +++ b/src/kernel/fs/elf.c @@ -33,7 +33,8 @@ struct process *elf_load(char *path) struct elf_program_header *program_header = (void *)header + header->phoff; if (!is_elf(header)) { - panic("File not valid"); + warn("File not valid: %s", path); + return NULL; } else { debug("File is valid: %s", path); } @@ -53,7 +54,6 @@ struct process *elf_load(char *path) case 0: break; case 1: - i += 0; debug("Allocating space for ELF binary section..."); uint32_t loc = (uint32_t)kmalloc_a(PAGE_S); paging_map_user(proc->cr3, loc, program_header->vaddr); diff --git a/src/kernel/kernel.c b/src/kernel/kernel.c index 83e0b35..662bb57 100644 --- a/src/kernel/kernel.c +++ b/src/kernel/kernel.c @@ -65,6 +65,9 @@ void kernel_main(uint32_t magic, uint32_t multiboot_address) syscalls_install(); struct process *proc = elf_load("/bin/user"); + proc->stdin = NULL; + proc->stdout = NULL; + proc->stderr = NULL; process_init(proc); halt_loop(); diff --git a/src/kernel/tasks/process.h b/src/kernel/tasks/process.h index df0f51f..fc277f4 100644 --- a/src/kernel/tasks/process.h +++ b/src/kernel/tasks/process.h @@ -23,7 +23,7 @@ struct process { int state; int thread; - uint32_t stdint; + uint32_t stdin; uint32_t stdout; uint32_t stderr; diff --git a/src/userspace/linker.ld b/src/userspace/linker.ld index d793912..8ede485 100644 --- a/src/userspace/linker.ld +++ b/src/userspace/linker.ld @@ -1,19 +1,24 @@ ENTRY(_start) - -SECTIONS { - .text : { +SECTIONS +{ + .text 0x40000000: + { + code = .; _code = .; __code = .; *(.text) - . = ALIGN(4096); } - .data : { + .data ALIGN(0x400000): + { + data = .; _data = .; __data = .; *(.data) *(.rodata) - . = ALIGN(4096); } - .bss : { + .bss ALIGN(0x400000): + { + bss = .; _bss = .; __bss = .; *(.bss) - . = ALIGN(4096); } + + end = .; _end = .; __end = .; } \ No newline at end of file -- cgit v1.2.3