#include "arch/PCI.h" #include "arch/x86_64/IO.h" #include #include #define PCI_ADDRESS_PORT 0xCF8 #define PCI_VALUE_PORT 0xCFC static inline constexpr u32 make_pci_address(const PCI::Device::Address& address, u32 field) { return 0x80000000 | (address.bus << 16) | (address.slot << 11) | (address.function << 8) | ((field)&0xFC); } namespace PCI { u8 read8(const Device::Address& address, u32 field) { IO::outl(PCI_ADDRESS_PORT, make_pci_address(address, field)); return IO::inb(PCI_VALUE_PORT + (field & 3)); } u16 read16(const Device::Address& address, u32 field) { IO::outl(PCI_ADDRESS_PORT, make_pci_address(address, field)); return IO::inw(PCI_VALUE_PORT + (field & 2)); } u32 read32(const Device::Address& address, u32 field) { IO::outl(PCI_ADDRESS_PORT, make_pci_address(address, field)); return IO::inl(PCI_VALUE_PORT); } void write8(const Device::Address& address, u32 field, u8 value) { ignore(address, field, value); todo(); } void write16(const Device::Address& address, u32 field, u8 value) { ignore(address, field, value); todo(); } void write32(const Device::Address& address, u32 field, u8 value) { ignore(address, field, value); todo(); } }