mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Antony Pavlov <antonynpavlov@gmail.com>
To: Shinya Kuribayashi <skuribay@gmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 1/3 v3] Add MIPS arch support to barebox
Date: Mon, 4 Jul 2011 09:21:52 +0400	[thread overview]
Message-ID: <CAA4bVAF7w+gL10MS-QJA4ij9jB7bYO5rQJp_wN=HWQ-nwUyW1w@mail.gmail.com> (raw)
In-Reply-To: <4E10880C.4050706@gmail.com>

On 3 July 2011 19:17, Shinya Kuribayashi <skuribay@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

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      parent reply	other threads:[~2011-07-04  5:22 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-30  9:32 Antony Pavlov
2011-06-30  9:32 ` [PATCH 2/3 v3] MIPS: add Malta machine " Antony Pavlov
2011-06-30  9:32 ` [PATCH 3/3 v3] MIPS: add qemu malta board " Antony Pavlov
2011-07-01  0:28 ` [PATCH 1/3 v3] Add MIPS arch " Jean-Christophe PLAGNIOL-VILLARD
2011-07-01  9:23   ` Antony Pavlov
2011-07-01 15:22   ` Antony Pavlov
2011-07-01 15:29   ` antonynpavlov
2011-07-03 15:17     ` Shinya Kuribayashi
2011-07-03 20:18       ` Antony Pavlov
2011-07-04  5:21       ` Antony Pavlov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAA4bVAF7w+gL10MS-QJA4ij9jB7bYO5rQJp_wN=HWQ-nwUyW1w@mail.gmail.com' \
    --to=antonynpavlov@gmail.com \
    --cc=barebox@lists.infradead.org \
    --cc=skuribay@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox