From ea937555b04ae7f39785341e45955b48515e5bf1 Mon Sep 17 00:00:00 2001 From: Amlal Date: Sun, 21 Jul 2024 09:48:52 +0200 Subject: [IMP] MHR-36: Much better ref class Signed-off-by: Amlal --- Kernel/KernelKit/PCI/Iterator.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Kernel/KernelKit/PCI/Iterator.hpp') diff --git a/Kernel/KernelKit/PCI/Iterator.hpp b/Kernel/KernelKit/PCI/Iterator.hpp index 2274df31..0d6d894c 100644 --- a/Kernel/KernelKit/PCI/Iterator.hpp +++ b/Kernel/KernelKit/PCI/Iterator.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #define NEWOS_BUS_COUNT (256) #define NEWOS_DEVICE_COUNT (33) -- cgit v1.2.3 From 8eee31685e4334415870bb00b11b6b0d29821f10 Mon Sep 17 00:00:00 2001 From: Amlal Date: Tue, 23 Jul 2024 09:03:11 +0200 Subject: [MHR-36] NVME driver improvements, add RLE flag for NewFS. NVME: - Rename NVME.hxx to Defines.hxx, inside NVME module. NewFS: - Add RLE flag to NewFS. Which marks catalog as compressed. Meta: - Remove unused headers. - Use Mahrouss API version for kernel version. Signed-off-by: Amlal --- Boot/BootKit/Vendor/Qr.hxx | 1 - Boot/Sources/HEL/AMD64/BootMain.cxx | 1 - Kernel/FSKit/NewFS.hxx | 2 + Kernel/HALKit/AMD64/HalKernelMain.cxx | 2 +- Kernel/HALKit/AMD64/PCI/PCI.cxx | 2 +- Kernel/KernelKit/PCI/Iterator.hpp | 7 +- Kernel/KernelKit/PCI/PCI.hpp | 58 ----------------- Kernel/KernelKit/PCI/PCI.hxx | 59 +++++++++++++++++ Kernel/Modules/NVME/Defines.hxx | 116 ++++++++++++++++++++++++++++++++++ Kernel/Modules/NVME/NVME.hxx | 107 ------------------------------- Kernel/NewKit/Macros.hpp | 2 +- 11 files changed, 186 insertions(+), 171 deletions(-) delete mode 100644 Kernel/KernelKit/PCI/PCI.hpp create mode 100644 Kernel/KernelKit/PCI/PCI.hxx create mode 100644 Kernel/Modules/NVME/Defines.hxx delete mode 100644 Kernel/Modules/NVME/NVME.hxx (limited to 'Kernel/KernelKit/PCI/Iterator.hpp') diff --git a/Boot/BootKit/Vendor/Qr.hxx b/Boot/BootKit/Vendor/Qr.hxx index 0571aa7c..8799d824 100644 --- a/Boot/BootKit/Vendor/Qr.hxx +++ b/Boot/BootKit/Vendor/Qr.hxx @@ -1,7 +1,6 @@ #ifndef QR_HXX #define QR_HXX -#include "BootKit/BootKit.hxx" extern "C" { #include #include diff --git a/Boot/Sources/HEL/AMD64/BootMain.cxx b/Boot/Sources/HEL/AMD64/BootMain.cxx index 15c9b7e5..5828e340 100644 --- a/Boot/Sources/HEL/AMD64/BootMain.cxx +++ b/Boot/Sources/HEL/AMD64/BootMain.cxx @@ -4,7 +4,6 @@ ------------------------------------------- */ -#include "NewKit/Json.hxx" #include #include #include diff --git a/Kernel/FSKit/NewFS.hxx b/Kernel/FSKit/NewFS.hxx index 86bd3be3..f8924fee 100644 --- a/Kernel/FSKit/NewFS.hxx +++ b/Kernel/FSKit/NewFS.hxx @@ -65,6 +65,8 @@ default. #define kNewFSCatalogKindDevice (9) #define kNewFSCatalogKindLock (10) +#define kNewFSCatalogKindRLE (11) + #define kNewFSSeparator '\\' #define kNewFSUpDir ".." diff --git a/Kernel/HALKit/AMD64/HalKernelMain.cxx b/Kernel/HALKit/AMD64/HalKernelMain.cxx index ad031b8b..1628e5e9 100644 --- a/Kernel/HALKit/AMD64/HalKernelMain.cxx +++ b/Kernel/HALKit/AMD64/HalKernelMain.cxx @@ -221,7 +221,7 @@ EXTERN_C void hal_init_platform( strVer += "\\Properties\\KernelVersion"; cKernelVersion.GetKey() = strVer; - cKernelVersion.GetValue() = 100; + cKernelVersion.GetValue() = __MAHROUSS__; Kernel::StringView strAutoMount(cMaxPropLen); strAutoMount += "\\Properties\\AutoMountFS?"; diff --git a/Kernel/HALKit/AMD64/PCI/PCI.cxx b/Kernel/HALKit/AMD64/PCI/PCI.cxx index 3fd3f193..d15b1b9a 100644 --- a/Kernel/HALKit/AMD64/PCI/PCI.cxx +++ b/Kernel/HALKit/AMD64/PCI/PCI.cxx @@ -4,4 +4,4 @@ ------------------------------------------- */ -#include +#include diff --git a/Kernel/KernelKit/PCI/Iterator.hpp b/Kernel/KernelKit/PCI/Iterator.hpp index 0d6d894c..8c2df3b4 100644 --- a/Kernel/KernelKit/PCI/Iterator.hpp +++ b/Kernel/KernelKit/PCI/Iterator.hpp @@ -1,3 +1,9 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies + +------------------------------------------- */ + #ifndef __PCI_ITERATOR_HPP__ #define __PCI_ITERATOR_HPP__ @@ -22,7 +28,6 @@ namespace Kernel::PCI explicit Iterator(const Types::PciDeviceKind& deviceType); Iterator& operator=(const Iterator&) = default; - Iterator(const Iterator&) = default; ~Iterator(); diff --git a/Kernel/KernelKit/PCI/PCI.hpp b/Kernel/KernelKit/PCI/PCI.hpp deleted file mode 100644 index b2d54a34..00000000 --- a/Kernel/KernelKit/PCI/PCI.hpp +++ /dev/null @@ -1,58 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies - -------------------------------------------- */ -#pragma once - -#include - -#define PCI_CONFIG_ADDRESS (0xCF8) -#define PCI_CONFIG_DATA (0xCFC) - -#define PCI_DEVICE_COUNT (32) -#define PCI_FUNC_COUNT (8) -#define PCI_BUS_COUNT (255) - -namespace Kernel::PCI -{ - // model - struct DeviceHeader - { - UInt16 VendorId; - UInt16 DeviceId; - UInt8 Command; - UInt8 Status; - UInt8 RevisionId; - UInt8 ProgIf; - UInt8 SubClass; - UInt8 Class; - UInt8 CacheLineSz; - UInt8 LatencyTimer; - UInt8 HeaderType; - UInt8 Bist; - UInt8 Bus; - UInt8 Device; - UInt8 Function; - }; - - namespace Detail - { - class BAR - { - public: - UIntPtr BAR; - SizeT Size; - }; - } // namespace Detail - - class BAR - { - public: - Detail::BAR BAR1; - Detail::BAR BAR2; - Detail::BAR BAR3; - Detail::BAR BAR4; - Detail::BAR BAR5; - }; -} // namespace Kernel::PCI diff --git a/Kernel/KernelKit/PCI/PCI.hxx b/Kernel/KernelKit/PCI/PCI.hxx new file mode 100644 index 00000000..e75215d6 --- /dev/null +++ b/Kernel/KernelKit/PCI/PCI.hxx @@ -0,0 +1,59 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies + +------------------------------------------- */ + +#pragma once + +#include + +#define cPCIConfigAddressPort (0xCF8) +#define cPCIConfigDataPort (0xCFC) + +#define cPCIDeviceCount (32) +#define cPCIFuncCount (8) +#define cPCIBusCount (255) + +namespace Kernel::PCI +{ + // model + struct DeviceHeader + { + UInt16 VendorId; + UInt16 DeviceId; + UInt8 Command; + UInt8 Status; + UInt8 RevisionId; + UInt8 ProgIf; + UInt8 SubClass; + UInt8 Class; + UInt8 CacheLineSz; + UInt8 LatencyTimer; + UInt8 HeaderType; + UInt8 Bist; + UInt8 Bus; + UInt8 Device; + UInt8 Function; + }; + + namespace Detail + { + class BAR + { + public: + UIntPtr BAR; + SizeT Size; + }; + } // namespace Detail + + class BAR + { + public: + Detail::BAR BAR1; + Detail::BAR BAR2; + Detail::BAR BAR3; + Detail::BAR BAR4; + Detail::BAR BAR5; + }; +} // namespace Kernel::PCI diff --git a/Kernel/Modules/NVME/Defines.hxx b/Kernel/Modules/NVME/Defines.hxx new file mode 100644 index 00000000..50960ed5 --- /dev/null +++ b/Kernel/Modules/NVME/Defines.hxx @@ -0,0 +1,116 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies + + Revision History: + + ??/??/24: Added file (amlel) + 23 Jul 24: Update filename to Defines.hxx and using ALIGN_NVME for NVME structs. (amlel) + +------------------------------------------- */ + +#ifndef __MODULE_NVME_HXX__ +#define __MODULE_NVME_HXX__ + +#include + +/// TODO: checklist in: https://wiki.osdev.org/NVMe + +#define ALIGN_NVME ATTRIBUTE(aligned(sizeof(Kernel::NVMEInt32))) + +namespace Kernel +{ + typedef UInt32 NVMEInt32; + + struct ALIGN_NVME NVMEBar0 final + { + NVMEInt32 fCap; + NVMEInt32 fVer; + NVMEInt32 fIntMaskSet; + NVMEInt32 fIntMaskClr; + NVMEInt32 fContrlConf; + NVMEInt32 fContrlStat; + NVMEInt32 fAdminQueueAttr; + NVMEInt32 fAdminSubmissionQueue; + NVMEInt32 fAdminCompletionQueue; + }; + + struct ALIGN_NVME NVMEQueue final + { + NVMEInt32 fOpcode; + NVMEInt32 fNSID; + NVMEInt32 fReserved[3]; + NVMEInt32 fMetadataPtr[5]; + NVMEInt32 fDataPtr[9]; + NVMEInt32 CommandSpecific[15]; + }; + + enum + { + eCreateCompletionQueueNVME = 0x05, + eCreateSubmissionQueueNVME = 0x01, + eIdentifyNVME = 0x06, + eReadNVME = 0x02, + eWriteNVME = 0x01, + }; + + template + inline Bool nvme_create_admin_command(NVMEQueue* entry, UInt32 nsid, + UInt32 prpTransfer[3], + UInt32 startingLba[2], UInt32 lowTransferBlocks) + { + if (entry == nullptr) + return false; + + entry->CommandSpecific[9] = startingLba[0]; + entry->CommandSpecific[10] = startingLba[1]; + + entry->CommandSpecific[11] = lowTransferBlocks; + + entry->CommandSpecific[5] = prpTransfer[0]; + entry->CommandSpecific[6] = prpTransfer[1]; + entry->CommandSpecific[7] = prpTransfer[2]; + + entry->CommandSpecific[0] = nsid; + + return true; + } + + template + inline Bool nvme_create_io_command(NVMEQueue* entry, UInt64 baseAddress, + UInt32 identLoAndQueueSizeHi, UInt32 flagsLoAndQueueComplIdHi, + UInt32 identify, Bool provideIdentify = false, Bool namespaceIdentify = false) + { + if (entry == nullptr) + return false; + + if (baseAddress == 0) + return false; + + entry->fOpcode = Opcode; + + entry->CommandSpecific[5] = (baseAddress & 0xFF); + entry->CommandSpecific[6] = static_cast(baseAddress); + + if (!provideIdentify) + { + entry->CommandSpecific[9] = identLoAndQueueSizeHi; + entry->CommandSpecific[10] = flagsLoAndQueueComplIdHi; + } + else + { + entry->CommandSpecific[9] = identify; + + if (namespaceIdentify) + { + entry->CommandSpecific[0] = 1; + } + } + + // use (1 << 0) as contigunous is better supported. + + return true; + } +} // namespace Kernel + +#endif // ifndef __MODULE_NVME_HXX__ diff --git a/Kernel/Modules/NVME/NVME.hxx b/Kernel/Modules/NVME/NVME.hxx deleted file mode 100644 index b306af4b..00000000 --- a/Kernel/Modules/NVME/NVME.hxx +++ /dev/null @@ -1,107 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies - -------------------------------------------- */ - -#ifndef __MODULE_NVME_HXX__ -#define __MODULE_NVME_HXX__ - -#include - -/// TODO: checklist in: https://wiki.osdev.org/NVMe - -#define mNVMEAlign ATTRIBUTE(aligned(sizeof(Kernel::NVMEInt32))) - -namespace Kernel -{ - typedef UInt32 NVMEInt32; - - struct NVMEBar0 final - { - NVMEInt32 fCap; - NVMEInt32 fVer; - NVMEInt32 fIntMaskSet; - NVMEInt32 fIntMaskClr; - NVMEInt32 fContrlConf; - NVMEInt32 fContrlStat; - NVMEInt32 fAdminQueueAttr; - NVMEInt32 fAdminSubmissionQueue; - NVMEInt32 fAdminCompletionQueue; - }; - - struct NVMEQueue final - { - NVMEInt32 fOpcode; - NVMEInt32 fNSID; - NVMEInt32 fReserved[3]; - NVMEInt32 fMetadataPtr[5]; - NVMEInt32 fDataPtr[9]; - NVMEInt32 CommandSpecific[15]; - }; - - enum - { - eCreateCompletionQueueNVME = 0x05, - eCreateSubmissionQueueNVME = 0x01, - eIdentifyNVME = 0x06, - eReadNVME = 0x02, - eWriteNVME = 0x01, - }; - - template - inline Bool nvme_create_admin_command(NVMEQueue* entry, UInt32 nsid, UInt32 prpTransfer[3], UInt32 startingLba[2], UInt32 lowTransferBlocks) - { - if (entry == nullptr) - return false; - - entry->CommandSpecific[9] = startingLba[0]; - entry->CommandSpecific[10] = startingLba[1]; - - entry->CommandSpecific[11] = lowTransferBlocks; - - entry->CommandSpecific[5] = prpTransfer[0]; - entry->CommandSpecific[6] = prpTransfer[1]; - entry->CommandSpecific[7] = prpTransfer[2]; - - entry->CommandSpecific[0] = nsid; - - return true; - } - - template - inline Bool nvme_create_admin_command(NVMEQueue* entry, UInt64 baseAddress, UInt32 identLoAndQueueSizeHi, UInt32 flagsLoAndQueueComplIdHi, UInt32 identify, Bool provideIdentify = false, Bool namespaceIdentify = false) - { - if (entry == nullptr) - return false; - - if (baseAddress == 0) - return false; - - entry->fOpcode = Opcode; - - entry->CommandSpecific[5] = (baseAddress & 0xFF); - entry->CommandSpecific[6] = static_cast(baseAddress); - - if (!provideIdentify) - { - entry->CommandSpecific[9] = identLoAndQueueSizeHi; - entry->CommandSpecific[10] = flagsLoAndQueueComplIdHi; - } - else - { - entry->CommandSpecific[9] = identify; - - if (namespaceIdentify) - { - entry->CommandSpecific[0] = 1; - } - } - - // use (1 << 0) as contigunous is better supported. - - return true; - } -} // namespace Kernel - -#endif // ifndef __MODULE_NVME_HXX__ diff --git a/Kernel/NewKit/Macros.hpp b/Kernel/NewKit/Macros.hpp index a8749cf4..ba636874 100644 --- a/Kernel/NewKit/Macros.hpp +++ b/Kernel/NewKit/Macros.hpp @@ -53,7 +53,7 @@ #endif // #ifndef ATTRIBUTE #ifndef __MAHROUSS__ -#define __MAHROUSS__ (202401) +#define __MAHROUSS__ (202404) #endif // !__MAHROUSS__ #ifndef EXTERN_C -- cgit v1.2.3