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 00:18:58 +0400 [thread overview]
Message-ID: <CAA4bVAG4nFa+a-F_2-SS8wnKHRWEiWwM2gga_M-Qz2Qbyr8F2w@mail.gmail.com> (raw)
In-Reply-To: <4E10880C.4050706@gmail.com>
On 3 July 2011 19:17, Shinya Kuribayashi <skuribay@gmail.com> wrote:
>> ---- Shinya-san's code start (arch/mips/cpu/start.S) ----
>> setup_c0_status_reset
>>
>> /*
>> * Config: K0 should be set to the desired Cache Coherency
>> * Algorithm (CCA) prior to accessing Kseg0.
>> */
>> mfc0 t0, CP0_CONFIG
>> /* T.B.D. */
>> mtc0 t0, CP0_CONFIG
>>
>> /*
>> * Config: (4KEm and 4KEp cores only) KU and K23 should be set to
>> * the desired CCA for USeg/KUSeg and KSeg2/3 respectively prior to
>> * accessing those regions.
>> */
>> mfc0 t0, CP0_CONFIG
>> /* T.B.D. */
>> mtc0 t0, CP0_CONFIG
>> ---- Shinya-san's code end ----
>>
>> does this code initialise KSEG0 cache mode?
>> does this code change CP0_CONFIG at all?
>> My answer is "no".
>
> Correct. Please keep in mind I didn't do anything set up in start.S.
> I was thinking around how to generalize the initialization procedures
> how we could maintain/support various MIPS processors, and what shape
> of code would be reasonable (and scalable).
The generalization is possible if you have the piece of code for the
processor A and the piece of code for the processor B.
Then you can make generalization and produce the piece of code for the
both processors.
But it is very difficult to write universal code without attempts to
check of it ability to work.
>> But bellow, you can see switching to KSEG0 (label 1f linked to 0x9fc00xxx)
>> ...
>>
>> ---- 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 ----
>
> It's intended to be converted to CKSEG0, but it's not necessarily
> 0x9fc00xxx.
In this particular example it is necessarily 0x9fc00xxx.
You have set CONFIG_TEXT_BASE=0x9fc00000.
>
>> 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 'link address' is supposed to be used
> _after_ relocation. You see?
No, I don't.
in barebox.lds.S you have:
---- begin ----
SECTIONS
{
. = TEXT_BASE;
/* read-only */
_text = .; /* Text and read-only data */
.text : {
----- end ----
So '_start' link address is always TEXT_BASE.
Here is the code:
---- Shinya-san's code start (arch/mips/cpu/start.S) ----
la t0, 1f // pc = 0xbfc00xxx
jr t0
1:
relocate:
ADR t0, _start, t1
PTR_LI t1, TEXT_BASE
---- Shinya-san's code end ----
ADR macro always run with pc == 'relocate' link address.
So ADR will compute '_start' link address.
This code always make t0 == t1.
Eventually you can try to check the code using an emulator.
--- Shinya-san's code start (arch/mips/cpu/start.S) ----
la t0, 1f // pc = 0xbfc00xxx
jr t0
1:
relocate:
ADR t0, _start, t1 // pc = 0x9fc00xxx, t0=0x9fc00000
PTR_LI t1, TEXT_BASE // t1 = 0x9fc00000
beq t0, t1, stack_setup
nop
---- Shinya-san's code end ----
--
Best regards,
Antony Pavlov
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2011-07-03 20:19 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 [this message]
2011-07-04 5:21 ` Antony Pavlov
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=CAA4bVAG4nFa+a-F_2-SS8wnKHRWEiWwM2gga_M-Qz2Qbyr8F2w@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