Core: Remove needless initialisations from spm_db.h
The structure holding the Secure Partition Manager database is
initialised to zero, so there is no need to set each member to 0 during
database initialisation. Only the members with non-zero value have to be
set.
Change-Id: Ic389b326b163288f23c612b5bc074662f4dea619
Signed-off-by: Mate Toth-Pal <mate.toth-pal@arm.com>
diff --git a/secure_fw/spm/spm_api.c b/secure_fw/spm/spm_api.c
index 06938fc..40d054d 100644
--- a/secure_fw/spm/spm_api.c
+++ b/secure_fw/spm/spm_api.c
@@ -8,6 +8,7 @@
/* This file contains the APIs exported by the SPM to tfm core */
#include <stdio.h>
+#include <string.h>
#include "spm_api.h"
#include "spm_db.h"
#include "tfm_api.h"
@@ -77,8 +78,9 @@
{
struct spm_partition_desc_t *part_ptr;
+ memset (&g_spm_partition_db, 0, sizeof(g_spm_partition_db));
+
/* This function initialises partition db */
- g_spm_partition_db.is_init = 1;
g_spm_partition_db.running_partition_idx = SPM_INVALID_PARTITION_IDX;
g_spm_partition_db.partition_count = 0;
@@ -112,6 +114,8 @@
/* Add user-defined secure partitions */
#include "user_partition_defines.inc"
+ g_spm_partition_db.is_init = 1;
+
return SPM_ERR_OK;
}
diff --git a/secure_fw/spm/spm_db.h b/secure_fw/spm/spm_db.h
index 5641bf1..cf6e7ef 100644
--- a/secure_fw/spm/spm_db.h
+++ b/secure_fw/spm/spm_db.h
@@ -77,11 +77,6 @@
do { \
data.partition_id = partition##_ID; \
data.partition_flags = flags; \
- data.periph_start = 0U; \
- data.periph_limit = 0U; \
- data.periph_ppc_bank = 0U; \
- data.periph_ppc_loc = 0U; \
- data.partition_init = 0U; \
} while (0)
#else
#define PARTITION_INIT_STATIC_DATA(data, partition, flags) \
@@ -98,11 +93,6 @@
data.zi_limit = PART_REGION_ADDR(partition, _DATA$$ZI$$Limit); \
data.stack_bottom = PART_REGION_ADDR(partition, _STACK$$ZI$$Base); \
data.stack_top = PART_REGION_ADDR(partition, _STACK$$ZI$$Limit); \
- data.periph_start = 0U; \
- data.periph_limit = 0U; \
- data.periph_ppc_bank = 0U; \
- data.periph_ppc_loc = 0U; \
- data.partition_init = 0U; \
} while (0)
#endif
@@ -110,21 +100,11 @@
#define PARTITION_INIT_RUNTIME_DATA(data, partition) \
do { \
data.partition_state = SPM_PARTITION_STATE_UNINIT; \
- data.caller_partition_idx = 0U; \
- data.orig_psp = 0U; \
- data.orig_psplim = 0U; \
- data.orig_lr = 0U; \
- data.share = 0U; \
} while (0)
#else
#define PARTITION_INIT_RUNTIME_DATA(data, partition) \
do { \
data.partition_state = SPM_PARTITION_STATE_UNINIT; \
- data.caller_partition_idx = 0U; \
- data.orig_psp = 0U; \
- data.orig_psplim = 0U; \
- data.orig_lr = 0U; \
- data.share = 0U; \
data.stack_ptr = \
PART_REGION_ADDR(partition, _STACK$$ZI$$Limit); \
} while (0)