summaryrefslogtreecommitdiffhomepage
path: root/Kernel/FirmwareKit/Handover.hxx
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-05-09 00:42:44 +0200
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-05-09 00:42:44 +0200
commitaf8a516fc22865abd80d6e26f1541fa3d6bebfdc (patch)
tree96d42a10945fc03df022389aef54708383c1d616 /Kernel/FirmwareKit/Handover.hxx
parenta874e9cc98df994178d55996943fe81799c61d2f (diff)
MHR-23: :boom:, refactors.
- Move NewBoot to /Boot, thus making Kernel directory only containing the kernel. Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Kernel/FirmwareKit/Handover.hxx')
-rw-r--r--Kernel/FirmwareKit/Handover.hxx110
1 files changed, 110 insertions, 0 deletions
diff --git a/Kernel/FirmwareKit/Handover.hxx b/Kernel/FirmwareKit/Handover.hxx
new file mode 100644
index 00000000..1d671f4e
--- /dev/null
+++ b/Kernel/FirmwareKit/Handover.hxx
@@ -0,0 +1,110 @@
+/* -------------------------------------------
+
+ Copyright SoftwareLabs
+
+------------------------------------------- */
+
+/**
+ * @file Handover.hxx
+ * @author Amlal El Mahrouss (amlalelmahrouss@icloud.com)
+ * @brief The handover boot protocol.
+ * @version 0.3
+ * @date 2024-02-23
+ *
+ * @copyright Copyright (c) 2024, SoftwareLabs
+ *
+ */
+
+#pragma once
+
+#include <NewKit/Defines.hpp>
+
+/* useful macros */
+
+#define kHandoverMagic 0xBADCC
+#define kHandoverVersion 0x112
+
+#define kHandoverStructSz sizeof(HEL::HandoverHeader)
+
+namespace NewOS::HEL
+{
+ /**
+ @brief the kind of executable we're loading.
+*/
+ enum
+ {
+ kTypeKernel = 100,
+ kTypeKernelDriver = 101,
+ kTypeRsrc = 102,
+ kTypeCount = 3,
+ };
+
+ /**
+ @brief The executable architecture.
+*/
+
+ enum
+ {
+ kArchAmd64 = 122,
+ kArchCount = 2,
+ };
+
+ /**
+@brief The first struct that we read when inspecting The executable
+it tells us more about it and IS format independent.
+*/
+ typedef struct HandoverHeader final
+ {
+ UInt64 f_TargetMagic;
+ Int32 f_TargetType;
+ Int32 f_TargetArch;
+ UIntPtr f_TargetStartAddress;
+ } __attribute__((packed)) HandoverHeader, *HandoverHeaderPtr;
+
+ struct HandoverInformationHeader
+ {
+ UInt64 f_Magic;
+ UInt64 f_Version;
+
+ voidPtr f_VirtualStart;
+ SizeT f_VirtualSize;
+ voidPtr f_PhysicalStart;
+
+ WideChar f_FirmwareVendorName[32];
+ SizeT f_FirmwareVendorLen;
+
+ struct
+ {
+ VoidPtr f_SmBios;
+ VoidPtr f_RsdPtr;
+ } f_HardwareTables;
+
+ struct
+ {
+ UIntPtr f_The;
+ SizeT f_Size;
+ UInt32 f_Width;
+ UInt32 f_Height;
+ UInt32 f_PixelFormat;
+ UInt32 f_PixelPerLine;
+ } f_GOP;
+
+ UInt64 f_FirmwareSpecific[8];
+ };
+
+ enum
+ {
+ kHandoverSpecificKind,
+ kHandoverSpecificAttrib,
+ kHandoverSpecificMemoryEfi,
+ };
+
+ /// @brief Bootloader main type.
+ typedef void (*BootMainKind)(NewOS::HEL::HandoverInformationHeader* handoverInfo);
+
+ /// @brief Alias of bootloader main type.
+ typedef void (*HandoverProc)(HandoverInformationHeader* handoverInfo);
+} // namespace NewOS::HEL
+
+/// @brief Bootloader global header.
+inline NewOS::HEL::HandoverInformationHeader* kHandoverHeader = nullptr;