1 // SPDX-License-Identifier: BSD-2-Clause 2 /* 3 * Copyright (c) 2020, Linaro Limited 4 * Copyright (c) 2014, STMicroelectronics International N.V. 5 */ 6 7 #include <initcall.h> 8 #include <trace.h> 9 #include <kernel/linker.h> 10 11 static void do_init_calls(const char *type __maybe_unused, 12 const struct initcall *begin, 13 const struct initcall *end) 14 { 15 const struct initcall *call = NULL; 16 TEE_Result ret = TEE_SUCCESS; 17 18 for (call = begin; call < end; call++) { 19 DMSG("%s level %d %s()", type, call->level, call->func_name); 20 ret = call->func(); 21 if (ret) { 22 EMSG("%s __text_start + 0x%08"PRIxVA" failed", 23 type, (vaddr_t)call - VCORE_START_VA); 24 } 25 } 26 } 27 28 #define DO_INIT_CALLS(name) \ 29 do_init_calls(#name, name##_begin, name##_end) 30 31 /* 32 * Note: this function is weak just to make it possible to exclude it from 33 * the unpaged area. 34 */ 35 void __weak call_preinitcalls(void) 36 { 37 DO_INIT_CALLS(preinitcall); 38 } 39 40 /* 41 * Note: this function is weak just to make it possible to exclude it from 42 * the unpaged area. 43 */ 44 void __weak call_early_initcalls(void) 45 { 46 DO_INIT_CALLS(early_initcall); 47 } 48 49 /* 50 * Note: this function is weak just to make it possible to exclude it from 51 * the unpaged area. 52 */ 53 void __weak call_service_initcalls(void) 54 { 55 DO_INIT_CALLS(service_initcall); 56 } 57 58 /* 59 * Note: this function is weak just to make it possible to exclude it from 60 * the unpaged area. 61 */ 62 void __weak call_driver_initcalls(void) 63 { 64 DO_INIT_CALLS(driver_initcall); 65 } 66 67 /* 68 * Note: this function is weak just to make it possible to exclude it from 69 * the unpaged area. 70 */ 71 void __weak call_finalcalls(void) 72 { 73 DO_INIT_CALLS(finalcall); 74 } 75