summaryrefslogtreecommitdiff
path: root/tools/generate_json/generate_json.sh
blob: 9ac13ecdbcfda2ae243d7ab43abd2235bf8cb155 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash

#
# Copyright (c) 2020-2022, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#

# Generate a JSON file which will be fed to TF-A as SPM_LAYOUT_FILE to package
# Secure Partitions as part of FIP.
# Note the script will append the partition to the existing layout file.
# If you wish to only generate a layout file with this partition first run
# "make realclean" to remove the existing file.

# $1 = Platform built path
# $2.. = List of Secure Partitions
# Output = $1/sp_layout.json

GENERATED_JSON=$1/sp_layout.json
shift # Shift arguments 1

PARTITION_ALREADY_PRESENT=false

CACTUS_PRESENT=false
IVY_PRESENT=false
IVY_SHIM_PRESENT=false

for target in "$@"
do
	case $target in
		cactus)
			CACTUS_PRESENT=true
			;;
		ivy)
			IVY_PRESENT=true
			;;
		ivy_shim)
			IVY_SHIM_PRESENT=true
			;;
		*)
			echo "Invalid target $target"
			exit 1
			;;
	esac
done

echo -e "{" > $GENERATED_JSON

# To demonstrate communication between SP's, two cactus S-EL1 instances used.
# To also test mapping of the RXTX region a third cactus S-EL1 instance is used.
# cactus-primary, cactus-secondary and cactus-tertiary have same binary but
# different partition manifests.
if [ $CACTUS_PRESENT == "true" ]; then
	echo -ne "\t\"cactus-primary\" : {\n \
	\t\"image\": {\n \
	\t\t\"file\": \"cactus.bin\",\n \
	\t\t\"offset\":\"0x2000\"\n\
	\t},\n \
	\t\"pm\": {\n \
	\t\t\"file\": \"cactus.dts\",\n \
	\t\t\"offset\":\"0x1000\"\n\
	\t},\n
	\t\"owner\": \"SiP\"\n\t},\n\n\t\"cactus-secondary\" : {\n \
	\t\"image\": \"cactus.bin\",\n \
	\t\"pm\": \"cactus-secondary.dts\",\n \
	\t\"owner\": \"Plat\"\n\t},\n\n\t\"cactus-tertiary\" : {\n \
	\t\"image\": \"cactus.bin\",\n \
	\t\"pm\": \"cactus-tertiary.dts\",\n \
	\t\"owner\": \"Plat\"\n\t}" \
	>> "$GENERATED_JSON"
	PARTITION_ALREADY_PRESENT=true
fi
if [ $IVY_PRESENT == "true" ]; then
	if [ $PARTITION_ALREADY_PRESENT == "true" ]; then
		echo -ne ",\n\n" >> $GENERATED_JSON
	fi
	echo -ne "\t\"ivy\" : {\n \
	\t\"image\": \"ivy.bin\",\n \
	\t\"pm\": \"ivy-sel0.dts\",\n \
	\t\"owner\": \"Plat\"\n\t}" >> "$GENERATED_JSON"
	PARTITION_ALREADY_PRESENT=true
elif [ $IVY_SHIM_PRESENT == "true" ]; then
	if [ $PARTITION_ALREADY_PRESENT == "true" ]; then
		echo -ne ",\n\n" >> $GENERATED_JSON
	fi
	echo -ne "\t\"ivy\" : {\n \
	\t\"image\": \"ivy.bin\",\n \
	\t\"pm\": \"ivy-sel1.dts\",\n \
	\t\"owner\": \"Plat\"\n\t}" >> "$GENERATED_JSON"
	PARTITION_ALREADY_PRESENT=true
fi

echo -e "\n}" >> "$GENERATED_JSON"