[OpenBIOS] Adding new device in the middle of device-tree

BALATON Zoltan balaton at eik.bme.hu
Sat Jun 3 15:09:22 CEST 2017


On Wed, 31 May 2017, Mark Cave-Ayland wrote:
> 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 at f0000000 has to
>> come before /pci at 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?

The only reason is that I don't know how to do that. All I know is to make 
USB work correctly we need to add a device-tree node for the /pci at f0000000 
bus (which can be empty but has to exist at least minimally) and this has 
to come before the existing /pci at f2000000 (so adding it by patching the 
device tree does not work unless we can put this node at the beginning 
which I could not figure out how to do in Forth). How this node is added 
is not important and I also don't know if the incorrect bus number causes 
any problem other than some warnings.

Where is the host bridge structure that you refer to above and should be 
turned into an array? I think at least ob_pci_init needs to be changed but 
I have no idea how so I'd need some more guidance.

Regards,
BALATON Zoltan



More information about the OpenBIOS mailing list