kernel/x86_64: Implement writing to PCI fields
This commit is contained in:
parent
3762d3f959
commit
cc8450751c
@ -33,19 +33,32 @@ namespace PCI
|
|||||||
|
|
||||||
void write8(const Device::Address& address, u32 field, u8 value)
|
void write8(const Device::Address& address, u32 field, u8 value)
|
||||||
{
|
{
|
||||||
ignore(address, field, value);
|
u8 offset = (u8)(field & ~0x3);
|
||||||
todo();
|
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);
|
u8 offset = (u8)(field & ~0x3);
|
||||||
todo();
|
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);
|
IO::outl(PCI_ADDRESS_PORT, make_pci_address(address, field));
|
||||||
todo();
|
IO::outl(PCI_VALUE_PORT, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user