From eba8b7ddd0a455d9e49f32dcae712c5612c0093c Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Fri, 26 Jan 2024 22:26:48 +0100 Subject: Kernel: Major repository refactor. Rework the repo into Private and Public modules. Signed-off-by: Amlal El Mahrouss --- Private/KernelKit/CodeManager.hpp | 73 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 Private/KernelKit/CodeManager.hpp (limited to 'Private/KernelKit/CodeManager.hpp') diff --git a/Private/KernelKit/CodeManager.hpp b/Private/KernelKit/CodeManager.hpp new file mode 100644 index 00000000..04d5647b --- /dev/null +++ b/Private/KernelKit/CodeManager.hpp @@ -0,0 +1,73 @@ +/* +* ======================================================== +* +* hCore +* Copyright 2024 Mahrouss Logic, all rights reserved. +* +* ======================================================== +*/ + +#ifndef _INC_CODE_MANAGER_ +#define _INC_CODE_MANAGER_ + +#include +#include +#include + +namespace hCore +{ + /// + /// \name PEFLoader + /// PEF container format implementation. + /// + class PEFLoader : public Loader + { + PEFLoader() = delete; + + public: + explicit PEFLoader(const char* path); + ~PEFLoader() override; + + public: + HCORE_COPY_DEFAULT(PEFLoader); + + public: + typedef void(*MainKind)(void); + + public: + const char* Path() override; + const char* Format() override; + const char* MIME() override; + + public: + ErrorOr LoadStart() override; + VoidPtr FindSymbol(const char* name, Int32 kind) override; + + public: + bool IsLoaded() noexcept; + + private: + Ref fPath; + VoidPtr fCachedBlob; + bool fBad; + + }; + + namespace Utils + { + /// \brief Much like Mac OS's UPP. + /// This is read-only by design. + /// It handles different kind of code. + /// PowerPC <-> AMD64 for example. + typedef struct UniversalProcedureTable + { + const Char NAME[kPefNameLen]; + const VoidPtr TRAP; + const SizeT ARCH; + } __attribute__((packed)) UniversalProcedureTableType; + + bool execute_from_image(PEFLoader& exec); + } +} + +#endif // ifndef _INC_CODE_MANAGER_ -- cgit v1.2.3