diff options
author | Liav A <liavalb@gmail.com> | 2022-09-02 11:23:32 +0300 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-09-20 18:43:05 +0100 |
commit | 84fbab6803bcb6ed02335a9b9bf83545a18cf4a4 (patch) | |
tree | ac231cce6bf7a3e952efc1dea35dbb73c2ae85db /Kernel/Bus | |
parent | cac72259d00fecb9b638adab2c32fc2c5943e1da (diff) | |
download | serenity-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/Bus')
-rw-r--r-- | Kernel/Bus/USB/UHCI/UHCIController.cpp | 5 | ||||
-rw-r--r-- | Kernel/Bus/USB/USBHub.cpp | 9 |
2 files changed, 8 insertions, 6 deletions
diff --git a/Kernel/Bus/USB/UHCI/UHCIController.cpp b/Kernel/Bus/USB/UHCI/UHCIController.cpp index ba80a1ee4e..7fed7817b7 100644 --- a/Kernel/Bus/USB/UHCI/UHCIController.cpp +++ b/Kernel/Bus/USB/UHCI/UHCIController.cpp @@ -6,6 +6,7 @@ */ #include <AK/Platform.h> +#include <Kernel/Arch/Delay.h> #include <Kernel/Bus/PCI/API.h> #include <Kernel/Bus/USB/UHCI/UHCIController.h> #include <Kernel/Bus/USB/USBRequest.h> @@ -633,7 +634,7 @@ void UHCIController::reset_port(u8 port) // Wait at least 50 ms for the port to reset. // This is T DRSTR in the USB 2.0 Specification Page 186 Table 7-13. constexpr u16 reset_delay = 50 * 1000; - IO::delay(reset_delay); + microseconds_delay(reset_delay); port_data &= ~UHCI_PORTSC_PORT_RESET; if (port == 0) @@ -644,7 +645,7 @@ void UHCIController::reset_port(u8 port) // Wait 10 ms for the port to recover. // This is T RSTRCY in the USB 2.0 Specification Page 188 Table 7-14. constexpr u16 reset_recovery_delay = 10 * 1000; - IO::delay(reset_recovery_delay); + microseconds_delay(reset_recovery_delay); port_data = port == 0 ? read_portsc1() : read_portsc2(); port_data |= UHCI_PORTSC_PORT_ENABLED; diff --git a/Kernel/Bus/USB/USBHub.cpp b/Kernel/Bus/USB/USBHub.cpp index bbb3d5bdcf..c2df5b8f4c 100644 --- a/Kernel/Bus/USB/USBHub.cpp +++ b/Kernel/Bus/USB/USBHub.cpp @@ -4,6 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include <Kernel/Arch/Delay.h> #include <Kernel/Arch/x86/IO.h> #include <Kernel/Bus/USB/USBClasses.h> #include <Kernel/Bus/USB/USBController.h> @@ -83,7 +84,7 @@ ErrorOr<void> Hub::enumerate_and_power_on_hub() } // Wait for the ports to power up. power_on_to_power_good_time is in units of 2 ms and we want in us, so multiply by 2000. - IO::delay(descriptor.power_on_to_power_good_time * 2000); + microseconds_delay(descriptor.power_on_to_power_good_time * 2000); memcpy(&m_hub_descriptor, &descriptor, sizeof(USBHubDescriptor)); @@ -171,7 +172,7 @@ void Hub::check_for_port_updates() // FIXME: Timeout while (debounce_timer < debounce_interval) { - IO::delay(debounce_disconnect_check_interval); + microseconds_delay(debounce_disconnect_check_interval); debounce_timer += debounce_disconnect_check_interval; if (auto result = get_port_status(port_number, port_status); result.is_error()) { @@ -203,7 +204,7 @@ void Hub::check_for_port_updates() // Wait at least 10 ms for the port to reset. // This is T DRST in the USB 2.0 Specification Page 186 Table 7-13. constexpr u16 reset_delay = 10 * 1000; - IO::delay(reset_delay); + microseconds_delay(reset_delay); if (auto result = get_port_status(port_number, port_status); result.is_error()) { dbgln("USB Hub: Error occurred when getting status while resetting port {}: {}.", port_number, result.error()); @@ -224,7 +225,7 @@ void Hub::check_for_port_updates() // Wait 10 ms for the port to recover. // This is T RSTRCY in the USB 2.0 Specification Page 188 Table 7-14. constexpr u16 reset_recovery_delay = 10 * 1000; - IO::delay(reset_recovery_delay); + microseconds_delay(reset_recovery_delay); dbgln_if(USB_DEBUG, "USB Hub: Reset complete!"); |