summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-09-04 21:07:01 +0200
committerAndreas Kling <kling@serenityos.org>2020-09-04 21:21:46 +0200
commiteb74f622019be2ab925765a7ee66881e383794fc (patch)
tree3423a4a8237f4fe54181a21c92c072dc4215f512 /Kernel
parent1254447bd7a3f5b36bae85824b2ba68caaf3b9b5 (diff)
downloadserenity-eb74f622019be2ab925765a7ee66881e383794fc.zip
Kernel/USB: Add a simple UHCIController::stop()
This stops the controller and waits for it to complete.
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Devices/UHCIController.cpp12
-rw-r--r--Kernel/Devices/UHCIController.h1
2 files changed, 13 insertions, 0 deletions
diff --git a/Kernel/Devices/UHCIController.cpp b/Kernel/Devices/UHCIController.cpp
index 192eab8829..d53e6342b2 100644
--- a/Kernel/Devices/UHCIController.cpp
+++ b/Kernel/Devices/UHCIController.cpp
@@ -73,6 +73,8 @@ UHCIController::~UHCIController()
void UHCIController::reset()
{
+ stop();
+
write_usbcmd(UHCI_USBCMD_HOST_CONTROLLER_RESET);
// FIXME: Timeout
@@ -85,6 +87,16 @@ void UHCIController::reset()
klog() << "UHCI: Reset completed!";
}
+void UHCIController::stop()
+{
+ write_usbcmd(read_usbcmd() & ~UHCI_USBCMD_RUN);
+ // FIXME: Timeout
+ for (;;) {
+ if (read_usbsts() & UHCI_USBSTS_HOST_CONTROLLER_HALTED)
+ break;
+ }
+}
+
void UHCIController::handle_irq(const RegisterState&)
{
}
diff --git a/Kernel/Devices/UHCIController.h b/Kernel/Devices/UHCIController.h
index 4816cfd990..b031449df0 100644
--- a/Kernel/Devices/UHCIController.h
+++ b/Kernel/Devices/UHCIController.h
@@ -35,6 +35,7 @@ public:
virtual ~UHCIController() override;
void reset();
+ void stop();
private:
UHCIController(PCI::Address, PCI::ID);