/******************************************************************************* * BL31 is responsible for setting up the runtime services for the primary cpu * before passing control to the bootloader or an Operating System. This * function calls runtime_svc_init() which initializes all registered runtime * services. The run time services would setup enough context for the core to * swtich to the next exception level. When this function returns, the core will * switch to the programmed exception level via. an ERET. ******************************************************************************/ void bl31_main(void) { /* Show Only to UART */ NOTICE("BL3-1: %s\n", version_string); NOTICE("BL3-1: %s\n", build_message); atf_arg_t_ptr teearg = (atf_arg_t_ptr)(uintptr_t)TEE_BOOT_INFO_ADDR; /* Initialize for ATF log buffer */ if(teearg->atf_log_buf_size != 0) { teearg->atf_aee_debug_buf_size = ATF_AEE_BUFFER_SIZE; teearg->atf_aee_debug_buf_start = teearg->atf_log_buf_start + teearg->atf_log_buf_size - ATF_AEE_BUFFER_SIZE; mt_log_setup(teearg->atf_log_buf_start, teearg->atf_log_buf_size, teearg->atf_aee_debug_buf_size); printf("ATF log service is registered (0x%x, aee:0x%x)\n", teearg->atf_log_buf_start, teearg->atf_aee_debug_buf_start); } else { teearg->atf_aee_debug_buf_size = 0; teearg->atf_aee_debug_buf_start = 0; } /* Show to ATF log buffer & UART */ printf("BL3-1: %s\n", version_string); printf("BL3-1: %s\n", build_message); /* Perform remaining generic architectural setup from EL3 */ bl31_arch_setup(); /* Perform platform setup in BL1 */ bl31_platform_setup(); /* Initialise helper libraries */ bl31_lib_init(); /* Initialize the runtime services e.g. psci */ INFO("BL3-1: Initializing runtime services\n"); runtime_svc_init(); /* Clean caches before re-entering normal world */ dcsw_op_all(DCCSW); /* * All the cold boot actions on the primary cpu are done. We now need to * decide which is the next image (BL32 or BL33) and how to execute it. * If the SPD runtime service is present, it would want to pass control * to BL32 first in S-EL1. In that case, SPD would have registered a * function to intialize bl32 where it takes responsibility of entering * S-EL1 and returning control back to bl31_main. Once this is done we * can prepare entry into BL33 as normal. */ /* * If SPD had registerd an init hook, invoke it. */ if(teearg->tee_support) { printf("[BL31] Jump to secure OS for initialization!\n\r"); if (bl32_init) { (*bl32_init)(); } else { printf("[ERROR] Secure OS is not initialized!\n\r"); } } else { printf("[BL31] Jump to FIQD for initialization!\n\r"); if (bl32_init) { (*bl32_init)(); } } /* * We are ready to enter the next EL. Prepare entry into the image * corresponding to the desired security state after the next ERET. */ bl31_prepare_next_image_entry(); printf("[BL31] Final dump!\n\r"); clear_uart_flag(); printf("[BL31] SHOULD not dump in UART but in log buffer!\n\r"); }
/******************************************************************************* * BL31 is responsible for setting up the runtime services for the primary cpu * before passing control to the bootloader or an Operating System. This * function calls runtime_svc_init() which initializes all registered runtime * services. The run time services would setup enough context for the core to * swtich to the next exception level. When this function returns, the core will * switch to the programmed exception level via. an ERET. ******************************************************************************/ void bl31_main(void) { #if DEBUG unsigned long mpidr = read_mpidr(); #endif atf_arg_t_ptr teearg = (atf_arg_t_ptr)(uintptr_t)TEE_BOOT_INFO_ADDR; if(teearg->atf_log_buf_size != 0) { teearg->atf_aee_debug_buf_size = ATF_AEE_BUFFER_SIZE; teearg->atf_aee_debug_buf_start = teearg->atf_log_buf_start + teearg->atf_log_buf_size - ATF_AEE_BUFFER_SIZE; mt_log_setup(teearg->atf_log_buf_start, teearg->atf_log_buf_size, teearg->atf_aee_debug_buf_size); printf("ATF log service is registered (0x%x, aee:0x%x)\n", teearg->atf_log_buf_start, teearg->atf_aee_debug_buf_start); } else { teearg->atf_aee_debug_buf_size = 0; teearg->atf_aee_debug_buf_start = 0; } /* Perform remaining generic architectural setup from EL3 */ bl31_arch_setup(); /* Perform platform setup in BL1 */ bl31_platform_setup(); printf("BL31 %s\n\r", build_message); /* Initialise helper libraries */ bl31_lib_init(); /* Initialize the runtime services e.g. psci */ runtime_svc_init(); /* Clean caches before re-entering normal world */ dcsw_op_all(DCCSW); /* * Use the more complex exception vectors now that context * management is setup. SP_EL3 should point to a 'cpu_context' * structure which has an exception stack allocated. The PSCI * service should have set the context. */ assert(cm_get_context(mpidr, NON_SECURE)); cm_set_next_eret_context(NON_SECURE); cm_init_pcpu_ptr_cache(); write_vbar_el3((uint64_t) runtime_exceptions); isb(); next_image_type = NON_SECURE; /* * All the cold boot actions on the primary cpu are done. We now need to * decide which is the next image (BL32 or BL33) and how to execute it. * If the SPD runtime service is present, it would want to pass control * to BL32 first in S-EL1. In that case, SPD would have registered a * function to intialize bl32 where it takes responsibility of entering * S-EL1 and returning control back to bl31_main. Once this is done we * can prepare entry into BL33 as normal. */ /* * If SPD had registerd an init hook, invoke it. */ if(teearg->tee_support) { printf("[BL31] Jump to secure OS for initialization!\n\r"); if (bl32_init) { (*bl32_init)(teearg->tee_entry, teearg->tee_boot_arg_addr); } else { printf("[ERROR] Secure OS is not initialized!\n\r"); //assert(0); } } else { printf("[BL31] Jump to FIQD for initialization!\n\r"); if (bl32_init) { (*bl32_init)(0, 0); } } /* * We are ready to enter the next EL. Prepare entry into the image * corresponding to the desired security state after the next ERET. */ bl31_prepare_next_image_entry(); printf("[BL31] Final dump!\n\r"); clear_uart_flag(); printf("[BL31] SHOULD not dump in UART but in log buffer!\n\r"); }