1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 03:57:44 +00:00

Kernel/USB: Add a rudimentary interrogation only EHCI driver

This adds a simple EHCI driver that currently only interrogates the
device and checks if all ports are addressable via associated legacy
controllers (companion controllers), and warns if this is not the case.

This also adds a lot of the other data structures needed for actually
driving the controller, but these are currently not hooked up to
anything.

To test this run with `SERENITY_EXTRA_QEMU_ARGS="--device usb-ehci"`
or the q35 machine type
This commit is contained in:
Hendiadyoin1 2023-12-13 21:59:03 +01:00 committed by Andrew Kaster
parent a768685d16
commit f4bfd0468b
6 changed files with 742 additions and 1 deletions

View file

@ -0,0 +1,46 @@
/*
* Copyright (c) 2023, Leon Albrecht <leon.a@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Types.h>
#include <Kernel/Bus/PCI/Device.h>
#include <Kernel/Bus/USB/EHCI/Registers.h>
#include <Kernel/Bus/USB/USBController.h>
#include <Kernel/Memory/TypedMapping.h>
namespace Kernel::USB::EHCI {
class EHCIController : public USBController
, public PCI::Device {
public:
static ErrorOr<NonnullLockRefPtr<EHCIController>> try_to_initialize(PCI::DeviceIdentifier const& pci_device_identifier);
virtual ~EHCIController() override = default;
// ^PCI::Device
virtual StringView device_name() const override { return "EHCI"sv; }
// ^USBController
virtual ErrorOr<void> initialize() override;
virtual ErrorOr<void> reset() override { return ENOTSUP; }
virtual ErrorOr<void> stop() override { return ENOTSUP; }
virtual ErrorOr<void> start() override { return ENOTSUP; }
virtual void cancel_async_transfer(NonnullLockRefPtr<Transfer>) override {};
virtual ErrorOr<size_t> submit_control_transfer(Transfer&) override { return ENOTSUP; }
virtual ErrorOr<size_t> submit_bulk_transfer(Transfer&) override { return ENOTSUP; }
virtual ErrorOr<void> submit_async_interrupt_transfer(NonnullLockRefPtr<Transfer>, u16) override { return ENOTSUP; }
private:
EHCIController(PCI::DeviceIdentifier const& pci_device_identifier, NonnullOwnPtr<Memory::Region> register_region);
NonnullOwnPtr<Memory::Region> m_register_region;
CapabilityRegisters const* m_cap_regs;
OperationalRegisters volatile* m_op_regs;
};
}