forked from SerenityOS/serenity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Kernel/USB: Create controller base class and introduce USBManagement
This removes Pipes dependency on the UHCIController by introducing a controller base class. This will be used to implement other controllers such as OHCI. Additionally, there can be multiple instances of a UHCI controller. For example, multiple UHCI instances can be required for systems with EHCI controllers. EHCI relies on using multiple of either UHCI or OHCI controllers to drive USB 1.x devices. This means UHCIController can no longer be a singleton. Multiple instances of it can now be created and passed to the device and then to the pipe. To handle finding and creating these instances, USBManagement has been introduced. It has the same pattern as the other management classes such as NetworkManagement.
- Loading branch information
1 parent
c5974d3
commit 7a86a8d
Showing
14 changed files
with
258 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Copyright (c) 2021, Luke Wilde <[email protected]> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
||
#include <Kernel/Bus/USB/USBController.h> | ||
|
||
namespace Kernel::USB { | ||
|
||
u8 USBController::allocate_address() | ||
{ | ||
// FIXME: This can be smarter. | ||
return m_next_device_index++; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright (c) 2021, Luke Wilde <[email protected]> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <AK/RefCounted.h> | ||
#include <Kernel/Bus/USB/USBDevice.h> | ||
#include <Kernel/Bus/USB/USBTransfer.h> | ||
#include <Kernel/KResult.h> | ||
|
||
namespace Kernel::USB { | ||
|
||
class USBController : public RefCounted<USBController> { | ||
public: | ||
virtual ~USBController() = default; | ||
|
||
virtual KResult initialize() = 0; | ||
|
||
virtual KResult reset() = 0; | ||
virtual KResult stop() = 0; | ||
virtual KResult start() = 0; | ||
|
||
virtual KResultOr<size_t> submit_control_transfer(Transfer&) = 0; | ||
|
||
virtual RefPtr<USB::Device> const get_device_at_port(USB::Device::PortNumber) = 0; | ||
virtual RefPtr<USB::Device> const get_device_from_address(u8) = 0; | ||
|
||
u8 allocate_address(); | ||
|
||
private: | ||
u8 m_next_device_index { 1 }; | ||
|
||
IntrusiveListNode<USBController, NonnullRefPtr<USBController>> m_controller_list_node; | ||
|
||
public: | ||
using List = IntrusiveList<USBController, NonnullRefPtr<USBController>, &USBController::m_controller_list_node>; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.