summaryrefslogtreecommitdiffhomepage
path: root/dev/Kernel/KernelKit/PCI
diff options
context:
space:
mode:
Diffstat (limited to 'dev/Kernel/KernelKit/PCI')
-rw-r--r--dev/Kernel/KernelKit/PCI/Database.hxx38
-rw-r--r--dev/Kernel/KernelKit/PCI/Device.hxx79
-rw-r--r--dev/Kernel/KernelKit/PCI/Dma.hxx81
-rw-r--r--dev/Kernel/KernelKit/PCI/Dma.inl20
-rw-r--r--dev/Kernel/KernelKit/PCI/Express.hxx11
-rw-r--r--dev/Kernel/KernelKit/PCI/IO-Impl-AMD64.inl54
-rw-r--r--dev/Kernel/KernelKit/PCI/IO.hxx59
-rw-r--r--dev/Kernel/KernelKit/PCI/Iterator.hxx43
-rw-r--r--dev/Kernel/KernelKit/PCI/PCI.hxx59
9 files changed, 0 insertions, 444 deletions
diff --git a/dev/Kernel/KernelKit/PCI/Database.hxx b/dev/Kernel/KernelKit/PCI/Database.hxx
deleted file mode 100644
index c5f3c953..00000000
--- a/dev/Kernel/KernelKit/PCI/Database.hxx
+++ /dev/null
@@ -1,38 +0,0 @@
-/* -------------------------------------------
-
- Copyright ZKA Technologies.
-
-------------------------------------------- */
-#pragma once
-
-#include <KernelKit/PCI/Device.hxx>
-#include <NewKit/Defines.hxx>
-
-namespace Kernel
-{
- namespace Types
- {
- // https://wiki.osdev.org/PCI
- enum class PciDeviceKind : UChar
- {
- MassStorageController = 0x1,
- NetworkController = 0x2,
- DisplayController = 0x3,
- MultimediaController = 0x4,
- MemoryController = 0x5,
- Bridge = 0x6,
- CommunicationController = 0x7,
- GenericSystemPeripheral = 0x8,
- InputDeviceController = 0x9,
- DockingStation = 0xa,
- Processor = 0xb,
- SerialBusController = 0xc,
- WirelessController = 0xd,
- IntelligentController = 0xe,
- SatelliteCommunicationsController = 0xf,
- CoProcessor = 0x40,
- Unassgined = 0xf,
- Invalid = Unassgined,
- };
- } // namespace Types
-} // namespace Kernel
diff --git a/dev/Kernel/KernelKit/PCI/Device.hxx b/dev/Kernel/KernelKit/PCI/Device.hxx
deleted file mode 100644
index a562219a..00000000
--- a/dev/Kernel/KernelKit/PCI/Device.hxx
+++ /dev/null
@@ -1,79 +0,0 @@
-/* -------------------------------------------
-
- Copyright ZKA Technologies.
-
-------------------------------------------- */
-#pragma once
-
-#include <NewKit/Defines.hxx>
-
-namespace Kernel::PCI
-{
- enum class PciConfigKind : UShort
- {
- ConfigAddress = 0xCF8,
- ConfigData = 0xCFC,
- Invalid = 0xFFF
- };
-
- class Device final
- {
- public:
- Device() = default;
-
- public:
- explicit Device(UShort bus, UShort device, UShort function, UShort bar);
-
- Device& operator=(const Device&) = default;
-
- Device(const Device&) = default;
-
- ~Device();
-
- public:
- UInt Read(UInt bar, Size szData);
- void Write(UInt bar, UIntPtr data, Size szData);
-
- public:
- operator bool();
-
- public:
- template <typename T>
- UInt Read(UInt bar)
- {
- static_assert(sizeof(T) <= 4, "64-bit PCI addressing is unsupported");
- return Read(bar, sizeof(T));
- }
-
- template <typename T>
- void Write(UInt bar, UIntPtr data)
- {
- static_assert(sizeof(T) <= 4, "64-bit PCI addressing is unsupported");
- Write(bar, data, sizeof(T));
- }
-
- public:
- UShort DeviceId();
- UShort VendorId();
- UShort InterfaceId();
- UChar Class();
- UChar Subclass();
- UChar ProgIf();
- UChar HeaderType();
-
- public:
- void EnableMmio();
- void BecomeBusMaster(); // for PCI-DMA, PC-DMA does not need that.
-
- UShort Vendor();
-
- private:
- UShort fBus;
- UShort fDevice;
- UShort fFunction;
- UShort fBar;
- };
-} // namespace Kernel::PCI
-
-EXTERN_C void NewOSPCISetCfgTarget(Kernel::UInt bar);
-EXTERN_C Kernel::UInt NewOSPCIReadRaw(Kernel::UInt bar);
diff --git a/dev/Kernel/KernelKit/PCI/Dma.hxx b/dev/Kernel/KernelKit/PCI/Dma.hxx
deleted file mode 100644
index 70292c19..00000000
--- a/dev/Kernel/KernelKit/PCI/Dma.hxx
+++ /dev/null
@@ -1,81 +0,0 @@
-/* -------------------------------------------
-
- Copyright ZKA Technologies.
-
-------------------------------------------- */
-
-#pragma once
-
-#include <KernelKit/DeviceManager.hxx>
-#include <KernelKit/PCI/Device.hxx>
-#include <NewKit/Array.hxx>
-#include <NewKit/OwnPtr.hxx>
-#include <NewKit/Ref.hxx>
-
-namespace Kernel
-{
- enum class DmaKind
- {
- PCI, // Bus mastering is required to be turned on. Basiaclly a request
- // control system. 64-Bit access depends on the PAE bit and the device
- // (if Double Address Cycle is available)
- ISA, // Four DMA channels 0-3; 8 bit transfers and only a megabyte of RAM.
- Invalid,
- };
-
- class DMAWrapper final
- {
- public:
- explicit DMAWrapper() = delete;
-
- public:
- explicit DMAWrapper(nullPtr) = delete;
- explicit DMAWrapper(voidPtr Ptr, DmaKind Kind = DmaKind::PCI)
- : fAddress(Ptr), fKind(Kind)
- {
- }
-
- public:
- DMAWrapper& operator=(voidPtr Ptr);
-
- public:
- DMAWrapper& operator=(const DMAWrapper&) = default;
- DMAWrapper(const DMAWrapper&) = default;
-
- public:
- ~DMAWrapper() = default;
-
- template <class T>
- T* operator->();
-
- template <class T>
- T* Get(const UIntPtr off = 0);
-
- public:
- operator bool();
- bool operator!();
-
- public:
- bool Write(const UIntPtr& bit, const UIntPtr& offset);
- UIntPtr Read(const UIntPtr& offset);
- Boolean Check(UIntPtr offset) const;
-
- public:
- UIntPtr operator[](const UIntPtr& offset);
-
- private:
- voidPtr fAddress{nullptr};
- DmaKind fKind{DmaKind::Invalid};
-
- private:
- friend class DMAFactory;
- };
-
- class DMAFactory final
- {
- public:
- static OwnPtr<IOBuf<Char*>> Construct(OwnPtr<DMAWrapper>& dma);
- };
-} // namespace Kernel
-
-#include <KernelKit/PCI/Dma.inl>
diff --git a/dev/Kernel/KernelKit/PCI/Dma.inl b/dev/Kernel/KernelKit/PCI/Dma.inl
deleted file mode 100644
index 1c164af8..00000000
--- a/dev/Kernel/KernelKit/PCI/Dma.inl
+++ /dev/null
@@ -1,20 +0,0 @@
-/* -------------------------------------------
-
- Copyright ZKA Technologies.
-
-------------------------------------------- */
-
-namespace Kernel
-{
- template <class T>
- T* DMAWrapper::operator->()
- {
- return fAddress;
- }
-
- template <class T>
- T* DMAWrapper::Get(const UIntPtr offset)
- {
- return reinterpret_cast<T*>((UIntPtr)fAddress + offset);
- }
-} // namespace Kernel
diff --git a/dev/Kernel/KernelKit/PCI/Express.hxx b/dev/Kernel/KernelKit/PCI/Express.hxx
deleted file mode 100644
index 1d6a86d0..00000000
--- a/dev/Kernel/KernelKit/PCI/Express.hxx
+++ /dev/null
@@ -1,11 +0,0 @@
-/* -------------------------------------------
-
- Copyright ZKA Technologies.
-
-------------------------------------------- */
-
-#pragma once
-
-#include <NewKit/Defines.hxx>
-
-#define PCI_EXPRESS_BUS_COUNT (4096)
diff --git a/dev/Kernel/KernelKit/PCI/IO-Impl-AMD64.inl b/dev/Kernel/KernelKit/PCI/IO-Impl-AMD64.inl
deleted file mode 100644
index b0252e63..00000000
--- a/dev/Kernel/KernelKit/PCI/IO-Impl-AMD64.inl
+++ /dev/null
@@ -1,54 +0,0 @@
-/* -------------------------------------------
-
- Copyright ZKA Technologies.
-
- File: IO-Impl-AMD64.hpp
- Purpose: I/O for AMD64.
-
- Revision History:
-
- 30/01/24: Add file. (amlel)
- 02/02/24: Update I/O routines. (amlel)
-
-------------------------------------------- */
-
-namespace Kernel
-{
- template <SizeT Sz>
- template <typename T>
- T IOArray<Sz>::In(SizeT index)
- {
- switch (sizeof(T))
- {
-#ifdef __NEWOS_AMD64__
- case 4:
- return HAL::In32(fPorts[index].Leak());
- case 2:
- return HAL::In16(fPorts[index].Leak());
- case 1:
- return HAL::In8(fPorts[index].Leak());
-#endif
- default:
- return 0xFFFF;
- }
- }
-
- template <SizeT Sz>
- template <typename T>
- void IOArray<Sz>::Out(SizeT index, T value)
- {
- switch (sizeof(T))
- {
-#ifdef __NEWOS_AMD64__
- case 4:
- HAL::Out32(fPorts[index].Leak(), value);
- case 2:
- HAL::Out16(fPorts[index].Leak(), value);
- case 1:
- HAL::Out8(fPorts[index].Leak(), value);
-#endif
- default:
- break;
- }
- }
-} // namespace Kernel
diff --git a/dev/Kernel/KernelKit/PCI/IO.hxx b/dev/Kernel/KernelKit/PCI/IO.hxx
deleted file mode 100644
index a86bcc52..00000000
--- a/dev/Kernel/KernelKit/PCI/IO.hxx
+++ /dev/null
@@ -1,59 +0,0 @@
-/* -------------------------------------------
-
- Copyright ZKA Technologies.
-
-------------------------------------------- */
-
-#pragma once
-
-#include <ArchKit/ArchKit.hxx>
-#include <NewKit/Array.hxx>
-#include <NewKit/Defines.hxx>
-#include <NewKit/Ref.hxx>
-
-namespace Kernel
-{
- template <SizeT Sz>
- class IOArray final
- {
- public:
- IOArray() = delete;
-
- IOArray(nullPtr) = delete;
-
- explicit IOArray(Array<UShort, Sz>& ports)
- : fPorts(ports)
- {
- }
- ~IOArray()
- {
- }
-
- IOArray& operator=(const IOArray&) = default;
-
- IOArray(const IOArray&) = default;
-
- operator bool()
- {
- return !fPorts.Empty();
- }
-
- public:
- template <typename T>
- T In(SizeT index);
-
- template <typename T>
- void Out(SizeT index, T value);
-
- private:
- Array<UShort, Sz> fPorts;
- };
-
- using IOArray16 = IOArray<16>;
-} // namespace Kernel
-
-#ifdef __x86_64__
-#include <KernelKit/PCI/IO-Impl-AMD64.inl>
-#else
-#error Please provide platform specific code for the I/O
-#endif // ifdef __x86_64__
diff --git a/dev/Kernel/KernelKit/PCI/Iterator.hxx b/dev/Kernel/KernelKit/PCI/Iterator.hxx
deleted file mode 100644
index 5f2ca089..00000000
--- a/dev/Kernel/KernelKit/PCI/Iterator.hxx
+++ /dev/null
@@ -1,43 +0,0 @@
-/* -------------------------------------------
-
- Copyright ZKA Technologies.
-
-------------------------------------------- */
-
-#ifndef __PCI_ITERATOR_HPP__
-#define __PCI_ITERATOR_HPP__
-
-#include <KernelKit/PCI/Database.hxx>
-#include <KernelKit/PCI/Device.hxx>
-#include <NewKit/Array.hxx>
-#include <NewKit/Defines.hxx>
-#include <NewKit/Ref.hxx>
-
-#define NEWOS_BUS_COUNT (256)
-#define NEWOS_DEVICE_COUNT (33)
-#define NEWOS_FUNCTION_COUNT (8)
-
-namespace Kernel::PCI
-{
- class Iterator final
- {
- public:
- Iterator() = delete;
-
- public:
- explicit Iterator(const Types::PciDeviceKind& deviceType);
-
- Iterator& operator=(const Iterator&) = default;
- Iterator(const Iterator&) = default;
-
- ~Iterator();
-
- public:
- Ref<PCI::Device> operator[](const Size& sz);
-
- private:
- Array<PCI::Device, NEWOS_BUS_COUNT> fDevices;
- };
-} // namespace Kernel::PCI
-
-#endif // __PCI_ITERATOR_HPP__
diff --git a/dev/Kernel/KernelKit/PCI/PCI.hxx b/dev/Kernel/KernelKit/PCI/PCI.hxx
deleted file mode 100644
index 8654defa..00000000
--- a/dev/Kernel/KernelKit/PCI/PCI.hxx
+++ /dev/null
@@ -1,59 +0,0 @@
-/* -------------------------------------------
-
- Copyright ZKA Technologies.
-
-------------------------------------------- */
-
-#pragma once
-
-#include <NewKit/Defines.hxx>
-
-#define cPCIConfigAddressPort (0xCF8)
-#define cPCIConfigDataPort (0xCFC)
-
-#define cPCIDeviceCount (32)
-#define cPCIFuncCount (8)
-#define cPCIBusCount (255)
-
-namespace Kernel::PCI
-{
- // model
- struct DeviceHeader
- {
- UInt16 VendorId;
- UInt16 DeviceId;
- UInt8 Command;
- UInt8 Status;
- UInt8 RevisionId;
- UInt8 ProgIf;
- UInt8 SubClass;
- UInt8 Class;
- UInt8 CacheLineSz;
- UInt8 LatencyTimer;
- UInt8 HeaderType;
- UInt8 Bist;
- UInt8 Bus;
- UInt8 Device;
- UInt8 Function;
- };
-
- namespace Detail
- {
- class BAR
- {
- public:
- UIntPtr BAR;
- SizeT Size;
- };
- } // namespace Detail
-
- class BAR
- {
- public:
- Detail::BAR BAR1;
- Detail::BAR BAR2;
- Detail::BAR BAR3;
- Detail::BAR BAR4;
- Detail::BAR BAR5;
- };
-} // namespace Kernel::PCI