[OpenBIOS] ppc64 MMU issues

Alexander Graf agraf at suse.de
Tue Nov 16 00:23:30 CET 2010


On 16.11.2010, at 00:11, Andreas Färber wrote:

> Am 16.11.2010 um 00:02 schrieb Segher Boessenkool:
> 
>>>> Who's responsible for r2 setup - GCC-generated code or QEMU?
>>> 
>>> r2 contains the GOT IIRC. But for ABI questions, it's probably best to
>>> consult Segher :). Unless I'm completely mistaken, usually the loader
>>> initializes r2, so in this case the asm code needs to set it up properly.
>> 
>> Depends what you call "loader".  Usually your crt1 equivalent sets GPR2.
>> It is probably a good idea to set it in all exception handlers as well
>> (if they want to call C code, or need it otherwise).
> 
> But set it to what value? :)

This is what Linux does:

arch/powerpc/kernel/head_64.S:

/*
 * This puts the TOC pointer into r2, offset by 0x8000 (as expected
 * by the toolchain).  It computes the correct value for wherever we
 * are running at the moment, using position-independent code.
 */
_GLOBAL(relative_toc)
        mflr    r0
        bcl     20,31,$+4
0:      mflr    r9
        ld      r2,(p_toc - 0b)(r9)
        add     r2,r2,r9
        mtlr    r0
        blr

p_toc:  .llong  __toc_start + 0x8000 - 0b


arch/powerpc/kernel/vmlinux.lds:

 .got : AT(ADDR(.got) - (0xc000000000000000 -0x00000000)) {
  __toc_start = .;
  *(.got)
  *(.toc)


Maybe you can get away with default names somehow, not sure :).


Alex




More information about the OpenBIOS mailing list