On Sun, 25 Sep 2022, BALATON Zoltan wrote:
Define the r[bwl][!@] register access words as io[bwl][!@] for now. I'm not sure this is correct.
After some more testing I think this is not correct but not sure how to implement these correctly, see below for details. Ping for the other patches though that could be merged independently from this one.
So io[bwl][!@] words use functions from include/atch/ppc/io.h which add an isa_io_base offset to the address that maybe only wotks for io BARs but I'm not sure these io words are correct at all as the address should already contain this offset as mac99 has 3 PCI buses and therefore 3 different offsets although QEMU only uses one). Anyway the register access words should work for any address so we can't use the io words here. Moreover these should also byte swap for PCI BARs. SLOF seems to have two implementations which it swaps for little endian versions before running FCode ROMs, see:
https://github.com/aik/SLOF/blob/master/slof/fs/fcode/evaluator.fs#L107 https://github.com/aik/SLOF/blob/master/slof/fs/fcode/tokens.fs#L19
(If these are FCode tokens I don't get when the big endian versions could be used as these should only be called from FCode so not sure this change of rokens is really necessary and we could just do little endian access in these register access words.)
OpenFirmware has a variable called in-little-endian? to set LE or BE:
https://github.com/openbios/openfirmware/blob/master/cpu/ppc/regacc.fth
But it does not seem to set it anywhere but maybe the PPC version wasn't much tested and on LE platforms which were tested this defaults to true.
I think in OpenBIOS we could implement these using in_le32/out_le32 and in_le16/out_le16 functions but before trying to do anything I'd like to get some feedback on what would be an acceptable implementation to avoid doing work which then will be deemed unacceptable and thus wasting my time.
Regards, BALATON Zoltan
Some more sfuff I've discovered:
While debugging these I've added debug printout to these r* words to see how they are called from ATI 7000 ROM. with using [cwl][!@] instead of io[cwl][!@] I get:
0 > 82020040 1 byte-load rl! f2001000 <- 108 rl@ f2001004 ati_mm_read 4 0x8010000 unknown -> 0x0 -> 0 rl! f2001000 <- 110 rl@ f2001004 ati_mm_read 4 0x10010000 unknown -> 0x0 -> 0 rl! 8200023c <- 81000000 ati_mm_write 4 0x23c unknown <- 0x81 rl! 8200033c <- 81000000 ati_mm_write 4 0x33c unknown <- 0x81 rl! 82000148 <- 80ff8100 ati_mm_write 4 0x148 MC_FB_LOCATION <- 0x81ff80 rl! 82000030 <- 5133a340 ati_mm_write 4 0x30 BUS_CNTL <- 0x40a33351 rl! 82000034 <- f ati_mm_write 4 0x34 BUS_CNTL1 <- 0xf000000
The first two accessing f200100[04] addresses try to access the IO BAR1 the rest accessing 8200xxxx uisng the memory mapped register BAR2. Besides the wrong endianness as discussed above the first IO BAR1 access is not working either. This should access ATI regs 0 and 4 (MM_INDEX and MM_DATA to read regs 108 and 110 vie indexed access) but this IO BAR1 is not mapped at f2001000 despite what the assigned-addresses property would suggest so maybe OpenBIOS should also map this BAR but as it goes further anyway maybe this is not needed:
0 > .properties name "pci1002,5159" vendor-id 1002 device-id 5159 revision-id 0 class-code 30000 interrupts 1 min-grant 0 max-latency 0 devsel-speed 0 subsystem-vendor-id 1af4 subsystem-id 1100 cache-line-size 0 assigned-addresses 42007010 00000000 81000000 00000000 01000000 01007014 00000000 00001000 00000000 00000100 02007018 00000000 82000000 00000000 00004000 reg 00007000 00000000 00000000 00000000 00000000 42007010 00000000 00000000 00000000 01000000 01007014 00000000 00000000 00000000 00000100 02007018 00000000 00000000 00000000 00004000
bus: pci.2 type PCI dev: ati-vga, id "" vgamem_mb = 16 (0x10) model = "rv100" x-device-id = 20825 (0x5159) guest_hwcursor = false addr = 0e.0 romfile = "ati-7000.rom" romsize = 131072 (0x20000) rombar = 1 (0x1) multifunction = false x-pcie-lnksta-dllla = true x-pcie-extcap-init = true failover_pair_id = "" acpi-index = 0 (0x0) class VGA controller, addr 00:0e.0, pci id 1002:5159 (sub 1af4:1100) bar 0: mem at 0x81000000 [0x81ffffff] bar 1: i/o at 0xffffffffffffffff [0xfe] bar 2: mem at 0x82000000 [0x82003fff] bar 6: mem at 0x82020000 [0x8203ffff]
memory-region: unin-pci-mmio 0000000000000000-00000000ffffffff (prio 0, i/o): unin-pci-mmio 00000000000a0000-00000000000bffff (prio 1, i/o): vga-lowmem 0000000080000000-000000008007ffff (prio 1, i/o): macio 0000000080000050-000000008000007f (prio 0, i/o): gpio 0000000080008000-0000000080008fff (prio 0, i/o): dbdma 0000000080012000-00000000800120ff (prio 0, i/o): escc-legacy 0000000080012000-0000000080012001 (prio 0, i/o): alias escc-legacy-port @escc 0000000000000000-0000000000000001 0000000080012002-0000000080012003 (prio 0, i/o): alias escc-legacy-port @escc 0000000000000020-0000000000000021 0000000080012004-0000000080012005 (prio 0, i/o): alias escc-legacy-port @escc 0000000000000010-0000000000000011 0000000080012006-0000000080012007 (prio 0, i/o): alias escc-legacy-port @escc 0000000000000030-0000000000000031 0000000080012008-0000000080012009 (prio 0, i/o): alias escc-legacy-port @escc 0000000000000040-0000000000000041 000000008001200a-000000008001200b (prio 0, i/o): alias escc-legacy-port @escc 0000000000000050-0000000000000051 0000000080012080-0000000080012081 (prio 0, i/o): alias escc-legacy-port @escc 0000000000000080-0000000000000081 0000000080012090-0000000080012091 (prio 0, i/o): alias escc-legacy-port @escc 0000000000000090-0000000000000091 00000000800120a0-00000000800120a1 (prio 0, i/o): alias escc-legacy-port @escc 00000000000000a0-00000000000000a1 00000000800120b0-00000000800120b1 (prio 0, i/o): alias escc-legacy-port @escc 00000000000000b0-00000000000000b1 0000000080013000-000000008001303f (prio 0, i/o): escc 0000000080015000-0000000080015fff (prio 0, i/o): timer 0000000080016000-0000000080017fff (prio 0, i/o): via-pmu 0000000080020000-0000000080020fff (prio 0, i/o): pmac-ide 0000000080021000-0000000080021fff (prio 0, i/o): pmac-ide 0000000080040000-000000008007ffff (prio 0, i/o): openpic 0000000080040000-00000000800410ef (prio 0, i/o): glb 00000000800410f0-000000008004130f (prio 0, i/o): tmr 0000000080050000-0000000080051fff (prio 0, i/o): src 0000000080060000-000000008007f0ff (prio 0, i/o): cpu 0000000080080000-00000000800800ff (prio 1, i/o): ohci 0000000081000000-0000000081ffffff (prio 1, ram): vga.vram 0000000082000000-0000000082003fff (prio 1, i/o): ati.mmregs 0000000082020000-000000008203ffff (prio 1, rom): ati-vga.rom
memory-region: system 0000000000000000-ffffffffffffffff (prio 0, i/o): system 0000000000000000-0000000007ffffff (prio 0, ram): ppc_core99.ram 0000000080000000-000000008fffffff (prio 0, i/o): alias unin-pci-hole @unin-pci-mmio 0000000080000000-000000008fffffff 00000000f0000510-00000000f0000511 (prio 0, i/o): fwcfg.ctl 00000000f0000512-00000000f0000512 (prio 0, i/o): fwcfg.data 00000000f0800000-00000000f0800fff (prio 0, i/o): unin-agp-conf-idx 00000000f0c00000-00000000f0c00fff (prio 0, i/o): unin-agp-conf-data 00000000f2000000-00000000f27fffff (prio 0, i/o): unin-pci-isa-mmio 00000000f20001ce-00000000f20001d1 (prio 0, i/o): vbe 00000000f20003b4-00000000f20003b5 (prio 0, i/o): vga 00000000f20003ba-00000000f20003ba (prio 0, i/o): vga 00000000f20003c0-00000000f20003cf (prio 0, i/o): vga 00000000f20003d4-00000000f20003d5 (prio 0, i/o): vga 00000000f20003da-00000000f20003da (prio 0, i/o): vga 00000000f2800000-00000000f2800fff (prio 0, i/o): unin-pci-conf-idx 00000000f2c00000-00000000f2c00fff (prio 0, i/o): unin-pci-conf-data 00000000f4800000-00000000f4800fff (prio 0, i/o): unin-pci-conf-idx 00000000f4c00000-00000000f4c00fff (prio 0, i/o): unin-pci-conf-data 00000000f8000000-00000000f8000fff (prio 0, i/o): unin 00000000fff00000-00000000ffffffff (prio 0, rom): ppc_core99.bios 00000000fff04000-00000000fff07fff (prio 0, i/o): macio-nvram
I've also enabled PCI_DEBUG in OpenBIOS to see what it does with the BARs but the output did not make much sense to me, inlcuding it here in case it helps; not sure why it did not map BAR1:
Cannot manage 'VGA controller' PCI device type 'display': 1002 5159 (3 0 0) 0:e.0 - 1002:5159 - /pci@f2000000/pci1002,5159 - ob_pci_encode_unit space=0 dev=14 fn=0 buf=e ob_pci_decode_unit idx=fff62198 ob_pci_decode_unit idx=fff62198 addr=00000000 00000000 00007000 changing mem_base from 0x80090000 to 0x82000000 Configuring BARs for /pci@f2000000/pci1002,5159: reloc 0x81000000 omask 0x8 io_base 0x1000 mem_base 0x82000000 size 0x1000000 changing io_base from 0x1000 to 0x1100 Configuring BARs for /pci@f2000000/pci1002,5159: reloc 0x1000 omask 0x1 io_base 0x1100 mem_base 0x82000000 size 0x100 changing mem_base from 0x82000000 to 0x82010000 Configuring BARs for /pci@f2000000/pci1002,5159: reloc 0x82000000 omask 0x0 io_base 0x1100 mem_base 0x82010000 size 0x10000 changing mem_base from 0x82010000 to 0x82040000 Configuring BARs for /pci@f2000000/pci1002,5159: reloc 0x82020000 omask 0x1 io_base 0x1100 mem_base 0x82040000 size 0x20000 *** missing pci_dev
ob_pci_encode_unit space=0 dev=14 fn=0 buf=e
=== CHANGED === package path old=/pci@f2000000/pci1002,5159 new=/pci@f2000000/pci1002,5159@e pci_set_reg reg 00007000 00000000 00000000 00000000 00000000 42007010 00000000 00000000 00000000 01000000 01007014 00000000 0000000
forth/device/other.fs | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/forth/device/other.fs b/forth/device/other.fs index 1bed9b8..0ff34b6 100644 --- a/forth/device/other.fs +++ b/forth/device/other.fs @@ -58,21 +58,27 @@ defer (poke) \ 5.3.7.2 Device-register access
: rb@ ( addr -- byte )
- ioc@ ;
: rw@ ( waddr -- w )
- iow@ ;
: rl@ ( qaddr -- quad )
- iol@ ;
: rb! ( byte addr -- )
- ioc! ;
: rw! ( w waddr -- )
- iow! ;
: rl! ( quad qaddr -- )
- iol! ;
: rx@ ( oaddr - o )