From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vw0-f188.google.com (mail-vw0-f188.google.com [209.85.212.188]) by bilbo.ozlabs.org (Postfix) with ESMTP id 106BFB7B68 for ; Wed, 2 Sep 2009 10:25:35 +1000 (EST) Received: by vws26 with SMTP id 26so472804vws.26 for ; Tue, 01 Sep 2009 17:25:33 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <4A9D5A99.5030101@am.sony.com> References: <5e2889710909010358v907022cs708dfc0dd3ed7fd0@mail.gmail.com> <4A9D5A99.5030101@am.sony.com> Date: Wed, 2 Sep 2009 09:25:33 +0900 Message-ID: <5e2889710909011725t275dcdc8oa8be58b6e32e51f4@mail.gmail.com> Subject: Re: Question about linux boot procedure (head_64.S) From: Lee HongWoo To: Geoff Levand Content-Type: multipart/alternative; boundary=00c09f8de08f1f952c04728d4e10 Cc: linuxppc-dev List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , --00c09f8de08f1f952c04728d4e10 Content-Type: text/plain; charset=ISO-8859-1 On Wed, Sep 2, 2009 at 2:32 AM, Geoff Levand wrote: > On 09/01/2009 03:58 AM, Lee HongWoo wrote: > > __start (in head_64.S) > > ---> __start_initialization_multiplatform (in head_64.S) > > ---> __boot_from_prom (in head_64.S) > > ---> prom_init ( in prom_init.c) > > ---> __start ??? > > > > And I don't understand where __start is called, because I can find > __start > > only in head_64.S. > > If it calls __start in head_64.S, it's a recursive call. > > > > Can anybody explain about this precedure ? > > In the general case, __start is the entry point of the kernel. > It is where the bootloader or boot wrapper program jumps to > when it transfers control to the kernel. > > -Geoff > > Thanks Geoff, I believe __start is the entry point of the kernel in this case. And the entry point is __GLOBAL(__start) in the head_64.S. What I asked is where or what __start is called in the prom_init.c __start(hdr, KERNELBASE + offset, 0); Below is the simple function call flow of linux kernel boot procedure. file : head_64.S _GLOBAL(__start) /* NOP this out unconditionally */ BEGIN_FTR_SECTION b .__start_initialization_multiplatform END_FTR_SECTION(0, 1) .... _GLOBAL(__start_initialization_multiplatform) /* * Are we booted from a PROM Of-type client-interface ? */ cmpldi cr0,r5,0 bne .__boot_from_prom /* yes -> prom */ .... _STATIC(__boot_from_prom) /* Save parameters */ mr r31,r3 mr r30,r4 mr r29,r5 mr r28,r6 mr r27,r7 /* * Align the stack to 16-byte boundary * Depending on the size and layout of the ELF sections in the initial * boot binary, the stack pointer will be unalignet on PowerMac */ rldicr r1,r1,0,59 /* Make sure we are running in 64 bits mode */ bl .enable_64b_mode /* put a relocation offset into r3 */ bl .reloc_offset LOAD_REG_IMMEDIATE(r2,__toc_start) addi r2,r2,0x4000 addi r2,r2,0x4000 /* Relocate the TOC from a virt addr to a real addr */ add r2,r2,r3 /* Restore parameters */ mr r3,r31 mr r4,r30 mr r5,r29 mr r6,r28 mr r7,r27 /* Do all of the interaction with OF client interface */ bl .prom_init /* We never return */ trap file : prom_init.c unsigned long __init prom_init(unsigned long r3, unsigned long r4, unsigned long pp, unsigned long r6, unsigned long r7) { ... ... __start(hdr, KERNELBASE + offset, 0); return 0; } HongWoo. --00c09f8de08f1f952c04728d4e10 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
On Wed, Sep 2, 2009 at 2:32 AM, Geoff Levand <geoffrey.= levand@am.sony.com> wrote:
On 09/01/2009 03:58 AM, Lee HongWoo wrote:
> __start =A0(in head_64.S)
> =A0 ---> __start_initialization_multiplatform (in head_64.S)
> =A0 =A0 ---> __boot_from_prom (in head_64.S)
> =A0 =A0 =A0 =A0---> prom_init ( in prom_init.c)
> =A0 =A0 =A0 =A0 =A0---> __start ???
>
> And I don't understand where __start is called, because I can find= __start
> only in head_64.S.
> If it calls __start in head_64.S, it's a recursive call.
>
> Can anybody explain about this precedure ?

In the general case, __start is the entry point of the kernel.
It is where the bootloader or boot wrapper program jumps to
when it transfers control to the kernel.

-Geoff


Thanks Geoff,

I believe __start is th= e entry point of the kernel in this case.
And the entry point is __GLOB= AL(__start) in the head_64.S.

What I asked is where or what __start= is called in the prom_init.c __start(hdr, KERNELBASE + offset, 0);
Below is the simple function call flow of linux kernel boot procedure.
=
file : head_64.S

