diff --git a/kernel/src/arch/x86_64/PCI.cpp b/kernel/src/arch/x86_64/PCI.cpp index 0ce6d920..16fd0815 100644 --- a/kernel/src/arch/x86_64/PCI.cpp +++ b/kernel/src/arch/x86_64/PCI.cpp @@ -33,19 +33,32 @@ namespace PCI void write8(const Device::Address& address, u32 field, u8 value) { - ignore(address, field, value); - todo(); + u8 offset = (u8)(field & ~0x3); + union { + u8 split[4]; + u32 full; + }; + full = read32(address, offset); + split[(field & 0x3)] = value; + write32(address, offset, full); } - void write16(const Device::Address& address, u32 field, u8 value) + void write16(const Device::Address& address, u32 field, u16 value) { - ignore(address, field, value); - todo(); + u8 offset = (u8)(field & ~0x3); + union { + u8 split[4]; + u32 full; + }; + full = read32(address, offset); + split[(field & 0x3)] = (u8)(value >> 8); + split[(field & 0x3) + 1] = (u8)(value & 0xff); + write32(address, offset, full); } - void write32(const Device::Address& address, u32 field, u8 value) + void write32(const Device::Address& address, u32 field, u32 value) { - ignore(address, field, value); - todo(); + IO::outl(PCI_ADDRESS_PORT, make_pci_address(address, field)); + IO::outl(PCI_VALUE_PORT, value); } }