[PATCH 1/3 v3] Add MIPS arch support to barebox

Antony Pavlov antonynpavlov at gmail.com
Mon Jul 4 01:21:52 EDT 2011


On 3 July 2011 19:17, Shinya Kuribayashi <skuribay at gmail.com> wrote:

>> Let's see relocate code:
>> ---- Shinya-san's code start (arch/mips/cpu/start.S) ----
>> relocate:
>>        ADR     t0, _start, t1                  # t0<- current position of
>> code
>>        PTR_LI  t1, TEXT_BASE
>>        beq     t0, t1, stack_setup
>>         nop
>> ---- Shinya-san's code end ----
>>
>> This code try to check if relocation needs. It try to compute
>> _start<<current>>
>> address.
>>
>> But
>>   * _start link address is KSEG0 address 0x9fc00000;
>>   * we have already switched to KSEG0, so _start<<current>>  address
>> is 0x9fc00000 too.
>
> No.  ADR tries to compute 'PC-relative' _start address.  If it starts
> from physical 0xbfc0000, t0 is set up to 0xbfc0000 even if _start link
> address is CKSEG0.  If it starts from physical 0xA0100000, t0 is set
> up to 0xA0100000, and in that case _start link address is supposed to
> be set to 0x80100000.

The main problem is <<_start link address is supposed to
 be set to 0x80100000>>.

But if not?

Imagine that you have Momentus Ocelot evolution board equipped with
8MB of memory-mapped flash starting at 0xb8000000.

you get you barebox.bin (linked to 0x9fc00000), burn it to 0xb8000000
and jump to 0xb8000000. Will it work correctly?

My answer is <<no>>.

See the code:

>> ---- Shinya-san's code start (arch/mips/cpu/start.S) ----
>>        /* Switch to CKSEG0 segment */
>>        la      t0, 1f
>>        /* T.B.D. -- Convert an addree of the label '1f' into CKSEG0 */
>>        jr      t0
>>
>> 1:
>> ---- Shinya-san's code end ----

The command 'la' will set t0 to 0x9fc00xxx, the command 'jr' will make
jump to 0x9fc00xxx, but we work in the 0xb8000xxx addresses!

We can't use link addresses to jump if we want to make possible to run
from any KSEG0 or KSEG1 address.

-- 
Best regards,
  Antony Pavlov



More information about the barebox mailing list