[U-Boot] [PATCH v4 3/4] generic board patch of manual reloc and zero gd_t

FengHua fenghua at phytium.com.cn
Wed Aug 21 15:15:17 CEST 2013




> -----原始邮件-----
> 发件人: "Simon Glass" <sjg at chromium.org>
> 发送时间: 2013年8月21日 星期三
> 收件人: FengHua <fenghua at phytium.com.cn>
> 抄送: "U-Boot Mailing List" <u-boot at lists.denx.de>, "trini at ti.com" <trini at ti.com>
> 主题: Re: [U-Boot] [PATCH v4 3/4] generic board patch of manual reloc and zero gd_t
> 
> Hi David,
> 
> On Tue, Aug 20, 2013 at 4:48 AM,  <fenghua at phytium.com.cn> wrote:
> > From: David Feng <fenghua at phytium.com.cn>
> >
> > 1. function board_init_f in board_f.c should firstly zero gd_t structure
> >    before it call initcall_run_list, otherwise the debug print will go run
> >    if DEBUG is defined. Because the printf function will use global data
> >    to determine whether serial port is initialized and could be written.
> > 2. function board_init_r in board_r.c should firstly relocate init_sequence_r
> >    table before it call initcall_run_list. Command table also should be relocated.
> >
> > Signed-off-by: David Feng <fenghua at phytium.com.cn>
> > ---
> >  common/board_f.c |    6 ++++++
> >  common/board_r.c |   17 +++++++++++++++++
> >  2 files changed, 23 insertions(+)
> >
> > diff --git a/common/board_f.c b/common/board_f.c
> > index 5e738fb..f437bcb 100644
> > --- a/common/board_f.c
> > +++ b/common/board_f.c
> > @@ -1009,6 +1009,12 @@ void board_init_f(ulong boot_flags)
> >         gd = &data;
> >  #endif
> >
> > +       /*
> > +        * Zero gd_t first, otherwise the debug print in initcall_run_list
> > +        * function before zero_global_data is called will go wrong.
> > +        */
> > +       memset((void *)gd, 0, sizeof(gd_t));
> > +
> 
> Yes, we need this. You should drop the zero_global_data() or whatever
> currently does the memset()
> 
> >         gd->flags = boot_flags;
> >
> >         if (initcall_run_list(init_sequence_f))
> > diff --git a/common/board_r.c b/common/board_r.c
> > index 86ca1cb..1b4bdd2 100644
> > --- a/common/board_r.c
> > +++ b/common/board_r.c
> > @@ -157,6 +157,13 @@ static int initr_reloc_global_data(void)
> >          */
> >         gd->env_addr += gd->relocaddr - CONFIG_SYS_MONITOR_BASE;
> >  #endif
> > +#ifdef CONFIG_NEEDS_MANUAL_RELOC
> > +       /*
> > +        * We have to relocate the command table manually
> > +        */
> > +       fixup_cmdtable(ll_entry_start(cmd_tbl_t, cmd),
> > +                       ll_entry_count(cmd_tbl_t, cmd));
> > +#endif /* CONFIG_NEEDS_MANUAL_RELOC */
> 
> Should this be done here or in main_loop()? How is this currently done
> when not using generic board?

Most of these operations appear in board_init_r() function, so we can not do this in main_loop(), otherwise we must get rid of this from all related board_init_r() functions.

> 
> >         return 0;
> >  }
> >
> > @@ -899,6 +906,7 @@ init_fnc_t init_sequence_r[] = {
> >         initr_modem,
> >  #endif
> >         run_main_loop,
> > +       NULL,
> >  };
> >
> >  void board_init_r(gd_t *new_gd, ulong dest_addr)
> > @@ -906,6 +914,15 @@ void board_init_r(gd_t *new_gd, ulong dest_addr)
> >  #ifndef CONFIG_X86
> >         gd = new_gd;
> >  #endif
> > +#ifdef CONFIG_NEEDS_MANUAL_RELOC
> > +       /*
> > +        * We have to relocate the init_sequence_r table manually
> > +        */
> > +       init_fnc_t      *init_fnc_ptr;
> > +       for (init_fnc_ptr = init_sequence_r; *init_fnc_ptr; ++init_fnc_ptr)
> > +               *init_fnc_ptr = (init_fnc_t *)((unsigned long)(*init_fnc_ptr) + gd->reloc_off);
> > +#endif /* CONFIG_NEEDS_MANUAL_RELOC */
> > +
> >         if (initcall_run_list(init_sequence_r))
> >                 hang();
> >
> 
> Regards,
> Simon








More information about the U-Boot mailing list