Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| u-boot_boot_sequence [2019/12/27 17:44] – [2.] rpjday | u-boot_boot_sequence [2019/12/28 08:33] (current) – [1.] rpjday | ||
|---|---|---|---|
| Line 19: | Line 19: | ||
| ===== arch/ | ===== arch/ | ||
| - | ==== 1. ==== | + | ==== Prologue |
| < | < | ||
| Line 25: | Line 25: | ||
| * start-up where a C runtime environment is needed. Its entry point | * start-up where a C runtime environment is needed. Its entry point | ||
| * is _main and is branched into from the target' | * is _main and is branched into from the target' | ||
| - | * | + | </ |
| - | * _main execution sequence is: | + | |
| - | * | + | ==== 1. ==== |
| + | |||
| + | < | ||
| * 1. Set up initial environment for calling board_init_f(). | * 1. Set up initial environment for calling board_init_f(). | ||
| | | ||
| Line 84: | Line 86: | ||
| | | ||
| | | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | #if !defined(CONFIG_SPL_BUILD) | ||
| + | /* | ||
| + | * Set up intermediate environment (new sp and gd) and call | ||
| + | * relocate_code(addr_moni). Trick here is that we'll return | ||
| + | * ' | ||
| + | */ | ||
| + | ldr x0, [x18, # | ||
| + | bic sp, x0, #0xf /* 16-byte alignment for ABI compliance */ | ||
| + | ldr x18, [x18, # | ||
| + | |||
| + | adr lr, relocation_return | ||
| + | #if CONFIG_POSITION_INDEPENDENT | ||
| + | /* Add in link-vs-runtime offset */ | ||
| + | adr x0, _start | ||
| + | ldr x9, _TEXT_BASE | ||
| + | sub x9, x9, x0 /* x9 <- Run-vs-link offset */ | ||
| + | add lr, lr, x9 | ||
| + | #endif | ||
| + | /* Add in link-vs-relocation offset */ | ||
| + | ldr x9, [x18, # | ||
| + | add lr, lr, x9 /* new return address after relocation */ | ||
| + | ldr x0, [x18, # | ||
| </ | </ | ||
| Line 92: | Line 119: | ||
| | | ||
| | | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | b | ||
| + | |||
| + | relocation_return: | ||
| </ | </ | ||
| Line 117: | Line 150: | ||
| | | ||
| </ | </ | ||
| - | |||
| - | ==== 7. ==== | ||
| < | < | ||
| - | * 7. Branch to board_init_r(). | + | /* |
| - | </code> | + | * Set up final (full) environment |
| - | + | */ | |
| - | ===== common/board_f.c ===== | + | |
| - | + | # | |
| - | ===== common/board_r.c (only most common) ===== | + | #if !defined(CONFIG_SPL_BUILD) || CONFIG_IS_ENABLED(FRAMEWORK) |
| - | + | #if defined(CONFIG_SPL_BUILD) | |
| - | ==== initr_dm() [C] ==== | + | |
| - | ==== board_init() [A,B] ==== | + | |
| - | + | | |
| - | ==== board_early_init_r() (not for Zynq) ==== | + | |
| - | + | | |
| - | ==== arch_early_init_r() [A] ==== | + | * Perform 'sp = (x0 != NULL) ? x0 : sp' while working |
| - | + | * around the constraint that conditional moves can not | |
| - | * arch/arm/ | + | * have ' |
| - | | + | */ |
| - | + | | |
| - | < | + | |
| - | #if defined(CONFIG_ARCH_EARLY_INIT_R) | + | |
| - | int arch_early_init_r(void) | + | mov sp, x0 |
| - | { | + | |
| - | #if (defined(CONFIG_FPGA) && | + | |
| - | | + | |
| - | | + | |
| - | + | ||
| - | if (cpu_id < 0) | + | |
| - | | + | |
| - | + | ||
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| #endif | #endif | ||
| - | return 0; | ||
| - | } | ||
| - | #endif | ||
| - | </ | ||
| - | |||
| - | ==== initr_mmc() [C] ==== | ||
| - | |||
| - | < | ||
| - | #ifdef CONFIG_MMC | ||
| - | static int initr_mmc(void) | ||
| - | { | ||
| - | puts(" | ||
| - | mmc_initialize(gd-> | ||
| - | return 0; | ||
| - | } | ||
| - | #endif | ||
| - | </ | ||
| - | |||
| - | ==== initr_env() [C] ==== | ||
| - | |||
| - | < | ||
| - | static int initr_env(void) | ||
| - | { | ||
| - | /* initialize environment */ | ||
| - | if (should_load_env()) | ||
| - | env_relocate(); | ||
| - | else | ||
| - | set_default_env(NULL, | ||
| - | #ifdef CONFIG_OF_CONTROL | ||
| - | env_set_hex(" | ||
| - | (unsigned long)map_to_sysmem(gd-> | ||
| - | #endif | ||
| - | |||
| - | /* Initialize from environment */ | ||
| - | load_addr = env_get_ulong(" | ||
| - | |||
| - | return 0; | ||
| - | } | ||
| - | </ | ||
| - | |||
| - | ==== show_board_info() [C] ==== | ||
| - | |||
| - | From '' | ||
| - | |||
| - | < | ||
| - | int __weak checkboard(void) | ||
| - | { | ||
| - | return 0; | ||
| - | } | ||
| /* | /* | ||
| - | | + | |
| - | * Then call checkboard(). | + | |
| */ | */ | ||
| - | int __weak show_board_info(void) | + | ldr x0, =__bss_start |
| - | { | + | |
| - | #ifdef CONFIG_OF_CONTROL | + | clear_loop: |
| - | | + | str xzr, [x0], #8 |
| - | | + | |
| + | | ||
| - | | + | |
| - | + | | |
| - | | + | |
| - | printf(" | + | |
| - | #endif | + | |
| - | + | ||
| - | return checkboard(); | + | |
| - | } | + | |
| </ | </ | ||
| - | + | ==== 7. ==== | |
| - | For '' | + | |
| < | < | ||
| - | int checkboard(void) | + | * 7. Branch to board_init_r(). |
| - | { | + | |
| - | puts(" | + | |
| - | return 0; | + | |
| - | } | + | |
| </ | </ | ||
| - | |||
| - | ==== arch_misc_init() ==== | ||
| - | |||
| - | Some arches and boards, not Zynq. | ||
| < | < | ||
| - | #ifdef CONFIG_ARCH_MISC_INIT | + | b |
| - | arch_misc_init, | + | |
| - | #endif | + | |
| - | </code> | + | |
| - | ==== misc_init_r() ==== | + | /* NOTREACHED - board_init_r() does not return */ |
| - | + | ||
| - | < | + | |
| - | #ifdef CONFIG_MISC_INIT_R | + | |
| - | misc_init_r, | + | |
| - | #endif | + | |
| </ | </ | ||
| - | ==== initr_enable_interrupts() | + | ===== common/ |
| < | < | ||
| - | #ifdef CONFIG_ARM | + | void board_init_f(ulong boot_flags) |
| - | static int initr_enable_interrupts(void) | + | |
| { | { | ||
| - | | + | |
| - | | + | |
| - | } | + | |
| - | #endif | + | if (initcall_run_list(init_sequence_f)) |
| + | hang(); | ||
| + | ... | ||
| </ | </ | ||
| - | From '' | + | ===== common/board_r.c ===== |
| < | < | ||
| - | int interrupt_init (void) | + | void board_init_r(gd_t *new_gd, ulong dest_addr) |
| { | { | ||
| /* | /* | ||
| - | | + | |
| + | * here. | ||
| + | * TODO(sjg@chromium.org): | ||
| + | * dropping the new_gd parameter. | ||
| */ | */ | ||
| - | IRQ_STACK_START_IN = gd-> | + | #if CONFIG_IS_ENABLED(X86_64) |
| + | arch_setup_gd(new_gd); | ||
| + | #endif | ||
| - | return 0; | + | #ifdef CONFIG_NEEDS_MANUAL_RELOC |
| - | } | + | int i; |
| - | + | ||
| - | void enable_interrupts (void) | + | |
| - | { | + | |
| - | | + | |
| - | } | + | |
| - | int disable_interrupts (void) | + | |
| - | { | + | |
| - | return 0; | + | |
| - | } | + | |
| - | </ | + | |
| - | + | ||
| - | ==== initr_ethaddr() [C] ==== | + | |
| - | + | ||
| - | < | + | |
| - | #ifdef CONFIG_CMD_NET | + | |
| - | initr_ethaddr, | + | |
| #endif | #endif | ||
| - | </ | ||
| - | < | + | #if !defined(CONFIG_X86) && !defined(CONFIG_ARM) && !defined(CONFIG_ARM64) |
| - | #ifdef CONFIG_CMD_NET | + | |
| - | static int initr_ethaddr(void) | + | |
| - | { | + | |
| - | bd_t *bd = gd-> | + | |
| - | + | ||
| - | /* kept around for legacy kernels only ... ignore the next section */ | + | |
| - | eth_env_get_enetaddr(" | + | |
| - | #ifdef CONFIG_HAS_ETH1 | + | |
| - | | + | |
| #endif | #endif | ||
| - | #ifdef CONFIG_HAS_ETH2 | + | gd->flags &= ~GD_FLG_LOG_READY; |
| - | eth_env_get_enetaddr(" | + | |
| - | #endif | + | |
| - | #ifdef CONFIG_HAS_ETH3 | + | |
| - | eth_env_get_enetaddr(" | + | |
| - | #endif | + | |
| - | #ifdef CONFIG_HAS_ETH4 | + | |
| - | eth_env_get_enetaddr(" | + | |
| - | #endif | + | |
| - | #ifdef CONFIG_HAS_ETH5 | + | |
| - | eth_env_get_enetaddr(" | + | |
| - | #endif | + | |
| - | return 0; | + | |
| - | } | + | |
| - | #endif /* CONFIG_CMD_NET */ | + | |
| - | </ | + | |
| - | ==== board_late_init() [B] ==== | + | #ifdef CONFIG_NEEDS_MANUAL_RELOC |
| - | + | for (i = 0; i < ARRAY_SIZE(init_sequence_r); i++) | |
| - | (Defined in board/ | + | init_sequence_r[i] += gd->reloc_off; |
| - | + | ||
| - | <code> | + | |
| - | #ifdef CONFIG_BOARD_LATE_INIT | + | |
| - | board_late_init, | + | |
| #endif | #endif | ||
| - | </ | ||
| - | ==== initr_net() ==== | + | if (initcall_run_list(init_sequence_r)) |
| + | hang(); | ||
| - | < | + | /* NOTREACHED - run_main_loop() does not return */ |
| - | #ifdef CONFIG_CMD_NET | + | |
| - | static int initr_net(void) | + | |
| - | { | + | |
| - | | + | |
| - | eth_initialize(); | + | |
| - | #if defined(CONFIG_RESET_PHY_R) | + | |
| - | debug(" | + | |
| - | reset_phy(); | + | |
| - | #endif | + | |
| - | return 0; | + | |
| - | } | + | |
| - | #endif | + | |
| </ | </ | ||
| - | |||