[OpenBIOS] [PATCH, RFC 6/6] ppc: Fix stack setup

Alexander Graf agraf at suse.de
Mon Oct 11 11:16:52 CEST 2010


Andreas Färber wrote:
> Am 11.10.2010 um 04:53 schrieb Segher Boessenkool:
>
>>> +    mfpvr    r14                /* check if ppc64 */
>>> +    li        r15, 4
>>> +    srw        r14, r14, r15    /* >> 4 */
>>
>> srwi 14,14,4
>>
>> but you actually want to shift 16, not 4.
>
> Oops!
>
>>> +    cmplwi    r14, 0x33
>>> +    blt        1f
>>> +    cmplwi    r14, 0x7033
>>> +    bge        1f
>>
>> This is too simplistic.
>
> Are you saying the original is_ppc64() function I transformed into
> assembler code is wrong, too?
>
> static int is_ppc64(void)
> {
>     unsigned int pvr;
>     asm volatile("mfspr %0, 0x11f" : "=r" (pvr) );
>
>     return ((pvr >= 0x330000) && (pvr < 0x70330000));
> }

In here we don't know if SF=1 because we forcefully disable it always.

>
>> Here's something that detects
>> whether the CPU is currently in 64-bit mode, without
>> using 64-bit-only instructions:
>>
>> lis 3,0x4000
>> add 3,3,3
>> addc 3,3,3
>> adde 3,3,3
>> cmplwi 3,0
>> beq 64bit
>> bne 32bit
>
> Thanks! I'll give it a try.
>
>> Anyway, can't you always align to 128 bytes, and create
>> one frame for the 64-bit ABI?  Or do you really want to
>> save those few bytes...
>
> As for "those few bytes", I guess I mixed up bits and hexadecimal
> digits once again. An example:
>
> -m 1024
>
> RAM       0..0x40000000
> OpenBIOS   @ 0x3ff00000
> Hash table @ 0x3fef0000 vs. 0x3fe00000
>
> We'd be wasting 960 KiB. If that's acceptable, it'll simplify the code
> a little of course.

I'd personally say go for simplicity.


Alex




More information about the OpenBIOS mailing list