summaryrefslogtreecommitdiffhomepage
path: root/dev/Kernel/HALKit/AMD64/PCI
diff options
context:
space:
mode:
Diffstat (limited to 'dev/Kernel/HALKit/AMD64/PCI')
-rw-r--r--dev/Kernel/HALKit/AMD64/PCI/Database.cxx11
-rw-r--r--dev/Kernel/HALKit/AMD64/PCI/Device.cxx130
-rw-r--r--dev/Kernel/HALKit/AMD64/PCI/Dma.cxx82
-rw-r--r--dev/Kernel/HALKit/AMD64/PCI/Express.cxx11
-rw-r--r--dev/Kernel/HALKit/AMD64/PCI/IO.cxx7
-rw-r--r--dev/Kernel/HALKit/AMD64/PCI/Iterator.cxx44
-rw-r--r--dev/Kernel/HALKit/AMD64/PCI/PCI.cxx7
7 files changed, 0 insertions, 292 deletions
diff --git a/dev/Kernel/HALKit/AMD64/PCI/Database.cxx b/dev/Kernel/HALKit/AMD64/PCI/Database.cxx
deleted file mode 100644
index 971d43f9..00000000
--- a/dev/Kernel/HALKit/AMD64/PCI/Database.cxx
+++ /dev/null
@@ -1,11 +0,0 @@
-/* -------------------------------------------
-
- Copyright ZKA Technologies.
-
-------------------------------------------- */
-
-#include <KernelKit/PCI/Database.hxx>
-
-namespace Kernel
-{
-}
diff --git a/dev/Kernel/HALKit/AMD64/PCI/Device.cxx b/dev/Kernel/HALKit/AMD64/PCI/Device.cxx
deleted file mode 100644
index 214a640a..00000000
--- a/dev/Kernel/HALKit/AMD64/PCI/Device.cxx
+++ /dev/null
@@ -1,130 +0,0 @@
-/* -------------------------------------------
-
- Copyright ZKA Technologies.
-
-------------------------------------------- */
-
-#include <ArchKit/ArchKit.hxx>
-#include <KernelKit/PCI/Device.hxx>
-
-Kernel::UInt NewOSPCIReadRaw(Kernel::UInt bar, Kernel::UShort bus, Kernel::UShort dev, Kernel::UShort fun)
-{
- Kernel::UInt target = 0x80000000 | ((Kernel::UInt)bus << 16) |
- ((Kernel::UInt)dev << 11) | ((Kernel::UInt)fun << 8) |
- (bar & 0xFC);
-
- Kernel::HAL::Out32((Kernel::UShort)Kernel::PCI::PciConfigKind::ConfigAddress,
- target);
-
- return Kernel::HAL::In32((Kernel::UShort)Kernel::PCI::PciConfigKind::ConfigData);
-}
-
-void NewOSPCISetCfgTarget(Kernel::UInt bar, Kernel::UShort bus, Kernel::UShort dev, Kernel::UShort fun)
-{
- Kernel::UInt target = 0x80000000 | ((Kernel::UInt)bus << 16) |
- ((Kernel::UInt)dev << 11) | ((Kernel::UInt)fun << 8) |
- (bar & ~3);
-
- Kernel::HAL::Out32((Kernel::UShort)Kernel::PCI::PciConfigKind::ConfigAddress,
- target);
-}
-
-namespace Kernel::PCI
-{
- Device::Device(UShort bus, UShort device, UShort func, UShort bar)
- : fBus(bus), fDevice(device), fFunction(func), fBar(bar)
- {
- }
-
- Device::~Device()
- {
- }
-
- UInt Device::Read(UInt bar, Size sz)
- {
- NewOSPCISetCfgTarget(bar, fBus, fDevice, fFunction);
-
- if (sz == 4)
- return HAL::In32((UShort)PciConfigKind::ConfigData + (fBar & 3));
- if (sz == 2)
- return HAL::In16((UShort)PciConfigKind::ConfigData + (fBar & 3));
- if (sz == 1)
- return HAL::In8((UShort)PciConfigKind::ConfigData + (fBar & 3));
-
- return 0xFFFF;
- }
-
- void Device::Write(UInt bar, UIntPtr data, Size sz)
- {
- NewOSPCISetCfgTarget(bar, fBus, fDevice, fFunction);
-
- if (sz == 4)
- HAL::Out32((UShort)PciConfigKind::ConfigData + (fBar & 3), (UInt)data);
- if (sz == 2)
- HAL::Out16((UShort)PciConfigKind::ConfigData + (fBar & 3), (UShort)data);
- if (sz == 1)
- HAL::Out8((UShort)PciConfigKind::ConfigData + (fBar & 3), (UChar)data);
- }
-
- UShort Device::DeviceId()
- {
- return (UShort)(NewOSPCIReadRaw(0x0 >> 16, fBus, fDevice, fFunction));
- }
-
- UShort Device::VendorId()
- {
- return (UShort)(NewOSPCIReadRaw(0x0, fBus, fDevice, fFunction) >> 16);
- }
-
- UShort Device::InterfaceId()
- {
- return (UShort)(NewOSPCIReadRaw(0x0, fBus, fDevice, fFunction) >> 16);
- }
-
- UChar Device::Class()
- {
- return (UChar)(NewOSPCIReadRaw(0x08, fBus, fDevice, fFunction) >> 24);
- }
-
- UChar Device::Subclass()
- {
- return (UChar)(NewOSPCIReadRaw(0x08, fBus, fDevice, fFunction) >> 16);
- }
-
- UChar Device::ProgIf()
- {
- return (UChar)(NewOSPCIReadRaw(0x08, fBus, fDevice, fFunction) >> 8);
- }
-
- UChar Device::HeaderType()
- {
- return (UChar)(NewOSPCIReadRaw(0xC, fBus, fDevice, fFunction) >> 16);
- }
-
- void Device::EnableMmio()
- {
- bool enable = Read(0x04, sizeof(UChar)) | (1 << 1);
- Write(0x04, enable, sizeof(UShort));
- }
-
- void Device::BecomeBusMaster()
- {
- bool enable = Read(0x04, sizeof(UShort)) | (1 << 2);
- Write(0x04, enable, sizeof(UShort));
- }
-
- UShort Device::Vendor()
- {
- UShort vendor = VendorId();
-
- if (vendor != (UShort)PciConfigKind::Invalid)
- fDevice = (UShort)Read(0x0, sizeof(UShort));
-
- return fDevice;
- }
-
- Device::operator bool()
- {
- return VendorId() != (UShort)PciConfigKind::Invalid;
- }
-} // namespace Kernel::PCI
diff --git a/dev/Kernel/HALKit/AMD64/PCI/Dma.cxx b/dev/Kernel/HALKit/AMD64/PCI/Dma.cxx
deleted file mode 100644
index bf1730d8..00000000
--- a/dev/Kernel/HALKit/AMD64/PCI/Dma.cxx
+++ /dev/null
@@ -1,82 +0,0 @@
-/* -------------------------------------------
-
- Copyright ZKA Technologies.
-
-------------------------------------------- */
-
-#include <KernelKit/PCI/Dma.hxx>
-
-namespace Kernel
-{
- DMAWrapper::operator bool()
- {
- return fAddress;
- }
-
- bool DMAWrapper::operator!()
- {
- return !fAddress;
- }
-
- Boolean DMAWrapper::Check(UIntPtr offset) const
- {
- if (!fAddress)
- return false;
- if (offset == 0)
- return true;
-
- kcout << "[DMAWrapper::IsIn] Checking offset..\n";
- return reinterpret_cast<UIntPtr>(fAddress) >= offset;
- }
-
- bool DMAWrapper::Write(const UIntPtr& bit, const UIntPtr& offset)
- {
- if (!fAddress)
- return false;
-
- kcout << "[DMAWrapper::Write] Writing at address..\n";
-
- auto addr =
- (volatile UIntPtr*)(reinterpret_cast<UIntPtr>(fAddress) + offset);
- *addr = bit;
-
- return true;
- }
-
- UIntPtr DMAWrapper::Read(const UIntPtr& offset)
- {
- kcout << "[DMAWrapper::Read] checking fAddress..\n";
- if (!fAddress)
- return 0;
-
- kcout << "[DMAWrapper::Read] Reading fAddress..\n";
- return *(volatile UIntPtr*)(reinterpret_cast<UIntPtr>(fAddress) + offset);
- ;
- }
-
- UIntPtr DMAWrapper::operator[](const UIntPtr& offset)
- {
- return this->Read(offset);
- }
-
- OwnPtr<IOBuf<Char*>> DMAFactory::Construct(OwnPtr<DMAWrapper>& dma)
- {
- if (!dma)
- return {};
-
- OwnPtr<IOBuf<Char*>> dmaOwnPtr =
- make_ptr<IOBuf<Char*>, char*>(reinterpret_cast<char*>(dma->fAddress));
-
- if (!dmaOwnPtr)
- return {};
-
- kcout << "Returning the new OwnPtr<IOBuf<Char*>>!\r";
- return dmaOwnPtr;
- }
-
- DMAWrapper& DMAWrapper::operator=(voidPtr Ptr)
- {
- fAddress = Ptr;
- return *this;
- }
-} // namespace Kernel
diff --git a/dev/Kernel/HALKit/AMD64/PCI/Express.cxx b/dev/Kernel/HALKit/AMD64/PCI/Express.cxx
deleted file mode 100644
index 6a926827..00000000
--- a/dev/Kernel/HALKit/AMD64/PCI/Express.cxx
+++ /dev/null
@@ -1,11 +0,0 @@
-/* -------------------------------------------
-
- Copyright ZKA Technologies.
-
-------------------------------------------- */
-
-#include <KernelKit/PCI/Express.hxx>
-
-namespace Kernel
-{
-}
diff --git a/dev/Kernel/HALKit/AMD64/PCI/IO.cxx b/dev/Kernel/HALKit/AMD64/PCI/IO.cxx
deleted file mode 100644
index ea91c7b7..00000000
--- a/dev/Kernel/HALKit/AMD64/PCI/IO.cxx
+++ /dev/null
@@ -1,7 +0,0 @@
-/* -------------------------------------------
-
- Copyright ZKA Technologies.
-
-------------------------------------------- */
-
-#include <KernelKit/PCI/IO.hxx>
diff --git a/dev/Kernel/HALKit/AMD64/PCI/Iterator.cxx b/dev/Kernel/HALKit/AMD64/PCI/Iterator.cxx
deleted file mode 100644
index 47b16462..00000000
--- a/dev/Kernel/HALKit/AMD64/PCI/Iterator.cxx
+++ /dev/null
@@ -1,44 +0,0 @@
-/* -------------------------------------------
-
- Copyright ZKA Technologies.
-
-------------------------------------------- */
-
-#include <KernelKit/PCI/Iterator.hxx>
-
-#define PCI_ITERATOR_FIND_AND_UNWRAP(DEV, SZ) \
- if (DEV.Leak().Leak()) \
- return *DEV.Leak().Leak();
-
-namespace Kernel::PCI
-{
- Iterator::Iterator(const Types::PciDeviceKind& type)
- {
- // probe devices.
- for (int bus = 0; bus < NEWOS_BUS_COUNT; ++bus)
- {
- for (int device = 0; device < NEWOS_DEVICE_COUNT; ++device)
- {
- for (int function = 0; function < NEWOS_FUNCTION_COUNT; ++function)
- {
- Device dev(bus, device, function, 0);
-
- if (dev.Class() == (UChar)type)
- {
- *fDevices[bus].Leak().Leak() = dev;
- }
- }
- }
- }
- }
-
- Iterator::~Iterator()
- {
- }
-
- Ref<PCI::Device> Iterator::operator[](const Size& sz)
- {
- PCI_ITERATOR_FIND_AND_UNWRAP(fDevices[sz], sz);
- return {};
- }
-} // namespace Kernel::PCI
diff --git a/dev/Kernel/HALKit/AMD64/PCI/PCI.cxx b/dev/Kernel/HALKit/AMD64/PCI/PCI.cxx
deleted file mode 100644
index 59e3b06e..00000000
--- a/dev/Kernel/HALKit/AMD64/PCI/PCI.cxx
+++ /dev/null
@@ -1,7 +0,0 @@
-/* -------------------------------------------
-
- Copyright ZKA Technologies.
-
-------------------------------------------- */
-
-#include <KernelKit/PCI/PCI.hxx>