diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-29 22:38:43 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-29 22:38:43 +0100 |
| commit | a8c17ccd6d97cc78830917dc6282b040b21ba16c (patch) | |
| tree | 2181e96ccf9c89c677d2208661bce5584a667470 /Private/Source/SharedObjectEntry.cxx | |
| parent | 78861f1b16f18a85e9f6890e16eb320412b6ab80 (diff) | |
Kernel: Update SPECS and TODO list.
Cleaned up the SPECS to get into the point.
Current Task: Load kernel into memory.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Private/Source/SharedObjectEntry.cxx')
| -rw-r--r-- | Private/Source/SharedObjectEntry.cxx | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/Private/Source/SharedObjectEntry.cxx b/Private/Source/SharedObjectEntry.cxx new file mode 100644 index 00000000..9fe14b39 --- /dev/null +++ b/Private/Source/SharedObjectEntry.cxx @@ -0,0 +1,58 @@ +/* + * ======================================================== + * + * hCore + * Copyright 2024 Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +#include <KernelKit/DebugOutput.hpp> +#include <KernelKit/PEF.hpp> +#include <KernelKit/ProcessManager.hpp> +#include <KernelKit/SharedObjectCore.hxx> +#include <KernelKit/ThreadLocalStorage.hxx> +#include <NewKit/Defines.hpp> + +using namespace hCore; + +/***********************************************************************************/ +/// @file SharedObjectEntry.cxx +/// @brief Shared Object Init code. +/***********************************************************************************/ + +/***********************************************************************************/ +/* @brief Allocate new library to be added to the lookup table. + */ +/***********************************************************************************/ + +extern "C" SharedObject *__LibMain(VoidPtr image) { + SharedObject *library = hcore_tls_new_class<SharedObject>(); + + if (!library) { + kcout << "__LibMain: Out of Memory!\n"; + ProcessManager::Shared().Leak().GetCurrent().Leak().Crash(); + + return nullptr; + } + + library->Mount(hcore_tls_new_class<SharedObject::SharedObjectTraits>()); + + if (!library->Get()) { + kcout << "__LibMain: Out of Memory!\n"; + ProcessManager::Shared().Leak().GetCurrent().Leak().Crash(); + + return nullptr; + } + + library->Get()->fImageObject = + ProcessManager::Shared().Leak().GetCurrent().Leak().Image; + + library->Get()->fImageEntrypointOffset = library->Load<VoidPtr>(kPefStart); + + kcout << "__LibMain: Done jumping to library...\n"; + + return library; +} + +/***********************************************************************************/ |
