Refactor FF-A boot info
Refactor the FF-A boot info related types to prepare for adding the FF-A
v1.1 structures.
Signed-off-by: Balint Dobszay <balint.dobszay@arm.com>
Change-Id: I03dd0275d367611e6156c4ba47bdbacb62296001
diff --git a/components/config/loader/sp/sp_config_loader.c b/components/config/loader/sp/sp_config_loader.c
index b4d81b4..6aaff4b 100644
--- a/components/config/loader/sp/sp_config_loader.c
+++ b/components/config/loader/sp/sp_config_loader.c
@@ -9,16 +9,17 @@
#include <platform/interface/device_region.h>
#include <platform/interface/memory_region.h>
#include <stdbool.h>
+#include <stdint.h>
#include <string.h>
#include <trace.h>
#include "sp_config_loader.h"
/*
- * According to the FF-A 1.0 spec: in the SP manifest the size of device and
+ * According to the FF-A spec: in the SP manifest the size of device and
* memory regions is expressed as a count of 4K pages.
*/
-#define FFA_SP_MANIFEST_PAGE_SIZE 0x1000
+#define FFA_SP_MANIFEST_PAGE_SIZE UINT32_C(0x1000)
struct sp_param_region {
char name[16];
@@ -26,7 +27,7 @@
size_t size;
};
-static bool load_device_regions(const struct ffa_name_value_pair *value_pair)
+static bool load_device_regions(const struct ffa_name_value_pair_v1_0 *value_pair)
{
struct sp_param_region *d = (struct sp_param_region *)value_pair->value;
@@ -55,7 +56,7 @@
return true;
}
-static bool load_memory_regions(const struct ffa_name_value_pair *value_pair)
+static bool load_memory_regions(const struct ffa_name_value_pair_v1_0 *value_pair)
{
struct sp_param_region *d = (struct sp_param_region *)value_pair->value;
@@ -82,7 +83,7 @@
return true;
}
-static bool load_blob(const struct ffa_name_value_pair *value_pair)
+static bool load_blob(const struct ffa_name_value_pair_v1_0 *value_pair)
{
struct config_blob blob;
@@ -98,10 +99,8 @@
return true;
}
-static bool load_fdt(const struct ffa_name_value_pair *value_pair)
+static bool load_fdt(const void *fdt, size_t fdt_size)
{
- const void *fdt = (const void *)value_pair->value;
- size_t fdt_size = value_pair->size;
int root = -1, node = -1, subnode = -1, rc = -1;
static const char *ffa_manifest_compatible = "arm,ffa-manifest-1.0";
@@ -262,36 +261,31 @@
return true;
}
-/**
- * Loads externally provided configuration data passed into the SP via
- * FFA initialisation parameters. Data can originate from
- * the SP manifest, an external device tree or a dynamic configuration
- * mechanism such as a handover block (HOB).
- */
-bool sp_config_load(struct ffa_init_info *init_info)
+static bool sp_config_load_v1_0(struct ffa_boot_info_v1_0 *boot_info)
{
/* Load deployment specific configuration */
- for (size_t param_index = 0; param_index < init_info->count; param_index++) {
- const char *name = (const char *)init_info->nvp[param_index].name;
- const size_t name_max_size = sizeof(init_info->nvp[param_index].name);
+ for (size_t param_index = 0; param_index < boot_info->count; param_index++) {
+ const char *name = (const char *)boot_info->nvp[param_index].name;
+ const size_t name_max_size = sizeof(boot_info->nvp[param_index].name);
if (!strncmp(name, "DEVICE_REGIONS", name_max_size)) {
- if (!load_device_regions(&init_info->nvp[param_index])) {
+ if (!load_device_regions(&boot_info->nvp[param_index])) {
EMSG("Failed to load device regions");
return false;
}
} else if (!strncmp(name, "MEMORY_REGIONS", name_max_size)) {
- if (!load_memory_regions(&init_info->nvp[param_index])) {
+ if (!load_memory_regions(&boot_info->nvp[param_index])) {
EMSG("Failed to load memory regions");
return false;
}
} else if (!memcmp(name, "TYPE_DT\0\0\0\0\0\0\0\0", name_max_size)) {
- if (!load_fdt(&init_info->nvp[param_index])) {
+ if (!load_fdt((void *)boot_info->nvp[param_index].value,
+ boot_info->nvp[param_index].size)) {
EMSG("Failed to load SP config from DT");
return false;
}
} else {
- if (!load_blob(&init_info->nvp[param_index])) {
+ if (!load_blob(&boot_info->nvp[param_index])) {
EMSG("Failed to load blob");
return false;
}
@@ -300,3 +294,19 @@
return true;
}
+
+bool sp_config_load(union ffa_boot_info *boot_info)
+{
+ if (!boot_info)
+ return false;
+
+ switch (boot_info->signature) {
+ case FFA_BOOT_INFO_SIGNATURE_V1_0:
+ return sp_config_load_v1_0((struct ffa_boot_info_v1_0 *)&boot_info->boot_info_v1_0);
+ default:
+ EMSG("Invalid FF-A boot info signature");
+ return false;
+ }
+
+ return false;
+}
diff --git a/components/config/loader/sp/sp_config_loader.h b/components/config/loader/sp/sp_config_loader.h
index 6448c62..3e585ce 100644
--- a/components/config/loader/sp/sp_config_loader.h
+++ b/components/config/loader/sp/sp_config_loader.h
@@ -14,6 +14,6 @@
* Loads the secure partition specific configuration passed as
* SP initialization parameters.
*/
-bool sp_config_load(struct ffa_init_info *init_info);
+bool sp_config_load(union ffa_boot_info *boot_info);
#endif /* SP_CONFIG_LOADER_H */
diff --git a/components/messaging/ffa/libsp/include/ffa_api_defines.h b/components/messaging/ffa/libsp/include/ffa_api_defines.h
index 163a0cd..03b1198 100644
--- a/components/messaging/ffa/libsp/include/ffa_api_defines.h
+++ b/components/messaging/ffa/libsp/include/ffa_api_defines.h
@@ -66,6 +66,9 @@
/* Special value for MBZ parameters */
#define FFA_PARAM_MBZ UINT32_C(0x0)
+/* Boot information signature */
+#define FFA_BOOT_INFO_SIGNATURE_V1_0 UINT32_C(0x412D4646) /* FF-A ASCII */
+
/* FFA_VERSION */
#define FFA_VERSION_MAJOR UINT32_C(1)
#define FFA_VERSION_MAJOR_SHIFT UINT32_C(16)
diff --git a/components/messaging/ffa/libsp/include/ffa_api_types.h b/components/messaging/ffa/libsp/include/ffa_api_types.h
index b1be7ac..8333488 100644
--- a/components/messaging/ffa/libsp/include/ffa_api_types.h
+++ b/components/messaging/ffa/libsp/include/ffa_api_types.h
@@ -11,25 +11,30 @@
#include <stdint.h>
/**
- * Init info
+ * Boot info
*/
/**
* @brief Boot protocol name-value pairs
*/
-struct ffa_name_value_pair {
+struct ffa_name_value_pair_v1_0 {
uint32_t name[4]; /**< Name of the item */
uintptr_t value; /**< Value of the item */
size_t size; /**< Size of the referenced value */
};
/**
- * @brief Structure for passing boot protocol data
+ * @brief Structure for passing boot protocol data (FF-A v1.0)
*/
-struct ffa_init_info {
+struct ffa_boot_info_v1_0 {
uint32_t magic; /**< FF-A */
uint32_t count; /**< Count of name value size pairs */
- struct ffa_name_value_pair nvp[]; /**< Array of name value size pairs */
+ struct ffa_name_value_pair_v1_0 nvp[]; /**< Array of name value size pairs */
+};
+
+union ffa_boot_info {
+ uint32_t signature;
+ struct ffa_boot_info_v1_0 boot_info_v1_0;
};
/**
diff --git a/components/messaging/ffa/libsp/include/sp_api.h b/components/messaging/ffa/libsp/include/sp_api.h
index 3c432bb..b220c91 100644
--- a/components/messaging/ffa/libsp/include/sp_api.h
+++ b/components/messaging/ffa/libsp/include/sp_api.h
@@ -30,9 +30,9 @@
* @brief Entry point of the SP's application code. SPs must implement this
* function.
*
- * @param init_info The boot info
+ * @param boot_info The boot info
*/
-void __noreturn sp_main(struct ffa_init_info *init_info);
+void __noreturn sp_main(union ffa_boot_info *boot_info);
#ifdef __cplusplus
}
diff --git a/components/service/spm_test/sp.c b/components/service/spm_test/sp.c
index 01cc7d2..30ddea7 100644
--- a/components/service/spm_test/sp.c
+++ b/components/service/spm_test/sp.c
@@ -744,10 +744,12 @@
return_error(err, msg);
}
-void __noreturn sp_main(struct ffa_init_info *init_info) {
+void __noreturn sp_main(union ffa_boot_info *boot_info) {
struct ffa_direct_msg msg = {0};
uint16_t own_id = 0;
+ (void)boot_info;
+
/* Boot phase */
if (sp_discovery_own_id_get(&own_id) != SP_RESULT_OK) {
EMSG("Couldn't get own_id!!");
diff --git a/deployments/attestation/env/commonsp/attestation_sp.c b/deployments/attestation/env/commonsp/attestation_sp.c
index b84fd23..266f3fb 100644
--- a/deployments/attestation/env/commonsp/attestation_sp.c
+++ b/deployments/attestation/env/commonsp/attestation_sp.c
@@ -28,7 +28,7 @@
static bool sp_init(uint16_t *own_sp_id);
static bool locate_crypto_service(void);
-void __noreturn sp_main(struct ffa_init_info *init_info)
+void __noreturn sp_main(union ffa_boot_info *boot_info)
{
/* Service provider objects */
struct attest_provider attest_provider = { 0 };
@@ -57,7 +57,7 @@
config_ramstore_init();
- if (!sp_config_load(init_info)) {
+ if (!sp_config_load(boot_info)) {
EMSG("Failed to load SP config");
goto fatal_error;
}
diff --git a/deployments/block-storage/env/commonsp/block_storage_sp.c b/deployments/block-storage/env/commonsp/block_storage_sp.c
index 012250c..5f3d53c 100644
--- a/deployments/block-storage/env/commonsp/block_storage_sp.c
+++ b/deployments/block-storage/env/commonsp/block_storage_sp.c
@@ -20,7 +20,7 @@
static bool sp_init(uint16_t *own_sp_id);
-void __noreturn sp_main(struct ffa_init_info *init_info)
+void __noreturn sp_main(union ffa_boot_info *boot_info)
{
struct ffa_call_ep ffarpc_call_ep = { 0 };
struct block_storage_provider service_provider = { 0 };
@@ -39,7 +39,7 @@
config_ramstore_init();
- if (!sp_config_load(init_info)) {
+ if (!sp_config_load(boot_info)) {
EMSG("Failed to load SP config");
goto fatal_error;
}
diff --git a/deployments/crypto/env/commonsp/crypto_sp.c b/deployments/crypto/env/commonsp/crypto_sp.c
index 2e6018e..a8abd46 100644
--- a/deployments/crypto/env/commonsp/crypto_sp.c
+++ b/deployments/crypto/env/commonsp/crypto_sp.c
@@ -18,7 +18,7 @@
static bool sp_init(uint16_t *own_sp_id);
-void __noreturn sp_main(struct ffa_init_info *init_info)
+void __noreturn sp_main(union ffa_boot_info *boot_info)
{
struct crypto_provider *crypto_provider = NULL;
struct ffa_call_ep ffarpc_call_ep = { 0 };
@@ -38,7 +38,7 @@
config_ramstore_init();
- if (!sp_config_load(init_info)) {
+ if (!sp_config_load(boot_info)) {
EMSG("Failed to load SP config");
goto fatal_error;
}
diff --git a/deployments/env-test/env/commonsp/env_test_sp.c b/deployments/env-test/env/commonsp/env_test_sp.c
index 3b1f472..35c871b 100644
--- a/deployments/env-test/env/commonsp/env_test_sp.c
+++ b/deployments/env-test/env/commonsp/env_test_sp.c
@@ -18,7 +18,7 @@
static bool sp_init(uint16_t *own_sp_id);
-void __noreturn sp_main(struct ffa_init_info *init_info)
+void __noreturn sp_main(union ffa_boot_info *boot_info)
{
struct test_runner_provider test_runner_provider = { 0 };
struct ffa_call_ep ffarpc_call_ep = { 0 };
@@ -36,7 +36,7 @@
config_ramstore_init();
- if (!sp_config_load(init_info)) {
+ if (!sp_config_load(boot_info)) {
EMSG("Failed to load SP config");
goto fatal_error;
}
diff --git a/deployments/fwu/env/commonsp/fwu_sp.c b/deployments/fwu/env/commonsp/fwu_sp.c
index 0dce92e..812db1e 100644
--- a/deployments/fwu/env/commonsp/fwu_sp.c
+++ b/deployments/fwu/env/commonsp/fwu_sp.c
@@ -41,7 +41,7 @@
static bool configure_for_platform(void);
const struct metadata_serializer *select_metadata_serializer(unsigned int version);
-void __noreturn sp_main(struct ffa_init_info *init_info)
+void __noreturn sp_main(union ffa_boot_info *boot_info)
{
struct ffa_call_ep ffarpc_call_ep = { 0 };
struct fwu_provider service_provider = { 0 };
@@ -61,7 +61,7 @@
config_ramstore_init();
- if (!sp_config_load(init_info)) {
+ if (!sp_config_load(boot_info)) {
EMSG("Failed to load SP config");
goto fatal_error;
}
diff --git a/deployments/internal-trusted-storage/env/commonsp/its_sp.c b/deployments/internal-trusted-storage/env/commonsp/its_sp.c
index 4c694ef..a1fe67f 100644
--- a/deployments/internal-trusted-storage/env/commonsp/its_sp.c
+++ b/deployments/internal-trusted-storage/env/commonsp/its_sp.c
@@ -17,7 +17,7 @@
static uint8_t tx_buffer[4096] __aligned(4096);
static uint8_t rx_buffer[4096] __aligned(4096);
-void sp_main(struct ffa_init_info *init_info)
+void sp_main(union ffa_boot_info *boot_info)
{
sp_result result = SP_RESULT_INTERNAL_ERROR;
struct rpc_interface *secure_storage_iface = NULL;
@@ -29,7 +29,7 @@
uint16_t own_id = 0;
/* Boot */
- (void) init_info;
+ (void)boot_info;
result = sp_rxtx_buffer_map(tx_buffer, rx_buffer, sizeof(rx_buffer));
if (result != SP_RESULT_OK) {
diff --git a/deployments/protected-storage/env/commonsp/ps_sp.c b/deployments/protected-storage/env/commonsp/ps_sp.c
index d4db0af..acd651b 100644
--- a/deployments/protected-storage/env/commonsp/ps_sp.c
+++ b/deployments/protected-storage/env/commonsp/ps_sp.c
@@ -17,7 +17,7 @@
static uint8_t tx_buffer[4096] __aligned(4096);
static uint8_t rx_buffer[4096] __aligned(4096);
-void sp_main(struct ffa_init_info *init_info)
+void sp_main(union ffa_boot_info *boot_info)
{
sp_result result = SP_RESULT_INTERNAL_ERROR;
struct rpc_interface *secure_storage_iface = NULL;
@@ -29,7 +29,7 @@
uint16_t own_id = 0;
/* Boot */
- (void) init_info;
+ (void)boot_info;
result = sp_rxtx_buffer_map(tx_buffer, rx_buffer, sizeof(rx_buffer));
if (result != SP_RESULT_OK) {
diff --git a/deployments/se-proxy/env/commonsp/se_proxy_sp.c b/deployments/se-proxy/env/commonsp/se_proxy_sp.c
index 45fcb38..5990bb2 100644
--- a/deployments/se-proxy/env/commonsp/se_proxy_sp.c
+++ b/deployments/se-proxy/env/commonsp/se_proxy_sp.c
@@ -16,7 +16,7 @@
static bool sp_init(uint16_t *own_sp_id);
-void __noreturn sp_main(struct ffa_init_info *init_info)
+void __noreturn sp_main(union ffa_boot_info *boot_info)
{
struct ffa_call_ep ffarpc_call_ep = { 0 };
struct sp_msg req_msg = { 0 };
@@ -34,7 +34,7 @@
config_ramstore_init();
- if (!sp_config_load(init_info)) {
+ if (!sp_config_load(boot_info)) {
EMSG("Failed to load SP config");
goto fatal_error;
}
diff --git a/deployments/sfs-demo/common/sfs_demo_sp.c b/deployments/sfs-demo/common/sfs_demo_sp.c
index ee0c93f..d7aaf71 100644
--- a/deployments/sfs-demo/common/sfs_demo_sp.c
+++ b/deployments/sfs-demo/common/sfs_demo_sp.c
@@ -122,7 +122,7 @@
IMSG("ITS test done");
}
-void __noreturn sp_main(struct ffa_init_info *init_info) {
+void __noreturn sp_main(union ffa_boot_info *boot_info) {
sp_result result = SP_RESULT_INTERNAL_ERROR;
struct sp_msg req_msg = { 0 };
@@ -136,7 +136,7 @@
psa_status_t psa_status = PSA_ERROR_GENERIC_ERROR;
/* Boot */
- (void) init_info;
+ (void)boot_info;
IMSG("Test SP started");
result = sp_rxtx_buffer_map(tx_buffer, rx_buffer, sizeof(rx_buffer));
diff --git a/deployments/smm-gateway/env/commonsp/smm_gateway_sp.c b/deployments/smm-gateway/env/commonsp/smm_gateway_sp.c
index 98388bb..9fbaa87 100644
--- a/deployments/smm-gateway/env/commonsp/smm_gateway_sp.c
+++ b/deployments/smm-gateway/env/commonsp/smm_gateway_sp.c
@@ -23,7 +23,7 @@
static bool sp_init(uint16_t *own_sp_id);
-void __noreturn sp_main(struct ffa_init_info *init_info)
+void __noreturn sp_main(union ffa_boot_info *boot_info)
{
struct memory_region mm_comm_buffer_region = { 0 };
struct rpc_interface *gateway_iface = NULL;
@@ -46,7 +46,7 @@
/* Load any dynamic configuration */
config_ramstore_init();
- if (!sp_config_load(init_info)) {
+ if (!sp_config_load(boot_info)) {
EMSG("Failed to load SP config");
goto fatal_error;
}
diff --git a/environments/opteesp/sp_entry.c b/environments/opteesp/sp_entry.c
index 6249407..f7d67cb 100644
--- a/environments/opteesp/sp_entry.c
+++ b/environments/opteesp/sp_entry.c
@@ -26,5 +26,5 @@
libc_init();
- sp_main((struct ffa_init_info *)a0);
+ sp_main((union ffa_boot_info *)a0);
}
diff --git a/environments/sp/sp_entry.c b/environments/sp/sp_entry.c
index 0a709c2..c9b2510 100644
--- a/environments/sp/sp_entry.c
+++ b/environments/sp/sp_entry.c
@@ -26,5 +26,5 @@
libc_init();
- sp_main((struct ffa_init_info *)a0);
+ sp_main((union ffa_boot_info *)a0);
}