sgi/dyncfg: add system-id node in hw-config dtb
authorChandni Cherukuri <[email protected]>
Thu, 10 May 2018 06:33:50 +0000 (12:03 +0530)
committerChandni Cherukuri <[email protected]>
Fri, 15 Jun 2018 04:47:24 +0000 (10:17 +0530)
Append a node to hw-config dtb which will include a property to hold
the value of the SSC_VERSION register. This will be used by the BL33
stage to determine the platform-id and the config-id of the platform
it is executing on.

Change-Id: Ie7b1e5d8c1bbe0efdb7ef0714f14b7794ec6058e
Signed-off-by: Amit Daniel Kachhap <[email protected]>
Signed-off-by: Chandni Cherukuri <[email protected]>
plat/arm/css/sgi/sgi-common.mk
plat/arm/css/sgi/sgi_image_load.c [new file with mode: 0644]

index d27cafeecf4e5d3cdb468e7141a7d8352394afcf..f4092f3894befd79268c306c1d9becf18738ede4 100644 (file)
@@ -30,7 +30,8 @@ BL1_SOURCES           +=      ${INTERCONNECT_SOURCES}                 \
                                ${CSS_ENT_BASE}/sgi_bl1_setup.c \
                                ${CSS_ENT_BASE}/sgi_plat_config.c
 
-BL2_SOURCES            +=      ${CSS_ENT_BASE}/sgi_security.c
+BL2_SOURCES            +=      ${CSS_ENT_BASE}/sgi_security.c          \
+                               ${CSS_ENT_BASE}/sgi_image_load.c
 
 BL31_SOURCES           +=      ${ENT_CPU_SOURCES}                      \
                                ${INTERCONNECT_SOURCES}                 \
diff --git a/plat/arm/css/sgi/sgi_image_load.c b/plat/arm/css/sgi/sgi_image_load.c
new file mode 100644 (file)
index 0000000..dda5e96
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <debug.h>
+#include <desc_image_load.h>
+#include <libfdt.h>
+#include <platform.h>
+
+/*******************************************************************************
+ * This function inserts Platform information via device tree nodes as,
+ * system-id {
+ *    platform-id = <0>;
+ * }
+ ******************************************************************************/
+static int plat_sgi_append_config_node(void)
+{
+       bl_mem_params_node_t *mem_params;
+       void *fdt;
+       int nodeoffset, err;
+       unsigned int platid = 0;
+       char *platform_name;
+
+       mem_params = get_bl_mem_params_node(HW_CONFIG_ID);
+       if (mem_params == NULL) {
+               ERROR("HW CONFIG base address is NULL");
+               return -1;
+       }
+
+       fdt = (void *)(mem_params->image_info.image_base);
+
+       /* Check the validity of the fdt */
+       if (fdt_check_header(fdt) != 0) {
+               ERROR("Invalid HW_CONFIG DTB passed\n");
+               return -1;
+       }
+
+       platform_name = (char *)fdt_getprop(fdt, 0, "compatible", NULL);
+
+       if (strcmp(platform_name, "arm,sgi575") == 0) {
+               platid = mmio_read_32(SSC_VERSION);
+       } else {
+               WARN("Invalid platform \n");
+               return -1;
+       }
+
+       /* Increase DTB blob by 512 byte */
+       err = fdt_open_into(fdt, fdt, mem_params->image_info.image_size + 512);
+       if (err < 0) {
+               ERROR("Failed to open HW_CONFIG DTB\n");
+               return -1;
+       }
+
+       /* Create "/system-id" node */
+       nodeoffset = fdt_add_subnode(fdt, 0, "system-id");
+       if (nodeoffset < 0) {
+               ERROR("Failed to add node system-id\n");
+               return -1;
+       }
+
+       err = fdt_setprop_u32(fdt, nodeoffset, "platform-id", platid);
+       if (err < 0) {
+               ERROR("Failed to add node platform-id\n");
+               return -1;
+       }
+       return 0;
+}
+
+/*******************************************************************************
+ * This function returns the list of executable images.
+ ******************************************************************************/
+bl_params_t *plat_get_next_bl_params(void)
+{
+       int ret;
+       bl_params_t *next_bl_params;
+
+       ret = plat_sgi_append_config_node();
+       if (ret != 0)
+               panic();
+
+       next_bl_params = get_next_bl_params_from_mem_params_desc();
+       populate_next_bl_params_config(next_bl_params);
+
+       return next_bl_params;
+}