summaryrefslogtreecommitdiffhomepage
path: root/Private/KernelKit
diff options
context:
space:
mode:
Diffstat (limited to 'Private/KernelKit')
-rw-r--r--Private/KernelKit/DebugOutput.hpp2
-rw-r--r--Private/KernelKit/DeviceManager.hpp (renamed from Private/KernelKit/Device.hpp)0
-rw-r--r--Private/KernelKit/DriveManager.hpp2
-rw-r--r--Private/KernelKit/MSDOS.hpp13
-rw-r--r--Private/KernelKit/PCI/Dma.hpp91
5 files changed, 59 insertions, 49 deletions
diff --git a/Private/KernelKit/DebugOutput.hpp b/Private/KernelKit/DebugOutput.hpp
index dd34df8e..6e651924 100644
--- a/Private/KernelKit/DebugOutput.hpp
+++ b/Private/KernelKit/DebugOutput.hpp
@@ -9,7 +9,7 @@
#pragma once
-#include <KernelKit/Device.hpp>
+#include <KernelKit/DeviceManager.hpp>
#include <NewKit/OwnPtr.hpp>
#include <NewKit/Stream.hpp>
diff --git a/Private/KernelKit/Device.hpp b/Private/KernelKit/DeviceManager.hpp
index 9a689b26..9a689b26 100644
--- a/Private/KernelKit/Device.hpp
+++ b/Private/KernelKit/DeviceManager.hpp
diff --git a/Private/KernelKit/DriveManager.hpp b/Private/KernelKit/DriveManager.hpp
index ac39c177..8e6aaefd 100644
--- a/Private/KernelKit/DriveManager.hpp
+++ b/Private/KernelKit/DriveManager.hpp
@@ -11,7 +11,7 @@
#define __DRIVE_MANAGER__
#include <CompilerKit/CompilerKit.hpp>
-#include <KernelKit/Device.hpp>
+#include <KernelKit/DeviceManager.hpp>
#include <NewKit/Defines.hpp>
#include <NewKit/String.hpp>
diff --git a/Private/KernelKit/MSDOS.hpp b/Private/KernelKit/MSDOS.hpp
index 4f098249..2276f3cb 100644
--- a/Private/KernelKit/MSDOS.hpp
+++ b/Private/KernelKit/MSDOS.hpp
@@ -16,6 +16,8 @@
#include <NewKit/Defines.hpp>
+#include "PE.hpp"
+
typedef HCore::UInt32 DosWord;
typedef HCore::Long DosLong;
@@ -41,4 +43,15 @@ typedef struct _DosHeader {
DosLong eLfanew;
} DosHeader, *DosHeaderPtr;
+namespace HCore {
+/// @brief Find the PE header inside the the blob.
+inline auto rt_find_exec_header(DosHeaderPtr ptrDos) -> VoidPtr {
+ if (!ptrDos) return nullptr;
+ if (ptrDos->eMagic[0] != kMagMz0) return nullptr;
+ if (ptrDos->eMagic[0] != kMagMz1) return nullptr;
+
+ return (VoidPtr)(&ptrDos->eLfanew + 1);
+}
+} // namespace HCore
+
#endif /* ifndef __MSDOS_EXEC__ */
diff --git a/Private/KernelKit/PCI/Dma.hpp b/Private/KernelKit/PCI/Dma.hpp
index 8e027179..0b4b55b8 100644
--- a/Private/KernelKit/PCI/Dma.hpp
+++ b/Private/KernelKit/PCI/Dma.hpp
@@ -9,73 +9,70 @@
#pragma once
-#include <KernelKit/Device.hpp>
+#include <KernelKit/DeviceManager.hpp>
#include <KernelKit/PCI/Device.hpp>
#include <NewKit/Array.hpp>
#include <NewKit/OwnPtr.hpp>
#include <NewKit/Ref.hpp>
-namespace HCore
-{
-enum class DmaKind
-{
- PCI, // Bus mastering is required to be turned on. Basiaclly a request
- // control system. 64-Bit access depends on the PAE bit and the device
- // (if Double Address Cycle is available)
- ISA, // Four DMA channels 0-3; 8 bit transfers and only a megabyte of RAM.
- Invalid,
+namespace HCore {
+enum class DmaKind {
+ PCI, // Bus mastering is required to be turned on. Basiaclly a request
+ // control system. 64-Bit access depends on the PAE bit and the device
+ // (if Double Address Cycle is available)
+ ISA, // Four DMA channels 0-3; 8 bit transfers and only a megabyte of RAM.
+ Invalid,
};
-class DMAWrapper final
-{
- public:
- explicit DMAWrapper() = delete;
+class DMAWrapper final {
+ public:
+ explicit DMAWrapper() = delete;
- public:
- explicit DMAWrapper(nullPtr) = delete;
- explicit DMAWrapper(voidPtr Ptr, DmaKind Kind = DmaKind::PCI) : m_Address(Ptr), m_Kind(Kind)
- {
- }
+ public:
+ explicit DMAWrapper(nullPtr) = delete;
+ explicit DMAWrapper(voidPtr Ptr, DmaKind Kind = DmaKind::PCI)
+ : m_Address(Ptr), m_Kind(Kind) {}
- public:
- DMAWrapper &operator=(voidPtr Ptr);
+ public:
+ DMAWrapper &operator=(voidPtr Ptr);
- public:
- DMAWrapper &operator=(const DMAWrapper &) = default;
- DMAWrapper(const DMAWrapper &) = default;
+ public:
+ DMAWrapper &operator=(const DMAWrapper &) = default;
+ DMAWrapper(const DMAWrapper &) = default;
- public:
- ~DMAWrapper() = default;
+ public:
+ ~DMAWrapper() = default;
- template <class T> T *operator->();
+ template <class T>
+ T *operator->();
- template <class T> T *Get(const UIntPtr off = 0);
+ template <class T>
+ T *Get(const UIntPtr off = 0);
- public:
- operator bool();
- bool operator!();
+ public:
+ operator bool();
+ bool operator!();
- public:
- bool Write(const UIntPtr &bit, const UIntPtr &offset);
- UIntPtr Read(const UIntPtr &offset);
- Boolean Check(UIntPtr offset) const;
+ public:
+ bool Write(const UIntPtr &bit, const UIntPtr &offset);
+ UIntPtr Read(const UIntPtr &offset);
+ Boolean Check(UIntPtr offset) const;
- public:
- UIntPtr operator[](const UIntPtr &offset);
+ public:
+ UIntPtr operator[](const UIntPtr &offset);
- private:
- voidPtr m_Address{nullptr};
- DmaKind m_Kind{DmaKind::Invalid};
+ private:
+ voidPtr m_Address{nullptr};
+ DmaKind m_Kind{DmaKind::Invalid};
- private:
- friend class DMAFactory;
+ private:
+ friend class DMAFactory;
};
-class DMAFactory final
-{
- public:
- static OwnPtr<IOBuf<Char *>> Construct(OwnPtr<DMAWrapper> &dma);
+class DMAFactory final {
+ public:
+ static OwnPtr<IOBuf<Char *>> Construct(OwnPtr<DMAWrapper> &dma);
};
-} // namespace HCore
+} // namespace HCore
#include <KernelKit/PCI/Dma.inl>