_GLOBAL(__start)
=A0=A0=A0=A0=A0=A0=A0 /* N= OP this out unconditionally */
BEGIN_FTR_SECTION
=A0=A0=A0=A0=A0=A0= =A0 b=A0=A0=A0=A0=A0=A0 .__start_initialization_multiplatform
END_FTR_SECTION(0, 1)

....

_GLOBAL(__start_initialization_mu= ltiplatform)
=A0=A0=A0=A0=A0=A0=A0 /*
=A0=A0=A0=A0=A0=A0=A0=A0 * Are = we booted from a PROM Of-type client-interface ?
=A0=A0=A0=A0=A0=A0=A0= =A0 */
=A0=A0=A0=A0=A0=A0=A0 cmpldi=A0 cr0,r5,0
=A0=A0=A0=A0=A0=A0=A0= bne=A0=A0=A0=A0 .__boot_from_prom=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0 /* yes -> prom */

....

_STATIC(__boot_from_prom)
=A0=A0=A0=A0=A0=A0=A0 /* Save= parameters */
=A0=A0=A0=A0=A0=A0=A0 mr=A0=A0=A0=A0=A0 r31,r3
=A0=A0= =A0=A0=A0=A0=A0 mr=A0=A0=A0=A0=A0 r30,r4
=A0=A0=A0=A0=A0=A0=A0 mr=A0=A0= =A0=A0=A0 r29,r5
=A0=A0=A0=A0=A0=A0=A0 mr=A0=A0=A0=A0=A0 r28,r6
=A0= =A0=A0=A0=A0=A0=A0 mr=A0=A0=A0=A0=A0 r27,r7

=A0=A0=A0=A0=A0=A0=A0 /*=
=A0=A0=A0=A0=A0=A0=A0=A0 * Align the stack to 16-byte boundary
=A0=A0=A0= =A0=A0=A0=A0=A0 * Depending on the size and layout of the ELF sections in t= he initial
=A0=A0=A0=A0=A0=A0=A0=A0 * boot binary, the stack pointer wil= l be unalignet on PowerMac
=A0=A0=A0=A0=A0=A0=A0=A0 */
=A0=A0=A0=A0=A0=A0=A0 rldicr=A0 r1,r1,0,59

=A0=A0=A0=A0=A0=A0=A0 /* = Make sure we are running in 64 bits mode */
=A0=A0=A0=A0=A0=A0=A0 bl=A0= =A0=A0=A0=A0 .enable_64b_mode

=A0=A0=A0=A0=A0=A0=A0 /* put a relocat= ion offset into r3 */
=A0=A0=A0=A0=A0=A0=A0 bl=A0=A0=A0=A0=A0 .reloc_off= set

=A0=A0=A0=A0=A0=A0=A0 LOAD_REG_IMMEDIATE(r2,__toc_start)
=A0=A0=A0=A0=A0=A0=A0 addi=A0=A0=A0 r2,r2,0x4000
=A0=A0=A0=A0=A0=A0=A0 a= ddi=A0=A0=A0 r2,r2,0x4000

=A0=A0=A0=A0=A0=A0=A0 /* Relocate the TOC = from a virt addr to a real addr */
=A0=A0=A0=A0=A0=A0=A0 add=A0=A0=A0=A0= r2,r2,r3

=A0=A0=A0=A0=A0=A0=A0 /* Restore parameters */
=A0=A0= =A0=A0=A0=A0=A0 mr=A0=A0=A0=A0=A0 r3,r31
=A0=A0=A0=A0=A0=A0=A0 mr=A0=A0=A0=A0=A0 r4,r30
=A0=A0=A0=A0=A0=A0=A0 mr= =A0=A0=A0=A0=A0 r5,r29
=A0=A0=A0=A0=A0=A0=A0 mr=A0=A0=A0=A0=A0 r6,r28=A0=A0=A0=A0=A0=A0=A0 mr=A0=A0=A0=A0=A0 r7,r27

=A0=A0=A0=A0=A0=A0= =A0 /* Do all of the interaction with OF client interface */
=A0=A0=A0= =A0=A0=A0=A0 bl=A0=A0=A0=A0=A0 .prom_init
=A0=A0=A0=A0=A0=A0=A0 /* We ne= ver return */
=A0=A0=A0=A0=A0=A0=A0 trap


file : prom_init.c

unsigned l= ong __init prom_init(unsigned long r3, unsigned long r4,
=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= unsigned long pp,
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 unsigned long r6, unsigned long r7)=
{
=A0=A0=A0 ...
=A0=A0=A0 ...
=A0=A0=A0=A0=A0=A0=A0 __start(hdr, K= ERNELBASE + offset, 0);

=A0=A0=A0=A0=A0=A0=A0 return 0;
}

=
HongWoo.

--00c09f8de08f1f952c04728d4e10--