diff options
author | Idan Horowitz <idan.horowitz@gmail.com> | 2021-04-23 17:26:52 +0300 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-17 18:15:25 +0200 |
commit | ba9b3dc65651d6aed8094deb7ce4d17ccfb28f01 (patch) | |
tree | 2484b2f1903a07b8f7692a087105dc2ebf2fa297 /Kernel/Devices/PCISerialDevice.h | |
parent | 62f69cc50fd5174c4202ad7f57138c27422b2b65 (diff) | |
download | serenity-ba9b3dc65651d6aed8094deb7ce4d17ccfb28f01.zip |
Kernel: Implement a PCI Serial Device driver
This simple driver simply finds a device in a device definitions list
and then sets up a SerialDevice instance based on the definition.
The driver currently only supports "WCH CH382 2S" pci serial boards,
as that is the only device available for me to test with, but most
other pci serial devices should be as easily addable as adding a
board_definitions entry.
Diffstat (limited to 'Kernel/Devices/PCISerialDevice.h')
-rw-r--r-- | Kernel/Devices/PCISerialDevice.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/Kernel/Devices/PCISerialDevice.h b/Kernel/Devices/PCISerialDevice.h new file mode 100644 index 0000000000..61f1e32afb --- /dev/null +++ b/Kernel/Devices/PCISerialDevice.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org> + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include <Kernel/Devices/CharacterDevice.h> +#include <Kernel/Devices/SerialDevice.h> +#include <Kernel/PCI/Device.h> +#include <Kernel/PCI/IDs.h> + +namespace Kernel { + +class PCISerialDevice { + AK_MAKE_ETERNAL +public: + static void detect(); + static SerialDevice& the(); + static bool is_available(); + +private: + struct BoardDefinition { + PCI::ID device_id; + 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 }; + }; + + static constexpr BoardDefinition board_definitions[1] = { + { { (u16)PCIVendorID::WCH, 0x3253 }, "WCH CH382 2S", 2, 0, 0xC0, 8, SerialDevice::Baud::Baud115200 } + }; +}; + +} |