summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlalelmahrouss@icloud.com>2024-02-04 10:59:24 +0100
committerAmlal El Mahrouss <amlalelmahrouss@icloud.com>2024-02-04 10:59:24 +0100
commite2bbec91d70847cc5a2ff67eb84ca4a3c2d03e85 (patch)
tree1e7fec7c232b0c750157007113ce8f86d43b7e76
parentaff54fd3dc6855b62c047f126c6fe20ca717ee0f (diff)
Kernel: Depend less on NewFS, add support for FileSystem protocol in
NewBoot. Signed-off-by: Amlal El Mahrouss <amlalelmahrouss@icloud.com>
-rw-r--r--Private/ArchKit/ArchKit.hpp106
-rw-r--r--Private/Drivers/AHCI/Defines.hxx46
-rw-r--r--Private/EFIKit/Api.hxx2
-rw-r--r--Private/EFIKit/EFI.hxx115
-rw-r--r--Private/FSKit/Defines.hpp2
-rw-r--r--Private/FSKit/IndexableProperty.hxx66
-rw-r--r--Private/FSKit/NewFS.hxx36
-rw-r--r--Private/KernelKit/FileManager.hpp8
-rw-r--r--Private/KernelKit/HError.hpp29
-rw-r--r--Private/KernelKit/OSErr.hpp29
-rw-r--r--Private/NewBoot/BootKit/Arch/AHCI.hxx10
-rw-r--r--Private/NewBoot/BootKit/BootKit.hxx5
-rw-r--r--Private/NewBoot/Source/Entrypoint.cxx19
-rw-r--r--Private/NewBoot/Source/FileReader.cxx118
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/AMD64-ATA.cxx1
-rw-r--r--Private/NewBoot/Source/String.cxx1
-rw-r--r--Private/NewBoot/Source/TextWriter.cxx1
-rw-r--r--Private/NewBoot/Source/makefile3
-rw-r--r--Private/NewKit/KernelHeap.hpp2
-rw-r--r--Private/Root/Boot/.gitkeep1
-rw-r--r--Private/Root/Users/.USERHASH (renamed from Private/Root/Users/guest/.hgkeep)0
-rw-r--r--Private/Root/Users/super/.gitkeep0
-rw-r--r--Private/Source/HError.cxx (renamed from Private/Source/OSErr.cxx)2
-rw-r--r--Private/Source/KernelHeap.cxx12
-rw-r--r--Private/Source/NewFS-IO.cxx7
-rw-r--r--Private/Source/NewFS-Journal.cxx7
-rw-r--r--Private/Source/NewFS.cxx9
-rw-r--r--Private/Source/PEFSharedObjectRT.cxx4
-rw-r--r--Private/Source/Storage/ATA.cxx8
-rw-r--r--Private/Source/UserHeap.cxx14
-rw-r--r--Private/makefile2
31 files changed, 442 insertions, 223 deletions
diff --git a/Private/ArchKit/ArchKit.hpp b/Private/ArchKit/ArchKit.hpp
index eefd6f5f..1b3d7884 100644
--- a/Private/ArchKit/ArchKit.hpp
+++ b/Private/ArchKit/ArchKit.hpp
@@ -9,80 +9,64 @@
#pragma once
+#include <NewKit/Array.hpp>
#include <NewKit/Defines.hpp>
#include <NewKit/Function.hpp>
-#include <NewKit/Array.hpp>
#ifdef __x86_64__
-# include <HALKit/AMD64/Hypervisor.hpp>
-# include <HALKit/AMD64/Processor.hpp>
-# include <HALKit/AMD64/HalPageAlloc.hpp>
+#include <HALKit/AMD64/HalPageAlloc.hpp>
+#include <HALKit/AMD64/Hypervisor.hpp>
+#include <HALKit/AMD64/Processor.hpp>
#elif defined(__powerpc64__)
-# include <HALKit/PowerPC/Processor.hpp>
+#include <HALKit/PowerPC/Processor.hpp>
#else
-# error Unknown architecture
+#error Unknown architecture
#endif
-namespace HCore
-{
- class SystemCallDefaultImpl final
- {
- public:
- static Int32 Exec() { return 0; }
-
- };
-
- template <SSizeT ID>
- class SystemCall
- {
- public:
- explicit SystemCall()
- {
- kcout << "SystemCall::SystemCall";
- }
-
- virtual ~SystemCall()
- {
- kcout << "SystemCall::~SystemCall";
- }
-
- SystemCall &operator=(const SystemCall &) = default;
- SystemCall(const SystemCall &) = default;
-
- // Should not be called alone!
- virtual bool Exec() const
- {
- kcout << "SystemCall->Exec<RET>()";
- return false;
- }
-
- };
-
- constexpr static inline SSizeT syscall_hash(const char *seed, int mul)
- {
- SSizeT hash = 0;
-
- for (SSizeT idx = 0; seed[idx] != 0; ++idx)
- {
- hash += seed[idx];
- hash ^= mul;
- }
-
- return hash;
- }
-
- bool ke_init_hal();
-} // namespace HCore
+namespace HCore {
+template <SSizeT ID>
+class SystemCall {
+ public:
+ explicit SystemCall() { kcout << "SystemCall::SystemCall"; }
+
+ virtual ~SystemCall() { kcout << "SystemCall::~SystemCall"; }
+
+ SystemCall &operator=(const SystemCall &) = default;
+ SystemCall(const SystemCall &) = default;
+
+ // Should not be called alone!
+ virtual bool Exec() const {
+ kcout << "SystemCall->Exec<RET>()";
+ return false;
+ }
+};
+
+constexpr static inline SSizeT syscall_hash(const char *seed, int mul) {
+ SSizeT hash = 0;
+
+ for (SSizeT idx = 0; seed[idx] != 0; ++idx) {
+ hash += seed[idx];
+ hash ^= mul;
+ }
+
+ return hash;
+}
+
+bool ke_init_hal();
+} // namespace HCore
#define kMaxSyscalls 0x100
#define kSyscallGate 0x21
-extern HCore::Array<void (*)(HCore::Int32 id, HCore::HAL::StackFrame *), kMaxSyscalls> kSyscalls;
+extern HCore::Array<void (*)(HCore::Int32 id, HCore::HAL::StackFrame *),
+ kMaxSyscalls>
+ kSyscalls;
-extern "C" void rt_wait_for_io();
-extern "C" void rt_syscall_handle(HCore::HAL::StackFrame* stackFrame);
-extern "C" HCore::HAL::StackFrame* rt_get_current_context();
-extern "C" int rt_do_context_switch(HCore::HAL::StackFrame* stackFrame);
+extern "C" HCore::Void rt_wait_for_io();
+extern "C" HCore::Void rt_syscall_handle(HCore::HAL::StackFramePtr stackFrame);
+extern "C" HCore::HAL::StackFramePtr rt_get_current_context();
+extern "C" HCore::Int32 rt_do_context_switch(
+ HCore::HAL::StackFramePtr stackFrame);
inline HCore::VoidPtr kKernelVirtualStart;
inline HCore::UIntPtr kKernelVirtualSize;
diff --git a/Private/Drivers/AHCI/Defines.hxx b/Private/Drivers/AHCI/Defines.hxx
index ac0c9de0..7b9ed28a 100644
--- a/Private/Drivers/AHCI/Defines.hxx
+++ b/Private/Drivers/AHCI/Defines.hxx
@@ -17,9 +17,14 @@
using namespace HCore;
-// forward decl
+// Forward declarations of structs.
struct HbaPort;
+struct FisData;
+struct FisRegD2H;
+struct FisRegH2D;
+
+// Enum types
typedef enum {
FIS_TYPE_REG_H2D = 0x27, // Register FIS - host to device
@@ -40,7 +45,7 @@ typedef enum {
AHCI_ATA_CMD_WRITE_DMA_EX = 0x35
} AHCI_FIS_COMMAND;
-typedef struct FisRegH2d {
+typedef struct FisRegH2D final {
// DWORD 0
UInt8 fisType; // FIS_TYPE_REG_H2D
@@ -71,9 +76,9 @@ typedef struct FisRegH2d {
// DWORD 4
UInt8 reserved1[4]; // Reserved
-} FisRegH2d;
+} FisRegH2D;
-typedef struct FisRegD2h {
+typedef struct FisRegD2H final {
// DWORD 0
UInt8 fisType; // FIS_TYPE_REG_D2H
@@ -104,9 +109,9 @@ typedef struct FisRegD2h {
// DWORD 4
UInt8 rsv4[4]; // Reserved
-} FisRegD2h;
+} FisRegD2H;
-typedef struct FisData {
+typedef struct FisData final {
// DWORD 0
UInt8 fisType; // FIS_TYPE_DATA
@@ -119,7 +124,7 @@ typedef struct FisData {
UInt32 data[1]; // Payload
} FisData;
-typedef struct FisPioSetup {
+typedef struct FisPioSetup final {
// DWORD 0
UInt8 fisType; // FIS_TYPE_PIO_SETUP
@@ -148,14 +153,14 @@ typedef struct FisPioSetup {
UInt8 countLow; // Count register, 7:0
UInt8 countHigh; // Count register, 15:8
UInt8 rsv3; // Reserved
- UInt8 e_status; // New value of status register
+ UInt8 eStatus; // New value of status register
// DWORD 4
UInt16 tc; // Transfer count
UInt8 rsv4[2]; // Reserved
} FisPioSetup;
-typedef struct FisDmaSetup {
+typedef struct FisDmaSetup final {
// DWORD 0
UInt8 fisType; // FIS_TYPE_DMA_SETUP
@@ -186,7 +191,7 @@ typedef struct FisDmaSetup {
UInt32 reserved3; // Reserved
} FisDmaSetup;
-typedef struct FisDevBits {
+typedef struct FisDevBits final {
// DWORD 0
UInt8 fisType; // FIS_TYPE_DMA_SETUP (A1h)
@@ -206,11 +211,12 @@ typedef struct FisDevBits {
UInt32 act;
} FisDevBits;
-#ifndef AHCI_GHC_AE
-#define AHCI_GHC_AE (31)
-#endif //! AHCI_GHC_AE
+/// \brief Enable AHCI device bit in GHC register.
+#ifndef kAhciGHC_AE
+#define kAhciGHC_AE (31)
+#endif //! ifndef kAhciGHC_AE
-typedef struct HbaPort {
+typedef struct HbaPort final {
UInt32 clb; // 0x00, command list base address, 1K-byte aligned
UInt32 clbu; // 0x04, command list base address upper 32 bits
UInt32 fb; // 0x08, FIS base address, 256-byte aligned
@@ -232,7 +238,7 @@ typedef struct HbaPort {
UInt32 vendor[4]; // 0x70 ~ 0x7F, vendor specific
} HbaPort;
-typedef struct HbaMem {
+typedef struct HbaMem final {
// 0x00 - 0x2B, Generic Host Control
UInt32 cap; // 0x00, Host capability
UInt32 ghc; // 0x04, Global host control
@@ -252,7 +258,7 @@ typedef struct HbaMem {
HbaPort ports[1]; // 1 ~ 32
} HbaMem;
-typedef struct HbaCmdHeader {
+typedef struct HbaCmdHeader final {
// DW0
UInt8 cfl : 5; // Command FIS length in DWORDS, 2 ~ 16
UInt8 atapi : 1; // ATAPI
@@ -274,7 +280,7 @@ typedef struct HbaCmdHeader {
UInt32 reserved1[4]; // Reserved
} HbaCmdHeader;
-typedef struct HbaFis {
+typedef struct HbaFis final {
// 0x00
FisDmaSetup dsfis; // DMA Setup FIS
UInt8 pad0[4];
@@ -282,7 +288,7 @@ typedef struct HbaFis {
FisPioSetup psfis; // PIO Setup FIS
UInt8 pad1[12];
// 0x40
- FisRegD2h rfis; // Register – Device to Host FIS
+ FisRegD2H rfis; // Register – Device to Host FIS
UInt8 pad2[4];
// 0x58
FisDevBits sdbfis; // Set Device Bit FIS
@@ -292,7 +298,7 @@ typedef struct HbaFis {
UInt8 rsv[0x100 - 0xA0];
} HbaFis;
-typedef struct HbaPrdtEntry {
+typedef struct HbaPrdtEntry final {
UInt32 dba; // Data base address
UInt32 dbau; // Data base address upper 32 bits
UInt32 reserved0; // Reserved
@@ -302,7 +308,7 @@ typedef struct HbaPrdtEntry {
UInt32 interruptBit : 1; // Interrupt on completion
} HbaPrdtEntry;
-typedef struct HbaCmdTbl {
+typedef struct HbaCmdTbl final {
UInt8 cfis[64]; // Command FIS
UInt8 acmd[16]; // ATAPI command, 12 or 16 bytes
UInt8 rsv[48]; // Reserved
diff --git a/Private/EFIKit/Api.hxx b/Private/EFIKit/Api.hxx
index c747b777..0d4b14cb 100644
--- a/Private/EFIKit/Api.hxx
+++ b/Private/EFIKit/Api.hxx
@@ -33,7 +33,7 @@ Bascially frees everything we have in the EFI side.
inline void ExitBootServices(UInt64 MapKey, EfiHandlePtr ImageHandle) noexcept {
if (!ST) return;
- ST->ConOut->OutputString(ST->ConOut, L"EFI: Exit Boot services...\r\n");
+ ST->ConOut->OutputString(ST->ConOut, L"EFI: Exit BootServices...\r\n");
ST->BootServices->ExitBootServices(ImageHandle, MapKey);
}
diff --git a/Private/EFIKit/EFI.hxx b/Private/EFIKit/EFI.hxx
index 0dba118d..5937f240 100644
--- a/Private/EFIKit/EFI.hxx
+++ b/Private/EFIKit/EFI.hxx
@@ -12,6 +12,8 @@
/**
@brief HCore Implementation of EFI.
+@note This API is in WiP, so it's not 'pretty', just deal with it. We'll be
+improving that later.
@author Amlal El Mahrouss
*/
@@ -39,10 +41,12 @@ struct EfiFileDevicePathProtocol;
struct EfiHandle;
struct EfiGraphicsOutputProtocol;
struct EfiBitmask;
+struct EfiFileProtocol;
/// @brief Core Handle Type
/// This is like NT's Win32 HANDLE type.
-typedef struct EfiHandle {} *EfiHandlePtr;
+typedef struct EfiHandle {
+} *EfiHandlePtr;
/* UEFI uses wide characters by default. */
typedef WideChar EfiCharType;
@@ -280,6 +284,13 @@ typedef struct EfiTableHeader {
} \
}
+#define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID \
+ { \
+ 0x0964e5b22, 0x6459, 0x11d2, { \
+ 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b \
+ } \
+ }
+
typedef UInt64(EfiImageUnload)(EfiHandlePtr ImageHandle);
enum {
@@ -325,8 +336,8 @@ typedef UInt64(EFI_API *EfiGraphicsOutputProtocolQueryMode)(
EfiGraphicsOutputProtocol *This, UInt32 ModeNumber, UInt32 *SizeOfInfo,
EfiGraphicsOutputProtocolModeInformation **Info);
-typedef UInt64(EFI_API *EfiGraphicsOutputProtocolSetMode)(EfiGraphicsOutputProtocol *This,
- UInt32 ModeNumber);
+typedef UInt64(EFI_API *EfiGraphicsOutputProtocolSetMode)(
+ EfiGraphicsOutputProtocol *This, UInt32 ModeNumber);
typedef UInt64(EFI_API *EfiGraphicsOutputProtocolBlt)(
EfiGraphicsOutputProtocol *This, EfiGraphicsOutputBltPixel *BltBuffer,
@@ -335,12 +346,12 @@ typedef UInt64(EFI_API *EfiGraphicsOutputProtocolBlt)(
UInt32 Height, UInt32 Delta);
typedef struct {
- UInt32 MaxMode;
- UInt32 Mode;
- EfiGraphicsOutputProtocolModeInformation *Info;
- UInt32 SizeOfInfo;
- UIntPtr FrameBufferBase;
- UInt32 FrameBufferSize;
+ UInt32 MaxMode;
+ UInt32 Mode;
+ EfiGraphicsOutputProtocolModeInformation *Info;
+ UInt32 SizeOfInfo;
+ UIntPtr FrameBufferBase;
+ UInt32 FrameBufferSize;
} EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE;
typedef struct EfiGraphicsOutputProtocol {
@@ -507,6 +518,16 @@ typedef struct EfiSimpleTextOutputProtocol {
VoidPtr Mode;
} EfiSimpleTextOutputProtocol;
+typedef UInt64 EfiStatusType;
+
+typedef UInt64(EFI_API *EfiOpenVolume)(struct EfiSimpleFilesystemProtocol *,
+ struct EfiFileProtocol **);
+
+struct EfiSimpleFilesystemProtocol {
+ UInt64 Revision;
+ EfiOpenVolume OpenVolume;
+};
+
/**
@brief The Structure that they give you when booting.
*/
@@ -566,4 +587,80 @@ enum {
#define kEfiOffsetOf(T, F) __builtin_offsetof(T, F)
+/// File I/O macros
+
+#define kEFIFileRead 0x0000000000000001
+#define kEFIFileWrite 0x0000000000000002
+#define kEFIFileCreate 0x0000000000000000
+
+#define kEFIReadOnly 0x01
+#define kEFIHidden 0x02
+#define kEFISystem 0x04
+#define kEFIReserved 0x08
+#define kEFIDirectory 0x10
+#define kEFIArchive 0x20
+
+typedef EfiStatusType(EFI_API *EfiRead)(struct EfiFileProtocol *, UInt64 *,
+ VoidPtr);
+
+struct EfiFileProtocol final {
+ UInt64 Revision;
+
+ EfiStatusType (*Open)(struct EfiFileProtocol *, struct EfiFileProtocol **,
+ EfiCharType *, UInt64, UInt64);
+
+ EfiStatusType (*Close)(struct EfiFileProtocol *);
+
+ void (*Unused1)();
+
+ EfiRead Read;
+
+ void (*Unused2)();
+ void (*Unused3)();
+ void (*Unused4)();
+
+ EfiStatusType (*GetInfo)(struct EfiFileProtocol *, struct EfiGUID *, UInt32 *,
+ void *);
+
+ void (*Unused6)();
+ void (*Unused7)();
+ void (*Unused8)();
+ void (*Unused9)();
+ void (*Unused10)();
+ void (*Unused11)();
+};
+
+typedef struct EfiTime {
+ UInt16 Year;
+ UInt8 Month;
+ UInt8 Day;
+ UInt8 Hour;
+ UInt8 Minute;
+ UInt8 Second;
+ UInt8 Pad1;
+ UInt32 Nanosecond;
+ Int16 TimeZone;
+ UInt8 Daylight;
+ UInt8 Pad2;
+} EfiTime;
+
+#define EFI_FILE_INFO_GUID \
+ { \
+ 0x09576e92, 0x6d3f, 0x11d2, { \
+ 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b \
+ } \
+ }
+
+struct EfiFileInfo final {
+ UInt64 Size;
+ UInt64 FileSize;
+ UInt64 PhysicalSize;
+ EfiTime CreateTime;
+ EfiTime LastAccessTome;
+ EfiTime EditTime;
+ UInt64 Attribute;
+ // Do not touch that, it's EFI specific.
+ WideChar FileName[];
+};
+
#endif // __EFI__
diff --git a/Private/FSKit/Defines.hpp b/Private/FSKit/Defines.hpp
index cb0903d1..1d64be5d 100644
--- a/Private/FSKit/Defines.hpp
+++ b/Private/FSKit/Defines.hpp
@@ -11,4 +11,4 @@
#include <NewKit/Defines.hpp>
-#define FSKIT_VERSION "1.0.0" \ No newline at end of file
+#define FSKIT_VERSION "1.0.0"
diff --git a/Private/FSKit/IndexableProperty.hxx b/Private/FSKit/IndexableProperty.hxx
index 3eddf5e1..553eb945 100644
--- a/Private/FSKit/IndexableProperty.hxx
+++ b/Private/FSKit/IndexableProperty.hxx
@@ -10,39 +10,37 @@
#pragma once
#include <CFKit/Property.hpp>
+#include <CompilerKit/CompilerKit.hpp>
#include <KernelKit/DriveManager.hpp>
-namespace HCore
-{
- namespace Indexer
- {
- struct IndexProperty final
- {
- public:
- Char Drive[kDriveNameLen];
- Char Path[256];
- Char From[256];
- Char To[256];
-
- };
-
- class IndexableProperty final : public Property
- {
- public:
- explicit IndexableProperty() : Property(StringBuilder::Construct("IndexableProperty").Leak().Leak()) {}
- ~IndexableProperty() override = default;
-
- public:
- IndexProperty& LeakProperty() noexcept;
-
- public:
- void AddFlag(Int16 flag);
- void RemoveFlag(Int16 flag);
-
- private:
- IndexProperty fIndex;
- UInt32 fFlags;
-
- };
- }
-}
+namespace HCore {
+namespace Indexer {
+struct IndexProperty final {
+ public:
+ Char Drive[kDriveNameLen];
+ Char Path[256];
+ Char From[256];
+ Char To[256];
+};
+
+class IndexableProperty final : public Property {
+ public:
+ explicit IndexableProperty()
+ : Property(StringBuilder::Construct("IndexableProperty").Leak().Leak()) {}
+ ~IndexableProperty() override = default;
+
+ HCORE_COPY_DEFAULT(IndexableProperty);
+
+ public:
+ IndexProperty& LeakProperty() noexcept;
+
+ public:
+ void AddFlag(Int16 flag);
+ void RemoveFlag(Int16 flag);
+
+ private:
+ IndexProperty fIndex;
+ UInt32 fFlags;
+};
+} // namespace Indexer
+} // namespace HCore
diff --git a/Private/FSKit/NewFS.hxx b/Private/FSKit/NewFS.hxx
index 0be6ece0..d0c43f02 100644
--- a/Private/FSKit/NewFS.hxx
+++ b/Private/FSKit/NewFS.hxx
@@ -13,6 +13,13 @@
#include <KernelKit/DriveManager.hpp>
#include <NewKit/Defines.hpp>
+#include "KernelKit/FileManager.hpp"
+
+/**
+ @brief NewFS or HCFS
+ HCore FileSystem.
+*/
+
#define kInvalidFork -1
#define kInvalidCatalog -1
#define kNameLen 256
@@ -68,20 +75,26 @@ struct PACKED NewCatalog final {
HCore::Lba FirstFork;
HCore::Lba LastFork;
+
+ HCore::Lba SiblingRecords[12];
+};
+
+#define kNewFSMaxEntries 256
+
+struct PACKED NewCatalogRecord final {
+ HCore::Lba Entries[kNewFSMaxEntries];
};
struct PACKED NewFork final {
HCore::Int32 Flags;
HCore::Int32 Kind;
- HCore::Int64 ID;
-
HCore::Int64 ResourceId;
HCore::Int32 ResourceKind;
HCore::Int32 ResourceFlags;
- HCore::Lba DataOffset;
- HCore::SizeT DataSize;
+ HCore::Lba DataOffset; // Where to look for this data?
+ HCore::SizeT DataSize; // Data size according using sector count.
HCore::Lba NextSibling;
HCore::Lba PreviousSibling;
@@ -136,7 +149,8 @@ struct PACKED NewPartitionBlock final {
#define kFilesystemUpDir ".."
#define kFilesystemRoot "\\"
-#define kFilesystemLE '\r'
+#define kFilesystemCR '\r'
+#define kFilesystemLF '\n'
#define kFilesystemEOF (-1)
#define kFilesystemBitWidth sizeof(NewCharType)
@@ -176,15 +190,15 @@ class NewFSImplementation {
};
///
-/// \name MeFilesystemHelper
-/// Filesystem helper and utils.
+/// \name NewFilesystemHelper
+/// \brief Filesystem helper and utils.
///
-class MeFilesystemHelper final {
+class NewFilesystemHelper final {
public:
- static const char* Root() { return kFilesystemRoot; }
- static const char* UpDir() { return kFilesystemUpDir; }
- static const char Separator() { return kFilesystemSeparator; }
+ static const char* Root();
+ static const char* UpDir();
+ static const char Separator();
};
} // namespace HCore
diff --git a/Private/KernelKit/FileManager.hpp b/Private/KernelKit/FileManager.hpp
index cfd06f07..a52daa7d 100644
--- a/Private/KernelKit/FileManager.hpp
+++ b/Private/KernelKit/FileManager.hpp
@@ -17,7 +17,10 @@
#pragma once
+#ifdef __USE_NEWFS__
#include <FSKit/NewFS.hxx>
+#endif // __USE_NEWFS__
+
#include <NewKit/ErrorID.hpp>
#include <NewKit/Ref.hpp>
#include <NewKit/Stream.hpp>
@@ -87,6 +90,7 @@ class IFilesystemManager {
/** @brief invalid position. (n-pos) */
#define kNPos (SizeT)(-1);
+#ifdef __USE_NEWFS__
/**
* @brief Based of IFilesystemManager, takes care of managing NewFS disks.
*/
@@ -148,12 +152,14 @@ class NewFilesystemManager final : public IFilesystemManager {
NewFSImplementation *fImpl{nullptr};
};
+#endif // ifdef __USE_NEWFS__
+
/**
* Usable FileStream
* @tparam Encoding file encoding (char, wchar_t...)
* @tparam FSClass Filesystem contract who takes care of it.
*/
-template <typename Encoding = char, typename FSClass = NewFilesystemManager>
+template <typename Encoding = char, typename FSClass = IFilesystemManager>
class FileStream final {
public:
explicit FileStream(const Encoding *path);
diff --git a/Private/KernelKit/HError.hpp b/Private/KernelKit/HError.hpp
new file mode 100644
index 00000000..c03e8104
--- /dev/null
+++ b/Private/KernelKit/HError.hpp
@@ -0,0 +1,29 @@
+/*
+ * ========================================================
+ *
+ * HCore
+ * Copyright Mahrouss Logic, all rights reserved.
+ *
+ * ========================================================
+ */
+
+#pragma once
+
+#include <NewKit/Defines.hpp>
+
+namespace HCore {
+typedef Int32 HError;
+
+inline constexpr HError kErrorExecutable = 33;
+inline constexpr HError kErrorExecutableLib = 34;
+inline constexpr HError kErrorFileNotFound = 35;
+inline constexpr HError kErrorDirectoryNotFound = 36;
+inline constexpr HError kErrorDiskReadOnly = 37;
+inline constexpr HError kErrorDiskIsFull = 38;
+inline constexpr HError kErrorProcessFault = 39;
+inline constexpr HError kErrorSocketHangUp = 40;
+inline constexpr HError kErrorThreadLocalStorage = 41;
+inline constexpr HError kErrorMath = 42;
+inline constexpr HError kErrorNoNetwork = 43;
+inline constexpr HError kErrorHeapOutOfMemory = 44;
+} // namespace HCore
diff --git a/Private/KernelKit/OSErr.hpp b/Private/KernelKit/OSErr.hpp
deleted file mode 100644
index 62916959..00000000
--- a/Private/KernelKit/OSErr.hpp
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * ========================================================
- *
- * HCore
- * Copyright Mahrouss Logic, all rights reserved.
- *
- * ========================================================
- */
-
-#pragma once
-
-#include <NewKit/Defines.hpp>
-
-namespace HCore {
-typedef Int32 OSErr;
-
-inline constexpr OSErr kErrorExecutable = 33;
-inline constexpr OSErr kErrorExecutableLib = 34;
-inline constexpr OSErr kErrorFileNotFound = 35;
-inline constexpr OSErr kErrorDirectoryNotFound = 36;
-inline constexpr OSErr kErrorDiskReadOnly = 37;
-inline constexpr OSErr kErrorDiskIsFull = 38;
-inline constexpr OSErr kErrorProcessFault = 39;
-inline constexpr OSErr kErrorSocketHangUp = 40;
-inline constexpr OSErr kErrorThreadLocalStorage = 41;
-inline constexpr OSErr kErrorMath = 42;
-inline constexpr OSErr kErrorNoNetwork = 43;
-inline constexpr OSErr kErrorHeapOutOfMemory = 44;
-} // namespace HCore
diff --git a/Private/NewBoot/BootKit/Arch/AHCI.hxx b/Private/NewBoot/BootKit/Arch/AHCI.hxx
index 0735baad..1f36ca00 100644
--- a/Private/NewBoot/BootKit/Arch/AHCI.hxx
+++ b/Private/NewBoot/BootKit/Arch/AHCI.hxx
@@ -38,12 +38,4 @@ class BDeviceAHCI final {
AHCITraits mTraits;
};
-enum {
- kATADevicePATA,
- kATADeviceSATA,
- kATADevicePATA_PI,
- kATADeviceSATA_PI,
- kATADeviceCount,
-};
-
-#define kATASectorSz 512
+#define kAHCISectorSz 512
diff --git a/Private/NewBoot/BootKit/BootKit.hxx b/Private/NewBoot/BootKit/BootKit.hxx
index 45f54cb4..6fec1724 100644
--- a/Private/NewBoot/BootKit/BootKit.hxx
+++ b/Private/NewBoot/BootKit/BootKit.hxx
@@ -62,9 +62,9 @@ HCore::SizeT BSetMem(CharacterType *src, const CharacterType byte,
class BFileReader final {
public:
explicit BFileReader(const CharacterType *path);
- ~BFileReader() = default;
+ ~BFileReader();
- HCore::VoidPtr Fetch(SizeT &size);
+ HCore::VoidPtr Fetch(EfiHandlePtr ImageHandle);
enum {
kOperationOkay,
@@ -83,6 +83,7 @@ class BFileReader final {
private:
Int32 mErrorCode{kOperationOkay};
+ VoidPtr mBlob{nullptr};
CharacterType mPath[kPathLen];
BTextWriter mWriter;
BDeviceATA mDevice;
diff --git a/Private/NewBoot/Source/Entrypoint.cxx b/Private/NewBoot/Source/Entrypoint.cxx
index 39769b87..4839ee1f 100644
--- a/Private/NewBoot/Source/Entrypoint.cxx
+++ b/Private/NewBoot/Source/Entrypoint.cxx
@@ -7,7 +7,6 @@
* ========================================================
*/
-#include "BootKit/Arch/ATA.hxx"
#define __BOOTLOADER__ 1
#include <BootKit/BootKit.hxx>
@@ -43,26 +42,18 @@ EFI_EXTERN_C Int EfiMain(EfiHandlePtr ImageHandle,
UInt64 mapKey = 0;
- BFileReader img(L"HCoreKrnl.exe");
+ BFileReader img(L"\\EFI\\BOOT\\HCoreKrnl.exe");
- SizeT sz = 0UL;
- PEImagePtr blob = (PEImagePtr)img.Fetch(sz);
+ PEImagePtr blob = (PEImagePtr)img.Fetch(ImageHandle);
- if (!blob || sz < 1)
+ if (!blob)
EFI::RaiseHardError(L"HCoreLdr_NoSuchKernel",
L"Couldn't find HCoreKrnl.exe!");
- ExecHeaderPtr headerPtr = (ExecHeaderPtr)blob;
+ writer.WriteString(L"HCoreLdr: Running HCoreKrnl.exe...\r\n");
- if (blob[0] == kMagMz0 && blob[1] == kMagMz1) {
- writer.WriteString(L"HCoreLdr: Running HCoreKrnl.exe...\r\n");
- /// Load Image here
- } else {
- EFI::RaiseHardError(L"HCoreLdr_NotPE", L"Not a PE file! Aborting...");
- }
-
- EFI::Stop();
EFI::ExitBootServices(mapKey, ImageHandle);
+ EFI::Stop();
return kEfiOk;
}
diff --git a/Private/NewBoot/Source/FileReader.cxx b/Private/NewBoot/Source/FileReader.cxx
index 39884f9f..3edacb5a 100644
--- a/Private/NewBoot/Source/FileReader.cxx
+++ b/Private/NewBoot/Source/FileReader.cxx
@@ -14,7 +14,8 @@
#include <BootKit/BootKit.hxx>
#include <EFIKit/Api.hxx>
-#include <FSKit/NewFS.hxx>
+
+#include "EFIKit/EFI.hxx"
////////////////////////////////////////////////////////////////////////////////////////////////////
//
@@ -27,7 +28,7 @@
/***
@brief File Reader constructor.
*/
-BFileReader::BFileReader(const CharacterType *path) {
+BFileReader::BFileReader(const CharacterType* path) {
if (path != nullptr) {
SizeT index = 0UL;
for (; path[index] != L'\0'; ++index) {
@@ -38,17 +39,122 @@ BFileReader::BFileReader(const CharacterType *path) {
}
}
+BFileReader::~BFileReader() {
+ if (this->mBlob) {
+ BS->FreePool(this->mBlob);
+ }
+}
+
/**
@brief this reads all of the buffer.
- @param size, new buffer size.
+ @param ImageHandle used internally.
*/
-HCore::VoidPtr BFileReader::Fetch(SizeT &size) {
+HCore::VoidPtr BFileReader::Fetch(EfiHandlePtr ImageHandle) {
mWriter.WriteString(L"HCoreLdr: Fetch-File: ")
.WriteString(mPath)
.WriteString(L"\r\n");
+ /// Load protocols with their GUIDs.
+
+ EfiGUID guidEfp = EfiGUID(EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID);
+
+ EfiSimpleFilesystemProtocol* efp = nullptr;
+ EfiFileProtocol* rootFs = nullptr;
+
+ EfiLoadImageProtocol* img = nullptr;
+ EfiGUID guidImg = EfiGUID(EFI_LOADED_IMAGE_PROTOCOL_GUID);
+
+ if (BS->OpenProtocol(ImageHandle, &guidImg, (void**)&img, ImageHandle,
+ nullptr,
+ EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL) != kEfiOk) {
+ mWriter.WriteString(L"HCoreLdr: Fetch-Protocol: No-Such-Protocol")
+ .WriteString(L"\r\n");
+ this->mErrorCode = kNotSupported;
+ }
+
+ if (BS->OpenProtocol(img->DeviceHandle, &guidEfp, (void**)&efp, ImageHandle,
+ nullptr,
+ EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL) != kEfiOk) {
+ mWriter.WriteString(L"HCoreLdr: Fetch-Protocol: No-Such-Protocol")
+ .WriteString(L"\r\n");
+ this->mErrorCode = kNotSupported;
+ return nullptr;
+ }
+
+ /// Start doing disk I/O
+
+ if (efp->OpenVolume(efp, &rootFs) != kEfiOk) {
+ mWriter.WriteString(L"HCoreLdr: Fetch-Protocol: No-Such-Volume")
+ .WriteString(L"\r\n");
+ this->mErrorCode = kNotSupported;
+ return nullptr;
+ }
+
+ /// Open kernel.
+
+ EfiFileProtocol* kernelFile;
+
+ if (rootFs->Open(rootFs, &kernelFile, mPath, kEFIFileRead,
+ kEFIReadOnly | kEFIHidden | kEFISystem) != kEfiOk) {
+ mWriter.WriteString(L"HCoreLdr: Fetch-Protocol: No-Such-Path: ")
+ .WriteString(mPath)
+ .WriteString(L"\r\n");
+ this->mErrorCode = kNotSupported;
+ return nullptr;
+ }
+
+ /// File FAT info.
+
+ UInt32 szInfo = sizeof(EfiFileInfo);
+ EfiFileInfo info{0};
+
+ guidEfp = EfiGUID(EFI_FILE_INFO_GUID);
+
+ if (kernelFile->GetInfo(kernelFile, &guidEfp, &szInfo, (void*)&info) !=
+ kEfiOk) {
+ mWriter.WriteString(L"HCoreLdr: Fetch-Protocol: No-Such-Path: ")
+ .WriteString(mPath)
+ .WriteString(L"\r\n");
+ this->mErrorCode = kNotSupported;
+ return nullptr;
+ }
+
+ mWriter.WriteString(L"HCoreLdr: Fetch-Info: In-Progress...")
+ .WriteString(L"\r\n");
+
+ UInt8* blob = nullptr;
+
+ mWriter.WriteString(L"HCoreLdr: Fetch-Info: OK...").WriteString(L"\r\n");
+
+ UInt64 sz = info.FileSize;
+
+ if (BS->AllocatePool(EfiBootServicesData, sz, (VoidPtr*)&blob) != kEfiOk) {
+ mWriter
+ .WriteString(
+ L"HCoreLdr: Fetch: Failed to call AllocatePool "
+ L"correctly!")
+ .WriteString(L"\r\n");
+
+ kernelFile->Close(kernelFile);
+
+ return nullptr;
+ }
+
+ BSetMem((CharacterType*)blob, 0, sz);
+
+ mWriter.WriteString(L"HCoreLdr: Fetch-File: In-Progress...")
+ .WriteString(L"\r\n");
+
+ kernelFile->Read(kernelFile, &sz, blob);
+
+ mWriter.WriteString(L"HCoreLdr: Fetch-File: OK").WriteString(L"\r\n");
+
+ kernelFile->Close(kernelFile);
+
this->mCached = true;
- this->mErrorCode = kNotSupported;
+ this->mErrorCode = kOperationOkay;
+
+ this->mBlob = blob;
- return nullptr;
+ return blob;
}
diff --git a/Private/NewBoot/Source/HEL/AMD64/AMD64-ATA.cxx b/Private/NewBoot/Source/HEL/AMD64/AMD64-ATA.cxx
index 20af043d..46bec94c 100644
--- a/Private/NewBoot/Source/HEL/AMD64/AMD64-ATA.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/AMD64-ATA.cxx
@@ -71,6 +71,7 @@ ATAInit_Retry:
auto statRdy = In8(IO + ATA_REG_STATUS);
if (statRdy & ATA_SR_ERR) {
+ writer.WriteString(L"HCoreLdr: Probe error.\r\n");
return false;
}
if ((statRdy & ATA_SR_BSY)) goto ATAInit_Retry;
diff --git a/Private/NewBoot/Source/String.cxx b/Private/NewBoot/Source/String.cxx
index e080a01d..c59e2bba 100644
--- a/Private/NewBoot/Source/String.cxx
+++ b/Private/NewBoot/Source/String.cxx
@@ -13,7 +13,6 @@
#include <BootKit/BootKit.hxx>
#include <EFIKit/Api.hxx>
-#include <FSKit/NewFS.hxx>
/// bugs 0
diff --git a/Private/NewBoot/Source/TextWriter.cxx b/Private/NewBoot/Source/TextWriter.cxx
index 77baa067..b6a8e3b8 100644
--- a/Private/NewBoot/Source/TextWriter.cxx
+++ b/Private/NewBoot/Source/TextWriter.cxx
@@ -13,7 +13,6 @@
#include <BootKit/BootKit.hxx>
#include <EFIKit/Api.hxx>
-#include <FSKit/NewFS.hxx>
/// bugs 0
diff --git a/Private/NewBoot/Source/makefile b/Private/NewBoot/Source/makefile
index 460b5dc1..3deef8f4 100644
--- a/Private/NewBoot/Source/makefile
+++ b/Private/NewBoot/Source/makefile
@@ -19,6 +19,7 @@ bootloader-amd64:
$(CC_GNU) $(FLAG_GNU) HEL/AMD64/*.cxx *.cxx
$(LD_GNU) *.o HEL/AMD64/*.obj -e efi_main -filealign:16 -shared --subsystem=10 -ffreestanding -o HCoreLdr.exe
cp HCoreLdr.exe CDROM/EFI/BOOT/BOOTX64.EFI
+ cp ../../HCoreKrnl.exe CDROM/EFI/BOOT/HCoreKrnl.exe
.PHONY: make-disk
make-disk:
@@ -27,7 +28,7 @@ make-disk:
.PHONY: run-efi-debug
run-efi-debug:
wget https://retrage.github.io/edk2-nightly/bin/DEBUGX64_OVMF.fd -O OVMF.fd
- qemu-system-x86_64 -M q35 -bios OVMF.fd -drive file=os.epm,index=0,if=ide,format=qcow2 -drive file=fat:rw:CDROM,index=1,format=raw -d int
+ qemu-system-x86_64 -m 8G -M q35 -bios OVMF.fd -drive file=os.epm,index=0,if=ide,format=qcow2 -drive file=fat:rw:CDROM,index=1,format=raw -d int
.PHONY: clean
clean:
diff --git a/Private/NewKit/KernelHeap.hpp b/Private/NewKit/KernelHeap.hpp
index 73562f2f..80934caf 100644
--- a/Private/NewKit/KernelHeap.hpp
+++ b/Private/NewKit/KernelHeap.hpp
@@ -19,5 +19,5 @@
namespace HCore {
Void ke_init_ke_heap() noexcept;
Int32 ke_delete_ke_heap(voidPtr allocatedPtr);
-voidPtr ke_new_ke_heap(const SizeT &sz, const bool rw, const bool user);
+voidPtr ke_new_ke_heap(SizeT sz, const bool rw, const bool user);
} // namespace HCore
diff --git a/Private/Root/Boot/.gitkeep b/Private/Root/Boot/.gitkeep
deleted file mode 100644
index 8b137891..00000000
--- a/Private/Root/Boot/.gitkeep
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/Private/Root/Users/guest/.hgkeep b/Private/Root/Users/.USERHASH
index e69de29b..e69de29b 100644
--- a/Private/Root/Users/guest/.hgkeep
+++ b/Private/Root/Users/.USERHASH
diff --git a/Private/Root/Users/super/.gitkeep b/Private/Root/Users/super/.gitkeep
deleted file mode 100644
index e69de29b..00000000
--- a/Private/Root/Users/super/.gitkeep
+++ /dev/null
diff --git a/Private/Source/OSErr.cxx b/Private/Source/HError.cxx
index 26a9ae7e..000843df 100644
--- a/Private/Source/OSErr.cxx
+++ b/Private/Source/HError.cxx
@@ -7,4 +7,4 @@
* ========================================================
*/
-#include <KernelKit/OSErr.hpp>
+#include <KernelKit/HError.hpp>
diff --git a/Private/Source/KernelHeap.cxx b/Private/Source/KernelHeap.cxx
index 3c3cb9ce..72aa2d67 100644
--- a/Private/Source/KernelHeap.cxx
+++ b/Private/Source/KernelHeap.cxx
@@ -21,7 +21,7 @@ static Ref<PTEWrapper *> kLastWrapper;
static Pmm kPmm;
namespace Detail {
-static voidPtr find_ptr(const SizeT &sz, const bool rw, const bool user) {
+STATIC voidPtr ke_find_heap(const SizeT &sz, const bool rw, const bool user) {
for (SizeT indexWrapper = 0; indexWrapper < kMaxWrappers; ++indexWrapper) {
if (!kWrapperList[indexWrapper]->Present()) {
kWrapperList[indexWrapper]
@@ -35,21 +35,19 @@ static voidPtr find_ptr(const SizeT &sz, const bool rw, const bool user) {
}
} // namespace Detail
-/// @brief manual allocation
+/// @brief Page allocation routine.
/// @param sz size of pointer
/// @param rw read write (true to enable it)
/// @param user is it accesible by user processes?
/// @return the pointer
-VoidPtr ke_new_ke_heap(const SizeT &sz, const bool rw, const bool user) {
- if (kWrapperCount < sz) return nullptr;
+VoidPtr ke_new_ke_heap(SizeT sz, const bool rw, const bool user) {
+ if (sz == 0) ++sz;
- if (auto ptr = Detail::find_ptr(sz, rw, user); ptr) return ptr;
+ if (auto ptr = Detail::ke_find_heap(sz, rw, user); ptr) return ptr;
Ref<PTEWrapper *> wrapper = kPmm.RequestPage(user, rw);
if (wrapper) {
- wrapper->NoExecute(true);
-
kLastWrapper = wrapper;
kWrapperList[kWrapperCount] = wrapper;
diff --git a/Private/Source/NewFS-IO.cxx b/Private/Source/NewFS-IO.cxx
index 2c044def..e90ed1a4 100644
--- a/Private/Source/NewFS-IO.cxx
+++ b/Private/Source/NewFS-IO.cxx
@@ -7,10 +7,13 @@
* ========================================================
*/
-#include <FSKit/NewFS.hxx>
#include <KernelKit/DriveManager.hpp>
#include <KernelKit/FileManager.hpp>
-/// @brief this implements NewFS with Device Abstraction in mind.
+#ifdef __USE_NEWFS__
+
+/// @brief This implements NewFS with Device Abstraction in mind.
/// bugs 0
+
+#endif // ifdef __USE_NEWFS__
diff --git a/Private/Source/NewFS-Journal.cxx b/Private/Source/NewFS-Journal.cxx
index 029e051a..72812b6e 100644
--- a/Private/Source/NewFS-Journal.cxx
+++ b/Private/Source/NewFS-Journal.cxx
@@ -7,9 +7,12 @@
* ========================================================
*/
-#include <FSKit/NewFS.hxx>
#include <KernelKit/DebugOutput.hpp>
+#include <KernelKit/FileManager.hpp>
+#ifdef __USE_NEWFS__
+
+//! bugs: 0
//! @brief Journaling for NewFS.
#define kOpCache (4)
@@ -57,3 +60,5 @@ class NewFSJournalRunner final {
}
};
} // namespace HCore
+
+#endif // ifdef __USE_NEWFS__
diff --git a/Private/Source/NewFS.cxx b/Private/Source/NewFS.cxx
index 114c1e6b..2cb4fae9 100644
--- a/Private/Source/NewFS.cxx
+++ b/Private/Source/NewFS.cxx
@@ -7,9 +7,10 @@
* ========================================================
*/
-#include <FSKit/NewFS.hxx>
#include <KernelKit/FileManager.hpp>
+#ifdef __USE_NEWFS__
+
namespace HCore {
NewFilesystemManager::NewFilesystemManager() = default;
@@ -40,4 +41,10 @@ NodePtr NewFilesystemManager::CreateDirectory(const char* path) {
NodePtr NewFilesystemManager::CreateAlias(const char* path) {
return node_cast(fImpl->CreateCatalog(path, 0, kCatalogKindAlias));
}
+
+const char* NewFilesystemHelper::Root() { return kFilesystemRoot; }
+const char* NewFilesystemHelper::UpDir() { return kFilesystemUpDir; }
+const char NewFilesystemHelper::Separator() { return kFilesystemSeparator; }
} // namespace HCore
+
+#endif // ifdef __USE_NEWFS__
diff --git a/Private/Source/PEFSharedObjectRT.cxx b/Private/Source/PEFSharedObjectRT.cxx
index 035b068f..c13314df 100644
--- a/Private/Source/PEFSharedObjectRT.cxx
+++ b/Private/Source/PEFSharedObjectRT.cxx
@@ -66,7 +66,7 @@ extern "C" SharedObject *__LibInit() {
library->Get()->fImageEntrypointOffset =
library->Load<VoidPtr>(kPefStart, string_length(kPefStart, 0), kPefCode);
- kcout << "__LibInit: Task was successful... Returning library...\n";
+ kcout << "__LibInit: Task was successful!\n";
return library;
}
@@ -94,6 +94,8 @@ extern "C" Void __LibFini(SharedObjectPtr lib, bool *successful) {
lib = nullptr;
+ kcout << "__LibFini: Task was successful!\n";
+
*successful = true;
}
diff --git a/Private/Source/Storage/ATA.cxx b/Private/Source/Storage/ATA.cxx
index 7d8ce32f..47c05ac8 100644
--- a/Private/Source/Storage/ATA.cxx
+++ b/Private/Source/Storage/ATA.cxx
@@ -40,6 +40,8 @@ enum {
};
const char* ata_read_28(ULong lba) {
+ if (!kPrdt) return nullptr;
+
static char buffer[512];
UIntPtr* packet = (UIntPtr*)kPrdt.Leak()->PhysicalAddress();
@@ -56,6 +58,8 @@ const char* ata_read_28(ULong lba) {
#define kBufferLen 512
const char* ata_read_48(ULong lba) {
+ if (!kPrdt) return nullptr;
+
static char buffer[kBufferLen];
rt_set_memory(buffer, 0, kBufferLen);
@@ -71,6 +75,8 @@ const char* ata_read_48(ULong lba) {
}
Int32 ata_write_48(ULong lba, const char* buffer) {
+ if (!kPrdt) return kATAError;
+
UIntPtr* packet = reinterpret_cast<UIntPtr*>(kPrdt.Leak()->PhysicalAddress());
packet[0] = k48BitWrite;
@@ -83,6 +89,8 @@ Int32 ata_write_48(ULong lba, const char* buffer) {
}
Int32 ata_write_28(ULong lba, const char* text) {
+ if (!kPrdt) return kATAError;
+
UIntPtr* packet = (UIntPtr*)kPrdt.Leak()->PhysicalAddress();
packet[0] = k28BitWrite;
diff --git a/Private/Source/UserHeap.cxx b/Private/Source/UserHeap.cxx
index e22fe4f9..6a173a44 100644
--- a/Private/Source/UserHeap.cxx
+++ b/Private/Source/UserHeap.cxx
@@ -12,8 +12,8 @@
/// @file Heap.cxx
/// @brief Heap Manager, Process heap allocator.
-/// @note if you want to look at the kernel allocator, please look for KernelHeap.cxx
-/// bugs: 0
+/// @note if you want to look at the kernel allocator, please look for
+/// KernelHeap.cxx bugs: 0
namespace HCore {
/**
@@ -105,10 +105,10 @@ STATIC void ke_free_heap_internal(voidPtr virtualAddress) {
/**
* @brief Check for the ptr and frees it.
- *
+ *
* @param index Where to look at.
* @param ptr The ptr to check.
- * @return Boolean true if successful.
+ * @return Boolean true if successful.
*/
STATIC Boolean ke_check_and_free_heap(const SizeT& index, voidPtr ptr) {
if (HeapManager::The()[index]) {
@@ -143,8 +143,8 @@ voidPtr ke_new_heap(Int32 flags) {
if (voidPtr ret = ke_find_unused_heap(flags)) return ret;
// this wasn't set to true
- auto ref_page = HeapManager::Leak().Leak().RequestPage(
- ((flags & kPoolUser)), (flags & kPoolRw));
+ auto ref_page = HeapManager::Leak().Leak().RequestPage(((flags & kPoolUser)),
+ (flags & kPoolRw));
if (ref_page) {
///! reserve page.
@@ -153,6 +153,8 @@ voidPtr ke_new_heap(Int32 flags) {
++ref; // increment the number of addresses we have now.
+ ref_page->NoExecute(true);
+
// finally make the pool address.
return ke_make_heap(
reinterpret_cast<voidPtr>(ref_page.Leak()->VirtualAddress()), flags);
diff --git a/Private/makefile b/Private/makefile
index 6834c0be..1f1d7b27 100644
--- a/Private/makefile
+++ b/Private/makefile
@@ -5,7 +5,7 @@
CC = x86_64-w64-mingw32-g++
LD = x86_64-w64-mingw32-ld
-CCFLAGS = -c -ffreestanding -fno-rtti -fno-exceptions -std=c++20 -D__HAVE_HCORE_APIS__ -D__HCORE__ -I../ -I./ -I$(HOME)/
+CCFLAGS = -c -ffreestanding -fno-rtti -fno-exceptions -std=c++20 -D__USE_NEWFS__ -D__HAVE_HCORE_APIS__ -D__HCORE__ -I../ -I./ -I$(HOME)/
ASM = nasm
ASMFLAGS = -f win64
LDFLAGS = -e Main -filealign:16 -shared --subsystem=10