summaryrefslogtreecommitdiffhomepage
path: root/Private/KernelKit/PEFCodeManager.hxx
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-01-31 19:36:16 +0100
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-01-31 19:36:16 +0100
commit8621867b0e4b38dedc8556e6c483e3575d776af0 (patch)
treeae8e9d271db301dc3f9433b909cd80636a8196e5 /Private/KernelKit/PEFCodeManager.hxx
parent8f7904569a60721cfd051a359dd17cc86ea67cfe (diff)
Kernel: Many improvements done to the kernel and it's HAL and protocols.
Will implement BFileReader on next commit. Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Private/KernelKit/PEFCodeManager.hxx')
-rw-r--r--Private/KernelKit/PEFCodeManager.hxx72
1 files changed, 72 insertions, 0 deletions
diff --git a/Private/KernelKit/PEFCodeManager.hxx b/Private/KernelKit/PEFCodeManager.hxx
new file mode 100644
index 00000000..3541d11b
--- /dev/null
+++ b/Private/KernelKit/PEFCodeManager.hxx
@@ -0,0 +1,72 @@
+/*
+ * ========================================================
+ *
+ * HCore
+ * Copyright Mahrouss Logic, all rights reserved.
+ *
+ * ========================================================
+ */
+
+#ifndef _INC_CODE_MANAGER_PEF_
+#define _INC_CODE_MANAGER_PEF_
+
+#include <KernelKit/PEF.hpp>
+#include <NewKit/ErrorOr.hpp>
+#include <NewKit/String.hpp>
+
+#include "NewKit/Defines.hpp"
+
+namespace HCore {
+///
+/// \name PEFLoader
+/// \brief PEF loader class.
+///
+class PEFLoader : public Loader {
+ private:
+ explicit PEFLoader() = delete;
+
+ public:
+ explicit PEFLoader(const VoidPtr blob);
+ 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<VoidPtr> LoadStart() override;
+ VoidPtr FindSymbol(const char *name, Int32 kind) override;
+
+ public:
+ bool IsLoaded() noexcept;
+
+ private:
+ Ref<StringView> 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.
+/// ARM <-> AMD64 for example.
+typedef struct UniversalProcedureTable final {
+ const Char NAME[kPefNameLen];
+ const VoidPtr TRAP;
+ const SizeT ARCH;
+} __attribute__((packed)) UniversalProcedureTableType;
+
+bool execute_from_image(PEFLoader &exec) noexcept;
+} // namespace Utils
+} // namespace HCore
+
+#endif // ifndef _INC_CODE_MANAGER_PEF_