mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-16 09:34:18 +00:00
feat(rme): set DRAM information in Boot Manifest platform data
This patch adds support for setting configuration of DRAM banks for FVP model in RMM-EL3 Boot Manifest structure. Structure 'rmm_manifest' is extended with 'plat_dram' structure which contains information about platform's DRAM layout: - number of DRAM banks; - pointer to 'dram_bank[]' array; - check sum: two's complement 64-bit value of the sum of data in 'plat_dram' and 'dram_bank[] array. Each 'dram_bank' structure holds information about DRAM bank base address and its size. This values must be aligned to 4KB page size. The patch increases Boot Manifest minor version to 2 and removes 'typedef rmm_manifest_t' as per "3.4.15.1. Avoid anonymous typedefs of structs/enums in headers" of https://trustedfirmware-a.readthedocs.io/en/latest/process/coding-style.html Signed-off-by: AlexeiFedorov <Alexei.Fedorov@arm.com> Change-Id: I5176caa5780e27d1e0daeb5dea3e40cf6ad5fd12
This commit is contained in:
parent
0185523948
commit
a97bfa5ff1
10 changed files with 89 additions and 33 deletions
|
@ -235,6 +235,8 @@
|
|||
#define ARM_DRAM2_SIZE PLAT_ARM_DRAM2_SIZE
|
||||
#define ARM_DRAM2_END (ARM_DRAM2_BASE + \
|
||||
ARM_DRAM2_SIZE - 1U)
|
||||
/* Number of DRAM banks */
|
||||
#define ARM_DRAM_BANKS_NUM 2UL
|
||||
|
||||
#define ARM_IRQ_SEC_PHY_TIMER 29
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
#include <lib/psci/psci.h>
|
||||
#if defined(SPD_spmd)
|
||||
#include <services/spm_core_manifest.h>
|
||||
#include <services/spm_core_manifest.h>
|
||||
#endif
|
||||
#if ENABLE_RME
|
||||
#include <services/rmm_core_manifest.h>
|
||||
|
@ -37,6 +37,7 @@ struct bl_params;
|
|||
struct mmap_region;
|
||||
struct spm_mm_boot_info;
|
||||
struct sp_res_desc;
|
||||
struct rmm_manifest;
|
||||
enum fw_enc_status_t;
|
||||
|
||||
/*******************************************************************************
|
||||
|
@ -322,7 +323,7 @@ int plat_rmmd_get_cca_attest_token(uintptr_t buf, size_t *len,
|
|||
int plat_rmmd_get_cca_realm_attest_key(uintptr_t buf, size_t *len,
|
||||
unsigned int type);
|
||||
size_t plat_rmmd_get_el3_rmm_shared_mem(uintptr_t *shared);
|
||||
int plat_rmmd_load_manifest(rmm_manifest_t *manifest);
|
||||
int plat_rmmd_load_manifest(struct rmm_manifest *manifest);
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include <lib/cassert.h>
|
||||
|
||||
#define RMMD_MANIFEST_VERSION_MAJOR U(0)
|
||||
#define RMMD_MANIFEST_VERSION_MINOR U(1)
|
||||
#define RMMD_MANIFEST_VERSION_MINOR U(2)
|
||||
|
||||
/*
|
||||
* Manifest version encoding:
|
||||
|
@ -35,16 +35,44 @@
|
|||
#define RMMD_GET_MANIFEST_VERSION_MINOR(_version) \
|
||||
(_version & 0xFFFF)
|
||||
|
||||
/* Boot manifest core structure as per v0.1 */
|
||||
typedef struct rmm_manifest {
|
||||
uint32_t version; /* Manifest version */
|
||||
uint32_t padding; /* RES0 */
|
||||
uintptr_t plat_data; /* Manifest platform data */
|
||||
} rmm_manifest_t;
|
||||
/* DRAM bank structure */
|
||||
struct dram_bank {
|
||||
uintptr_t base; /* Base address */
|
||||
uint64_t size; /* Size of bank */
|
||||
};
|
||||
|
||||
CASSERT(offsetof(rmm_manifest_t, version) == 0,
|
||||
rmm_manifest_t_version_unaligned);
|
||||
CASSERT(offsetof(rmm_manifest_t, plat_data) == 8,
|
||||
rmm_manifest_t_plat_data_unaligned);
|
||||
CASSERT(offsetof(struct dram_bank, base) == 0,
|
||||
rmm_manifest_base_unaligned);
|
||||
CASSERT(offsetof(struct dram_bank, size) == 8,
|
||||
rmm_manifest_size_unaligned);
|
||||
|
||||
/* DRAM layout info structure */
|
||||
struct dram_info {
|
||||
uint64_t banks_num; /* Number of DRAM banks */
|
||||
struct dram_bank *dram_data; /* Pointer to dram_bank[] */
|
||||
uint64_t check_sum; /* Checksum of dram_info data */
|
||||
};
|
||||
|
||||
CASSERT(offsetof(struct dram_info, banks_num) == 0,
|
||||
rmm_manifest_banks_num_unaligned);
|
||||
CASSERT(offsetof(struct dram_info, dram_data) == 8,
|
||||
rmm_manifest_dram_data_unaligned);
|
||||
CASSERT(offsetof(struct dram_info, check_sum) == 16,
|
||||
rmm_manifest_check_sum_unaligned);
|
||||
|
||||
/* Boot manifest core structure as per v0.2 */
|
||||
struct rmm_manifest {
|
||||
uint32_t version; /* Manifest version */
|
||||
uint32_t padding; /* RES0 */
|
||||
uintptr_t plat_data; /* Manifest platform data */
|
||||
struct dram_info plat_dram; /* Platform DRAM data */
|
||||
};
|
||||
|
||||
CASSERT(offsetof(struct rmm_manifest, version) == 0,
|
||||
rmm_manifest_version_unaligned);
|
||||
CASSERT(offsetof(struct rmm_manifest, plat_data) == 8,
|
||||
rmm_manifest_plat_data_unaligned);
|
||||
CASSERT(offsetof(struct rmm_manifest, plat_dram) == 16,
|
||||
rmm_manifest_plat_dram_unaligned);
|
||||
|
||||
#endif /* RMM_CORE_MANIFEST_H */
|
||||
|
|
|
@ -9,9 +9,11 @@
|
|||
|
||||
#include <services/rmm_core_manifest.h>
|
||||
|
||||
struct rmm_manifest;
|
||||
|
||||
/*******************************************************************************
|
||||
* Mandatory TRP functions (only if platform contains a TRP)
|
||||
******************************************************************************/
|
||||
void trp_early_platform_setup(rmm_manifest_t *manifest);
|
||||
void trp_early_platform_setup(struct rmm_manifest *manifest);
|
||||
|
||||
#endif /* PLATFORM_TRP_H */
|
||||
|
|
|
@ -17,14 +17,13 @@
|
|||
#include <lib/xlat_tables/xlat_tables_compat.h>
|
||||
#include <platform_def.h>
|
||||
#include <services/arm_arch_svc.h>
|
||||
#if ENABLE_RME
|
||||
#include <services/rmm_core_manifest.h>
|
||||
#endif
|
||||
#if SPM_MM
|
||||
#include <services/spm_mm_partition.h>
|
||||
#endif
|
||||
|
||||
#include <plat/arm/common/arm_config.h>
|
||||
#include <plat/arm/common/arm_pas_def.h>
|
||||
#include <plat/arm/common/plat_arm.h>
|
||||
#include <plat/common/platform.h>
|
||||
|
||||
|
@ -531,15 +530,46 @@ size_t plat_rmmd_get_el3_rmm_shared_mem(uintptr_t *shared)
|
|||
return (size_t)RMM_SHARED_SIZE;
|
||||
}
|
||||
|
||||
int plat_rmmd_load_manifest(rmm_manifest_t *manifest)
|
||||
CASSERT(ARM_DRAM_BANKS_NUM == 2UL, ARM_DRAM_BANKS_NUM_mismatch);
|
||||
|
||||
/* FVP DRAM banks */
|
||||
const struct dram_bank fvp_dram_banks[ARM_DRAM_BANKS_NUM] = {
|
||||
{ARM_PAS_2_BASE, ARM_PAS_2_SIZE},
|
||||
{ARM_PAS_4_BASE, ARM_PAS_4_SIZE}
|
||||
};
|
||||
|
||||
int plat_rmmd_load_manifest(struct rmm_manifest *manifest)
|
||||
{
|
||||
uint64_t check_sum;
|
||||
struct dram_bank *bank_ptr;
|
||||
|
||||
assert(manifest != NULL);
|
||||
|
||||
manifest->version = RMMD_MANIFEST_VERSION;
|
||||
manifest->padding = 0U; /* RES0 */
|
||||
manifest->plat_data = (uintptr_t)NULL;
|
||||
manifest->plat_dram.banks_num = ARM_DRAM_BANKS_NUM;
|
||||
|
||||
/* Array dram_banks[] follows dram_info structure */
|
||||
bank_ptr = (struct dram_bank *)
|
||||
((uintptr_t)&manifest->plat_dram.check_sum +
|
||||
sizeof(manifest->plat_dram.check_sum));
|
||||
|
||||
manifest->plat_dram.dram_data = bank_ptr;
|
||||
|
||||
/* Copy FVP DRAM banks data to Boot Manifest */
|
||||
(void)memcpy((void *)bank_ptr, &fvp_dram_banks, sizeof(fvp_dram_banks));
|
||||
|
||||
/* Calculate check sum of plat_dram structure */
|
||||
check_sum = ARM_DRAM_BANKS_NUM + (uint64_t)bank_ptr;
|
||||
|
||||
for (unsigned long i = 0UL; i < ARM_DRAM_BANKS_NUM; i++) {
|
||||
check_sum += bank_ptr[i].base + bank_ptr[i].size;
|
||||
}
|
||||
|
||||
/* Check sum must be 0 */
|
||||
manifest->plat_dram.check_sum = ~check_sum + 1UL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif /* ENABLE_RME */
|
||||
|
|
|
@ -18,16 +18,12 @@
|
|||
#include <drivers/partition/partition.h>
|
||||
#include <lib/fconf/fconf.h>
|
||||
#include <lib/fconf/fconf_dyn_cfg_getter.h>
|
||||
#if ENABLE_RME
|
||||
#include <lib/gpt_rme/gpt_rme.h>
|
||||
#endif /* ENABLE_RME */
|
||||
#ifdef SPD_opteed
|
||||
#include <lib/optee_utils.h>
|
||||
#endif
|
||||
#include <lib/utils.h>
|
||||
#if ENABLE_RME
|
||||
#include <plat/arm/common/arm_pas_def.h>
|
||||
#endif /* ENABLE_RME */
|
||||
#include <plat/arm/common/plat_arm.h>
|
||||
#include <plat/common/platform.h>
|
||||
|
||||
|
|
|
@ -13,9 +13,7 @@
|
|||
#include <drivers/console.h>
|
||||
#include <lib/debugfs.h>
|
||||
#include <lib/extensions/ras.h>
|
||||
#if ENABLE_RME
|
||||
#include <lib/gpt_rme/gpt_rme.h>
|
||||
#endif
|
||||
#include <lib/mmio.h>
|
||||
#include <lib/xlat_tables/xlat_tables_compat.h>
|
||||
#include <plat/arm/common/plat_arm.h>
|
||||
|
|
|
@ -26,7 +26,7 @@ extern uint32_t trp_boot_manifest_version;
|
|||
******************************************************************************/
|
||||
static console_t arm_trp_runtime_console;
|
||||
|
||||
static int arm_trp_process_manifest(rmm_manifest_t *manifest)
|
||||
static int arm_trp_process_manifest(struct rmm_manifest *manifest)
|
||||
{
|
||||
/* padding field on the manifest must be RES0 */
|
||||
assert(manifest->padding == 0U);
|
||||
|
@ -38,12 +38,12 @@ static int arm_trp_process_manifest(rmm_manifest_t *manifest)
|
|||
}
|
||||
|
||||
trp_boot_manifest_version = manifest->version;
|
||||
flush_dcache_range((uintptr_t)manifest, sizeof(rmm_manifest_t));
|
||||
flush_dcache_range((uintptr_t)manifest, sizeof(struct rmm_manifest));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void arm_trp_early_platform_setup(rmm_manifest_t *manifest)
|
||||
void arm_trp_early_platform_setup(struct rmm_manifest *manifest)
|
||||
{
|
||||
int rc;
|
||||
|
||||
|
@ -66,10 +66,9 @@ void arm_trp_early_platform_setup(rmm_manifest_t *manifest)
|
|||
|
||||
console_set_scope(&arm_trp_runtime_console,
|
||||
CONSOLE_FLAG_BOOT | CONSOLE_FLAG_RUNTIME);
|
||||
|
||||
}
|
||||
|
||||
void trp_early_platform_setup(rmm_manifest_t *manifest)
|
||||
void trp_early_platform_setup(struct rmm_manifest *manifest)
|
||||
{
|
||||
arm_trp_early_platform_setup(manifest);
|
||||
}
|
||||
|
|
|
@ -171,7 +171,7 @@ int rmmd_setup(void)
|
|||
uint32_t ep_attr;
|
||||
unsigned int linear_id = plat_my_core_pos();
|
||||
rmmd_rmm_context_t *rmm_ctx = &rmm_context[linear_id];
|
||||
rmm_manifest_t *manifest;
|
||||
struct rmm_manifest *manifest;
|
||||
int rc;
|
||||
|
||||
/* Make sure RME is supported. */
|
||||
|
@ -206,7 +206,7 @@ int rmmd_setup(void)
|
|||
((void *)shared_buf_base != NULL));
|
||||
|
||||
/* Load the boot manifest at the beginning of the shared area */
|
||||
manifest = (rmm_manifest_t *)shared_buf_base;
|
||||
manifest = (struct rmm_manifest *)shared_buf_base;
|
||||
rc = plat_rmmd_load_manifest(manifest);
|
||||
if (rc != 0) {
|
||||
ERROR("Error loading RMM Boot Manifest (%i)\n", rc);
|
||||
|
|
|
@ -62,7 +62,7 @@ void trp_setup(uint64_t x0,
|
|||
sizeof(trp_shared_region_start));
|
||||
|
||||
/* Perform early platform-specific setup */
|
||||
trp_early_platform_setup((rmm_manifest_t *)trp_shared_region_start);
|
||||
trp_early_platform_setup((struct rmm_manifest *)trp_shared_region_start);
|
||||
}
|
||||
|
||||
int trp_validate_warmboot_args(uint64_t x0, uint64_t x1,
|
||||
|
|
Loading…
Add table
Reference in a new issue