kernel/x86_64: Implement writing to PCI fields

This commit is contained in:
apio 2023-05-14 21:45:18 +02:00
parent 3762d3f959
commit cc8450751c
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -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);
}
}