diff --git a/bl31/bl31_main.c b/bl31/bl31_main.c index 7b0b675..fae5ee4 100644 --- a/bl31/bl31_main.c +++ b/bl31/bl31_main.c @@ -53,21 +53,27 @@ ******************************************************************************/ static uint32_t next_image_type = NON_SECURE; +/* + * Implement the ARM Standard Service function to get arguments for a + * particular service. + */ +uintptr_t get_arm_std_svc_args(unsigned int svc_mask) +{ + /* Setup the arguments for PSCI Library */ + DEFINE_STATIC_PSCI_LIB_ARGS_V1(psci_args, bl31_warm_entrypoint); + + /* PSCI is the only ARM Standard Service implemented */ + assert(svc_mask == PSCI_FID_MASK); + + return (uintptr_t)&psci_args; +} + /******************************************************************************* * Simple function to initialise all BL31 helper libraries. ******************************************************************************/ void bl31_lib_init(void) { - /* Setup the arguments for PSCI Library */ - DEFINE_STATIC_PSCI_LIB_ARGS_V1(psci_args, bl31_warm_entrypoint); - cm_init(); - - /* - * Initialize the PSCI library here. This also does EL3 architectural - * setup. - */ - psci_setup(&psci_args); } /******************************************************************************* @@ -89,7 +95,7 @@ /* Initialise helper libraries */ bl31_lib_init(); - /* Initialize the runtime services e.g. psci */ + /* Initialize the runtime services e.g. psci. */ INFO("BL31: Initializing runtime services\n"); runtime_svc_init(); diff --git a/bl32/sp_min/sp_min_main.c b/bl32/sp_min/sp_min_main.c index c1ba8fc..02663a2 100644 --- a/bl32/sp_min/sp_min_main.c +++ b/bl32/sp_min/sp_min_main.c @@ -151,30 +151,33 @@ } /****************************************************************************** + * Implement the ARM Standard Service function to get arguments for a + * particular service. + *****************************************************************************/ +uintptr_t get_arm_std_svc_args(unsigned int svc_mask) +{ + /* Setup the arguments for PSCI Library */ + DEFINE_STATIC_PSCI_LIB_ARGS_V1(psci_args, sp_min_warm_entrypoint); + + /* PSCI is the only ARM Standard Service implemented */ + assert(svc_mask == PSCI_FID_MASK); + + return (uintptr_t)&psci_args; +} + +/****************************************************************************** * The SP_MIN main function. Do the platform and PSCI Library setup. Also * initialize the runtime service framework. *****************************************************************************/ void sp_min_main(void) { - /* Setup the arguments for PSCI Library */ - DEFINE_STATIC_PSCI_LIB_ARGS_V1(psci_args, sp_min_warm_entrypoint); - NOTICE("SP_MIN: %s\n", version_string); NOTICE("SP_MIN: %s\n", build_message); /* Perform the SP_MIN platform setup */ sp_min_platform_setup(); - /* - * Initialize the PSCI library and perform the remaining generic - * architectural setup from PSCI. - */ - psci_setup(&psci_args); - - /* - * Initialize the runtime services e.g. psci - * This is where the monitor mode will be initialized - */ + /* Initialize the runtime services e.g. psci */ INFO("SP_MIN: Initializing runtime services\n"); runtime_svc_init(); diff --git a/include/services/std_svc.h b/include/services/std_svc.h index 0feb2ea..38ce8bb 100644 --- a/include/services/std_svc.h +++ b/include/services/std_svc.h @@ -42,4 +42,13 @@ #define STD_SVC_VERSION_MAJOR 0x0 #define STD_SVC_VERSION_MINOR 0x1 +/* + * Get the ARM Standard Service argument from EL3 Runtime. + * This function must be implemented by EL3 Runtime and the + * `svc_mask` identifies the service. `svc_mask` is a bit + * mask identifying the range of SMC function IDs available + * to the service. + */ +uintptr_t get_arm_std_svc_args(unsigned int svc_mask); + #endif /* __STD_SVC_H__ */ diff --git a/services/std_svc/std_svc_setup.c b/services/std_svc/std_svc_setup.c index 06647e0..e096601 100644 --- a/services/std_svc/std_svc_setup.c +++ b/services/std_svc/std_svc_setup.c @@ -28,6 +28,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include #include @@ -41,6 +42,21 @@ 0x108d905b, 0xf863, 0x47e8, 0xae, 0x2d, 0xc0, 0xfb, 0x56, 0x41, 0xf6, 0xe2); +/* Setup Standard Services */ +static int32_t std_svc_setup(void) +{ + uintptr_t svc_arg; + + svc_arg = get_arm_std_svc_args(PSCI_FID_MASK); + assert(svc_arg); + + /* + * PSCI is the only specification implemented as a Standard Service. + * The `psci_setup()` also does EL3 architectural setup. + */ + return psci_setup((const psci_lib_args_t *)svc_arg); +} + /* * Top-level Standard Service SMC handler. This handler will in turn dispatch * calls to PSCI SMC handler @@ -93,6 +109,6 @@ OEN_STD_START, OEN_STD_END, SMC_TYPE_FAST, - NULL, + std_svc_setup, std_svc_smc_handler );