From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Petazzoni Date: Wed, 16 Aug 2017 10:47:40 +0200 Subject: [U-Boot] Initializing global_data on SuperH before board_init_f() ? In-Reply-To: <48db112b-383c-5ea3-fb53-fd72f1b2c62f@ti.com> References: <20170815230730.680cdcd8@windsurf> <48db112b-383c-5ea3-fb53-fd72f1b2c62f@ti.com> Message-ID: <20170816104740.5d45138c@windsurf> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hello, On Wed, 16 Aug 2017 08:09:06 +0530, Lokesh Vutla wrote: > > Should we put global_data within the .bss section, so that it gets > > zero-initialized automatically? Should we zero-initialize it explicitly? > > I am not sure how SuperH allocates the space for global data but > typically the following two function takes care of allocating and > zeroing global data(at least for arm): > > In file common/init/board_init.c > board_init_f_alloc_reserve() > board_init_f_init_reserve() > > May be, using these two functions might solve your problem. Seems like a good idea indeed, I hadn't noticed those functions. If I understand correctly, and after looking at how a few architectures do, they: - Initialize the stack pointer just below the U-Boot entry point - Call board_init_f_alloc_reserve(), to allocate enough space for the global data on the stack - Call board_init_f_init_reserve() to zero initialize it I guess the SH code can be adapted to use this logic, I'll have a look into that. Could take a while though, since I'm not fluent in SH assembly. Thanks for the hint! Thomas -- Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com