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/FSKit/.hgkeep | 0 newBoot/Source/FSKit/FileType.hxx | 30 ----------------- newBoot/Source/FSKit/Files32.cxx | 10 ------ newBoot/Source/FSKit/Files32.hxx | 36 -------------------- newBoot/Source/FSKit/MPT.hxx | 29 ---------------- newBoot/Source/MPT/.hgkeep | 0 newBoot/Source/MPT/API.cxx | 71 +++++++++++++++++++++++++++++++++++++++ newBoot/Source/MPT/API.hxx | 17 ++++++++++ newBoot/Source/MPT/FileType.hxx | 30 +++++++++++++++++ newBoot/Source/MPT/MPT.hxx | 29 ++++++++++++++++ 10 files changed, 147 insertions(+), 105 deletions(-) delete mode 100644 newBoot/Source/FSKit/.hgkeep delete mode 100644 newBoot/Source/FSKit/FileType.hxx delete mode 100644 newBoot/Source/FSKit/Files32.cxx delete mode 100644 newBoot/Source/FSKit/Files32.hxx delete mode 100644 newBoot/Source/FSKit/MPT.hxx create mode 100644 newBoot/Source/MPT/.hgkeep create mode 100644 newBoot/Source/MPT/API.cxx create mode 100644 newBoot/Source/MPT/API.hxx create mode 100644 newBoot/Source/MPT/FileType.hxx create mode 100644 newBoot/Source/MPT/MPT.hxx diff --git a/newBoot/Source/FSKit/.hgkeep b/newBoot/Source/FSKit/.hgkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/newBoot/Source/FSKit/FileType.hxx b/newBoot/Source/FSKit/FileType.hxx deleted file mode 100644 index 26beb114..00000000 --- a/newBoot/Source/FSKit/FileType.hxx +++ /dev/null @@ -1,30 +0,0 @@ -/* - * ======================================================== - * - * newBoot - * Copyright Mahrouss Logic, all rights reserved. - * - * ======================================================== - */ - -#pragma once - -// @brief this file purpose is to read/write files. - -#include - -/// \brief File buffer class -/// \tparam _Manager The disk manager -template -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/FSKit/Files32.cxx b/newBoot/Source/FSKit/Files32.cxx deleted file mode 100644 index e7ba96f9..00000000 --- a/newBoot/Source/FSKit/Files32.cxx +++ /dev/null @@ -1,10 +0,0 @@ -/* - * ======================================================== - * - * newBoot - * Copyright Mahrouss Logic, all rights reserved. - * - * ======================================================== - */ - -#include "Files32.hxx" diff --git a/newBoot/Source/FSKit/Files32.hxx b/newBoot/Source/FSKit/Files32.hxx deleted file mode 100644 index 9e940f6d..00000000 --- a/newBoot/Source/FSKit/Files32.hxx +++ /dev/null @@ -1,36 +0,0 @@ -/* - * ======================================================== - * - * newBoot - * Copyright Mahrouss Logic, all rights reserved. - * - * ======================================================== - */ - -#pragma once - -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 } diff --git a/newBoot/Source/FSKit/MPT.hxx b/newBoot/Source/FSKit/MPT.hxx deleted file mode 100644 index e2a548e4..00000000 --- a/newBoot/Source/FSKit/MPT.hxx +++ /dev/null @@ -1,29 +0,0 @@ -/* - * ======================================================== - * - * newBoot - * Copyright Mahrouss Logic, all rights reserved. - * - * ======================================================== - */ - -#pragma once - -// @brief 255 size partiton 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', - kPartXpm = 'xpm', - kPartEbr = 'ebr', -}; \ No newline at end of file diff --git a/newBoot/Source/MPT/.hgkeep b/newBoot/Source/MPT/.hgkeep new file mode 100644 index 00000000..e69de29b 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 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 + +/// \brief File buffer class +/// \tparam _Manager The disk manager +template +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 -- cgit v1.2.3