From b06f525d69e6adab8da0a5129bcd39fc592c6922 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Mon, 8 Jan 2024 16:42:01 +0100 Subject: Add MPT API (newBoot) Signed-off-by: Amlal El Mahrouss --- newBoot/Source/MPT/API.cxx | 71 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 newBoot/Source/MPT/API.cxx (limited to 'newBoot/Source/MPT/API.cxx') 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 +Cls* new_class() +{ + Cls* cls = (Cls*)AllocPtr(sizeof(Cls)); + *cls = Cls(); + + return cls; +} +} + +namespace mpt +{ +bool filesystem_init(void) +{ + kRootGroup = detail::new_class(); + Assert(kRootGroup != nullptr); + + return true; +} +} \ No newline at end of file -- cgit v1.2.3