summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorGunnar Beutner <gbeutner@serenityos.org>2021-04-27 10:54:22 +0200
committerAndreas Kling <kling@serenityos.org>2021-04-27 11:36:24 +0200
commitbf703ee553eeb1f5b51ced0c4001bd0daba02092 (patch)
tree48d772f2dc9090d94b19cdc65e8d713dd6af2993 /Kernel
parenteaf8fc90e71b6ef877d1b3d8bfbd943de8f19f37 (diff)
downloadserenity-bf703ee553eeb1f5b51ced0c4001bd0daba02092.zip
Kernel: Move PCI vendor and device IDs into Kernel/PCI/IDs.h
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Net/E1000NetworkAdapter.cpp5
-rw-r--r--Kernel/PCI/IDs.h21
-rw-r--r--Kernel/VirtIO/VirtIO.cpp7
-rw-r--r--Kernel/VirtIO/VirtIO.h2
-rw-r--r--Kernel/VirtIO/VirtIOConsole.h2
-rw-r--r--Kernel/VirtIO/VirtIORNG.h2
6 files changed, 27 insertions, 12 deletions
diff --git a/Kernel/Net/E1000NetworkAdapter.cpp b/Kernel/Net/E1000NetworkAdapter.cpp
index 46af215644..1b1ddb97ad 100644
--- a/Kernel/Net/E1000NetworkAdapter.cpp
+++ b/Kernel/Net/E1000NetworkAdapter.cpp
@@ -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;
diff --git a/Kernel/PCI/IDs.h b/Kernel/PCI/IDs.h
new file mode 100644
index 0000000000..38c0912c5c
--- /dev/null
+++ b/Kernel/PCI/IDs.h
@@ -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,
+};
+
+}
diff --git a/Kernel/VirtIO/VirtIO.cpp b/Kernel/VirtIO/VirtIO.cpp
index 73e1f99d36..00649f870a 100644
--- a/Kernel/VirtIO/VirtIO.cpp
+++ b/Kernel/VirtIO/VirtIO.cpp
@@ -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;
}
diff --git a/Kernel/VirtIO/VirtIO.h b/Kernel/VirtIO/VirtIO.h
index 3a9c5d0dae..b764bebb00 100644
--- a/Kernel/VirtIO/VirtIO.h
+++ b/Kernel/VirtIO/VirtIO.h
@@ -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
diff --git a/Kernel/VirtIO/VirtIOConsole.h b/Kernel/VirtIO/VirtIOConsole.h
index ed4ed5bae3..7dc51be0bd 100644
--- a/Kernel/VirtIO/VirtIOConsole.h
+++ b/Kernel/VirtIO/VirtIOConsole.h
@@ -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)
diff --git a/Kernel/VirtIO/VirtIORNG.h b/Kernel/VirtIO/VirtIORNG.h
index 3d81dbaa2b..49ca1f0b2b 100644
--- a/Kernel/VirtIO/VirtIORNG.h
+++ b/Kernel/VirtIO/VirtIORNG.h
@@ -12,8 +12,6 @@
namespace Kernel {
-#define VIRTIO_ENTROPY_PCI_DEVICE_ID 0x1005
-
#define REQUESTQ 0
class VirtIORNG final : public CharacterDevice