Manish Pandey | 270ee15 | 2020-03-16 22:25:40 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # |
Olivier Deprez | 6baf5b8 | 2021-05-14 19:04:40 +0200 | [diff] [blame] | 4 | # Copyright (c) 2020-2022, Arm Limited. All rights reserved. |
Manish Pandey | 270ee15 | 2020-03-16 22:25:40 +0000 | [diff] [blame] | 5 | # |
| 6 | # SPDX-License-Identifier: BSD-3-Clause |
| 7 | # |
| 8 | |
| 9 | # Generate a JSON file which will be fed to TF-A as SPM_LAYOUT_FILE to package |
| 10 | # Secure Partitions as part of FIP. |
Olivier Deprez | 6baf5b8 | 2021-05-14 19:04:40 +0200 | [diff] [blame] | 11 | # Note the script will append the partition to the existing layout file. |
| 12 | # If you wish to only generate a layout file with this partition first run |
| 13 | # "make realclean" to remove the existing file. |
Manish Pandey | 270ee15 | 2020-03-16 22:25:40 +0000 | [diff] [blame] | 14 | |
Daniel Boulby | f6c288e | 2022-07-25 14:07:57 +0100 | [diff] [blame] | 15 | # $1 = Platform built path |
| 16 | # $2.. = List of Secure Partitions |
| 17 | # Output = $1/sp_layout.json |
Manish Pandey | 270ee15 | 2020-03-16 22:25:40 +0000 | [diff] [blame] | 18 | |
Daniel Boulby | f6c288e | 2022-07-25 14:07:57 +0100 | [diff] [blame] | 19 | GENERATED_JSON=$1/sp_layout.json |
| 20 | shift # Shift arguments 1 |
Olivier Deprez | 6baf5b8 | 2021-05-14 19:04:40 +0200 | [diff] [blame] | 21 | |
Daniel Boulby | f6c288e | 2022-07-25 14:07:57 +0100 | [diff] [blame] | 22 | PARTITION_ALREADY_PRESENT=false |
Daniel Boulby | a285826 | 2022-07-05 11:03:37 +0100 | [diff] [blame] | 23 | |
Daniel Boulby | f6c288e | 2022-07-25 14:07:57 +0100 | [diff] [blame] | 24 | CACTUS_PRESENT=false |
| 25 | IVY_PRESENT=false |
| 26 | IVY_SHIM_PRESENT=false |
| 27 | |
| 28 | for target in "$@" |
| 29 | do |
| 30 | case $target in |
| 31 | cactus) |
| 32 | CACTUS_PRESENT=true |
| 33 | ;; |
| 34 | ivy) |
| 35 | IVY_PRESENT=true |
| 36 | ;; |
| 37 | ivy_shim) |
| 38 | IVY_SHIM_PRESENT=true |
| 39 | ;; |
| 40 | *) |
| 41 | echo "Invalid target $target" |
| 42 | exit 1 |
| 43 | ;; |
| 44 | esac |
| 45 | done |
| 46 | |
| 47 | echo -e "{" > $GENERATED_JSON |
Manish Pandey | 270ee15 | 2020-03-16 22:25:40 +0000 | [diff] [blame] | 48 | |
| 49 | # To demonstrate communication between SP's, two cactus S-EL1 instances used. |
Max Shvetsov | 93119e3 | 2020-07-01 14:09:48 +0100 | [diff] [blame] | 50 | # To also test mapping of the RXTX region a third cactus S-EL1 instance is used. |
| 51 | # cactus-primary, cactus-secondary and cactus-tertiary have same binary but |
| 52 | # different partition manifests. |
Daniel Boulby | f6c288e | 2022-07-25 14:07:57 +0100 | [diff] [blame] | 53 | if [ $CACTUS_PRESENT == "true" ]; then |
| 54 | echo -ne "\t\"cactus-primary\" : {\n \ |
J-Alves | 31d8795 | 2022-04-04 12:34:16 +0100 | [diff] [blame] | 55 | \t\"image\": {\n \ |
Daniel Boulby | f6c288e | 2022-07-25 14:07:57 +0100 | [diff] [blame] | 56 | \t\t\"file\": \"cactus.bin\",\n \ |
J-Alves | 31d8795 | 2022-04-04 12:34:16 +0100 | [diff] [blame] | 57 | \t\t\"offset\":\"0x2000\"\n\ |
| 58 | \t},\n \ |
| 59 | \t\"pm\": {\n \ |
Daniel Boulby | f6c288e | 2022-07-25 14:07:57 +0100 | [diff] [blame] | 60 | \t\t\"file\": \"cactus.dts\",\n \ |
J-Alves | 31d8795 | 2022-04-04 12:34:16 +0100 | [diff] [blame] | 61 | \t\t\"offset\":\"0x1000\"\n\ |
| 62 | \t},\n |
Daniel Boulby | f6c288e | 2022-07-25 14:07:57 +0100 | [diff] [blame] | 63 | \t\"owner\": \"SiP\"\n\t},\n\n\t\"cactus-secondary\" : {\n \ |
| 64 | \t\"image\": \"cactus.bin\",\n \ |
| 65 | \t\"pm\": \"cactus-secondary.dts\",\n \ |
| 66 | \t\"owner\": \"Plat\"\n\t},\n\n\t\"cactus-tertiary\" : {\n \ |
| 67 | \t\"image\": \"cactus.bin\",\n \ |
| 68 | \t\"pm\": \"cactus-tertiary.dts\",\n \ |
Olivier Deprez | 6baf5b8 | 2021-05-14 19:04:40 +0200 | [diff] [blame] | 69 | \t\"owner\": \"Plat\"\n\t}" \ |
| 70 | >> "$GENERATED_JSON" |
Daniel Boulby | f6c288e | 2022-07-25 14:07:57 +0100 | [diff] [blame] | 71 | PARTITION_ALREADY_PRESENT=true |
| 72 | fi |
| 73 | if [ $IVY_PRESENT == "true" ]; then |
| 74 | if [ $PARTITION_ALREADY_PRESENT == "true" ]; then |
| 75 | echo -ne ",\n\n" >> $GENERATED_JSON |
| 76 | fi |
| 77 | echo -ne "\t\"ivy\" : {\n \ |
Ruari Phipps | 8747ed2 | 2020-09-01 13:32:17 +0100 | [diff] [blame] | 78 | \t\"image\": \"ivy.bin\",\n \ |
Daniel Boulby | f6c288e | 2022-07-25 14:07:57 +0100 | [diff] [blame] | 79 | \t\"pm\": \"ivy-sel0.dts\",\n \ |
Olivier Deprez | 6baf5b8 | 2021-05-14 19:04:40 +0200 | [diff] [blame] | 80 | \t\"owner\": \"Plat\"\n\t}" >> "$GENERATED_JSON" |
Daniel Boulby | f6c288e | 2022-07-25 14:07:57 +0100 | [diff] [blame] | 81 | PARTITION_ALREADY_PRESENT=true |
| 82 | elif [ $IVY_SHIM_PRESENT == "true" ]; then |
| 83 | if [ $PARTITION_ALREADY_PRESENT == "true" ]; then |
| 84 | echo -ne ",\n\n" >> $GENERATED_JSON |
| 85 | fi |
Daniel Boulby | 427be2a | 2022-08-01 10:57:37 +0100 | [diff] [blame] | 86 | echo -ne "\t\"ivy\" : {\n \ |
Daniel Boulby | f6c288e | 2022-07-25 14:07:57 +0100 | [diff] [blame] | 87 | \t\"image\": \"ivy.bin\",\n \ |
| 88 | \t\"pm\": \"ivy-sel1.dts\",\n \ |
| 89 | \t\"owner\": \"Plat\"\n\t}" >> "$GENERATED_JSON" |
| 90 | PARTITION_ALREADY_PRESENT=true |
Manish Pandey | 270ee15 | 2020-03-16 22:25:40 +0000 | [diff] [blame] | 91 | fi |
Olivier Deprez | 6baf5b8 | 2021-05-14 19:04:40 +0200 | [diff] [blame] | 92 | |
Daniel Boulby | f6c288e | 2022-07-25 14:07:57 +0100 | [diff] [blame] | 93 | echo -e "\n}" >> "$GENERATED_JSON" |