summaryrefslogtreecommitdiff
path: root/Kernel/Storage/NVMe
diff options
context:
space:
mode:
authorLiav A <liavalb@gmail.com>2022-09-02 11:23:32 +0300
committerLinus Groh <mail@linusgroh.de>2022-09-20 18:43:05 +0100
commit84fbab6803bcb6ed02335a9b9bf83545a18cf4a4 (patch)
treeac231cce6bf7a3e952efc1dea35dbb73c2ae85db /Kernel/Storage/NVMe
parentcac72259d00fecb9b638adab2c32fc2c5943e1da (diff)
downloadserenity-84fbab6803bcb6ed02335a9b9bf83545a18cf4a4.zip
Kernel: Move IO delay code to x86 architecture subdirectory
Many code patterns and hardware procedures rely on reliable delay in the microseconds granularity, and since they are using such delays which are valid cases, but should not rely on x86 specific code, we allow to determine in compile time the proper platform-specific code to use to invoke such delays.
Diffstat (limited to 'Kernel/Storage/NVMe')
-rw-r--r--Kernel/Storage/NVMe/NVMeController.cpp5
-rw-r--r--Kernel/Storage/NVMe/NVMePollQueue.cpp4
-rw-r--r--Kernel/Storage/NVMe/NVMeQueue.cpp4
3 files changed, 6 insertions, 7 deletions
diff --git a/Kernel/Storage/NVMe/NVMeController.cpp b/Kernel/Storage/NVMe/NVMeController.cpp
index 95d2c434da..dab462ddb7 100644
--- a/Kernel/Storage/NVMe/NVMeController.cpp
+++ b/Kernel/Storage/NVMe/NVMeController.cpp
@@ -7,9 +7,8 @@
#include <AK/Format.h>
#include <AK/Types.h>
+#include <Kernel/Arch/Delay.h>
#include <Kernel/Arch/SafeMem.h>
-#include <Kernel/Arch/x86/IO.h>
-#include <Kernel/Arch/x86/Processor.h>
#include <Kernel/Bus/PCI/API.h>
#include <Kernel/CommandLine.h>
#include <Kernel/Devices/Device.h>
@@ -77,7 +76,7 @@ bool NVMeController::wait_for_ready(bool expected_ready_bit_value)
u32 expected_rdy = expected_ready_bit_value ? 1 : 0;
while (((m_controller_regs->csts >> CSTS_RDY_BIT) & 0x1) != expected_rdy) {
- IO::delay(one_ms_io_delay);
+ microseconds_delay(one_ms_io_delay);
if (--wait_iterations == 0) {
if (((m_controller_regs->csts >> CSTS_RDY_BIT) & 0x1) != expected_rdy) {
diff --git a/Kernel/Storage/NVMe/NVMePollQueue.cpp b/Kernel/Storage/NVMe/NVMePollQueue.cpp
index 086c042a51..91664a4640 100644
--- a/Kernel/Storage/NVMe/NVMePollQueue.cpp
+++ b/Kernel/Storage/NVMe/NVMePollQueue.cpp
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-#include <Kernel/Arch/x86/IO.h>
+#include <Kernel/Arch/Delay.h>
#include <Kernel/Devices/BlockDevice.h>
#include <Kernel/Storage/NVMe/NVMeDefinitions.h>
#include <Kernel/Storage/NVMe/NVMePollQueue.h>
@@ -20,7 +20,7 @@ void NVMePollQueue::submit_sqe(NVMeSubmission& sub)
NVMeQueue::submit_sqe(sub);
SpinlockLocker lock_cq(m_cq_lock);
while (!process_cq()) {
- IO::delay(1);
+ microseconds_delay(1);
}
}
diff --git a/Kernel/Storage/NVMe/NVMeQueue.cpp b/Kernel/Storage/NVMe/NVMeQueue.cpp
index 46cd951ab7..09ae9f767d 100644
--- a/Kernel/Storage/NVMe/NVMeQueue.cpp
+++ b/Kernel/Storage/NVMe/NVMeQueue.cpp
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-#include <Kernel/Arch/x86/IO.h>
+#include <Kernel/Arch/Delay.h>
#include <Kernel/StdLib.h>
#include <Kernel/Storage/NVMe/NVMeController.h>
#include <Kernel/Storage/NVMe/NVMeInterruptQueue.h>
@@ -126,7 +126,7 @@ u16 NVMeQueue::submit_sync_sqe(NVMeSubmission& sub)
index = m_qdepth - 1;
}
cqe_cid = m_cqe_array[index].command_id;
- IO::delay(1);
+ microseconds_delay(1);
} while (cid != cqe_cid);
auto status = CQ_STATUS_FIELD(m_cqe_array[m_cq_head].status);