2021-04-23 14:26:52 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2021-08-21 03:58:43 +00:00
|
|
|
#include <Kernel/Bus/PCI/Device.h>
|
2021-06-25 06:46:17 +00:00
|
|
|
#include <Kernel/Bus/PCI/IDs.h>
|
2021-04-23 14:26:52 +00:00
|
|
|
#include <Kernel/Devices/CharacterDevice.h>
|
|
|
|
#include <Kernel/Devices/SerialDevice.h>
|
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
|
|
|
class PCISerialDevice {
|
|
|
|
public:
|
|
|
|
static void detect();
|
|
|
|
static SerialDevice& the();
|
|
|
|
static bool is_available();
|
|
|
|
|
|
|
|
private:
|
|
|
|
struct BoardDefinition {
|
2021-09-23 06:14:51 +00:00
|
|
|
PCI::HardwareID device_id;
|
2021-04-23 14:26:52 +00:00
|
|
|
StringView name;
|
|
|
|
u32 port_count { 0 };
|
|
|
|
u32 pci_bar { 0 };
|
|
|
|
u32 first_offset { 0 };
|
|
|
|
u32 port_size { 0 };
|
|
|
|
SerialDevice::Baud baud_rate { SerialDevice::Baud::Baud38400 };
|
|
|
|
};
|
|
|
|
|
2023-08-10 21:19:09 +00:00
|
|
|
static constexpr BoardDefinition board_definitions[] = {
|
2022-07-11 17:32:29 +00:00
|
|
|
{ { PCI::VendorID::RedHat, 0x0002 }, "QEMU PCI 16550A"sv, 1, 0, 0, 8, SerialDevice::Baud::Baud115200 },
|
|
|
|
{ { PCI::VendorID::RedHat, 0x0003 }, "QEMU PCI Dual-port 16550A"sv, 2, 0, 0, 8, SerialDevice::Baud::Baud115200 },
|
2023-08-10 21:19:09 +00:00
|
|
|
{ { PCI::VendorID::RedHat, 0x0004 }, "QEMU PCI Quad-port 16550A"sv, 4, 0, 0, 8, SerialDevice::Baud::Baud115200 },
|
|
|
|
{ { PCI::VendorID::WCH, 0x2273 }, "WCH CH351"sv, 2, 0, 0, 8, SerialDevice::Baud::Baud115200 },
|
|
|
|
{ { PCI::VendorID::WCH, 0x3253 }, "WCH CH382 2S"sv, 2, 0, 0xC0, 8, SerialDevice::Baud::Baud115200 }
|
2021-04-23 14:26:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|