summaryrefslogtreecommitdiffhomepage
path: root/dev/modules/NVME
diff options
context:
space:
mode:
authorAmlal <amlal@nekernel.org>2025-04-25 13:08:33 +0200
committerAmlal <amlal@nekernel.org>2025-04-25 13:08:33 +0200
commitfb790b07aeba8e22e4190cf3e1834d11ecde6c96 (patch)
tree4cec7d1b321307b1d5935577631dae116a658a37 /dev/modules/NVME
parent63a2d92c5dfe976175cda024ec01905d11b43738 (diff)
dev: better .clang-format, ran format command.
Signed-off-by: Amlal <amlal@nekernel.org>
Diffstat (limited to 'dev/modules/NVME')
-rw-r--r--dev/modules/NVME/NVME.h183
1 files changed, 87 insertions, 96 deletions
diff --git a/dev/modules/NVME/NVME.h b/dev/modules/NVME/NVME.h
index f58aacf9..6572187b 100644
--- a/dev/modules/NVME/NVME.h
+++ b/dev/modules/NVME/NVME.h
@@ -1,11 +1,11 @@
/* -------------------------------------------
- Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved.
+ Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved.
- Revision History:
+ Revision History:
- ??/??/24: Added file (amlel)
- 23 Jul 24: Update filename to Defines.h and using NE_ALIGN_NVME for NVME structs. (amlel)
+ ??/??/24: Added file (amlel)
+ 23 Jul 24: Update filename to Defines.h and using NE_ALIGN_NVME for NVME structs. (amlel)
------------------------------------------- */
@@ -19,95 +19,86 @@
#define NE_ALIGN_NVME ATTRIBUTE(aligned(sizeof(Kernel::UInt32)))
-namespace Kernel
-{
- struct NE_ALIGN_NVME HAL_NVME_BAR_0 final
- {
- UInt32 fCapabilities;
- UInt32 fVersion;
- UInt32 fIntMaskSet;
- UInt32 fIntMaskClr;
- UInt32 fContrlConf;
- UInt32 fContrlStat;
- UInt32 fAdminQueueAttr;
- UInt32 fAdminSubmissionQueue;
- UInt32 fAdminCompletionQueue;
- };
-
- struct NE_ALIGN_NVME HAL_NVME_QUEUE final
- {
- UInt32 fOpcode;
- UInt32 fNSID;
- UInt32 fReserved[3];
- UInt32 fMetadataPtr[5];
- UInt32 fDataPtr[9];
- UInt32 CommandSpecific[15];
- };
-
- enum
- {
- kInvalidNVME = 0xFF,
- kCreateCompletionQueueNVME = 0x05,
- kCreateSubmissionQueueNVME = 0x01,
- kIdentifyNVME = 0x06,
- kReadNVME = 0x02,
- kWriteNVME = 0x01,
- kCountNVME = 5,
- };
-
- /// @brief Creates an admin command for a DMA operation.
- template <Int32 Opcode>
- inline Bool nvme_create_admin_command(HAL_NVME_QUEUE* 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;
- }
-
- /// @brief Creates an I/O command for a DMA operation.
- template <Int32 Opcode>
- inline Bool nvme_create_io_command(HAL_NVME_QUEUE* 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<UInt32>(baseAddress);
-
- if (!provideIdentify)
- {
- entry->CommandSpecific[9] = identLoAndQueueSizeHi;
- entry->CommandSpecific[10] = flagsLoAndQueueComplIdHi;
- }
- else
- {
- entry->CommandSpecific[9] = identify;
-
- if (namespaceIdentify)
- {
- entry->CommandSpecific[0] = 1;
- }
- }
-
- return true;
- }
-} // namespace Kernel
-
-#endif // ifndef __MODULE_NVME_H__
+namespace Kernel {
+struct NE_ALIGN_NVME HAL_NVME_BAR_0 final {
+ UInt32 fCapabilities;
+ UInt32 fVersion;
+ UInt32 fIntMaskSet;
+ UInt32 fIntMaskClr;
+ UInt32 fContrlConf;
+ UInt32 fContrlStat;
+ UInt32 fAdminQueueAttr;
+ UInt32 fAdminSubmissionQueue;
+ UInt32 fAdminCompletionQueue;
+};
+
+struct NE_ALIGN_NVME HAL_NVME_QUEUE final {
+ UInt32 fOpcode;
+ UInt32 fNSID;
+ UInt32 fReserved[3];
+ UInt32 fMetadataPtr[5];
+ UInt32 fDataPtr[9];
+ UInt32 CommandSpecific[15];
+};
+
+enum {
+ kInvalidNVME = 0xFF,
+ kCreateCompletionQueueNVME = 0x05,
+ kCreateSubmissionQueueNVME = 0x01,
+ kIdentifyNVME = 0x06,
+ kReadNVME = 0x02,
+ kWriteNVME = 0x01,
+ kCountNVME = 5,
+};
+
+/// @brief Creates an admin command for a DMA operation.
+template <Int32 Opcode>
+inline Bool nvme_create_admin_command(HAL_NVME_QUEUE* 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;
+}
+
+/// @brief Creates an I/O command for a DMA operation.
+template <Int32 Opcode>
+inline Bool nvme_create_io_command(HAL_NVME_QUEUE* 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<UInt32>(baseAddress);
+
+ if (!provideIdentify) {
+ entry->CommandSpecific[9] = identLoAndQueueSizeHi;
+ entry->CommandSpecific[10] = flagsLoAndQueueComplIdHi;
+ } else {
+ entry->CommandSpecific[9] = identify;
+
+ if (namespaceIdentify) {
+ entry->CommandSpecific[0] = 1;
+ }
+ }
+
+ return true;
+}
+} // namespace Kernel
+
+#endif // ifndef __MODULE_NVME_H__