mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 18:02:05 -05:00
500b7b08d6
The Storage subsystem, like the Audio and HID subsystems, exposes Unix device files (for example, in the /dev directory). To ensure consistency across the repository, we should make the Storage subsystem to reside in the Kernel/Devices directory like the two other mentioned subsystems.
50 lines
1.4 KiB
C++
50 lines
1.4 KiB
C++
/*
|
|
* Copyright (c) 2023, the SerenityOS developers.
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <Kernel/Bus/PCI/API.h>
|
|
#include <Kernel/Bus/PCI/Device.h>
|
|
#include <Kernel/Devices/Storage/SD/SDHostController.h>
|
|
#include <Kernel/Memory/TypedMapping.h>
|
|
|
|
namespace Kernel {
|
|
|
|
class PCISDHostController : public PCI::Device
|
|
, public SDHostController {
|
|
public:
|
|
static ErrorOr<NonnullRefPtr<PCISDHostController>> try_initialize(PCI::DeviceIdentifier const& device_identifier);
|
|
|
|
// ^PCI::Device
|
|
virtual StringView device_name() const override { return "SD Host Controller"sv; }
|
|
|
|
protected:
|
|
// ^SDHostController
|
|
virtual SD::HostControlRegisterMap volatile* get_register_map_base_address() override { return m_registers.ptr(); }
|
|
|
|
private:
|
|
PCISDHostController(PCI::DeviceIdentifier const& device_identifier);
|
|
|
|
struct [[gnu::packed]] SlotInformationRegister {
|
|
u8 first_bar_number : 3;
|
|
u8 : 1;
|
|
u8 number_of_slots : 3;
|
|
u8 : 1;
|
|
|
|
u8 slots_available() const { return number_of_slots + 1; }
|
|
};
|
|
static_assert(AssertSize<SlotInformationRegister, 1>());
|
|
|
|
SlotInformationRegister read_slot_information() const
|
|
{
|
|
SpinlockLocker locker(device_identifier().operation_lock());
|
|
return bit_cast<SlotInformationRegister>(PCI::Access::the().read8_field(device_identifier(), 0x40));
|
|
}
|
|
|
|
Memory::TypedMapping<SD::HostControlRegisterMap volatile> m_registers;
|
|
};
|
|
|
|
}
|