On 28/05/17 11:38, BALATON Zoltan wrote:
On Sat, 27 May 2017, Tarl Neustaedter wrote:
On 2017-May-27 16:59 , BALATON Zoltan wrote:
Is there a way to add a new device in the middle of the device tree (before or after an existing node) from Forth? If I try:
dev / new-device " newdev" device-name finish-device show-devs
/newdev appears at the end of the device-tree but that's not what I want. I need this device to go at a specific place in the middle but I could not find out how to achieve that. Any ideas?
Nope. That's the way it generally works, the node is added at the beginning or end of a linked list for that level. You'd have to fiddle with private structures to change the order.
If there's a way to add it to the beginning instead of the end that may work as well. How to do that? Or I was thinking about copying the exising device tree one by one and insert the new device to the copy at the right place, then replacing the device tree with the new one but I'm not sure how to do that. Could you give some hints?
But why do you care where it appears in the tree? You should always be finding the node by name and/or unit address, so it shouldn't matter what order things are in.
I'm trying to do this so I don't need the patch to OpenBIOS:
https://mail.coreboot.org/pipermail/openbios/2017-January/009867.html
Unfortunately the code relying on this (which I can't change) seems to have some assumptions about order of pci busses in the device tree and only works if added before the exising entry (i.e. /pci@f0000000 has to come before /pci@f2000000).
Would it still not be easier just to update OpenBIOS so that the PCI host bridge structure becomes and array, add the bus number, and then add an empty bus to QEMU?
Just refreshing my memory, in the message above you mention that the bus number is wrong - this is because it is currently hardcoded to 0 in OpenBIOS. I do have a local fix for this based upon some work I'm doing to add support for PCI bridges, so is there any reason why combining these things together shouldn't work?
ATB,
Mark.