[RFC 2/3] MIPS: boot: realize _start in C

Antony Pavlov antonynpavlov at gmail.com
Sat Nov 24 11:18:09 EST 2012


Sorry for delay.

On 20 November 2012 11:58, Sascha Hauer <s.hauer at pengutronix.de> wrote:
> On Sat, Nov 17, 2012 at 04:10:38PM +0400, Antony Pavlov wrote:
>> The pbl will be incharge of the lowlevel init and
>> barebox relocation. So we can skip it in barebox itself
>> and use simple _start.
>>
>> Signed-off-by: Antony Pavlov <antonynpavlov at gmail.com>
>> ---
>>  arch/mips/boot/Makefile     |    1 -
>>  arch/mips/boot/main_entry.c |   18 ++++++
>>  arch/mips/boot/start.S      |  142 -------------------------------------------
>>  3 files changed, 18 insertions(+), 143 deletions(-)
>>  delete mode 100644 arch/mips/boot/start.S
>>
>> diff --git a/arch/mips/boot/Makefile b/arch/mips/boot/Makefile
>> index 6b093f1..4f11a48 100644
>> --- a/arch/mips/boot/Makefile
>> +++ b/arch/mips/boot/Makefile
>> @@ -1,4 +1,3 @@
>> -obj-y += start.o
>>  obj-y += main_entry.o
>>
>>  pbl-y += start-pbl.o main_entry-pbl.o
>> diff --git a/arch/mips/boot/main_entry.c b/arch/mips/boot/main_entry.c
>> index 0a33c45..422d40b 100644
>> --- a/arch/mips/boot/main_entry.c
>> +++ b/arch/mips/boot/main_entry.c
>> @@ -22,6 +22,8 @@
>>  #include <asm/cpu-features.h>
>>  #include <asm/mipsregs.h>
>>  #include <asm/addrspace.h>
>> +#include <asm/regdef.h>
>> +#include <asm-generic/memory_layout.h>
>>
>>  extern void start_barebox(void);
>>  extern void handle_reserved(void);
>> @@ -92,3 +94,19 @@ void main_entry(void)
>>
>>       start_barebox();
>>  }
>> +
>> +void __naked __section(.text_entry) _start(void)
>> +{
>> +     u32 r;
>> +
>> +     /* setup the stack */
>> +     r = STACK_BASE + STACK_SIZE - 16;
>> +
>> +     __asm__ __volatile__(
>> +             "move\t$sp, %0\n\t"
>> +             : /* no outputs */
>> +             : "r" (r)
>> +     );
>> +
>> +     main_entry();
>
> I wonder that the C function skips several things the Assembler version
> does. Is this done in the pbl now?

Yes, all lowlevel init is in pbl after this patch.

> Does this patch make the pbl mandatory?

Not at all, but the patch decrease pbl-free barebox "survival".

> We haven't done this on Arm, mostly because we were not
> confident enough that it works on every board. That may be different on
> mips, but should be mentioned in the commit log. But maybe I am
> misreading the patches...

Now I think you are right and we must postpone this patch. It make
sense to introduce this patch after full ELF support adding. If we had
ELF support, we should load barebox ELF image without pbl and drop
bin-image support in bootm.

-- 
Best regards,
  Antony Pavlov



More information about the barebox mailing list