diff options
author | Olivier Deprez <olivier.deprez@arm.com> | 2020-04-16 13:39:06 +0200 |
---|---|---|
committer | Olivier Deprez <olivier.deprez@arm.com> | 2020-05-13 08:08:39 +0200 |
commit | 52696946ab3f441496436ad7223cb2bd853c8beb (patch) | |
tree | 0c535f247b619a3e9a4ec6ce30e49fd593470897 /plat/common | |
parent | 4e2887f2da05dc510e9ce1e9d648ef2b5d745649 (diff) | |
download | trusted-firmware-a-52696946ab3f441496436ad7223cb2bd853c8beb.tar.gz |
SPMD: code/comments cleanup
As a follow-up to bdd2596d4, and related to SPM Dispatcher
EL3 component and SPM Core S-EL2/S-EL1 component: update
with cosmetic and coding rules changes. In addition:
-Add Armv8.4-SecEL2 arch detection helper.
-Add an SPMC context (on current core) get helper.
-Return more meaningful error return codes.
-Remove complexity in few spmd_smc_handler switch-cases.
-Remove unused defines and structures from spmd_private.h
Signed-off-by: Olivier Deprez <olivier.deprez@arm.com>
Change-Id: I99e642450b0dafb19d3218a2f0e2d3107e8ca3fe
Diffstat (limited to 'plat/common')
-rw-r--r-- | plat/common/plat_spmd_manifest.c | 105 |
1 files changed, 58 insertions, 47 deletions
diff --git a/plat/common/plat_spmd_manifest.c b/plat/common/plat_spmd_manifest.c index 8330356ae9..a3e30e89cc 100644 --- a/plat/common/plat_spmd_manifest.c +++ b/plat/common/plat_spmd_manifest.c @@ -5,65 +5,78 @@ */ #include <assert.h> +#include <errno.h> #include <string.h> #include <libfdt.h> #include <common/debug.h> #include <common/fdt_wrappers.h> -#include <errno.h> #include <platform_def.h> #include <services/spm_core_manifest.h> +#define ATTRIBUTE_ROOT_NODE_STR "attribute" + /******************************************************************************* - * Attribute section handler + * SPMC attribute node parser ******************************************************************************/ -static int manifest_parse_attribute(spmc_manifest_sect_attribute_t *attr, +static int manifest_parse_attribute(spmc_manifest_attribute_t *attr, const void *fdt, int node) { uint32_t val32; - int rc = 0; + int rc; - assert(attr && fdt); + assert((attr != NULL) && (fdt != NULL)); rc = fdt_read_uint32(fdt, node, "maj_ver", &attr->major_version); - if (rc) { - ERROR("Missing SPCI major version in SPM core manifest.\n"); - return -ENOENT; + if (rc != 0) { + ERROR("Missing SPCI %s version in SPM Core manifest.\n", + "major"); + return rc; } rc = fdt_read_uint32(fdt, node, "min_ver", &attr->minor_version); - if (rc) { - ERROR("Missing SPCI minor version in SPM core manifest.\n"); - return -ENOENT; + if (rc != 0) { + ERROR("Missing SPCI %s version in SPM Core manifest.\n", + "minor"); + return rc; } rc = fdt_read_uint32(fdt, node, "spmc_id", &val32); - if (rc) { + if (rc != 0) { ERROR("Missing SPMC ID in manifest.\n"); - return -ENOENT; + return rc; } - attr->spmc_id = val32; + + attr->spmc_id = val32 & 0xffff; rc = fdt_read_uint32(fdt, node, "exec_state", &attr->exec_state); - if (rc) - NOTICE("Execution state not specified in SPM core manifest.\n"); + if (rc != 0) { + NOTICE("%s not specified in SPM Core manifest.\n", + "Execution state"); + } rc = fdt_read_uint32(fdt, node, "binary_size", &attr->binary_size); - if (rc) - NOTICE("Binary size not specified in SPM core manifest.\n"); + if (rc != 0) { + NOTICE("%s not specified in SPM Core manifest.\n", + "Binary size"); + } rc = fdt_read_uint64(fdt, node, "load_address", &attr->load_address); - if (rc) - NOTICE("Load address not specified in SPM core manifest.\n"); + if (rc != 0) { + NOTICE("%s not specified in SPM Core manifest.\n", + "Load address"); + } rc = fdt_read_uint64(fdt, node, "entrypoint", &attr->entrypoint); - if (rc) - NOTICE("Entrypoint not specified in SPM core manifest.\n"); + if (rc != 0) { + NOTICE("%s not specified in SPM Core manifest.\n", + "Entry point"); + } - VERBOSE("SPM core manifest attribute section:\n"); - VERBOSE(" version: %x.%x\n", attr->major_version, attr->minor_version); - VERBOSE(" spmc_id: %x\n", attr->spmc_id); + VERBOSE("SPM Core manifest attribute section:\n"); + VERBOSE(" version: %u.%u\n", attr->major_version, attr->minor_version); + VERBOSE(" spmc_id: 0x%x\n", attr->spmc_id); VERBOSE(" binary_size: 0x%x\n", attr->binary_size); VERBOSE(" load_address: 0x%llx\n", attr->load_address); VERBOSE(" entrypoint: 0x%llx\n", attr->entrypoint); @@ -74,53 +87,51 @@ static int manifest_parse_attribute(spmc_manifest_sect_attribute_t *attr, /******************************************************************************* * Root node handler ******************************************************************************/ -static int manifest_parse_root(spmc_manifest_sect_attribute_t *manifest, - const void *fdt, - int root) +static int manifest_parse_root(spmc_manifest_attribute_t *manifest, + const void *fdt, + int root) { int node; - char *str; - str = "attribute"; - node = fdt_subnode_offset_namelen(fdt, root, str, strlen(str)); + assert(manifest != NULL); + + node = fdt_subnode_offset_namelen(fdt, root, ATTRIBUTE_ROOT_NODE_STR, + sizeof(ATTRIBUTE_ROOT_NODE_STR) - 1); if (node < 0) { - ERROR("Root node doesn't contain subnode '%s'\n", str); - return -ENOENT; + ERROR("Root node doesn't contain subnode '%s'\n", + ATTRIBUTE_ROOT_NODE_STR); + return node; } return manifest_parse_attribute(manifest, fdt, node); } /******************************************************************************* - * Platform handler to parse a SPM core manifest. + * Platform handler to parse a SPM Core manifest. ******************************************************************************/ -int plat_spm_core_manifest_load(spmc_manifest_sect_attribute_t *manifest, +int plat_spm_core_manifest_load(spmc_manifest_attribute_t *manifest, const void *ptr, size_t size) { int rc; - int root_node; assert(manifest != NULL); assert(ptr != NULL); - INFO("Reading SPM core manifest at address %p\n", ptr); + INFO("Reading SPM Core manifest at address %p\n", ptr); rc = fdt_check_header(ptr); if (rc != 0) { - ERROR("Wrong format for SPM core manifest (%d).\n", rc); - return -EINVAL; + ERROR("Wrong format for SPM Core manifest (%d).\n", rc); + return rc; } - INFO("Reading SPM core manifest at address %p\n", ptr); - - root_node = fdt_node_offset_by_compatible(ptr, -1, + rc = fdt_node_offset_by_compatible(ptr, -1, "arm,spci-core-manifest-1.0"); - if (root_node < 0) { - ERROR("Unrecognized SPM core manifest\n"); - return -ENOENT; + if (rc < 0) { + ERROR("Unrecognized SPM Core manifest\n"); + return rc; } - INFO("Reading SPM core manifest at address %p\n", ptr); - return manifest_parse_root(manifest, ptr, root_node); + return manifest_parse_root(manifest, ptr, rc); } |