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 15:52] – [arch/arm/cpu/armv7/lowlevel_init.S] rpjday | u-boot_boot_sequence [2019/12/28 08:33] (current) – [1.] rpjday | ||
|---|---|---|---|
| Line 17: | Line 17: | ||
| - | ===== arch/ | + | ===== arch/ |
| - | ==== Set up to call board_init_f() | + | ==== Prologue ==== |
| + | |||
| + | < | ||
| + | * This file handles the target-independent stages of the U-Boot | ||
| + | * start-up where a C runtime environment is needed. Its entry point | ||
| + | * is _main and is branched into from the target' | ||
| + | </ | ||
| + | |||
| + | ==== 1. ==== | ||
| < | < | ||
| Line 37: | Line 45: | ||
| * Set up initial C runtime environment and call board_init_f(0). | * Set up initial C runtime environment and call board_init_f(0). | ||
| */ | */ | ||
| - | + | #if defined(CONFIG_TPL_BUILD) && defined(CONFIG_TPL_NEEDS_SEPARATE_STACK) | |
| - | #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_STACK) | + | ldr x0, =(CONFIG_TPL_STACK) |
| - | ldr r0, =(CONFIG_SPL_STACK) | + | #elif defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_STACK) |
| + | ldr x0, =(CONFIG_SPL_STACK) | ||
| + | #elif defined(CONFIG_INIT_SP_RELATIVE) | ||
| + | adr x0, __bss_start | ||
| + | add x0, x0, # | ||
| #else | #else | ||
| - | ldr r0, =(CONFIG_SYS_INIT_SP_ADDR) | + | ldr x0, =(CONFIG_SYS_INIT_SP_ADDR) |
| #endif | #endif | ||
| - | bic r0, r0, #7 | + | bic sp, x0, #0xf |
| - | mov sp, r0 | + | mov x0, sp |
| bl board_init_f_alloc_reserve | bl board_init_f_alloc_reserve | ||
| - | mov | + | mov |
| /* set up gd here, outside any C code */ | /* set up gd here, outside any C code */ | ||
| - | mov r9, r0 | + | mov x18, x0 |
| bl board_init_f_init_reserve | bl board_init_f_init_reserve | ||
| - | |||
| - | mov r0, #0 | ||
| </ | </ | ||
| - | ==== Call board_init_f() | + | ==== 2. ==== |
| < | < | ||
| Line 66: | Line 76: | ||
| < | < | ||
| + | mov x0, #0 | ||
| bl board_init_f | bl board_init_f | ||
| </ | </ | ||
| - | ==== Set up to call relocate_code() | + | ==== 3. ==== |
| < | < | ||
| - | #if ! defined(CONFIG_SPL_BUILD) | + | * 3. Set up intermediate environment where the stack and GD are the |
| + | | ||
| + | | ||
| + | </ | ||
| + | < | ||
| + | #if !defined(CONFIG_SPL_BUILD) | ||
| /* | /* | ||
| * Set up intermediate environment (new sp and gd) and call | * Set up intermediate environment (new sp and gd) and call | ||
| Line 79: | Line 95: | ||
| * ' | * ' | ||
| */ | */ | ||
| + | ldr x0, [x18, # | ||
| + | bic sp, x0, #0xf /* 16-byte alignment for ABI compliance */ | ||
| + | ldr x18, [x18, # | ||
| - | | + | |
| - | | + | #if CONFIG_POSITION_INDEPENDENT |
| - | mov sp, r0 | + | |
| - | ldr r9, [r9, # | + | |
| - | sub r9, r9, # | + | ldr x9, _TEXT_BASE |
| - | + | sub x9, x9, x0 | |
| - | adr lr, here | + | add lr, lr, x9 |
| - | ldr r0, [r9, # | + | |
| - | add lr, lr, r0 | + | |
| - | #if defined(CONFIG_CPU_V7M) | + | |
| - | orr lr, #1 /* As required by Thumb-only */ | + | |
| - | #endif | + | |
| - | ldr r0, [r9, # | + | |
| - | b | + | |
| - | here: | + | |
| - | /* | + | |
| - | * now relocate vectors | + | |
| - | */ | + | |
| - | + | ||
| - | bl relocate_vectors | + | |
| - | + | ||
| - | /* Set up final (full) environment */ | + | |
| - | + | ||
| - | bl c_runtime_cpu_setup | + | |
| #endif | #endif | ||
| + | /* Add in link-vs-relocation offset */ | ||
| + | ldr x9, [x18, # | ||
| + | add lr, lr, x9 /* new return address after relocation */ | ||
| + | ldr x0, [x18, # | ||
| </ | </ | ||
| - | ==== Set up to call board_init_r() | + | ==== 4a. ==== |
| < | < | ||
| - | /* call board_init_r(gd_t *id, ulong dest_addr) */ | + | * 4a.For U-Boot proper |
| - | mov r0, r9 /* gd_t */ | + | |
| - | ldr r1, [r9, # | + | |
| - | /* call board_init_r */ | + | |
| - | #if CONFIG_IS_ENABLED(SYS_THUMB_BUILD) | + | |
| - | | + | |
| - | | + | |
| - | #else | + | |
| - | ldr pc, =board_init_r | + | |
| - | #endif | + | |
| - | /* we should not return here. */ | + | |
| - | #endif | + | |
| </ | </ | ||
| - | ===== common/ | + | < |
| + | b | ||
| - | ===== common/board_r.c (only most common) ===== | + | relocation_return: |
| + | </code> | ||
| - | ==== initr_dm() [C] ==== | + | ==== 4b. ==== |
| - | ==== board_init() [A,B] ==== | + | |
| - | + | ||
| - | ==== board_early_init_r() (not for Zynq) ==== | + | |
| - | + | ||
| - | ==== arch_early_init_r() [A] ==== | + | |
| - | + | ||
| - | * arch/ | + | |
| - | * arch/ | + | |
| < | < | ||
| - | #if defined(CONFIG_ARCH_EARLY_INIT_R) | + | * 4b.For SPL, board_init_f() just returns |
| - | int arch_early_init_r(void) | + | * code relocation in SPL. |
| - | { | + | |
| - | #if (defined(CONFIG_FPGA) && !defined(CONFIG_SPL_BUILD)) || \ | + | |
| - | (defined(CONFIG_SPL_FPGA_SUPPORT) && defined(CONFIG_SPL_BUILD)) | + | |
| - | int cpu_id = cpu_desc_id(); | + | |
| - | + | ||
| - | if (cpu_id < 0) | + | |
| - | return 0; | + | |
| - | + | ||
| - | fpga.size = zynq_fpga_descs[cpu_id].fpga_size; | + | |
| - | fpga.name = zynq_fpga_descs[cpu_id].devicename; | + | |
| - | fpga_init(); | + | |
| - | fpga_add(fpga_xilinx, | + | |
| - | #endif | + | |
| - | return 0; | + | |
| - | } | + | |
| - | #endif | + | |
| </ | </ | ||
| - | ==== initr_mmc() [C] ==== | + | ==== 5. ==== |
| < | < | ||
| - | #ifdef CONFIG_MMC | + | * 5. Set up final environment for calling board_init_r(). This |
| - | static int initr_mmc(void) | + | * environment has BSS (initialized to 0), initialized non-const |
| - | { | + | * data (initialized to their intended value), and stack in system |
| - | puts(" | + | * RAM (for SPL moving the stack and GD into RAM is optional |
| - | | + | * CONFIG_SPL_STACK_R). GD has retained values set by board_init_f(). |
| - | | + | |
| - | } | + | |
| - | #endif | + | |
| </ | </ | ||
| - | ==== initr_env() [C] ==== | + | ==== 6. ==== |
| < | < | ||
| - | static int initr_env(void) | + | * 6. For U-Boot proper |
| - | { | + | |
| - | /* initialize environment */ | + | |
| - | if (should_load_env()) | + | |
| - | env_relocate(); | + | |
| - | else | + | |
| - | set_default_env(NULL, 0); | + | |
| - | #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) | + | /* |
| - | { | + | * Set up final (full) environment |
| - | return 0; | + | */ |
| - | } | + | |
| + | #endif /* !CONFIG_SPL_BUILD */ | ||
| + | #if !defined(CONFIG_SPL_BUILD) || CONFIG_IS_ENABLED(FRAMEWORK) | ||
| + | #if defined(CONFIG_SPL_BUILD) | ||
| + | bl spl_relocate_stack_gd | ||
| + | /* set up gd here, outside any C code, if new stack is returned */ | ||
| + | cmp x0, #0 | ||
| + | | ||
| + | /* | ||
| + | * Perform 'sp = (x0 != NULL) ? x0 : sp' while working | ||
| + | * around the constraint that conditional moves can not | ||
| + | * have ' | ||
| + | */ | ||
| + | mov x1, sp | ||
| + | cmp x0, #0 | ||
| + | csel x0, x0, x1, ne | ||
| + | mov sp, x0 | ||
| + | #endif | ||
| /* | /* | ||
| - | | + | |
| - | * 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 | + | |
| </ | </ | ||
| - | |||