On Fri, 19 Jul 2019, Segher Boessenkool wrote:
The address used to identify your device is the first address in reg . It is the PCI configuration space address. This address has the last two cells zero always. The first cell is busdevfn. See page 4 and 5 of https://www.openfirmware.info/data/docs/bus.pci.pdf .
my-space give you that first cell. my-address gives you the rest, so two zeroes here. my-unit gives you all three.
OK thanks it makes more sense now (I haven't yet checked the doc but probably will look at it later). At least for the problem of running ATI FCode ROM, based on the above I think the pci-map-in implemented in OpenBIOS's pci driver approximately does what map-in we're missing should do:
https://github.com/openbios/openbios/blob/master/drivers/pci.c#L413
I've also found before that the other missing words seem to have similar but differently named implementations in OpenBIOS as well:
On Mon, 15 Jul 2019, BALATON Zoltan wrote:
Investigating it some more I've found that in OpenBIOS we're missing the register read/write words: r[bwl][!@] besides the pci config-[bwl][!@] words. However we have non-standard io[cwl][!@] words instead (implemented by the io[cwl]{fetch,store} functions in kernel/forth.c) which I think correspond to the missing r[bwl][!@] words so these could be aliased to those. For pci config access we also have non-standard equivalents in
https://github.com/openbios/openbios/blob/master/forth/util/pci.fs
These pci-* words are not much used so maybe we could just rename them to config-* to match OpemFirmware?
Does anyone see a problem with that or do you think this could work?
So I could try to connect the dots and make a patch to test this but is there a way to try from OpenBIOS command line first without patching? I can define words for r* and config-* words like:
: rb! ioc! ; : rb@ ioc@ ; : config-b! pci-c! ; : config-b@ pci-c@ ;
and so on for w and l but how do I define map-in? This should be a method of the parent of the device so it should be added to /pci@f2000000 somehow where it now has pci-map-in. Is there a way to define a new method that's alias of an existing one?
Or maybe it's easier to just rename pci-map-in in source as it only seems to be used by the vga driver FCode part in drivers/vga.fs (where it is used to map PCI BARs of the card, the same as the ATI ROM is trying to do). So is there a reason this is not yet called map-in but pci-map in?
I'll try this when I'll have time but if anyone else wants to test this and come up with a patch I won't mind. (One can tell if it works if the ATI FCode pokes the ati-vga card regs which can be seen with -trace enable='ati*' on QEMU command line.)
Regards, BALATON Zoltan