summaryrefslogtreecommitdiff
path: root/Kernel/Process.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-06-02 09:50:18 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-06-02 09:53:42 +0200
commit4320c5fd58a3c313bc3551b266de725b51a9732b (patch)
tree50761f16757dc2c832b5b344735c92d36867cc50 /Kernel/Process.cpp
parent8454d3e184499feec4b7c623191087b110fd9728 (diff)
downloadserenity-4320c5fd58a3c313bc3551b266de725b51a9732b.zip
Kernel: Make better use of the multiboot info.
Define the multiboot info struct properly so we don't have to grab at byte offsets in the memory access checker code. Also print kernel command line in init().
Diffstat (limited to 'Kernel/Process.cpp')
-rw-r--r--Kernel/Process.cpp28
1 files changed, 4 insertions, 24 deletions
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp
index d8d7767241..5b84737ac2 100644
--- a/Kernel/Process.cpp
+++ b/Kernel/Process.cpp
@@ -25,6 +25,7 @@
#include <Kernel/SharedMemory.h>
#include <Kernel/ProcessTracer.h>
#include <Kernel/FileSystem/Custody.h>
+#include <Kernel/Multiboot.h>
//#define DEBUG_POLL_SELECT
//#define DEBUG_IO
@@ -1433,33 +1434,12 @@ enum class KernelMemoryCheckResult {
AccessDenied
};
-// FIXME: Nothing about this is really super...
-// This structure is only present at offset 28 in the main multiboot info struct
-// if bit 5 of offset 0 (flags) is set. We're just assuming that the flag is set.
-//
-// Also, there's almost certainly a better way to get that information here than
-// a global set by boot.S
-//
-// Also I'm not 100% sure any of this is correct...
-
-struct mb_elf {
- uint32_t num;
- uint32_t size;
- uint32_t addr;
- uint32_t shndx;
-};
-
-extern "C" {
-void* multiboot_ptr;
-}
-
static KernelMemoryCheckResult check_kernel_memory_access(LinearAddress laddr, bool is_write)
{
- // FIXME: It would be better to have a proper structure for this...
- auto* sections = (const mb_elf*)((const byte*)multiboot_ptr + 28);
+ auto& sections = multiboot_info_ptr->u.elf_sec;
- auto* kernel_program_headers = (Elf32_Phdr*)(sections->addr);
- for (unsigned i = 0; i < sections->num; ++i) {
+ auto* kernel_program_headers = (Elf32_Phdr*)(sections.addr);
+ for (unsigned i = 0; i < sections.num; ++i) {
auto& segment = kernel_program_headers[i];
if (segment.p_type != PT_LOAD || !segment.p_vaddr || !segment.p_memsz)
continue;