Implement serial logging. Finish modularizing power management.
[monolithium.git] / kernel / src / exec / aout.c
index ea6aace71395dd83449731e89d24b1a266978d91..6d071962b88a9987e458b0a3a519c101e0cb335d 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * aout.c
- * 
+ *
  * Copyright (C) 2016 Aleksandar Andrejevic <theflash@sdf.lonestar.org>
- * 
+ *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Affero General Public License as
  * published by the Free Software Foundation, either version 3 of the
@@ -22,7 +22,7 @@
 #include <heap.h>
 #include <syscalls.h>
 
-dword_t load_aout(handle_t file, process_params_t *parameters, thread_state_t *initial_state)
+dword_t load_aout(handle_t file, thread_state_t *initial_state)
 {
     aout_header_t header;
     size_t bytes_read;
@@ -49,12 +49,10 @@ dword_t load_aout(handle_t file, process_params_t *parameters, thread_state_t *i
                   0x200000,
                   MEMORY_BLOCK_ACCESSIBLE | MEMORY_BLOCK_WRITABLE | MEMORY_BLOCK_USERMODE | MEMORY_BLOCK_EVICTABLE);
     if (ret != ERR_SUCCESS) return ret;
-    initial_state->regs.esp = (uintptr_t)address + 0x200000 - (MAX_PARAMETERS * sizeof(uintptr_t)) - sizeof(process_params_t);
 
-    *(process_params_t*)initial_state->regs.esp = *parameters;
-    push_to_stack(&initial_state->regs.esp, initial_state->regs.esp);
+    initial_state->regs.esp = (uintptr_t)address + 0x200000;
 
-    address = (void*)0x100000;
+    address = (void*)0x1000;
 
     switch (header.midmag & 0xFFFF)
     {
@@ -98,8 +96,8 @@ dword_t load_aout(handle_t file, process_params_t *parameters, thread_state_t *i
                       INVALID_HANDLE,
                       section,
                       &address,
-                      0ULL,
-                      PAGE_ALIGN_UP(header.text_size + sizeof(aout_header_t)),
+                      (qword_t)sizeof(aout_header_t),
+                      PAGE_ALIGN_UP(header.text_size),
                       MEMORY_BLOCK_ACCESSIBLE
                       | MEMORY_BLOCK_WRITABLE
                       | MEMORY_BLOCK_USERMODE
@@ -145,7 +143,7 @@ dword_t load_aout(handle_t file, process_params_t *parameters, thread_state_t *i
         }
 
         syscall(SYSCALL_CLOSE_OBJECT, section);
-        initial_state->regs.eip = (uintptr_t)address + header.entry_point + sizeof(aout_header_t);
+        initial_state->regs.eip = (uintptr_t)address + header.entry_point;
         break;
     }