[U-Boot-Users] [PATCH] Move init_sequence table into code.
Joakim Tjernlund
Joakim.Tjernlund at transmode.se
Fri Mar 28 16:45:58 CET 2008
Global variables are not ideal before relocation to RAM.
---
I hope this still applies.
lib_ppc/board.c | 144 +++++++++++++++++++++++++-----------------------------
1 files changed, 67 insertions(+), 77 deletions(-)
diff --git a/lib_ppc/board.c b/lib_ppc/board.c
index 8a18350..c64bbd5 100644
--- a/lib_ppc/board.c
+++ b/lib_ppc/board.c
@@ -288,124 +288,114 @@ static int init_func_watchdog_reset (void)
************************************************************************
*/
-init_fnc_t *init_sequence[] = {
+/************************************************************************
+ *
+ * This is the first part of the initialization sequence that is
+ * implemented in C, but still running from ROM.
+ *
+ * The main purpose is to provide a (serial) console interface as
+ * soon as possible (so we can see any error messages), and to
+ * initialize the RAM so that we can relocate the monitor code to
+ * RAM.
+ *
+ * Be aware of the restrictions: global data is read-only, BSS is not
+ * initialized, and stack space is limited to a few kB.
+ *
+ ************************************************************************
+ */
+
+void board_init_f (ulong bootflag)
+{
+ bd_t *bd;
+ ulong len, addr, addr_sp;
+ ulong *s;
+ gd_t *id;
+ init_fnc_t **init_fnc_ptr;
+#ifdef CONFIG_PRAM
+ int i;
+ ulong reg;
+ uchar tmp[64]; /* long enough for environment variables */
+#endif
+
+ /* Pointer is writable since we allocated a register for it */
+ gd = (gd_t *) (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET);
+ /* compiler optimization barrier needed for GCC >= 3.4 */
+ __asm__ __volatile__("": : :"memory");
+
+#if !defined(CONFIG_CPM2) && !defined(CONFIG_MPC83XX)
+ /* Clear initial global data */
+ memset ((void *) gd, 0, sizeof (gd_t));
+#endif
#if defined(CONFIG_BOARD_EARLY_INIT_F)
- board_early_init_f,
+ board_early_init_f();
#endif
#if !defined(CONFIG_8xx_CPUCLK_DEFAULT)
- get_clocks, /* get CPU and bus clocks (etc.) */
+ get_clocks(); /* get CPU and bus clocks (etc.) */
#if defined(CONFIG_TQM8xxL) && !defined(CONFIG_TQM866M) \
&& !defined(CONFIG_TQM885D)
- adjust_sdram_tbs_8xx,
+ adjust_sdram_tbs_8xx();
#endif
- init_timebase,
+ init_timebase();
#endif
#ifdef CFG_ALLOC_DPRAM
#if !defined(CONFIG_CPM2)
- dpram_init,
+ dpram_init();
#endif
#endif
#if defined(CONFIG_BOARD_POSTCLK_INIT)
- board_postclk_init,
+ board_postclk_init();
#endif
- env_init,
+ env_init();
#if defined(CONFIG_8xx_CPUCLK_DEFAULT)
- get_clocks_866, /* get CPU and bus clocks according to the environment variable */
- sdram_adjust_866, /* adjust sdram refresh rate according to the new clock */
- init_timebase,
-#endif
- init_baudrate,
- serial_init,
- console_init_f,
- display_options,
+ get_clocks_866(); /* get CPU and bus clocks according to the environment variable */
+ sdram_adjust_866(); /* adjust sdram refresh rate according to the new clock */
+ init_timebase();
+#endif
+ init_baudrate();
+ serial_init();
+ console_init_f();
+ display_options();
#if defined(CONFIG_8260)
- prt_8260_rsr,
- prt_8260_clks,
+ prt_8260_rsr();
+ prt_8260_clks();
#endif /* CONFIG_8260 */
#if defined(CONFIG_MPC83XX)
- prt_83xx_rsr,
+ prt_83xx_rsr();
#endif
- checkcpu,
+ checkcpu();
#if defined(CONFIG_MPC5xxx)
- prt_mpc5xxx_clks,
+ prt_mpc5xxx_clks();
#endif /* CONFIG_MPC5xxx */
#if defined(CONFIG_MPC8220)
- prt_mpc8220_clks,
+ prt_mpc8220_clks();
#endif
- checkboard,
+ checkboard();
INIT_FUNC_WATCHDOG_INIT
#if defined(CONFIG_MISC_INIT_F)
- misc_init_f,
+ misc_init_f();
#endif
INIT_FUNC_WATCHDOG_RESET
#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
- init_func_i2c,
+ init_func_i2c();
#endif
#if defined(CONFIG_HARD_SPI)
- init_func_spi,
+ init_func_spi();
#endif
#if defined(CONFIG_DTT) /* Digital Thermometers and Thermostats */
- dtt_init,
+ dtt_init();
#endif
#ifdef CONFIG_POST
- post_init_f,
+ post_init_f();
#endif
INIT_FUNC_WATCHDOG_RESET
- init_func_ram,
+ init_func_ram();
#if defined(CFG_DRAM_TEST)
- testdram,
+ testdram();
#endif /* CFG_DRAM_TEST */
INIT_FUNC_WATCHDOG_RESET
- NULL, /* Terminate this list */
-};
-
-/************************************************************************
- *
- * This is the first part of the initialization sequence that is
- * implemented in C, but still running from ROM.
- *
- * The main purpose is to provide a (serial) console interface as
- * soon as possible (so we can see any error messages), and to
- * initialize the RAM so that we can relocate the monitor code to
- * RAM.
- *
- * Be aware of the restrictions: global data is read-only, BSS is not
- * initialized, and stack space is limited to a few kB.
- *
- ************************************************************************
- */
-
-void board_init_f (ulong bootflag)
-{
- bd_t *bd;
- ulong len, addr, addr_sp;
- ulong *s;
- gd_t *id;
- init_fnc_t **init_fnc_ptr;
-#ifdef CONFIG_PRAM
- int i;
- ulong reg;
- uchar tmp[64]; /* long enough for environment variables */
-#endif
-
- /* Pointer is writable since we allocated a register for it */
- gd = (gd_t *) (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET);
- /* compiler optimization barrier needed for GCC >= 3.4 */
- __asm__ __volatile__("": : :"memory");
-
-#if !defined(CONFIG_CPM2) && !defined(CONFIG_MPC83XX)
- /* Clear initial global data */
- memset ((void *) gd, 0, sizeof (gd_t));
-#endif
-
- for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
- if ((*init_fnc_ptr) () != 0) {
- hang ();
- }
- }
/*
* Now that we have DRAM mapped and working, we can
--
1.5.4.3
More information about the U-Boot
mailing list