On Sun, 14 Jul 2019, BALATON Zoltan wrote:
On Sun, 14 Jul 2019, BALATON Zoltan wrote:
I might be able to try to implement config-* words based on the config-l you've added but not sure if these should all call back to C or should we base them on config-l or config-b or some other generic C helper in Forth? For reading bytes one could do config-l@ then extract the needed byte somehow (need to find the forth for that) but for storing we may be better off with a helper otherwise we need to 'config-l@ modify-it config-l!' if we only have config-l! or if we base it on config-b! then we need to do multiple of these for config-l so C helpers or a generic one like do_config_{read,write}(addr, size) might be simpler. I should check how other open firmware implementation do this in forth (although probably I won't understand it). Do you think it's worth trying to do in Forth or should I try to do that in pci.c?
AFAIU looks like most implementations use a C helper for this: most of SmartFirmware is in C, SLOF seem to call back to rtas and maybe only OpenFirmware tries to do this in Forth:
https://github.com/openbios/openfirmware/blob/master/dev/pci/configm1.fth
but even in OF I've seen machine specific implementations that use assembly. So probably doing it in OpenBIOS in a C helper would be simplest or maybe could be done in Forth if the config base address is available somewhere.
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?
Regards, BALATON Zoltan