summaryrefslogtreecommitdiffhomepage
path: root/newBoot/Source/MPT/API.cxx
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-01-08 16:42:01 +0100
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-01-08 16:43:43 +0100
commitb06f525d69e6adab8da0a5129bcd39fc592c6922 (patch)
tree8e8ba6dbae00081c6c9031be53bc9aa9f1d445b1 /newBoot/Source/MPT/API.cxx
parentf546108501aed048b7719765c3f221015abfd835 (diff)
Add MPT API (newBoot)
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'newBoot/Source/MPT/API.cxx')
-rw-r--r--newBoot/Source/MPT/API.cxx71
1 files changed, 71 insertions, 0 deletions
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