mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 17:58:18 +03:00
Kernel: Rename two PCI components
Rename ID => HardwareID, and PhysicalID => DeviceIdentifier. This change merely does that to clarify what these objects really are.
This commit is contained in:
parent
82bb08a15c
commit
da327746a2
Notes:
sideshowbarker
2024-07-18 03:21:17 +09:00
Author: https://github.com/supercomputer7 Commit: https://github.com/SerenityOS/serenity/commit/da327746a27 Pull-request: https://github.com/SerenityOS/serenity/pull/10187 Reviewed-by: https://github.com/awesomekling
@ -17,17 +17,17 @@ u8 read8(Address address, u32 field) { return Access::the().read8_field(address,
|
||||
u16 read16(Address address, u32 field) { return Access::the().read16_field(address, field); }
|
||||
u32 read32(Address address, u32 field) { return Access::the().read32_field(address, field); }
|
||||
|
||||
void enumerate(Function<void(Address, PhysicalID const&)> callback)
|
||||
void enumerate(Function<void(Address, DeviceIdentifier const&)> callback)
|
||||
{
|
||||
Access::the().fast_enumerate(callback);
|
||||
}
|
||||
|
||||
PhysicalID get_physical_id(Address address)
|
||||
DeviceIdentifier get_device_identifier(Address address)
|
||||
{
|
||||
return Access::the().get_physical_id(address);
|
||||
return Access::the().get_device_identifier(address);
|
||||
}
|
||||
|
||||
ID get_id(Address address)
|
||||
HardwareID get_hardware_id(Address address)
|
||||
{
|
||||
return { read16(address, PCI_VENDOR_ID), read16(address, PCI_DEVICE_ID) };
|
||||
}
|
||||
|
@ -17,9 +17,9 @@ u8 read8(Address address, u32 field);
|
||||
u16 read16(Address address, u32 field);
|
||||
u32 read32(Address address, u32 field);
|
||||
|
||||
ID get_id(PCI::Address);
|
||||
HardwareID get_hardware_id(PCI::Address);
|
||||
bool is_io_space_enabled(Address);
|
||||
void enumerate(Function<void(Address, PhysicalID const&)> callback);
|
||||
void enumerate(Function<void(Address, DeviceIdentifier const&)> callback);
|
||||
void enable_interrupt_line(Address);
|
||||
void disable_interrupt_line(Address);
|
||||
u8 get_interrupt_line(Address);
|
||||
@ -44,6 +44,6 @@ void enable_io_space(Address);
|
||||
void disable_io_space(Address);
|
||||
void enable_memory_space(Address);
|
||||
void disable_memory_space(Address);
|
||||
PhysicalID get_physical_id(Address address);
|
||||
DeviceIdentifier get_device_identifier(Address address);
|
||||
|
||||
}
|
||||
|
@ -299,7 +299,7 @@ u32 Access::read32_field(Address address, u32 field)
|
||||
UNMAP_AFTER_INIT void Access::rescan_hardware()
|
||||
{
|
||||
MutexLocker locker(m_scan_lock);
|
||||
VERIFY(m_physical_ids.is_empty());
|
||||
VERIFY(m_device_identifiers.is_empty());
|
||||
if (m_access_type == AccessType::IO) {
|
||||
dbgln_if(PCI_DEBUG, "PCI: IO enumerating hardware");
|
||||
|
||||
@ -381,14 +381,14 @@ UNMAP_AFTER_INIT void Access::enumerate_functions(int type, u8 bus, u8 device, u
|
||||
Address address(0, bus, device, function);
|
||||
auto read_type = (read8_field(address, PCI_CLASS) << 8u) | read8_field(address, PCI_SUBCLASS);
|
||||
if (type == -1 || type == read_type) {
|
||||
PCI::ID id = { read16_field(address, PCI_VENDOR_ID), read16_field(address, PCI_DEVICE_ID) };
|
||||
HardwareID id = { read16_field(address, PCI_VENDOR_ID), read16_field(address, PCI_DEVICE_ID) };
|
||||
ClassCode class_code = read8_field(address, PCI_CLASS);
|
||||
SubclassCode subclass_code = read8_field(address, PCI_SUBCLASS);
|
||||
ProgrammingInterface prog_if = read8_field(address, PCI_PROG_IF);
|
||||
RevisionID revision_id = read8_field(address, PCI_REVISION_ID);
|
||||
SubsystemID subsystem_id = read16_field(address, PCI_SUBSYSTEM_ID);
|
||||
SubsystemVendorID subsystem_vendor_id = read16_field(address, PCI_SUBSYSTEM_VENDOR_ID);
|
||||
m_physical_ids.append(PhysicalID { address, id, revision_id, class_code, subclass_code, prog_if, subsystem_id, subsystem_vendor_id, get_capabilities(address) });
|
||||
m_device_identifiers.append(DeviceIdentifier { address, id, revision_id, class_code, subclass_code, prog_if, subsystem_id, subsystem_vendor_id, get_capabilities(address) });
|
||||
}
|
||||
|
||||
if (read_type == PCI_TYPE_BRIDGE && recursive && (!m_enumerated_buses.get(read8_field(address, PCI_SECONDARY_BUS)))) {
|
||||
@ -423,23 +423,23 @@ UNMAP_AFTER_INIT void Access::enumerate_bus(int type, u8 bus, bool recursive)
|
||||
enumerate_device(type, bus, device, recursive);
|
||||
}
|
||||
|
||||
void Access::fast_enumerate(Function<void(Address, PhysicalID const&)>& callback) const
|
||||
void Access::fast_enumerate(Function<void(Address, DeviceIdentifier const&)>& callback) const
|
||||
{
|
||||
MutexLocker locker(m_scan_lock);
|
||||
VERIFY(!m_physical_ids.is_empty());
|
||||
for (auto& physical_id : m_physical_ids) {
|
||||
callback(physical_id.address(), physical_id);
|
||||
VERIFY(!m_device_identifiers.is_empty());
|
||||
for (auto& device_identifier : m_device_identifiers) {
|
||||
callback(device_identifier.address(), device_identifier);
|
||||
}
|
||||
}
|
||||
|
||||
PhysicalID Access::get_physical_id(Address address) const
|
||||
DeviceIdentifier Access::get_device_identifier(Address address) const
|
||||
{
|
||||
for (auto physical_id : m_physical_ids) {
|
||||
if (physical_id.address().domain() == address.domain()
|
||||
&& physical_id.address().bus() == address.bus()
|
||||
&& physical_id.address().device() == address.device()
|
||||
&& physical_id.address().function() == address.function()) {
|
||||
return physical_id;
|
||||
for (auto device_identifier : m_device_identifiers) {
|
||||
if (device_identifier.address().domain() == address.domain()
|
||||
&& device_identifier.address().bus() == address.bus()
|
||||
&& device_identifier.address().device() == address.device()
|
||||
&& device_identifier.address().function() == address.function()) {
|
||||
return device_identifier;
|
||||
}
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
|
@ -25,7 +25,7 @@ public:
|
||||
static bool initialize_for_memory_access(PhysicalAddress mcfg_table);
|
||||
static bool initialize_for_io_access();
|
||||
|
||||
void fast_enumerate(Function<void(Address, PhysicalID const&)>&) const;
|
||||
void fast_enumerate(Function<void(Address, DeviceIdentifier const&)>&) const;
|
||||
void rescan_hardware();
|
||||
|
||||
static Access& the();
|
||||
@ -37,7 +37,7 @@ public:
|
||||
u8 read8_field(Address address, u32 field);
|
||||
u16 read16_field(Address address, u32 field);
|
||||
u32 read32_field(Address address, u32 field);
|
||||
PhysicalID get_physical_id(Address address) const;
|
||||
DeviceIdentifier get_device_identifier(Address address) const;
|
||||
|
||||
private:
|
||||
void enumerate_bus(int type, u8 bus, bool recursive);
|
||||
@ -80,6 +80,6 @@ private:
|
||||
mutable Mutex m_scan_lock;
|
||||
Bitmap m_enumerated_buses;
|
||||
AccessType m_access_type;
|
||||
Vector<PhysicalID> m_physical_ids;
|
||||
Vector<DeviceIdentifier> m_device_identifiers;
|
||||
};
|
||||
}
|
||||
|
@ -59,17 +59,17 @@ namespace Kernel {
|
||||
#define PCI_AHCI_IF_PROGIF 0x1
|
||||
|
||||
namespace PCI {
|
||||
struct ID {
|
||||
struct HardwareID {
|
||||
u16 vendor_id { 0 };
|
||||
u16 device_id { 0 };
|
||||
|
||||
bool is_null() const { return !vendor_id && !device_id; }
|
||||
|
||||
bool operator==(const ID& other) const
|
||||
bool operator==(const HardwareID& other) const
|
||||
{
|
||||
return vendor_id == other.vendor_id && device_id == other.device_id;
|
||||
}
|
||||
bool operator!=(const ID& other) const
|
||||
bool operator!=(const HardwareID& other) const
|
||||
{
|
||||
return vendor_id != other.vendor_id || device_id != other.device_id;
|
||||
}
|
||||
@ -189,11 +189,11 @@ TYPEDEF_DISTINCT_ORDERED_ID(u16, SubsystemID);
|
||||
TYPEDEF_DISTINCT_ORDERED_ID(u16, SubsystemVendorID);
|
||||
|
||||
class Access;
|
||||
class PhysicalID {
|
||||
class DeviceIdentifier {
|
||||
public:
|
||||
PhysicalID(Address address, ID id, RevisionID revision_id, ClassCode class_code, SubclassCode subclass_code, ProgrammingInterface prog_if, SubsystemID subsystem_id, SubsystemVendorID subsystem_vendor_id, Vector<Capability> capabilities)
|
||||
DeviceIdentifier(Address address, HardwareID hardware_id, RevisionID revision_id, ClassCode class_code, SubclassCode subclass_code, ProgrammingInterface prog_if, SubsystemID subsystem_id, SubsystemVendorID subsystem_vendor_id, Vector<Capability> capabilities)
|
||||
: m_address(address)
|
||||
, m_id(id)
|
||||
, m_hardware_id(hardware_id)
|
||||
, m_revision_id(revision_id)
|
||||
, m_class_code(class_code)
|
||||
, m_subclass_code(subclass_code)
|
||||
@ -209,7 +209,7 @@ public:
|
||||
}
|
||||
|
||||
Vector<Capability> capabilities() const { return m_capabilities; }
|
||||
const ID& id() const { return m_id; }
|
||||
const HardwareID& hardware_id() const { return m_hardware_id; }
|
||||
const Address& address() const { return m_address; }
|
||||
|
||||
RevisionID revision_id() const { return m_revision_id; }
|
||||
@ -230,7 +230,7 @@ public:
|
||||
|
||||
private:
|
||||
Address m_address;
|
||||
ID m_id;
|
||||
HardwareID m_hardware_id;
|
||||
|
||||
RevisionID m_revision_id;
|
||||
ClassCode m_class_code;
|
||||
@ -259,11 +259,11 @@ struct AK::Formatter<Kernel::PCI::Address> : Formatter<FormatString> {
|
||||
};
|
||||
|
||||
template<>
|
||||
struct AK::Formatter<Kernel::PCI::ID> : Formatter<FormatString> {
|
||||
void format(FormatBuilder& builder, Kernel::PCI::ID value)
|
||||
struct AK::Formatter<Kernel::PCI::HardwareID> : Formatter<FormatString> {
|
||||
void format(FormatBuilder& builder, Kernel::PCI::HardwareID value)
|
||||
{
|
||||
return Formatter<FormatString>::format(
|
||||
builder,
|
||||
"PCI::ID [{:04x}:{:04x}]", value.vendor_id, value.device_id);
|
||||
"PCI::HardwareID [{:04x}:{:04x}]", value.vendor_id, value.device_id);
|
||||
}
|
||||
};
|
||||
|
@ -17,7 +17,7 @@ Device::Device(Address address)
|
||||
|
||||
bool Device::is_msi_capable() const
|
||||
{
|
||||
for (const auto& capability : PCI::get_physical_id(pci_address()).capabilities()) {
|
||||
for (const auto& capability : PCI::get_device_identifier(pci_address()).capabilities()) {
|
||||
if (capability.id() == PCI_CAPABILITY_MSI)
|
||||
return true;
|
||||
}
|
||||
@ -25,7 +25,7 @@ bool Device::is_msi_capable() const
|
||||
}
|
||||
bool Device::is_msix_capable() const
|
||||
{
|
||||
for (const auto& capability : PCI::get_physical_id(pci_address()).capabilities()) {
|
||||
for (const auto& capability : PCI::get_device_identifier(pci_address()).capabilities()) {
|
||||
if (capability.id() == PCI_CAPABILITY_MSIX)
|
||||
return true;
|
||||
}
|
||||
|
@ -56,8 +56,8 @@ UNMAP_AFTER_INIT void initialize()
|
||||
|
||||
PCI::PCIBusSysFSDirectory::initialize();
|
||||
|
||||
PCI::enumerate([&](const Address& address, PhysicalID const& physical_id) {
|
||||
dmesgln("{} {}", address, physical_id.id());
|
||||
PCI::enumerate([&](const Address& address, DeviceIdentifier const& device_identifier) {
|
||||
dmesgln("{} {}", address, device_identifier.hardware_id());
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ UNMAP_AFTER_INIT void PCIBusSysFSDirectory::initialize()
|
||||
UNMAP_AFTER_INIT PCIBusSysFSDirectory::PCIBusSysFSDirectory()
|
||||
: SysFSDirectory("pci", SysFSComponentRegistry::the().buses_directory())
|
||||
{
|
||||
PCI::enumerate([&](const Address& address, PhysicalID const&) {
|
||||
PCI::enumerate([&](const Address& address, DeviceIdentifier const&) {
|
||||
auto pci_device = PCI::PCIDeviceSysFSDirectory::create(*this, address);
|
||||
m_components.append(pci_device);
|
||||
});
|
||||
|
@ -72,7 +72,7 @@ KResultOr<NonnullRefPtr<UHCIController>> UHCIController::try_to_initialize(PCI::
|
||||
|
||||
KResult UHCIController::initialize()
|
||||
{
|
||||
dmesgln("UHCI: Controller found {} @ {}", PCI::get_id(pci_address()), pci_address());
|
||||
dmesgln("UHCI: Controller found {} @ {}", PCI::get_hardware_id(pci_address()), pci_address());
|
||||
dmesgln("UHCI: I/O base {}", m_io_base);
|
||||
dmesgln("UHCI: Interrupt line: {}", PCI::get_interrupt_line(pci_address()));
|
||||
|
||||
|
@ -27,10 +27,10 @@ UNMAP_AFTER_INIT void USBManagement::enumerate_controllers()
|
||||
if (kernel_command_line().disable_usb())
|
||||
return;
|
||||
|
||||
PCI::enumerate([this](PCI::Address const& address, PCI::PhysicalID const& physical_id) {
|
||||
if (!(physical_id.class_code().value() == 0xc && physical_id.subclass_code().value() == 0x3))
|
||||
PCI::enumerate([this](PCI::Address const& address, PCI::DeviceIdentifier const& device_identifier) {
|
||||
if (!(device_identifier.class_code().value() == 0xc && device_identifier.subclass_code().value() == 0x3))
|
||||
return;
|
||||
if (physical_id.prog_if().value() == 0x0) {
|
||||
if (device_identifier.prog_if().value() == 0x0) {
|
||||
if (kernel_command_line().disable_uhci_controller())
|
||||
return;
|
||||
|
||||
@ -40,22 +40,22 @@ UNMAP_AFTER_INIT void USBManagement::enumerate_controllers()
|
||||
return;
|
||||
}
|
||||
|
||||
if (physical_id.prog_if().value() == 0x10) {
|
||||
if (device_identifier.prog_if().value() == 0x10) {
|
||||
dmesgln("USBManagement: OHCI controller found at {} is not currently supported.", address);
|
||||
return;
|
||||
}
|
||||
|
||||
if (physical_id.prog_if().value() == 0x20) {
|
||||
if (device_identifier.prog_if().value() == 0x20) {
|
||||
dmesgln("USBManagement: EHCI controller found at {} is not currently supported.", address);
|
||||
return;
|
||||
}
|
||||
|
||||
if (physical_id.prog_if().value() == 0x30) {
|
||||
if (device_identifier.prog_if().value() == 0x30) {
|
||||
dmesgln("USBManagement: xHCI controller found at {} is not currently supported.", address);
|
||||
return;
|
||||
}
|
||||
|
||||
dmesgln("USBManagement: Unknown/unsupported controller at {} with programming interface 0x{:02x}", address, physical_id.prog_if().value());
|
||||
dmesgln("USBManagement: Unknown/unsupported controller at {} with programming interface 0x{:02x}", address, device_identifier.prog_if().value());
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -18,13 +18,13 @@ UNMAP_AFTER_INIT void detect()
|
||||
{
|
||||
if (kernel_command_line().disable_virtio())
|
||||
return;
|
||||
PCI::enumerate([&](const PCI::Address& address, PCI::PhysicalID const& physical_id) {
|
||||
if (address.is_null() || physical_id.id().is_null())
|
||||
PCI::enumerate([&](const PCI::Address& address, PCI::DeviceIdentifier const& device_identifier) {
|
||||
if (address.is_null() || device_identifier.hardware_id().is_null())
|
||||
return;
|
||||
// TODO: We should also be checking that the device_id is in between 0x1000 - 0x107F inclusive
|
||||
if (physical_id.id().vendor_id != PCI::VendorID::VirtIO)
|
||||
if (device_identifier.hardware_id().vendor_id != PCI::VendorID::VirtIO)
|
||||
return;
|
||||
switch (physical_id.id().device_id) {
|
||||
switch (device_identifier.hardware_id().device_id) {
|
||||
case PCI::DeviceID::VirtIOConsole: {
|
||||
auto& console = Console::must_create(address).leak_ref();
|
||||
console.initialize();
|
||||
@ -40,7 +40,7 @@ UNMAP_AFTER_INIT void detect()
|
||||
break;
|
||||
}
|
||||
default:
|
||||
dbgln_if(VIRTIO_DEBUG, "VirtIO: Unknown VirtIO device with ID: {}", physical_id.id().device_id);
|
||||
dbgln_if(VIRTIO_DEBUG, "VirtIO: Unknown VirtIO device with ID: {}", device_identifier.hardware_id().device_id);
|
||||
break;
|
||||
}
|
||||
});
|
||||
@ -67,7 +67,7 @@ static StringView const determine_device_class(const PCI::Address& address)
|
||||
}
|
||||
}
|
||||
|
||||
auto id = PCI::get_id(address);
|
||||
auto id = PCI::get_hardware_id(address);
|
||||
VERIFY(id.vendor_id == PCI::VendorID::VirtIO);
|
||||
switch (id.device_id) {
|
||||
case PCI::DeviceID::VirtIONetAdapter:
|
||||
@ -93,7 +93,7 @@ UNMAP_AFTER_INIT void Device::initialize()
|
||||
PCI::enable_interrupt_line(pci_address());
|
||||
enable_irq();
|
||||
|
||||
auto capabilities = PCI::get_physical_id(address).capabilities();
|
||||
auto capabilities = PCI::get_device_identifier(address).capabilities();
|
||||
for (auto& capability : capabilities) {
|
||||
if (capability.id() == PCI_CAPABILITY_VENDOR_SPECIFIC) {
|
||||
// We have a virtio_pci_cap
|
||||
|
@ -15,12 +15,12 @@ static SerialDevice* s_the = nullptr;
|
||||
UNMAP_AFTER_INIT void PCISerialDevice::detect()
|
||||
{
|
||||
size_t current_device_minor = 68;
|
||||
PCI::enumerate([&](const PCI::Address& address, PCI::PhysicalID const& physical_id) {
|
||||
PCI::enumerate([&](const PCI::Address& address, PCI::DeviceIdentifier const& device_identifier) {
|
||||
if (address.is_null())
|
||||
return;
|
||||
|
||||
for (auto& board_definition : board_definitions) {
|
||||
if (board_definition.device_id != physical_id.id())
|
||||
if (board_definition.device_id != device_identifier.hardware_id())
|
||||
continue;
|
||||
|
||||
auto bar_base = PCI::get_BAR(address, board_definition.pci_bar) & ~1;
|
||||
|
@ -22,7 +22,7 @@ public:
|
||||
|
||||
private:
|
||||
struct BoardDefinition {
|
||||
PCI::ID device_id;
|
||||
PCI::HardwareID device_id;
|
||||
StringView name;
|
||||
u32 port_count { 0 };
|
||||
u32 pci_bar { 0 };
|
||||
|
@ -614,19 +614,19 @@ private:
|
||||
virtual KResult try_generate(KBufferBuilder& builder) override
|
||||
{
|
||||
JsonArraySerializer array { builder };
|
||||
PCI::enumerate([&array](PCI::Address address, PCI::PhysicalID const& physical_id) {
|
||||
PCI::enumerate([&array](PCI::Address address, PCI::DeviceIdentifier const& device_identifier) {
|
||||
auto obj = array.add_object();
|
||||
obj.add("domain", address.domain());
|
||||
obj.add("bus", address.bus());
|
||||
obj.add("device", address.device());
|
||||
obj.add("function", address.function());
|
||||
obj.add("vendor_id", physical_id.id().vendor_id);
|
||||
obj.add("device_id", physical_id.id().device_id);
|
||||
obj.add("revision_id", physical_id.revision_id().value());
|
||||
obj.add("subclass", physical_id.subclass_code().value());
|
||||
obj.add("class", physical_id.class_code().value());
|
||||
obj.add("subsystem_id", physical_id.subsystem_id().value());
|
||||
obj.add("subsystem_vendor_id", physical_id.subsystem_vendor_id().value());
|
||||
obj.add("vendor_id", device_identifier.hardware_id().vendor_id);
|
||||
obj.add("device_id", device_identifier.hardware_id().device_id);
|
||||
obj.add("revision_id", device_identifier.revision_id().value());
|
||||
obj.add("subclass", device_identifier.subclass_code().value());
|
||||
obj.add("class", device_identifier.class_code().value());
|
||||
obj.add("subsystem_id", device_identifier.subsystem_id().value());
|
||||
obj.add("subsystem_vendor_id", device_identifier.subsystem_vendor_id().value());
|
||||
});
|
||||
array.finish();
|
||||
return KSuccess;
|
||||
|
@ -73,7 +73,7 @@ struct [[gnu::packed]] BochsDisplayMMIORegisters {
|
||||
|
||||
UNMAP_AFTER_INIT NonnullRefPtr<BochsGraphicsAdapter> BochsGraphicsAdapter::initialize(PCI::Address address)
|
||||
{
|
||||
PCI::ID id = PCI::get_id(address);
|
||||
PCI::HardwareID id = PCI::get_hardware_id(address);
|
||||
VERIFY((id.vendor_id == PCI::VendorID::QEMUOld && id.device_id == 0x1111) || (id.vendor_id == PCI::VendorID::VirtualBox && id.device_id == 0xbeef));
|
||||
return adopt_ref(*new BochsGraphicsAdapter(address));
|
||||
}
|
||||
@ -111,7 +111,7 @@ UNMAP_AFTER_INIT BochsGraphicsAdapter::BochsGraphicsAdapter(PCI::Address pci_add
|
||||
GraphicsManagement::the().m_console = m_framebuffer_console;
|
||||
|
||||
// Note: If we use VirtualBox graphics adapter (which is based on Bochs one), we need to use IO ports
|
||||
auto id = PCI::get_id(pci_address);
|
||||
auto id = PCI::get_hardware_id(pci_address);
|
||||
if (id.vendor_id == 0x80ee && id.device_id == 0xbeef)
|
||||
m_io_required = true;
|
||||
|
||||
|
@ -64,7 +64,7 @@ static inline bool is_display_controller_pci_device(PCI::Address address)
|
||||
return PCI::get_class(address) == 0x3;
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT bool GraphicsManagement::determine_and_initialize_graphics_device(const PCI::Address& address, PCI::ID id)
|
||||
UNMAP_AFTER_INIT bool GraphicsManagement::determine_and_initialize_graphics_device(const PCI::Address& address, PCI::HardwareID id)
|
||||
{
|
||||
VERIFY(is_vga_compatible_pci_device(address) || is_display_controller_pci_device(address));
|
||||
auto add_and_configure_adapter = [&](GraphicsDevice& graphics_device) {
|
||||
@ -179,13 +179,13 @@ UNMAP_AFTER_INIT bool GraphicsManagement::initialize()
|
||||
dbgln("Forcing no initialization of framebuffer devices");
|
||||
}
|
||||
|
||||
PCI::enumerate([&](const PCI::Address& address, PCI::PhysicalID const& physical_id) {
|
||||
PCI::enumerate([&](const PCI::Address& address, PCI::DeviceIdentifier const& device_identifier) {
|
||||
// Note: Each graphics controller will try to set its native screen resolution
|
||||
// upon creation. Later on, if we don't want to have framebuffer devices, a
|
||||
// framebuffer console will take the control instead.
|
||||
if (!is_vga_compatible_pci_device(address) && !is_display_controller_pci_device(address))
|
||||
return;
|
||||
determine_and_initialize_graphics_device(address, physical_id.id());
|
||||
determine_and_initialize_graphics_device(address, device_identifier.hardware_id());
|
||||
});
|
||||
|
||||
if (m_graphics_devices.is_empty()) {
|
||||
|
@ -47,7 +47,7 @@ public:
|
||||
void activate_graphical_mode();
|
||||
|
||||
private:
|
||||
bool determine_and_initialize_graphics_device(const PCI::Address& address, PCI::ID id);
|
||||
bool determine_and_initialize_graphics_device(const PCI::Address& address, PCI::HardwareID id);
|
||||
NonnullRefPtrVector<GraphicsDevice> m_graphics_devices;
|
||||
RefPtr<Graphics::Console> m_console;
|
||||
|
||||
|
@ -43,7 +43,7 @@ static bool is_supported_model(u16 device_id)
|
||||
|
||||
RefPtr<IntelNativeGraphicsAdapter> IntelNativeGraphicsAdapter::initialize(PCI::Address address)
|
||||
{
|
||||
auto id = PCI::get_id(address);
|
||||
auto id = PCI::get_hardware_id(address);
|
||||
VERIFY(id.vendor_id == 0x8086);
|
||||
if (!is_supported_model(id.device_id))
|
||||
return {};
|
||||
|
@ -15,7 +15,7 @@ namespace Kernel::Graphics::VirtIOGPU {
|
||||
|
||||
NonnullRefPtr<GraphicsAdapter> GraphicsAdapter::initialize(PCI::Address base_address)
|
||||
{
|
||||
VERIFY(PCI::get_id(base_address).vendor_id == PCI::VendorID::VirtIO);
|
||||
VERIFY(PCI::get_hardware_id(base_address).vendor_id == PCI::VendorID::VirtIO);
|
||||
return adopt_ref(*new GraphicsAdapter(base_address));
|
||||
}
|
||||
|
||||
|
@ -182,7 +182,7 @@ static bool is_valid_device_id(u16 device_id)
|
||||
|
||||
UNMAP_AFTER_INIT RefPtr<E1000ENetworkAdapter> E1000ENetworkAdapter::try_to_initialize(PCI::Address address)
|
||||
{
|
||||
auto id = PCI::get_id(address);
|
||||
auto id = PCI::get_hardware_id(address);
|
||||
if (id.vendor_id != PCI::VendorID::Intel)
|
||||
return {};
|
||||
if (!is_valid_device_id(id.device_id))
|
||||
|
@ -160,7 +160,7 @@ UNMAP_AFTER_INIT static bool is_valid_device_id(u16 device_id)
|
||||
|
||||
UNMAP_AFTER_INIT RefPtr<E1000NetworkAdapter> E1000NetworkAdapter::try_to_initialize(PCI::Address address)
|
||||
{
|
||||
auto id = PCI::get_id(address);
|
||||
auto id = PCI::get_hardware_id(address);
|
||||
if (id.vendor_id != PCI::VendorID::Intel)
|
||||
return {};
|
||||
if (!is_valid_device_id(id.device_id))
|
||||
|
@ -140,21 +140,21 @@ struct [[gnu::packed]] received_packet_header {
|
||||
UNMAP_AFTER_INIT RefPtr<NE2000NetworkAdapter> NE2000NetworkAdapter::try_to_initialize(PCI::Address address)
|
||||
{
|
||||
constexpr auto ne2k_ids = Array {
|
||||
PCI::ID { 0x10EC, 0x8029 }, // RealTek RTL-8029(AS)
|
||||
PCI::HardwareID { 0x10EC, 0x8029 }, // RealTek RTL-8029(AS)
|
||||
|
||||
// List of clones, taken from Linux's ne2k-pci.c
|
||||
PCI::ID { 0x1050, 0x0940 }, // Winbond 89C940
|
||||
PCI::ID { 0x11f6, 0x1401 }, // Compex RL2000
|
||||
PCI::ID { 0x8e2e, 0x3000 }, // KTI ET32P2
|
||||
PCI::ID { 0x4a14, 0x5000 }, // NetVin NV5000SC
|
||||
PCI::ID { 0x1106, 0x0926 }, // Via 86C926
|
||||
PCI::ID { 0x10bd, 0x0e34 }, // SureCom NE34
|
||||
PCI::ID { 0x1050, 0x5a5a }, // Winbond W89C940F
|
||||
PCI::ID { 0x12c3, 0x0058 }, // Holtek HT80232
|
||||
PCI::ID { 0x12c3, 0x5598 }, // Holtek HT80229
|
||||
PCI::ID { 0x8c4a, 0x1980 }, // Winbond W89C940 (misprogrammed)
|
||||
PCI::HardwareID { 0x1050, 0x0940 }, // Winbond 89C940
|
||||
PCI::HardwareID { 0x11f6, 0x1401 }, // Compex RL2000
|
||||
PCI::HardwareID { 0x8e2e, 0x3000 }, // KTI ET32P2
|
||||
PCI::HardwareID { 0x4a14, 0x5000 }, // NetVin NV5000SC
|
||||
PCI::HardwareID { 0x1106, 0x0926 }, // Via 86C926
|
||||
PCI::HardwareID { 0x10bd, 0x0e34 }, // SureCom NE34
|
||||
PCI::HardwareID { 0x1050, 0x5a5a }, // Winbond W89C940F
|
||||
PCI::HardwareID { 0x12c3, 0x0058 }, // Holtek HT80232
|
||||
PCI::HardwareID { 0x12c3, 0x5598 }, // Holtek HT80229
|
||||
PCI::HardwareID { 0x8c4a, 0x1980 }, // Winbond W89C940 (misprogrammed)
|
||||
};
|
||||
auto id = PCI::get_id(address);
|
||||
auto id = PCI::get_hardware_id(address);
|
||||
if (!ne2k_ids.span().contains_slow(id))
|
||||
return {};
|
||||
u8 irq = PCI::get_interrupt_line(address);
|
||||
|
@ -91,9 +91,9 @@ UNMAP_AFTER_INIT RefPtr<NetworkAdapter> NetworkingManagement::determine_network_
|
||||
bool NetworkingManagement::initialize()
|
||||
{
|
||||
if (!kernel_command_line().is_physical_networking_disabled()) {
|
||||
PCI::enumerate([&](const PCI::Address& address, PCI::PhysicalID const& physical_id) {
|
||||
PCI::enumerate([&](const PCI::Address& address, PCI::DeviceIdentifier const& device_identifier) {
|
||||
// Note: PCI class 2 is the class of Network devices
|
||||
if (physical_id.class_code().value() != 0x02)
|
||||
if (device_identifier.class_code().value() != 0x02)
|
||||
return;
|
||||
if (auto adapter = determine_network_device(address); !adapter.is_null())
|
||||
m_adapters.append(adapter.release_nonnull());
|
||||
|
@ -114,8 +114,8 @@ namespace Kernel {
|
||||
|
||||
UNMAP_AFTER_INIT RefPtr<RTL8139NetworkAdapter> RTL8139NetworkAdapter::try_to_initialize(PCI::Address address)
|
||||
{
|
||||
constexpr PCI::ID rtl8139_id = { 0x10EC, 0x8139 };
|
||||
auto id = PCI::get_id(address);
|
||||
constexpr PCI::HardwareID rtl8139_id = { 0x10EC, 0x8139 };
|
||||
auto id = PCI::get_hardware_id(address);
|
||||
if (id != rtl8139_id)
|
||||
return {};
|
||||
u8 irq = PCI::get_interrupt_line(address);
|
||||
|
@ -183,7 +183,7 @@ namespace Kernel {
|
||||
|
||||
UNMAP_AFTER_INIT RefPtr<RTL8168NetworkAdapter> RTL8168NetworkAdapter::try_to_initialize(PCI::Address address)
|
||||
{
|
||||
auto id = PCI::get_id(address);
|
||||
auto id = PCI::get_hardware_id(address);
|
||||
if (id.vendor_id != PCI::VendorID::Realtek)
|
||||
return {};
|
||||
if (id.device_id != 0x8168)
|
||||
|
@ -44,14 +44,14 @@ UNMAP_AFTER_INIT void StorageManagement::enumerate_controllers(bool force_pio)
|
||||
VERIFY(m_controllers.is_empty());
|
||||
if (!kernel_command_line().disable_physical_storage()) {
|
||||
if (kernel_command_line().is_ide_enabled()) {
|
||||
PCI::enumerate([&](const PCI::Address& address, PCI::PhysicalID const& physical_id) {
|
||||
if (physical_id.class_code().value() == PCI_MASS_STORAGE_CLASS_ID && physical_id.subclass_code().value() == PCI_IDE_CTRL_SUBCLASS_ID) {
|
||||
PCI::enumerate([&](const PCI::Address& address, PCI::DeviceIdentifier const& device_identifier) {
|
||||
if (device_identifier.class_code().value() == PCI_MASS_STORAGE_CLASS_ID && device_identifier.subclass_code().value() == PCI_IDE_CTRL_SUBCLASS_ID) {
|
||||
m_controllers.append(IDEController::initialize(address, force_pio));
|
||||
}
|
||||
});
|
||||
}
|
||||
PCI::enumerate([&](const PCI::Address& address, PCI::PhysicalID const& physical_id) {
|
||||
if (physical_id.class_code().value() == PCI_MASS_STORAGE_CLASS_ID && physical_id.subclass_code().value() == PCI_SATA_CTRL_SUBCLASS_ID && physical_id.prog_if().value() == PCI_AHCI_IF_PROGIF) {
|
||||
PCI::enumerate([&](const PCI::Address& address, PCI::DeviceIdentifier const& device_identifier) {
|
||||
if (device_identifier.class_code().value() == PCI_MASS_STORAGE_CLASS_ID && device_identifier.subclass_code().value() == PCI_SATA_CTRL_SUBCLASS_ID && device_identifier.prog_if().value() == PCI_AHCI_IF_PROGIF) {
|
||||
m_controllers.append(AHCIController::initialize(address));
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user