2024-09-16 20:45:00 -05:00
|
|
|
stn := @use("rel:../../stn/src/lib.hb");
|
|
|
|
.{string, memory, buffer} := stn
|
|
|
|
|
2024-09-14 03:51:57 -05:00
|
|
|
PCIAddress := struct {
|
|
|
|
bus: u8,
|
|
|
|
device: u8,
|
|
|
|
function: u8,
|
|
|
|
}
|
|
|
|
|
|
|
|
find_device := fn(vendor_id: int, device_id: int, pci_address: PCIAddress): int {
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
scan_bus := fn(): void {
|
|
|
|
}
|
|
|
|
|
|
|
|
config_read32 := fn(bus: u32, device: u32, func: u32, offset: u32): u32 {
|
|
|
|
// construct address param
|
2024-09-16 20:45:00 -05:00
|
|
|
offset_and := offset & 0xFC
|
|
|
|
|
|
|
|
address := bus << 16
|
|
|
|
address |= device << 11
|
|
|
|
address |= func << 8
|
|
|
|
address |= offset_and
|
2024-09-14 04:28:45 -05:00
|
|
|
address |= 0x80000000
|
2024-09-14 03:51:57 -05:00
|
|
|
|
|
|
|
// write address
|
2024-09-16 20:45:00 -05:00
|
|
|
memory.outl(0xCF8, address)
|
2024-09-14 03:51:57 -05:00
|
|
|
|
|
|
|
// read data
|
2024-09-16 20:45:00 -05:00
|
|
|
return memory.inl(0xCFC)
|
2024-09-14 03:51:57 -05:00
|
|
|
}
|