mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-03 06:40:05 +00:00
Kernel: Clarify and make it easy to not use raw numbers
Let's put the PCI IDs as enums in the PCI namespace so they're free to pollute that namespace, but it's also more easier to use them.
This commit is contained in:
parent
b4e230a7bb
commit
3fae7ca113
Notes:
sideshowbarker
2024-07-18 11:03:45 +09:00
Author: https://github.com/supercomputer7
Commit: 3fae7ca113
Pull-request: https://github.com/SerenityOS/serenity/pull/8399
Reviewed-by: https://github.com/alimpfard ✅
9 changed files with 25 additions and 21 deletions
|
@ -8,6 +8,7 @@
|
|||
#include <AK/Checked.h>
|
||||
#include <AK/Singleton.h>
|
||||
#include <Kernel/Bus/PCI/Access.h>
|
||||
#include <Kernel/Bus/PCI/IDs.h>
|
||||
#include <Kernel/Debug.h>
|
||||
#include <Kernel/Graphics/Bochs.h>
|
||||
#include <Kernel/Graphics/BochsGraphicsAdapter.h>
|
||||
|
@ -47,7 +48,7 @@ struct [[gnu::packed]] BochsDisplayMMIORegisters {
|
|||
UNMAP_AFTER_INIT NonnullRefPtr<BochsGraphicsAdapter> BochsGraphicsAdapter::initialize(PCI::Address address)
|
||||
{
|
||||
PCI::ID id = PCI::get_id(address);
|
||||
VERIFY((id.vendor_id == 0x1234 && id.device_id == 0x1111) || (id.vendor_id == 0x80ee && id.device_id == 0xbeef));
|
||||
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));
|
||||
}
|
||||
|
||||
|
|
|
@ -82,18 +82,18 @@ UNMAP_AFTER_INIT bool GraphicsManagement::determine_and_initialize_graphics_devi
|
|||
|
||||
RefPtr<GraphicsDevice> adapter;
|
||||
switch (id.vendor_id) {
|
||||
case 0x1234:
|
||||
case PCI::VendorID::QEMUOld:
|
||||
if (id.device_id == 0x1111)
|
||||
adapter = BochsGraphicsAdapter::initialize(address);
|
||||
break;
|
||||
case 0x80ee:
|
||||
case PCI::VendorID::VirtualBox:
|
||||
if (id.device_id == 0xbeef)
|
||||
adapter = BochsGraphicsAdapter::initialize(address);
|
||||
break;
|
||||
case 0x8086:
|
||||
case PCI::VendorID::Intel:
|
||||
adapter = IntelNativeGraphicsAdapter::initialize(address);
|
||||
break;
|
||||
case static_cast<u16>(PCIVendorID::VirtIO):
|
||||
case PCI::VendorID::VirtIO:
|
||||
dmesgln("Graphics: Using VirtIO console");
|
||||
adapter = Graphics::VirtIOGraphicsAdapter::initialize(address);
|
||||
break;
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Kernel::Graphics {
|
|||
|
||||
NonnullRefPtr<VirtIOGraphicsAdapter> VirtIOGraphicsAdapter::initialize(PCI::Address base_address)
|
||||
{
|
||||
VERIFY(PCI::get_id(base_address).vendor_id == static_cast<u16>(PCIVendorID::VirtIO));
|
||||
VERIFY(PCI::get_id(base_address).vendor_id == PCI::VendorID::VirtIO);
|
||||
return adopt_ref(*new VirtIOGraphicsAdapter(base_address));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue