diff options
author | Liav A <liavalb@gmail.com> | 2021-09-23 10:20:54 +0300 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-29 11:24:33 +0200 |
commit | 057f5a12c2c69b1bad1d8b778d3cb934b3a8f346 (patch) | |
tree | e982c24df38e71e0d1c7dc0745c8ceec99c926cd /Kernel/Graphics/Bochs/GraphicsAdapter.cpp | |
parent | da327746a2702bd40ae6fa79017850ed357f5c1f (diff) | |
download | serenity-057f5a12c2c69b1bad1d8b778d3cb934b3a8f346.zip |
Kernel/PCI: Propagate usage of DeviceIdentifier everywhere
This allows us to remove a bunch of PCI API functions, and instead to
leverage the cached data from DeviceIdentifier object in many places.
Diffstat (limited to 'Kernel/Graphics/Bochs/GraphicsAdapter.cpp')
-rw-r--r-- | Kernel/Graphics/Bochs/GraphicsAdapter.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/Kernel/Graphics/Bochs/GraphicsAdapter.cpp b/Kernel/Graphics/Bochs/GraphicsAdapter.cpp index 0a4e2c84e6..1f6157e2fa 100644 --- a/Kernel/Graphics/Bochs/GraphicsAdapter.cpp +++ b/Kernel/Graphics/Bochs/GraphicsAdapter.cpp @@ -71,11 +71,11 @@ struct [[gnu::packed]] BochsDisplayMMIORegisters { ExtensionRegisters extension_regs; }; -UNMAP_AFTER_INIT NonnullRefPtr<BochsGraphicsAdapter> BochsGraphicsAdapter::initialize(PCI::Address address) +UNMAP_AFTER_INIT NonnullRefPtr<BochsGraphicsAdapter> BochsGraphicsAdapter::initialize(PCI::DeviceIdentifier const& pci_device_identifier) { - PCI::HardwareID id = PCI::get_hardware_id(address); + PCI::HardwareID id = pci_device_identifier.hardware_id(); 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)); + return adopt_ref(*new BochsGraphicsAdapter(pci_device_identifier)); } void BochsGraphicsAdapter::set_framebuffer_to_big_endian_format() @@ -100,21 +100,23 @@ void BochsGraphicsAdapter::set_framebuffer_to_little_endian_format() full_memory_barrier(); } -UNMAP_AFTER_INIT BochsGraphicsAdapter::BochsGraphicsAdapter(PCI::Address pci_address) - : PCI::Device(pci_address) - , m_mmio_registers(PCI::get_BAR2(pci_address) & 0xfffffff0) +UNMAP_AFTER_INIT BochsGraphicsAdapter::BochsGraphicsAdapter(PCI::DeviceIdentifier const& pci_device_identifier) + : PCI::Device(pci_device_identifier.address()) + , m_mmio_registers(PCI::get_BAR2(pci_device_identifier.address()) & 0xfffffff0) , m_registers(Memory::map_typed_writable<BochsDisplayMMIORegisters volatile>(m_mmio_registers)) { // We assume safe resolutio is 1024x768x32 - m_framebuffer_console = Graphics::ContiguousFramebufferConsole::initialize(PhysicalAddress(PCI::get_BAR0(pci_address) & 0xfffffff0), 1024, 768, 1024 * sizeof(u32)); + m_framebuffer_console = Graphics::ContiguousFramebufferConsole::initialize(PhysicalAddress(PCI::get_BAR0(pci_device_identifier.address()) & 0xfffffff0), 1024, 768, 1024 * sizeof(u32)); // FIXME: This is a very wrong way to do this... 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_hardware_id(pci_address); - if (id.vendor_id == 0x80ee && id.device_id == 0xbeef) + if (pci_device_identifier.hardware_id().vendor_id == 0x80ee && pci_device_identifier.hardware_id().device_id == 0xbeef) m_io_required = true; + if (pci_device_identifier.class_code().value() == 0x3 && pci_device_identifier.subclass_code().value() == 0x0) + m_is_vga_capable = true; + // Note: According to Gerd Hoffmann - "The linux driver simply does // the unblank unconditionally. With bochs-display this is not needed but // it also has no bad side effect". @@ -132,7 +134,7 @@ UNMAP_AFTER_INIT void BochsGraphicsAdapter::initialize_framebuffer_devices() GraphicsDevice::Type BochsGraphicsAdapter::type() const { - if (PCI::get_class(pci_address()) == 0x3 && PCI::get_subclass(pci_address()) == 0x0) + if (m_is_vga_capable) return Type::VGACompatible; return Type::Bochs; } |