summaryrefslogtreecommitdiffhomepage
path: root/newBoot/Source/MPT
diff options
context:
space:
mode:
Diffstat (limited to 'newBoot/Source/MPT')
-rw-r--r--newBoot/Source/MPT/.hgkeep0
-rw-r--r--newBoot/Source/MPT/API.cxx71
-rw-r--r--newBoot/Source/MPT/API.hxx17
-rw-r--r--newBoot/Source/MPT/FileType.hxx30
-rw-r--r--newBoot/Source/MPT/MPT.hxx29
5 files changed, 147 insertions, 0 deletions
diff --git a/newBoot/Source/MPT/.hgkeep b/newBoot/Source/MPT/.hgkeep
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/newBoot/Source/MPT/.hgkeep
diff --git a/newBoot/Source/MPT/API.cxx b/newBoot/Source/MPT/API.cxx
new file mode 100644
index 00000000..2cedd73e
--- /dev/null
+++ b/newBoot/Source/MPT/API.cxx
@@ -0,0 +1,71 @@
+/*
+ * ========================================================
+ *
+ * newBoot
+ * Copyright Mahrouss Logic, all rights reserved.
+ *
+ * ========================================================
+ */
+
+#include "API.hxx"
+
+struct Files32FileHdr
+{
+ char Filename[32];
+ char Ext[3];
+ char Attr;
+ char Case;
+ char CreateMs;
+ unsigned short Create;
+ unsigned short CreateDate;
+ unsigned short LastAccess;
+ unsigned short Timestamp;
+ unsigned short Datestamp;
+ unsigned short StartLba;
+ unsigned int SizeFile;
+};
+
+#define kFilesR 0x01 /* read-only */
+#define kFilesH 0x02 /* hidden */
+#define kFilesS 0x04 /* system */
+#define kFilesL 0x08 /* volume label */
+#define kFilesD 0x10 /* directory */
+#define kFilesZ 0x20 /* archive */
+
+// @brief Array of unused bits.
+#define kFilesU { 0x40, 0x80 }
+
+struct Files32FileGroup {
+ Files32FileHdr* fHdr{ nullptr };
+
+ Files32FileGroup* fUpper{ nullptr };
+ Files32FileGroup* fLower{ nullptr };
+ Files32FileGroup* fPrev{ nullptr };
+ Files32FileGroup* fNext{ nullptr };
+} kRootGroup = nullptr;
+
+extern "C" Assert(bool expr);
+extern "C" void* AllocPtr(long sz);
+
+namespace detail
+{
+template <typename Cls>
+Cls* new_class()
+{
+ Cls* cls = (Cls*)AllocPtr(sizeof(Cls));
+ *cls = Cls();
+
+ return cls;
+}
+}
+
+namespace mpt
+{
+bool filesystem_init(void)
+{
+ kRootGroup = detail::new_class<Files32FileGroup>();
+ Assert(kRootGroup != nullptr);
+
+ return true;
+}
+} \ No newline at end of file
diff --git a/newBoot/Source/MPT/API.hxx b/newBoot/Source/MPT/API.hxx
new file mode 100644
index 00000000..42822371
--- /dev/null
+++ b/newBoot/Source/MPT/API.hxx
@@ -0,0 +1,17 @@
+/*
+ * ========================================================
+ *
+ * newBoot
+ * Copyright Mahrouss Logic, all rights reserved.
+ *
+ * ========================================================
+ */
+
+#pragma once
+
+namespace mpt
+{
+/// initializes the Master Partition Table Files32 filesystem.
+/// \return status, assert(fail) is also triggered, use filesystem_hook_error if you want to catch it.
+bool filesystem_init(void);
+} \ No newline at end of file
diff --git a/newBoot/Source/MPT/FileType.hxx b/newBoot/Source/MPT/FileType.hxx
new file mode 100644
index 00000000..26beb114
--- /dev/null
+++ b/newBoot/Source/MPT/FileType.hxx
@@ -0,0 +1,30 @@
+/*
+ * ========================================================
+ *
+ * newBoot
+ * Copyright Mahrouss Logic, all rights reserved.
+ *
+ * ========================================================
+ */
+
+#pragma once
+
+// @brief this file purpose is to read/write files.
+
+#include <NewKit/Defines.hpp>
+
+/// \brief File buffer class
+/// \tparam _Manager The disk manager
+template <typename _Manager>
+class FileType
+{
+public:
+ hCore::SizeT DiskId{ 0 };
+ hCore::VoidPtr DiskSpace{ nullptr };
+ hCore::SizeT DiskSize{ 0 };
+ hCore::Int32 DiskError{ 0 };
+
+ FileType* Read(const char* path) { return _Manager::Read(path); }
+ FileType* Write(FileType* path) { return _Manager::Write(path); }
+
+}; \ No newline at end of file
diff --git a/newBoot/Source/MPT/MPT.hxx b/newBoot/Source/MPT/MPT.hxx
new file mode 100644
index 00000000..d407a2f2
--- /dev/null
+++ b/newBoot/Source/MPT/MPT.hxx
@@ -0,0 +1,29 @@
+/*
+ * ========================================================
+ *
+ * newBoot
+ * Copyright Mahrouss Logic, all rights reserved.
+ *
+ * ========================================================
+ */
+
+#pragma once
+
+// @brief 255 size partition header.
+// we use that to gather information about this hard drive.
+
+struct MasterPartitionTable final
+{
+ char fPartName[32];
+ int fPartType;
+ int fPartSectorSz;
+ int fPartSectorCnt;
+ char fReserved[211];
+};
+
+enum
+{
+ kPartEfi = 'efi',
+ kPartEpm = 'epm',
+ kPartEbr = 'ebr',
+}; \ No newline at end of file