1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 05:48:12 +00:00

Kernel: Detect devices when enumerating the PCI bus

Instead of making each driver to enumerate the PCI bus itself,
PCI::Initializer will call detect_devices() to do one enumeration
of the bus.
This commit is contained in:
Liav A 2020-02-02 01:52:51 +02:00 committed by Andreas Kling
parent 60715695b2
commit 583e9ad372
10 changed files with 64 additions and 50 deletions

View file

@ -27,6 +27,8 @@
#include <Kernel/ACPI/ACPIParser.h>
#include <Kernel/IO.h>
#include <Kernel/KParams.h>
#include <Kernel/Net/E1000NetworkAdapter.h>
#include <Kernel/Net/RTL8139NetworkAdapter.h>
#include <Kernel/PCI/IOAccess.h>
#include <Kernel/PCI/Initializer.h>
#include <Kernel/PCI/MMIOAccess.h>
@ -43,11 +45,29 @@ PCI::Initializer& PCI::Initializer::the()
void PCI::Initializer::initialize_pci_mmio_access(ACPI_RAW::MCFG& mcfg)
{
PCI::MMIOAccess::initialize(mcfg);
detect_devices();
}
void PCI::Initializer::initialize_pci_io_access()
{
PCI::IOAccess::initialize();
detect_devices();
}
void PCI::Initializer::detect_devices()
{
PCI::enumerate_all([&](const PCI::Address& address, PCI::ID id) {
kprintf("PCI: device @ %w:%b:%b.%d [%w:%w]\n",
address.seg(),
address.bus(),
address.slot(),
address.function(),
id.vendor_id,
id.device_id);
E1000NetworkAdapter::detect(address);
RTL8139NetworkAdapter::detect(address);
});
}
void PCI::Initializer::test_and_initialize(bool disable_pci_mmio)
{
if (disable_pci_mmio) {
@ -129,4 +149,4 @@ void PCI::Initializer::dismiss()
PCI::Initializer::~Initializer()
{
}
}