On Sun, May 28, 2017 at 12:38:47PM +0200, 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?
There is no portable way to do it, and this doesn't matter at all; anything that relies on the order of devices in the device tree is broken.
If you want this merely for aesthetic purposes, just arrange for all device nodes to be created in the order you want them to appear in?
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).
What is that code you cannot change? Sounds like OS9?
Segher