[OpenBIOS] Fwd: Re: [PATCH] next-property
Olivier Danet
odanet at caramail.com
Tue Feb 4 01:45:44 CET 2014
On 03/02/2014 23:12, Olivier Danet wrote:
> On 03/02/2014 15:21, Artyom Tarasenko wrote:
>> On Sat, Feb 1, 2014 at 9:54 PM, Olivier Danet <odanet at caramail.com>
>> wrote:
>>> obp_nextprop(node,name) calls the Forth word "next-property" then
>>> pops the
>>> result. "next-property" should therefore always return something :
>>> * A string when the property provided is not the last one of the
>>> node.
>>> * Zero when the property provided is the last one of the node.
>>> * Zero when the property provided does not exist in the current node.
>>>
>>> Previously, next-property returned nothing when the property didn't
>>> exist.
>>>
>>> "next-property" behavior with last and nonexistant properties differs
>>> between implementations of OF.
>> Right. As discussed before, the current behavior matches the OBP
>> behavior on
>> sun4u machines.
>>
>> It would be nice to keep the comatibility with OBP. Can the C function
>> obp_nextprop(node,name) be modified instead?
>>
>> Artyom
>>
>>> This problem was found with NetBSD on Sparc32. It ennumerates
>>> peripherals
>>> when starting X11 and asks for the "name" and "device_type" property
>>> of many
>>> nodes, including some which have neither "name" nor "device_type"
>>> properties.
>>>
>>> Signed-off-by: Olivier Danet <odanet at caramail.com>
>>> ===================================================================
>>> --- forth/device/property.fs (révision 1257)
>>> +++ forth/device/property.fs (copie de travail)
>>> @@ -70,7 +70,7 @@
>>> 2drop r> >dn.properties @
>>> else
>>> r> find-property dup if @ then
>>> - ?dup if >prop.next @ then
>>> + dup if >prop.next @ then
>>> then
>>>
>>> ?dup if
>>> ===================================================================
>>>
>>> --
>>> OpenBIOS http://openbios.org/
>>> Mailinglist: http://lists.openbios.org/mailman/listinfo
>>> Free your System - May the Forth be with you
>>
>>
>
> OpenBIOS's current behavior does not match any other !
>
> For "next-property" we have 3 cases :
> a) The property is not the last
> b) The property is the last
> c) The property does not exist
>
> Current OpenBIOS : a) -1 "string" b) 0 c) nothing
> Standard : a) true "string" b) false c) false
> Sun Ultra10 : a) -1 "string" b) nothing c) nothing
> PowerPC iBook : a) -1 "string" b) -1 0 0 c) 0
> Previous patch : a) -1 "string" b) 0 c) 0
>
> Here is a patch adhering to the Ultra10's behavior, maybe other
> Sun4u computers do differently :
>
> ===================================================================
> --- arch/sparc32/romvec.c (révision 1257)
> +++ arch/sparc32/romvec.c (copie de travail)
> @@ -173,8 +173,9 @@
>
> const char *obp_nextprop(int node, const char *name)
> {
> - int found;
> + int stackcnt;
>
> + stackcnt = dstackcnt;
> if (!name || *name == '\0') {
> // NULL name means get first property
> push_str("");
> @@ -184,14 +185,13 @@
> }
> PUSH(node);
> fword("next-property");
> - found = POP();
> - if (!found) {
> + if (dstackcnt == stackcnt) {
> DPRINTF("obp_nextprop(0x%x, %s) (not found)\n", node, name);
>
> return "";
> } else {
> char *str;
> -
> + POP(); /* true */
> POP(); /* len */
> str = (char *) POP();
>
> ===================================================================
> --- forth/device/property.fs (révision 1257)
> +++ forth/device/property.fs (copie de travail)
> @@ -70,14 +70,12 @@
> 2drop r> >dn.properties @
> else
> r> find-property dup if @ then
> - ?dup if >prop.next @ then
> + dup if >prop.next @ then
> then
>
> ?dup if
> >prop.name @ dup cstrlen true
> ( phandle name-str name-len true )
> - else
> - false
> then
> ;
>
> ===================================================================
>
> The 'standard' way makes next-property more useable as
> a Forth word, but, really, I don't care.
>
> Olivier
>
>
Oh, sorry, please forget this patch.
It breaks things elsewhere (".properties" ...)
More information about the OpenBIOS
mailing list