sgi_image_load.c 2.1 KB
Newer Older
1
2
3
4
5
6
/*
 * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

7
#include <arch_helpers.h>
8
9
10
11
#include <debug.h>
#include <desc_image_load.h>
#include <libfdt.h>
#include <platform.h>
12
#include <sgi_variant.h>
13
14
15
16
17

/*******************************************************************************
 * This function inserts Platform information via device tree nodes as,
 * system-id {
 *    platform-id = <0>;
18
 *    config-id = <0>;
19
20
21
22
23
24
25
 * }
 ******************************************************************************/
static int plat_sgi_append_config_node(void)
{
	bl_mem_params_node_t *mem_params;
	void *fdt;
	int nodeoffset, err;
26
	unsigned int platid = 0, platcfg = 0;
27

28
	mem_params = get_bl_mem_params_node(NT_FW_CONFIG_ID);
29
	if (mem_params == NULL) {
30
		ERROR("NT_FW CONFIG base address is NULL");
31
32
33
34
35
36
37
		return -1;
	}

	fdt = (void *)(mem_params->image_info.image_base);

	/* Check the validity of the fdt */
	if (fdt_check_header(fdt) != 0) {
38
		ERROR("Invalid NT_FW_CONFIG DTB passed\n");
39
40
41
		return -1;
	}

42
43
44
	nodeoffset = fdt_subnode_offset(fdt, 0, "system-id");
	if (nodeoffset < 0) {
		ERROR("Failed to get system-id node offset\n");
45
46
47
		return -1;
	}

48
	platid = plat_arm_sgi_get_platform_id();
49
50
51
	err = fdt_setprop_u32(fdt, nodeoffset, "platform-id", platid);
	if (err < 0) {
		ERROR("Failed to set platform-id\n");
52
53
54
		return -1;
	}

55
	platcfg = plat_arm_sgi_get_config_id();
56
	err = fdt_setprop_u32(fdt, nodeoffset, "config-id", platcfg);
57
	if (err < 0) {
58
		ERROR("Failed to set config-id\n");
59
60
		return -1;
	}
61
62
63

	flush_dcache_range((uintptr_t)fdt, mem_params->image_info.image_size);

64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
	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;
}