feat(rme): pass console info via RMM-EL3 ifc

This patch modifies the boot manifest to add console information to
be passed from EL3 to RMM.

Boot manifest version is bumped to v0.3

Signed-off-by: Harry Moulton <harry.moulton@arm.com>
Signed-off-by: Soby Mathew <soby.mathew@arm.com>
Change-Id: Iedc4e640fb7a4450ce5ce966ae76936d1b7b742d
This commit is contained in:
Soby Mathew 2024-03-26 17:16:00 +00:00 committed by Harry Moulton
parent eee0ec48b5
commit 32904472cc
3 changed files with 138 additions and 34 deletions

View File

@ -14,7 +14,9 @@
#include <lib/cassert.h>
#define RMMD_MANIFEST_VERSION_MAJOR U(0)
#define RMMD_MANIFEST_VERSION_MINOR U(2)
#define RMMD_MANIFEST_VERSION_MINOR U(3)
#define RMM_CONSOLE_MAX_NAME_LEN U(8)
/*
* Manifest version encoding:
@ -60,12 +62,49 @@ CASSERT(offsetof(struct ns_dram_info, banks) == 8UL,
CASSERT(offsetof(struct ns_dram_info, checksum) == 16UL,
rmm_manifest_checksum_unaligned);
/* Boot manifest core structure as per v0.2 */
/* Console info structure */
struct console_info {
uintptr_t base; /* Console base address */
uint64_t map_pages; /* Num of pages to be mapped in RMM for the console MMIO */
char name[RMM_CONSOLE_MAX_NAME_LEN]; /* Name of console */
uint64_t clk_in_hz; /* UART clock (in HZ) for the console */
uint64_t baud_rate; /* Baud rate */
uint64_t flags; /* Additional flags RES0 */
};
CASSERT(offsetof(struct console_info, base) == 0UL,
rmm_manifest_console_base_unaligned);
CASSERT(offsetof(struct console_info, map_pages) == 8UL,
rmm_manifest_console_map_pages_unaligned);
CASSERT(offsetof(struct console_info, name) == 16UL,
rmm_manifest_console_name_unaligned);
CASSERT(offsetof(struct console_info, clk_in_hz) == 24UL,
rmm_manifest_console_clk_in_hz_unaligned);
CASSERT(offsetof(struct console_info, baud_rate) == 32UL,
rmm_manifest_console_baud_rate_unaligned);
CASSERT(offsetof(struct console_info, flags) == 40UL,
rmm_manifest_console_flags_unaligned);
struct console_list {
uint64_t num_consoles; /* Number of consoles */
struct console_info *consoles; /* Pointer to ns_dram_bank[] */
uint64_t checksum; /* Checksum of ns_dram_info data */
};
CASSERT(offsetof(struct console_list, num_consoles) == 0UL,
rmm_manifest_num_consoles);
CASSERT(offsetof(struct console_list, consoles) == 8UL,
rmm_manifest_consoles);
CASSERT(offsetof(struct console_list, checksum) == 16UL,
rmm_manifest_console_list_checksum);
/* Boot manifest core structure as per v0.3 */
struct rmm_manifest {
uint32_t version; /* Manifest version */
uint32_t padding; /* RES0 */
uintptr_t plat_data; /* Manifest platform data */
struct ns_dram_info plat_dram; /* Platform NS DRAM data */
uint32_t version; /* Manifest version */
uint32_t padding; /* RES0 */
uintptr_t plat_data; /* Manifest platform data */
struct ns_dram_info plat_dram; /* Platform NS DRAM data (v0.2) */
struct console_list plat_console; /* Platform console list (v0.3) */
};
CASSERT(offsetof(struct rmm_manifest, version) == 0UL,
@ -74,5 +113,7 @@ CASSERT(offsetof(struct rmm_manifest, plat_data) == 8UL,
rmm_manifest_plat_data_unaligned);
CASSERT(offsetof(struct rmm_manifest, plat_dram) == 16UL,
rmm_manifest_plat_dram_unaligned);
CASSERT(offsetof(struct rmm_manifest, plat_console) == 40UL,
rmm_manifest_plat_console_unaligned);
#endif /* RMM_CORE_MANIFEST_H */

View File

@ -5,6 +5,7 @@
*/
#include <assert.h>
#include <string.h>
#include <common/debug.h>
#include <drivers/arm/cci.h>
@ -33,6 +34,14 @@
#define FVP_GICV2 1
#define FVP_GICV3 2
/* Defines for RMM Console*/
#define FVP_RMM_CONSOLE_BASE UL(0x1c0c0000)
#define FVP_RMM_CONSOLE_BAUD UL(115200)
#define FVP_RMM_CONSOLE_CLK_IN_HZ UL(14745600)
#define FVP_RMM_CONSOLE_NAME "pl011"
#define FVP_RMM_CONSOLE_COUNT UL(1)
/*******************************************************************************
* arm_config holds the characteristics of the differences between the three FVP
* platforms (Base, A53_A57 & Foundation). It will be populated during cold boot
@ -552,8 +561,9 @@ size_t plat_rmmd_get_el3_rmm_shared_mem(uintptr_t *shared)
int plat_rmmd_load_manifest(struct rmm_manifest *manifest)
{
uint64_t checksum, num_banks;
uint64_t checksum, num_banks, num_consoles;
struct ns_dram_bank *bank_ptr;
struct console_info *console_ptr;
assert(manifest != NULL);
@ -561,43 +571,74 @@ int plat_rmmd_load_manifest(struct rmm_manifest *manifest)
num_banks = FCONF_GET_PROPERTY(hw_config, dram_layout, num_banks);
assert(num_banks <= ARM_DRAM_NUM_BANKS);
/* Set number of consoles */
num_consoles = FVP_RMM_CONSOLE_COUNT;
manifest->version = RMMD_MANIFEST_VERSION;
manifest->padding = 0U; /* RES0 */
manifest->plat_data = (uintptr_t)NULL;
manifest->plat_dram.num_banks = num_banks;
manifest->plat_console.num_consoles = num_consoles;
/*
* Array ns_dram_banks[] follows ns_dram_info structure:
* Boot Manifest structure illustration, with two dram banks and
* a single console.
*
* +-----------------------------------+
* | offset | field | comment |
* +----------+-----------+------------+
* | 0 | version | 0x00000002 |
* +----------+-----------+------------+
* | 4 | padding | 0x00000000 |
* +----------+-----------+------------+
* | 8 | plat_data | NULL |
* +----------+-----------+------------+
* | 16 | num_banks | |
* +----------+-----------+ |
* | 24 | banks | plat_dram |
* +----------+-----------+ |
* | 32 | checksum | |
* +----------+-----------+------------+
* | 40 | base 0 | |
* +----------+-----------+ bank[0] |
* | 48 | size 0 | |
* +----------+-----------+------------+
* | 56 | base 1 | |
* +----------+-----------+ bank[1] |
* | 64 | size 1 | |
* +----------+-----------+------------+
* +----------------------------------------+
* | offset | field | comment |
* +--------+----------------+--------------+
* | 0 | version | 0x00000003 |
* +--------+----------------+--------------+
* | 4 | padding | 0x00000000 |
* +--------+----------------+--------------+
* | 8 | plat_data | NULL |
* +--------+----------------+--------------+
* | 16 | num_banks | |
* +--------+----------------+ |
* | 24 | banks | plat_dram |
* +--------+----------------+ |
* | 32 | checksum | |
* +--------+----------------+--------------+
* | 40 | num_consoles | |
* +--------+----------------+ |
* | 48 | consoles | plat_console |
* +--------+----------------+ |
* | 56 | checksum | |
* +--------+----------------+--------------+
* | 64 | base 0 | |
* +--------+----------------+ bank[0] |
* | 72 | size 0 | |
* +--------+----------------+--------------+
* | 80 | base 1 | |
* +--------+----------------+ bank[1] |
* | 88 | size 1 | |
* +--------+----------------+--------------+
* | 96 | base | |
* +--------+----------------+ |
* | 104 | map_pages | |
* +--------+----------------+ |
* | 112 | name | |
* +--------+----------------+ consoles[0] |
* | 120 | clk_in_hz | |
* +--------+----------------+ |
* | 128 | baud_rate | |
* +--------+----------------+ |
* | 136 | flags | |
* +--------+----------------+--------------+
*/
bank_ptr = (struct ns_dram_bank *)
((uintptr_t)&manifest->plat_dram.checksum +
sizeof(manifest->plat_dram.checksum));
(((uintptr_t)manifest) + sizeof(*manifest));
console_ptr = (struct console_info *)
((uintptr_t)bank_ptr + (num_banks * sizeof(*bank_ptr)));
manifest->plat_dram.banks = bank_ptr;
manifest->plat_console.consoles = console_ptr;
/* Ensure the manifest is not larger than the shared buffer */
assert((sizeof(struct rmm_manifest) +
(sizeof(struct console_info) * manifest->plat_console.num_consoles) +
(sizeof(struct ns_dram_bank) * manifest->plat_dram.num_banks)) <= ARM_EL3_RMM_SHARED_SIZE);
/* Calculate checksum of plat_dram structure */
checksum = num_banks + (uint64_t)bank_ptr;
@ -617,6 +658,26 @@ int plat_rmmd_load_manifest(struct rmm_manifest *manifest)
/* Checksum must be 0 */
manifest->plat_dram.checksum = ~checksum + 1UL;
/* Calculate the checksum of the plat_consoles structure */
checksum = num_consoles + (uint64_t)console_ptr;
/* Zero out the console info struct */
memset((void *)console_ptr, '\0', sizeof(struct console_info) * num_consoles);
console_ptr[0].map_pages = 1;
console_ptr[0].base = FVP_RMM_CONSOLE_BASE;
console_ptr[0].clk_in_hz = FVP_RMM_CONSOLE_CLK_IN_HZ;
console_ptr[0].baud_rate = FVP_RMM_CONSOLE_BAUD;
strlcpy(console_ptr[0].name, FVP_RMM_CONSOLE_NAME, RMM_CONSOLE_MAX_NAME_LEN-1UL);
/* Update checksum */
checksum += console_ptr[0].base + console_ptr[0].map_pages +
console_ptr[0].clk_in_hz + console_ptr[0].baud_rate;
/* Checksum must be 0 */
manifest->plat_console.checksum = ~checksum + 1UL;
return 0;
}
#endif /* ENABLE_RME */

View File

@ -232,8 +232,10 @@ int rmmd_setup(void)
assert((shared_buf_size == SZ_4K) &&
((void *)shared_buf_base != NULL));
/* Load the boot manifest at the beginning of the shared area */
/* Zero out and load the boot manifest at the beginning of the share area */
manifest = (struct rmm_manifest *)shared_buf_base;
memset((void *)manifest, 0, sizeof(manifest));
rc = plat_rmmd_load_manifest(manifest);
if (rc != 0) {
ERROR("Error loading RMM Boot Manifest (%i)\n", rc);