mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-12 14:12:52 +00:00
Kernel: Move PCI vendor and device IDs into Kernel/PCI/IDs.h
This commit is contained in:
parent
eaf8fc90e7
commit
bf703ee553
Notes:
sideshowbarker
2024-07-18 19:02:25 +09:00
Author: https://github.com/gunnarbeutner
Commit: bf703ee553
Pull-request: https://github.com/SerenityOS/serenity/pull/6669
Reviewed-by: https://github.com/IdanHo ✅
Reviewed-by: https://github.com/supercomputer7
6 changed files with 27 additions and 12 deletions
|
@ -7,6 +7,7 @@
|
|||
#include <AK/MACAddress.h>
|
||||
#include <Kernel/Debug.h>
|
||||
#include <Kernel/Net/E1000NetworkAdapter.h>
|
||||
#include <Kernel/PCI/IDs.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
|
@ -117,8 +118,6 @@ namespace Kernel {
|
|||
#define INTERRUPT_TXD_LOW (1 << 15)
|
||||
#define INTERRUPT_SRPD (1 << 16)
|
||||
|
||||
#define PCI_VENDOR_INTEL 0x8086
|
||||
|
||||
// https://www.intel.com/content/dam/doc/manual/pci-pci-x-family-gbe-controllers-software-dev-manual.pdf Section 5.2
|
||||
static bool is_valid_device_id(u16 device_id)
|
||||
{
|
||||
|
@ -162,7 +161,7 @@ UNMAP_AFTER_INIT void E1000NetworkAdapter::detect()
|
|||
PCI::enumerate([&](const PCI::Address& address, PCI::ID id) {
|
||||
if (address.is_null())
|
||||
return;
|
||||
if (id.vendor_id != PCI_VENDOR_INTEL)
|
||||
if (id.vendor_id != (u16)PCIVendorID::Intel)
|
||||
return;
|
||||
if (!is_valid_device_id(id.device_id))
|
||||
return;
|
||||
|
|
21
Kernel/PCI/IDs.h
Normal file
21
Kernel/PCI/IDs.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Gunnar Beutner <gbeutner@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
enum class PCIVendorID {
|
||||
VirtIO = 0x1af4,
|
||||
Intel = 0x8086,
|
||||
};
|
||||
|
||||
enum class PCIDeviceID {
|
||||
VirtIOConsole = 0x1003,
|
||||
VirtIOEntropy = 0x1005,
|
||||
};
|
||||
|
||||
}
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <Kernel/CommandLine.h>
|
||||
#include <Kernel/PCI/IDs.h>
|
||||
#include <Kernel/VirtIO/VirtIO.h>
|
||||
#include <Kernel/VirtIO/VirtIOConsole.h>
|
||||
#include <Kernel/VirtIO/VirtIORNG.h>
|
||||
|
@ -18,14 +19,14 @@ void VirtIO::detect()
|
|||
PCI::enumerate([&](const PCI::Address& address, PCI::ID id) {
|
||||
if (address.is_null() || id.is_null())
|
||||
return;
|
||||
if (id.vendor_id != VIRTIO_PCI_VENDOR_ID)
|
||||
if (id.vendor_id != (u16)PCIVendorID::VirtIO)
|
||||
return;
|
||||
switch (id.device_id) {
|
||||
case VIRTIO_CONSOLE_PCI_DEVICE_ID: {
|
||||
case (u16)PCIDeviceID::VirtIOConsole: {
|
||||
[[maybe_unused]] auto& unused = adopt_ref(*new VirtIOConsole(address)).leak_ref();
|
||||
break;
|
||||
}
|
||||
case VIRTIO_ENTROPY_PCI_DEVICE_ID: {
|
||||
case (u16)PCIDeviceID::VirtIOEntropy: {
|
||||
[[maybe_unused]] auto& unused = adopt_ref(*new VirtIORNG(address)).leak_ref();
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
#define VIRTIO_PCI_VENDOR_ID 0x1AF4
|
||||
|
||||
#define REG_DEVICE_FEATURES 0x0
|
||||
#define REG_GUEST_FEATURES 0x4
|
||||
#define REG_QUEUE_ADDRESS 0x8
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
#define VIRTIO_CONSOLE_PCI_DEVICE_ID 0x1003
|
||||
|
||||
#define VIRTIO_CONSOLE_F_SIZE (1 << 0)
|
||||
#define VIRTIO_CONSOLE_F_MULTIPORT (1 << 1)
|
||||
#define VIRTIO_CONSOLE_F_EMERG_WRITE (1 << 2)
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
#define VIRTIO_ENTROPY_PCI_DEVICE_ID 0x1005
|
||||
|
||||
#define REQUESTQ 0
|
||||
|
||||
class VirtIORNG final : public CharacterDevice
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue