Antonio de Angelis | 75024f0 | 2024-11-02 22:46:23 +0000 | [diff] [blame] | 1 | From fb40e180945f17b78cc4c1d95eeb030efc05dcd3 Mon Sep 17 00:00:00 2001 |
Gabor Abonyi | 0a32b4e | 2024-10-25 09:34:08 +0200 | [diff] [blame] | 2 | From: Gabor Abonyi <gabor.abonyi@arm.com> |
| 3 | Date: Thu, 8 Aug 2024 15:44:55 +0200 |
Antonio de Angelis | 75024f0 | 2024-11-02 22:46:23 +0000 | [diff] [blame] | 4 | Subject: [PATCH 5/5] Add rp2350 platform |
Gabor Abonyi | 0a32b4e | 2024-10-25 09:34:08 +0200 | [diff] [blame] | 5 | |
| 6 | Change-Id: I50777e655dfecdac7e4cacecbff8459efa4d7a77 |
| 7 | Signed-off-by: Gabor Abonyi <gabor.abonyi@arm.com> |
| 8 | --- |
Antonio de Angelis | 75024f0 | 2024-11-02 22:46:23 +0000 | [diff] [blame] | 9 | .../drivers/watchdog/rpi/pal_wd_rpi.c | 103 +++++ |
Gabor Abonyi | 0a32b4e | 2024-10-25 09:34:08 +0200 | [diff] [blame] | 10 | .../drivers/watchdog/rpi/pal_wd_rpi.h | 35 ++ |
| 11 | .../nspe/pal_attestation_config.h | 108 +++++ |
| 12 | .../tgt_dev_apis_tfm_rp2350/nspe/pal_config.h | 97 +++++ |
| 13 | .../nspe/pal_crypto_config.h | 404 ++++++++++++++++++ |
| 14 | .../nspe/pal_driver_intf.c | 143 +++++++ |
| 15 | .../nspe/pal_storage_config.h | 24 ++ |
| 16 | .../tgt_dev_apis_tfm_rp2350/target.cfg | 41 ++ |
| 17 | .../tgt_dev_apis_tfm_rp2350/target.cmake | 97 +++++ |
| 18 | .../tgt_ff_tfm_rp2350/nspe/pal_config.h | 71 +++ |
| 19 | .../nspe/pal_driver_ipc_intf.c | 338 +++++++++++++++ |
| 20 | .../tgt_ff_tfm_rp2350/spe/pal_driver_intf.c | 132 ++++++ |
| 21 | .../tgt_ff_tfm_rp2350/spe/pal_driver_intf.h | 35 ++ |
| 22 | .../targets/tgt_ff_tfm_rp2350/target.cfg | 64 +++ |
| 23 | .../targets/tgt_ff_tfm_rp2350/target.cmake | 74 ++++ |
Antonio de Angelis | 75024f0 | 2024-11-02 22:46:23 +0000 | [diff] [blame] | 24 | 15 files changed, 1766 insertions(+) |
Gabor Abonyi | 0a32b4e | 2024-10-25 09:34:08 +0200 | [diff] [blame] | 25 | create mode 100644 api-tests/platform/drivers/watchdog/rpi/pal_wd_rpi.c |
| 26 | create mode 100644 api-tests/platform/drivers/watchdog/rpi/pal_wd_rpi.h |
| 27 | create mode 100644 api-tests/platform/targets/tgt_dev_apis_tfm_rp2350/nspe/pal_attestation_config.h |
| 28 | create mode 100644 api-tests/platform/targets/tgt_dev_apis_tfm_rp2350/nspe/pal_config.h |
| 29 | create mode 100644 api-tests/platform/targets/tgt_dev_apis_tfm_rp2350/nspe/pal_crypto_config.h |
| 30 | create mode 100644 api-tests/platform/targets/tgt_dev_apis_tfm_rp2350/nspe/pal_driver_intf.c |
| 31 | create mode 100644 api-tests/platform/targets/tgt_dev_apis_tfm_rp2350/nspe/pal_storage_config.h |
| 32 | create mode 100644 api-tests/platform/targets/tgt_dev_apis_tfm_rp2350/target.cfg |
| 33 | create mode 100644 api-tests/platform/targets/tgt_dev_apis_tfm_rp2350/target.cmake |
| 34 | create mode 100644 api-tests/platform/targets/tgt_ff_tfm_rp2350/nspe/pal_config.h |
| 35 | create mode 100644 api-tests/platform/targets/tgt_ff_tfm_rp2350/nspe/pal_driver_ipc_intf.c |
| 36 | create mode 100644 api-tests/platform/targets/tgt_ff_tfm_rp2350/spe/pal_driver_intf.c |
| 37 | create mode 100644 api-tests/platform/targets/tgt_ff_tfm_rp2350/spe/pal_driver_intf.h |
| 38 | create mode 100644 api-tests/platform/targets/tgt_ff_tfm_rp2350/target.cfg |
| 39 | create mode 100644 api-tests/platform/targets/tgt_ff_tfm_rp2350/target.cmake |
| 40 | |
| 41 | diff --git a/api-tests/platform/drivers/watchdog/rpi/pal_wd_rpi.c b/api-tests/platform/drivers/watchdog/rpi/pal_wd_rpi.c |
| 42 | new file mode 100644 |
Antonio de Angelis | 75024f0 | 2024-11-02 22:46:23 +0000 | [diff] [blame] | 43 | index 0000000..444480c |
Gabor Abonyi | 0a32b4e | 2024-10-25 09:34:08 +0200 | [diff] [blame] | 44 | --- /dev/null |
| 45 | +++ b/api-tests/platform/drivers/watchdog/rpi/pal_wd_rpi.c |
Antonio de Angelis | 75024f0 | 2024-11-02 22:46:23 +0000 | [diff] [blame] | 46 | @@ -0,0 +1,103 @@ |
Gabor Abonyi | 0a32b4e | 2024-10-25 09:34:08 +0200 | [diff] [blame] | 47 | +/** @file |
| 48 | + * Copyright (c) 2024, Arm Limited or its affiliates. All rights reserved. |
| 49 | + * SPDX-License-Identifier : Apache-2.0 |
| 50 | + * |
| 51 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 52 | + * you may not use this file except in compliance with the License. |
| 53 | + * You may obtain a copy of the License at |
| 54 | + * |
| 55 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 56 | + * |
| 57 | + * Unless required by applicable law or agreed to in writing, software |
| 58 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 59 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 60 | + * See the License for the specific language governing permissions and |
| 61 | + * limitations under the License. |
| 62 | +**/ |
| 63 | + |
| 64 | +#include "pal_wd_rpi.h" |
| 65 | + |
| 66 | + |
| 67 | +#define REG_ALIAS_SET_BITS ((0x2u) << (12u)) |
| 68 | +#define REG_ALIAS_CLR_BITS ((0x3u) << (12u)) |
| 69 | + |
| 70 | +#define SET_ADDR_ALIAS(addr) ((void *)(REG_ALIAS_SET_BITS + (addr))) |
| 71 | +#define CLR_ADDR_ALIAS(addr) ((void *)(REG_ALIAS_CLR_BITS + (addr))) |
| 72 | + |
| 73 | +#define HW_SET_BITS(addr, mask) \ |
| 74 | + do{*(uint32_t *) SET_ADDR_ALIAS((volatile void *) addr) = mask;}while(0) |
| 75 | + |
| 76 | +#define HW_CLEAR_BITS(addr, mask) \ |
| 77 | + do{*(uint32_t *) CLR_ADDR_ALIAS((volatile void *) addr) = mask;}while(0) |
| 78 | + |
| 79 | +/** |
| 80 | + @brief - Initializes an hardware watchdog timer |
| 81 | + @param - base_addr : Base address of the watchdog module |
| 82 | + - time_us : Time in micro seconds |
| 83 | + - timer_tick_us : Number of ticks per micro second |
| 84 | + @return - SUCCESS/FAILURE |
| 85 | +**/ |
| 86 | +int pal_wd_rpi_init(addr_t base_addr, uint32_t time_us, uint32_t timer_tick_us) |
| 87 | +{ |
| 88 | + /* Disable Timer */ |
| 89 | + HW_CLEAR_BITS(&((wd_timer_t *)base_addr)->CTRL, WATCHDOG_CTRL_ENABLE_BITS); |
| 90 | + |
| 91 | + uint32_t dbg_bits = WATCHDOG_CTRL_PAUSE_DBG0_BITS | |
| 92 | + WATCHDOG_CTRL_PAUSE_DBG1_BITS | |
| 93 | + WATCHDOG_CTRL_PAUSE_JTAG_BITS; |
| 94 | + /* Pause on debug */ |
| 95 | + HW_SET_BITS(&((wd_timer_t *)base_addr)->CTRL, dbg_bits); |
| 96 | + |
| 97 | + if (time_us == 0) |
| 98 | + { |
| 99 | + HW_SET_BITS(&((wd_timer_t *)base_addr)->CTRL, WATCHDOG_CTRL_TRIGGER_BITS); |
| 100 | + } |
| 101 | + else |
| 102 | + { |
| 103 | + uint32_t load_value = time_us * timer_tick_us; |
| 104 | + if (load_value > WATCHDOG_LOAD_BITS) |
| 105 | + { |
| 106 | + load_value = WATCHDOG_LOAD_BITS; |
| 107 | + } |
| 108 | + /* Set Load value */ |
| 109 | + ((wd_timer_t *)base_addr)->LOAD = load_value; |
| 110 | + } |
| 111 | + |
| 112 | + return 0; |
| 113 | +} |
| 114 | + |
| 115 | +/** |
| 116 | + @brief - Enables a hardware watchdog timer |
| 117 | + @param - base_addr : Base address of the watchdog module |
| 118 | + @return - SUCCESS/FAILURE |
| 119 | +**/ |
| 120 | +int pal_wd_rpi_enable(addr_t base_addr) |
| 121 | +{ |
| 122 | + /* Enable counter */ |
| 123 | + HW_SET_BITS(&((wd_timer_t *)base_addr)->CTRL, WATCHDOG_CTRL_ENABLE_BITS); |
| 124 | + |
| 125 | + return 0; |
| 126 | +} |
| 127 | + |
| 128 | +/** |
| 129 | + @brief - Disables a hardware watchdog timer |
| 130 | + @param - base_addr : Base address of the watchdog module |
| 131 | + @return - SUCCESS/FAILURE |
| 132 | +**/ |
| 133 | +int pal_wd_rpi_disable(addr_t base_addr) |
| 134 | +{ |
| 135 | + /* Disable Timer */ |
| 136 | + HW_CLEAR_BITS(&((wd_timer_t *)base_addr)->CTRL, WATCHDOG_CTRL_ENABLE_BITS); |
| 137 | + |
| 138 | + return 0; |
| 139 | +} |
| 140 | + |
| 141 | +/** |
| 142 | + @brief - Checks whether hardware watchdog timer is enabled |
| 143 | + @param - base_addr : Base address of the watchdog module |
| 144 | + @return - Enabled : 1, Disabled : 0 |
| 145 | +**/ |
| 146 | +int pal_wd_rpi_is_enabled(addr_t base_addr) |
| 147 | +{ |
| 148 | + return (((wd_timer_t *)base_addr)->CTRL & WATCHDOG_CTRL_ENABLE_BITS ? 1 : 0); |
| 149 | +} |
Gabor Abonyi | 0a32b4e | 2024-10-25 09:34:08 +0200 | [diff] [blame] | 150 | diff --git a/api-tests/platform/drivers/watchdog/rpi/pal_wd_rpi.h b/api-tests/platform/drivers/watchdog/rpi/pal_wd_rpi.h |
| 151 | new file mode 100644 |
| 152 | index 0000000..da2f0b8 |
| 153 | --- /dev/null |
| 154 | +++ b/api-tests/platform/drivers/watchdog/rpi/pal_wd_rpi.h |
| 155 | @@ -0,0 +1,35 @@ |
| 156 | +/** @file |
| 157 | + * Copyright (c) 2024, Arm Limited. All rights reserved. |
| 158 | + * |
| 159 | + * SPDX-License-Identifier: BSD-3-Clause |
| 160 | + * |
| 161 | +**/ |
| 162 | + |
| 163 | +#ifndef _PAL_WD_RPI_H_ |
| 164 | +#define _PAL_WD_RPI_H_ |
| 165 | + |
| 166 | +#include "pal_common.h" |
| 167 | + |
| 168 | +#define WDOG_TIMER_MAX_VALUE 0xFFFFFFFF |
| 169 | + |
| 170 | +typedef struct { |
| 171 | + uint32_t CTRL; /* Offset: 0x000 (R/W) Watchdog Control Register */ |
| 172 | + uint32_t LOAD; /* Offset: 0x004 (R/W) Watchdog Load Register */ |
| 173 | + uint32_t REASON; /* Offset: 0x008 (R/ ) Watchdog Reason Register */ |
| 174 | + uint32_t SCRATCH[8]; /* Offset: 0x00C (R/ ) Watchdog Reason Register */ |
| 175 | +} wd_timer_t; |
| 176 | + |
| 177 | +#define WATCHDOG_CTRL_TRIGGER_BITS (0x80000000) |
| 178 | +#define WATCHDOG_CTRL_ENABLE_BITS (0x40000000) |
| 179 | +#define WATCHDOG_CTRL_PAUSE_DBG1_BITS (0x04000000) |
| 180 | +#define WATCHDOG_CTRL_PAUSE_DBG0_BITS (0x02000000) |
| 181 | +#define WATCHDOG_CTRL_PAUSE_JTAG_BITS (0x01000000) |
| 182 | + |
| 183 | +#define WATCHDOG_LOAD_BITS (0x00ffffff) |
| 184 | + |
| 185 | +int pal_wd_rpi_init(addr_t base_addr, uint32_t time_us, uint32_t timer_tick_us); |
| 186 | +int pal_wd_rpi_enable(addr_t base_addr); |
| 187 | +int pal_wd_rpi_disable(addr_t base_addr); |
| 188 | +int pal_wd_rpi_is_enabled(addr_t base_addr); |
| 189 | + |
| 190 | +#endif /* _PAL_WD_RPI_H_ */ |
| 191 | diff --git a/api-tests/platform/targets/tgt_dev_apis_tfm_rp2350/nspe/pal_attestation_config.h b/api-tests/platform/targets/tgt_dev_apis_tfm_rp2350/nspe/pal_attestation_config.h |
| 192 | new file mode 100644 |
| 193 | index 0000000..0cb190c |
| 194 | --- /dev/null |
| 195 | +++ b/api-tests/platform/targets/tgt_dev_apis_tfm_rp2350/nspe/pal_attestation_config.h |
| 196 | @@ -0,0 +1,108 @@ |
| 197 | +/** @file |
| 198 | + * Copyright (c) 2020-2024, Arm Limited or its affiliates. All rights reserved. |
| 199 | + * SPDX-License-Identifier : Apache-2.0 |
| 200 | + * |
| 201 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 202 | + * you may not use this file except in compliance with the License. |
| 203 | + * You may obtain a copy of the License at |
| 204 | + * |
| 205 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 206 | + * |
| 207 | + * Unless required by applicable law or agreed to in writing, software |
| 208 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 209 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 210 | + * See the License for the specific language governing permissions and |
| 211 | + * limitations under the License. |
| 212 | +**/ |
| 213 | + |
| 214 | +#ifndef _PAL_ATTESTATION_CONFIG_H_ |
| 215 | +#define _PAL_ATTESTATION_CONFIG_H_ |
| 216 | + |
| 217 | +#define COSE_ALGORITHM_ES256 -7 |
| 218 | +#define COSE_ALG_SHA256_PROPRIETARY -72000 |
| 219 | + |
| 220 | +#define USEFUL_BUF_MAKE_STACK_UB UsefulBuf_MAKE_STACK_UB |
| 221 | + |
| 222 | +#define COSE_SIG_CONTEXT_STRING_SIGNATURE1 "Signature1" |
| 223 | + |
| 224 | +/* Private value. Intentionally not documented for Doxygen. |
| 225 | + * This is the size allocated for the encoded protected headers. It |
| 226 | + * needs to be big enough for make_protected_header() to succeed. It |
| 227 | + * currently sized for one header with an algorithm ID up to 32 bits |
| 228 | + * long -- one byte for the wrapping map, one byte for the label, 5 |
| 229 | + * bytes for the ID. If this is made accidentially too small, QCBOR will |
| 230 | + * only return an error, and not overrun any buffers. |
| 231 | + * |
| 232 | + * 9 extra bytes are added, rounding it up to 16 total, in case some |
| 233 | + * other protected header is to be added. |
| 234 | + */ |
| 235 | +#define T_COSE_SIGN1_MAX_PROT_HEADER (1+1+5+9) |
| 236 | + |
| 237 | +/** |
| 238 | + * This is the size of the first part of the CBOR encoded TBS |
| 239 | + * bytes. It is around 20 bytes. See create_tbs_hash(). |
| 240 | + */ |
| 241 | +#define T_COSE_SIZE_OF_TBS \ |
| 242 | + 1 + /* For opening the array */ \ |
| 243 | + sizeof(COSE_SIG_CONTEXT_STRING_SIGNATURE1) + /* "Signature1" */ \ |
| 244 | + 2 + /* Overhead for encoding string */ \ |
| 245 | + T_COSE_SIGN1_MAX_PROT_HEADER + /* entire protected headers */ \ |
| 246 | + 3 * (/* 3 NULL bstrs for fields not used */ \ |
| 247 | + 1 /* size of a NULL bstr */ \ |
| 248 | + ) |
| 249 | +#define NULL_USEFUL_BUF_C NULLUsefulBufC |
| 250 | + |
| 251 | +#define ATTEST_PUBLIC_KEY_SLOT 4 |
| 252 | +#define ECC_CURVE_SECP256R1_PULBIC_KEY_LENGTH (1 + 2 * PSA_BITS_TO_BYTES(256)) |
| 253 | + |
| 254 | +typedef struct { |
| 255 | + uint8_t *pubx_key; |
| 256 | + size_t pubx_key_size; |
| 257 | + uint8_t *puby_key; |
| 258 | + size_t puby_key_size; |
| 259 | +} ecc_key_t; |
| 260 | + |
| 261 | +struct ecc_public_key_t { |
| 262 | + const uint8_t a; |
| 263 | + uint8_t public_key[]; /* X-coordinate || Y-coordinate */ |
| 264 | +}; |
| 265 | + |
| 266 | +static const struct ecc_public_key_t attest_public_key = { |
| 267 | + /* Constant byte */ |
| 268 | + .a = 0x04, |
| 269 | + /* X-coordinate */ |
| 270 | + .public_key = { |
| 271 | + 0x79, 0xEB, 0xA9, 0x0E, 0x8B, 0xF4, 0x50, 0xA6, |
| 272 | + 0x75, 0x15, 0x76, 0xAD, 0x45, 0x99, 0xB0, 0x7A, |
| 273 | + 0xDF, 0x93, 0x8D, 0xA3, 0xBB, 0x0B, 0xD1, 0x7D, |
| 274 | + 0x00, 0x36, 0xED, 0x49, 0xA2, 0xD0, 0xFC, 0x3F, |
| 275 | + /* Y-coordinate */ |
| 276 | + 0xBF, 0xCD, 0xFA, 0x89, 0x56, 0xB5, 0x68, 0xBF, |
| 277 | + 0xDB, 0x86, 0x73, 0xE6, 0x48, 0xD8, 0xB5, 0x8D, |
| 278 | + 0x92, 0x99, 0x55, 0xB1, 0x4A, 0x26, 0xC3, 0x08, |
| 279 | + 0x0F, 0x34, 0x11, 0x7D, 0x97, 0x1D, 0x68, 0x64}, |
| 280 | +}; |
| 281 | + |
| 282 | +static const uint8_t initial_attestation_public_x_key[] = { |
| 283 | + 0x79, 0xEB, 0xA9, 0x0E, 0x8B, 0xF4, 0x50, 0xA6, |
| 284 | + 0x75, 0x15, 0x76, 0xAD, 0x45, 0x99, 0xB0, 0x7A, |
| 285 | + 0xDF, 0x93, 0x8D, 0xA3, 0xBB, 0x0B, 0xD1, 0x7D, |
| 286 | + 0x00, 0x36, 0xED, 0x49, 0xA2, 0xD0, 0xFC, 0x3F |
| 287 | +}; |
| 288 | + |
| 289 | +static const uint8_t initial_attestation_public_y_key[] = { |
| 290 | + 0xBF, 0xCD, 0xFA, 0x89, 0x56, 0xB5, 0x68, 0xBF, |
| 291 | + 0xDB, 0x86, 0x73, 0xE6, 0x48, 0xD8, 0xB5, 0x8D, |
| 292 | + 0x92, 0x99, 0x55, 0xB1, 0x4A, 0x26, 0xC3, 0x08, |
| 293 | + 0x0F, 0x34, 0x11, 0x7D, 0x97, 0x1D, 0x68, 0x64 |
| 294 | +}; |
| 295 | + |
| 296 | +/* Initialize the structure with given public key */ |
| 297 | +static const ecc_key_t attest_key = { |
| 298 | + (uint8_t *)initial_attestation_public_x_key, |
| 299 | + sizeof(initial_attestation_public_x_key), |
| 300 | + (uint8_t *)initial_attestation_public_y_key, |
| 301 | + sizeof(initial_attestation_public_y_key) |
| 302 | +}; |
| 303 | + |
| 304 | +#endif /* _PAL_ATTESTATION_CONFIG_H_ */ |
| 305 | diff --git a/api-tests/platform/targets/tgt_dev_apis_tfm_rp2350/nspe/pal_config.h b/api-tests/platform/targets/tgt_dev_apis_tfm_rp2350/nspe/pal_config.h |
| 306 | new file mode 100644 |
| 307 | index 0000000..f99acf0 |
| 308 | --- /dev/null |
| 309 | +++ b/api-tests/platform/targets/tgt_dev_apis_tfm_rp2350/nspe/pal_config.h |
| 310 | @@ -0,0 +1,97 @@ |
| 311 | +/** @file |
| 312 | + * Copyright (c) 2019-2023, Arm Limited or its affiliates. All rights reserved. |
| 313 | + * SPDX-License-Identifier : Apache-2.0 |
| 314 | + * |
| 315 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 316 | + * you may not use this file except in compliance with the License. |
| 317 | + * You may obtain a copy of the License at |
| 318 | + * |
| 319 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 320 | + * |
| 321 | + * Unless required by applicable law or agreed to in writing, software |
| 322 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 323 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 324 | + * See the License for the specific language governing permissions and |
| 325 | + * limitations under the License. |
| 326 | +**/ |
| 327 | + |
| 328 | +#ifndef _PAL_CONFIG_H_ |
| 329 | +#define _PAL_CONFIG_H_ |
| 330 | + |
| 331 | +#include "pal_crypto_config.h" |
| 332 | +#include "pal_attestation_config.h" |
| 333 | +#include "pal_storage_config.h" |
| 334 | + |
| 335 | +/* Define PSA test suite dependent macros for non-cmake build */ |
| 336 | +#if !defined(PSA_CMAKE_BUILD) |
| 337 | + |
| 338 | +/* Print verbosity = TEST */ |
| 339 | +#define VERBOSE 3 |
| 340 | + |
| 341 | +/* NSPE or SPE VAL build? */ |
| 342 | +#define VAL_NSPE_BUILD |
| 343 | + |
| 344 | +/* NSPE or SPE TEST build? */ |
| 345 | +#define NONSECURE_TEST_BUILD |
| 346 | + |
| 347 | +/* If not defined, skip watchdog programming */ |
| 348 | +#define WATCHDOG_AVAILABLE |
| 349 | + |
| 350 | +/* Are Dynamic memory APIs available to secure partition? */ |
| 351 | +#define SP_HEAP_MEM_SUPP |
| 352 | + |
| 353 | +/* PSA Isolation level supported by platform */ |
| 354 | +#define PLATFORM_PSA_ISOLATION_LEVEL 3 |
| 355 | +#endif /* PSA_CMAKE_BUILD */ |
| 356 | + |
| 357 | +/* Version of crypto spec used in attestation */ |
| 358 | +#define CRYPTO_VERSION_BETA3 |
| 359 | + |
| 360 | +#ifndef PLATFORM_HAS_ATTEST_PK |
| 361 | +/* Use hardcoded public key */ |
| 362 | +#define PLATFORM_OVERRIDE_ATTEST_PK |
| 363 | +#endif |
| 364 | + |
| 365 | +/* |
| 366 | + * Include of PSA defined Header files |
| 367 | + */ |
| 368 | +#ifdef IPC |
| 369 | +/* psa/client.h: Contains the PSA Client API elements */ |
| 370 | +#include "psa/client.h" |
| 371 | + |
| 372 | +/* |
| 373 | + * psa_manifest/sid.h: Macro definitions derived from manifest files that map from RoT Service |
| 374 | + * names to Service IDs (SIDs). Partition manifest parse build tool must provide the implementation |
| 375 | + * of this file. |
| 376 | +*/ |
| 377 | +#include "psa_manifest/sid.h" |
| 378 | + |
| 379 | +/* |
| 380 | + * psa_manifest/pid.h: Secure Partition IDs |
| 381 | + * Macro definitions that map from Secure Partition names to Secure Partition IDs. |
| 382 | + * Partition manifest parse build tool must provide the implementation of this file. |
| 383 | +*/ |
| 384 | +#include "psa_manifest/pid.h" |
| 385 | +#endif |
| 386 | + |
| 387 | +#ifdef CRYPTO |
| 388 | +/* psa/crypto.h: Contains the PSA Crypto API elements */ |
| 389 | +#include "psa/crypto.h" |
| 390 | +#endif |
| 391 | + |
| 392 | +#if defined(INTERNAL_TRUSTED_STORAGE) || defined(STORAGE) |
| 393 | +/* psa/internal_trusted_storage.h: Contains the PSA ITS API elements */ |
| 394 | +#include "psa/internal_trusted_storage.h" |
| 395 | +#endif |
| 396 | + |
| 397 | +#if defined(PROTECTED_STORAGE) || defined(STORAGE) |
| 398 | +/* psa/protected_storage.h: Contains the PSA PS API elements */ |
| 399 | +#include "psa/protected_storage.h" |
| 400 | +#endif |
| 401 | + |
| 402 | +#ifdef INITIAL_ATTESTATION |
| 403 | +/* psa/initial_attestation.h: Contains the PSA Initial Attestation API elements */ |
| 404 | +#include "psa/initial_attestation.h" |
| 405 | +#endif |
| 406 | + |
| 407 | +#endif /* _PAL_CONFIG_H_ */ |
| 408 | diff --git a/api-tests/platform/targets/tgt_dev_apis_tfm_rp2350/nspe/pal_crypto_config.h b/api-tests/platform/targets/tgt_dev_apis_tfm_rp2350/nspe/pal_crypto_config.h |
| 409 | new file mode 100644 |
| 410 | index 0000000..c6da0d7 |
| 411 | --- /dev/null |
| 412 | +++ b/api-tests/platform/targets/tgt_dev_apis_tfm_rp2350/nspe/pal_crypto_config.h |
| 413 | @@ -0,0 +1,404 @@ |
| 414 | +/** @file |
| 415 | + * Copyright (c) 2019-2023, Arm Limited or its affiliates. All rights reserved. |
| 416 | + * SPDX-License-Identifier : Apache-2.0 |
| 417 | + * |
| 418 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 419 | + * you may not use this file except in compliance with the License. |
| 420 | + * You may obtain a copy of the License at |
| 421 | + * |
| 422 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 423 | + * |
| 424 | + * Unless required by applicable law or agreed to in writing, software |
| 425 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 426 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 427 | + * See the License for the specific language governing permissions and |
| 428 | + * limitations under the License. |
| 429 | +**/ |
| 430 | + |
| 431 | +/* |
| 432 | + * \file pal_crypto_config.h |
| 433 | + * |
| 434 | + * \brief Configuration options for crypto tests (set of defines) |
| 435 | + * |
| 436 | + * This set of compile-time options may be used to enable |
| 437 | + * or disable features selectively for crypto test suite |
| 438 | + */ |
| 439 | + |
| 440 | +#ifndef _PAL_CRYPTO_CONFIG_H_ |
| 441 | +#define _PAL_CRYPTO_CONFIG_H_ |
| 442 | +/** |
| 443 | + * \def ARCH_TEST_RSA |
| 444 | + * |
| 445 | + * Enable the RSA public-key cryptosystem. |
| 446 | + * By default all supported keys are enabled. |
| 447 | + * |
| 448 | + * Comment macros to disable the types |
| 449 | + */ |
| 450 | +#ifndef TF_M_PROFILE_SMALL |
| 451 | +#ifndef TF_M_PROFILE_MEDIUM |
| 452 | +#define ARCH_TEST_RSA |
| 453 | +#define ARCH_TEST_RSA_1024 |
| 454 | +#define ARCH_TEST_RSA_2048 |
| 455 | +#define ARCH_TEST_RSA_3072 |
| 456 | +#endif |
| 457 | +#endif |
| 458 | + |
| 459 | +/** |
| 460 | + * \def ARCH_TEST_ECC |
| 461 | + * \def ARCH_TEST_ECC_CURVE_SECPXXXR1 |
| 462 | + * |
| 463 | + * Enable the elliptic curve |
| 464 | + * Enable specific curves within the Elliptic Curve |
| 465 | + * module. By default all supported curves are enabled. |
| 466 | + * |
| 467 | + * Requires: ARCH_TEST_ECC |
| 468 | + * Comment macros to disable the curve |
| 469 | + */ |
| 470 | +#ifndef TF_M_PROFILE_SMALL |
| 471 | +#define ARCH_TEST_ECC |
| 472 | +#define ARCH_TEST_ECC_CURVE_SECP192R1 |
| 473 | +#ifndef TF_M_PROFILE_MEDIUM |
| 474 | +#define ARCH_TEST_ECC_CURVE_SECP224R1 |
| 475 | +#endif |
| 476 | +#define ARCH_TEST_ECC_CURVE_SECP256R1 |
| 477 | +#ifndef TF_M_PROFILE_MEDIUM |
| 478 | +#define ARCH_TEST_ECC_CURVE_SECP384R1 |
| 479 | +#endif |
| 480 | +#endif |
| 481 | +/* curves of size <255 are obsolete algorithms, should be disabled. */ |
| 482 | +#undef ARCH_TEST_ECC_CURVE_SECP192R1 |
| 483 | +#undef ARCH_TEST_ECC_CURVE_SECP224R1 |
| 484 | + |
| 485 | +/** |
| 486 | + * \def ARCH_TEST_AES |
| 487 | + * |
| 488 | + * Enable the AES block cipher. |
| 489 | + * By default all supported keys are enabled. |
| 490 | + * |
| 491 | + * Comment macros to disable the types |
| 492 | + */ |
| 493 | +#define ARCH_TEST_AES |
| 494 | +#define ARCH_TEST_AES_128 |
| 495 | +#define ARCH_TEST_AES_192 |
| 496 | +#define ARCH_TEST_AES_256 |
| 497 | +#define ARCH_TEST_AES_512 |
| 498 | + |
| 499 | +/** |
| 500 | + * \def ARCH_TEST_DES |
| 501 | + * |
| 502 | + * Enable the DES block cipher. |
| 503 | + * By default all supported keys are enabled. |
| 504 | + * |
| 505 | + * Comment macros to disable the types |
| 506 | + */ |
| 507 | +//#define ARCH_TEST_DES |
| 508 | +//#define ARCH_TEST_DES_1KEY |
| 509 | +//#define ARCH_TEST_DES_2KEY |
| 510 | +//#define ARCH_TEST_DES_3KEY |
| 511 | + |
| 512 | +/** |
| 513 | + * \def ARCH_TEST_RAW |
| 514 | + * |
| 515 | + * A "key" of this type cannot be used for any cryptographic operation. |
| 516 | + * Applications may use this type to store arbitrary data in the keystore. |
| 517 | + */ |
| 518 | +#define ARCH_TEST_RAW |
| 519 | + |
| 520 | +/** |
| 521 | + * \def ARCH_TEST_CIPHER |
| 522 | + * |
| 523 | + * Enable the generic cipher layer. |
| 524 | + */ |
| 525 | + |
| 526 | +#define ARCH_TEST_CIPHER |
| 527 | + |
| 528 | +/** |
| 529 | + * \def ARCH_TEST_ARC4 |
| 530 | + * |
| 531 | + * Enable the ARC4 key type. |
| 532 | + */ |
| 533 | +//#define ARCH_TEST_ARC4 |
| 534 | + |
| 535 | +/** |
| 536 | + * \def ARCH_TEST_CIPHER_MODE_CTR |
| 537 | + * |
| 538 | + * Enable Counter Block Cipher mode (CTR) for symmetric ciphers. |
| 539 | + * |
| 540 | + * Requires: ARCH_TEST_CIPHER |
| 541 | + */ |
| 542 | +#ifndef TF_M_PROFILE_SMALL |
| 543 | +#ifndef TF_M_PROFILE_MEDIUM |
| 544 | +#define ARCH_TEST_CIPHER_MODE_CTR |
| 545 | +#endif |
| 546 | +#endif |
| 547 | + |
| 548 | +/** |
| 549 | + * \def ARCH_TEST_CIPHER_MODE_CFB |
| 550 | + * |
| 551 | + * Enable Cipher Feedback mode (CFB) for symmetric ciphers. |
| 552 | + * |
| 553 | + * Requires: ARCH_TEST_CIPHER |
| 554 | + */ |
| 555 | +#define ARCH_TEST_CIPHER_MODE_CFB |
| 556 | + |
| 557 | +/** |
| 558 | + * \def ARCH_TEST_CIPHER_MODE_CBC |
| 559 | + * |
| 560 | + * Enable Cipher Block Chaining mode (CBC) for symmetric ciphers. |
| 561 | + * |
| 562 | + * Requires: ARCH_TEST_CIPHER |
| 563 | + */ |
| 564 | +#define ARCH_TEST_CIPHER_MODE_CBC |
| 565 | + |
| 566 | +/** |
| 567 | + * \def ARCH_TEST_CTR_AES |
| 568 | + * |
| 569 | + * Requires: ARCH_TEST_CIPHER, ARCH_TEST_AES, ARCH_TEST_CIPHER_MODE_CTR |
| 570 | + */ |
| 571 | +#ifndef TF_M_PROFILE_SMALL |
| 572 | +#ifndef TF_M_PROFILE_MEDIUM |
| 573 | +#define ARCH_TEST_CTR_AES |
| 574 | +#endif |
| 575 | +#endif |
| 576 | + |
| 577 | +/** |
| 578 | + * \def ARCH_TEST_CBC_AES |
| 579 | + * |
| 580 | + * Requires: ARCH_TEST_CIPHER, ARCH_TEST_AES, ARCH_TEST_CIPHER_MODE_CBC |
| 581 | + * |
| 582 | + * Comment macros to disable the types |
| 583 | + */ |
| 584 | +#define ARCH_TEST_CBC_AES |
| 585 | +#define ARCH_TEST_CBC_AES_NO_PADDING |
| 586 | + |
| 587 | +/** |
| 588 | + * \def ARCH_TEST_CBC_NO_PADDING |
| 589 | + * |
| 590 | + * Requires: ARCH_TEST_CIPHER, ARCH_TEST_CIPHER_MODE_CBC |
| 591 | + * |
| 592 | + * Comment macros to disable the types |
| 593 | + */ |
| 594 | +#ifndef TF_M_PROFILE_SMALL |
| 595 | +#ifndef TF_M_PROFILE_MEDIUM |
| 596 | +#define ARCH_TEST_CBC_NO_PADDING |
| 597 | +#endif |
| 598 | +#endif |
| 599 | + |
| 600 | +/** |
| 601 | + * \def ARCH_TEST_CFB_AES |
| 602 | + * |
| 603 | + * Requires: ARCH_TEST_CIPHER, ARCH_TEST_AES, ARCH_TEST_CIPHER_MODE_CFB |
| 604 | + */ |
| 605 | +#define ARCH_TEST_CFB_AES |
| 606 | + |
| 607 | +/** |
| 608 | + * \def ARCH_TEST_PKCS1V15_* |
| 609 | + * |
| 610 | + * Enable support for PKCS#1 v1.5 encoding. |
| 611 | + * Enable support for PKCS#1 v1.5 operations. |
| 612 | + * Enable support for RSA-OAEP |
| 613 | + * |
| 614 | + * Requires: ARCH_TEST_RSA, ARCH_TEST_PKCS1V15 |
| 615 | + * |
| 616 | + * Comment macros to disable the types |
| 617 | + */ |
| 618 | +#ifndef TF_M_PROFILE_SMALL |
| 619 | +#ifndef TF_M_PROFILE_MEDIUM |
| 620 | +#define ARCH_TEST_PKCS1V15 |
| 621 | +#define ARCH_TEST_RSA_PKCS1V15_SIGN |
| 622 | +#define ARCH_TEST_RSA_PKCS1V15_SIGN_RAW |
| 623 | +#define ARCH_TEST_RSA_PKCS1V15_CRYPT |
| 624 | +#define ARCH_TEST_RSA_OAEP |
| 625 | +#endif |
| 626 | +#endif |
| 627 | + |
| 628 | +/** |
| 629 | + * \def ARCH_TEST_CBC_PKCS7 |
| 630 | + * |
| 631 | + * Requires: ARCH_TEST_CIPHER_MODE_CBC |
| 632 | + * |
| 633 | + * Comment macros to disable the types |
| 634 | + */ |
| 635 | +#ifndef TF_M_PROFILE_SMALL |
| 636 | +#ifndef TF_M_PROFILE_MEDIUM |
| 637 | +#define ARCH_TEST_CBC_PKCS7 |
| 638 | +#endif |
| 639 | +#endif |
| 640 | + |
| 641 | +/** |
| 642 | + * \def ARCH_TEST_ASYMMETRIC_ENCRYPTION |
| 643 | + * |
| 644 | + * Enable support for Asymmetric encryption algorithms |
| 645 | + */ |
| 646 | +#define ARCH_TEST_ASYMMETRIC_ENCRYPTION |
| 647 | + |
| 648 | +/** |
| 649 | + * \def ARCH_TEST_HASH |
| 650 | + * |
| 651 | + * Enable the hash algorithm. |
| 652 | + */ |
| 653 | +#define ARCH_TEST_HASH |
| 654 | + |
| 655 | +/** |
| 656 | + * \def ARCH_TEST_HMAC |
| 657 | + * |
| 658 | + * The key policy determines which underlying hash algorithm the key can be |
| 659 | + * used for. |
| 660 | + * |
| 661 | + * Requires: ARCH_TEST_HASH |
| 662 | + */ |
| 663 | +#define ARCH_TEST_HMAC |
| 664 | + |
| 665 | +/** |
| 666 | + * \def ARCH_TEST_MDX |
| 667 | + * \def ARCH_TEST_SHAXXX |
| 668 | + * |
| 669 | + * Enable the MDX algorithm. |
| 670 | + * Enable the SHAXXX algorithm. |
| 671 | + * |
| 672 | + * Requires: ARCH_TEST_HASH |
| 673 | + * |
| 674 | + * Comment macros to disable the types |
| 675 | + */ |
| 676 | +//#define ARCH_TEST_MD2 |
| 677 | +//#define ARCH_TEST_MD4 |
| 678 | +//#define ARCH_TEST_MD5 |
| 679 | +//#define ARCH_TEST_RIPEMD160 |
| 680 | +//#define ARCH_TEST_SHA1 |
| 681 | +#ifndef TF_M_PROFILE_SMALL |
| 682 | +#define ARCH_TEST_SHA224 |
| 683 | +#endif |
| 684 | +#define ARCH_TEST_SHA256 |
| 685 | +#ifndef TF_M_PROFILE_SMALL |
| 686 | +#ifndef TF_M_PROFILE_MEDIUM |
| 687 | +#define ARCH_TEST_SHA384 |
| 688 | +#define ARCH_TEST_SHA512 |
| 689 | +#endif |
| 690 | +#endif |
| 691 | +//#define ARCH_TEST_SHA512_224 |
| 692 | +//#define ARCH_TEST_SHA512_256 |
| 693 | +//#define ARCH_TEST_SHA3_224 |
| 694 | +//#define ARCH_TEST_SHA3_256 |
| 695 | +//#define ARCH_TEST_SHA3_384 |
| 696 | +//#define ARCH_TEST_SHA3_512 |
| 697 | + |
| 698 | +/** |
| 699 | + * \def ARCH_TEST_HKDF |
| 700 | + * |
| 701 | + * Enable the HKDF algorithm (RFC 5869). |
| 702 | + * |
| 703 | + * Requires: ARCH_TEST_HASH |
| 704 | +*/ |
| 705 | +#define ARCH_TEST_HKDF |
| 706 | + |
| 707 | +/** |
| 708 | + * \def ARCH_TEST_TLS12_PRF |
| 709 | + * |
| 710 | + * Enable the TLS-1.2 PRF algorithm (RFC 5246). |
| 711 | + * |
| 712 | + * Requires: ARCH_TEST_HASH |
| 713 | +*/ |
| 714 | +#define ARCH_TEST_TLS12_PRF |
| 715 | + |
| 716 | +/** |
| 717 | + * \def ARCH_TEST_xMAC |
| 718 | + * |
| 719 | + * Enable the xMAC (Cipher/Hash/G-based Message Authentication Code) mode for block |
| 720 | + * ciphers. |
| 721 | + * Requires: ARCH_TEST_AES or ARCH_TEST_DES |
| 722 | + * |
| 723 | + * Comment macros to disable the types |
| 724 | + */ |
| 725 | +#ifndef TF_M_PROFILE_SMALL |
| 726 | +#ifndef TF_M_PROFILE_MEDIUM |
| 727 | +#define ARCH_TEST_CMAC |
| 728 | +#endif |
| 729 | +#endif |
| 730 | +//#define ARCH_TEST_GMAC |
| 731 | +#define ARCH_TEST_HMAC |
| 732 | + |
| 733 | +/** |
| 734 | + * \def ARCH_TEST_CCM |
| 735 | + * |
| 736 | + * Enable the Counter with CBC-MAC (CCM) mode for 128-bit block cipher. |
| 737 | + * |
| 738 | + * Requires: ARCH_TEST_AES |
| 739 | + */ |
| 740 | +#define ARCH_TEST_CCM |
| 741 | + |
| 742 | +/** |
| 743 | + * \def ARCH_TEST_GCM |
| 744 | + * |
| 745 | + * Enable the Galois/Counter Mode (GCM) for AES. |
| 746 | + * |
| 747 | + * Requires: ARCH_TEST_AES |
| 748 | + * |
| 749 | + */ |
| 750 | +#ifndef TF_M_PROFILE_SMALL |
| 751 | +#ifndef TF_M_PROFILE_MEDIUM |
| 752 | +#define ARCH_TEST_GCM |
| 753 | +#endif |
| 754 | +#endif |
| 755 | + |
| 756 | +/** |
| 757 | + * \def ARCH_TEST_TRUNCATED_MAC |
| 758 | + * |
| 759 | + * Enable support for RFC 6066 truncated HMAC in SSL. |
| 760 | + * |
| 761 | + * Comment this macro to disable support for truncated HMAC in SSL |
| 762 | + */ |
| 763 | +#define ARCH_TEST_TRUNCATED_MAC |
| 764 | + |
| 765 | + |
| 766 | +/** |
| 767 | + * \def ARCH_TEST_ECDH |
| 768 | + * |
| 769 | + * Enable the elliptic curve Diffie-Hellman library. |
| 770 | + * |
| 771 | + * Requires: ARCH_TEST_ECC |
| 772 | + */ |
| 773 | +#ifndef TF_M_PROFILE_SMALL |
| 774 | +#define ARCH_TEST_ECDH |
| 775 | +#endif |
| 776 | + |
| 777 | +/** |
| 778 | + * \def ARCH_TEST_ECDSA |
| 779 | + * |
| 780 | + * Enable the elliptic curve DSA library. |
| 781 | + * Requires: ARCH_TEST_ECC |
| 782 | + */ |
| 783 | +#ifndef TF_M_PROFILE_SMALL |
| 784 | +#define ARCH_TEST_ECDSA |
| 785 | +#endif |
| 786 | + |
| 787 | +/** |
| 788 | + * \def ARCH_TEST_DETERMINISTIC_ECDSA |
| 789 | + * |
| 790 | + * Enable deterministic ECDSA (RFC 6979). |
| 791 | +*/ |
| 792 | +#define ARCH_TEST_DETERMINISTIC_ECDSA |
| 793 | + |
| 794 | +/** |
| 795 | + * \def ARCH_TEST_ECC_ASYMMETRIC_API_SUPPORT |
| 796 | + * |
| 797 | + * Enable ECC support for asymmetric API. |
| 798 | +*/ |
| 799 | +//#define ARCH_TEST_ECC_ASYMMETRIC_API_SUPPORT |
| 800 | + |
| 801 | +/** |
| 802 | + * \def ARCH_TEST_HASH_SUSPEND |
| 803 | + * |
| 804 | + * Enable has suspend. |
| 805 | +*/ |
| 806 | +//#define ARCH_TEST_HASH_SUSPEND |
| 807 | + |
| 808 | +/** |
| 809 | + * \def ARCH_TEST_HASH_RESUME |
| 810 | + * |
| 811 | + * Enable has resume. |
| 812 | +*/ |
| 813 | +//#define ARCH_TEST_HASH_RESUME |
| 814 | + |
| 815 | +#include "pal_crypto_config_check.h" |
| 816 | + |
| 817 | +#endif /* _PAL_CRYPTO_CONFIG_H_ */ |
| 818 | diff --git a/api-tests/platform/targets/tgt_dev_apis_tfm_rp2350/nspe/pal_driver_intf.c b/api-tests/platform/targets/tgt_dev_apis_tfm_rp2350/nspe/pal_driver_intf.c |
| 819 | new file mode 100644 |
| 820 | index 0000000..217d7d7 |
| 821 | --- /dev/null |
| 822 | +++ b/api-tests/platform/targets/tgt_dev_apis_tfm_rp2350/nspe/pal_driver_intf.c |
| 823 | @@ -0,0 +1,143 @@ |
| 824 | +/** @file |
| 825 | + * Copyright (c) 2019-2024, Arm Limited or its affiliates. All rights reserved. |
| 826 | + * SPDX-License-Identifier : Apache-2.0 |
| 827 | + * |
| 828 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 829 | + * you may not use this file except in compliance with the License. |
| 830 | + * You may obtain a copy of the License at |
| 831 | + * |
| 832 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 833 | + * |
| 834 | + * Unless required by applicable law or agreed to in writing, software |
| 835 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 836 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 837 | + * See the License for the specific language governing permissions and |
| 838 | + * limitations under the License. |
| 839 | +**/ |
| 840 | + |
| 841 | +#include "pal_common.h" |
| 842 | +#include "pal_uart.h" |
| 843 | +#include "pal_nvmem.h" |
| 844 | +#include "pal_wd_rpi.h" |
| 845 | + |
| 846 | +/** |
| 847 | + @brief - This function initializes the UART |
| 848 | + @param - uart base addr |
| 849 | + @return - SUCCESS/FAILURE |
| 850 | +**/ |
| 851 | +int pal_uart_init_ns(uint32_t uart_base_addr) |
| 852 | +{ |
| 853 | + pal_uart_pl011_init(uart_base_addr); |
| 854 | + return PAL_STATUS_SUCCESS; |
| 855 | +} |
| 856 | + |
| 857 | +/** |
| 858 | + @brief - This function parses the input string and writes bytes into UART TX FIFO |
| 859 | + @param - str : Input String |
| 860 | + - data : Value for format specifier |
| 861 | + @return - SUCCESS/FAILURE |
| 862 | +**/ |
| 863 | + |
| 864 | +int pal_print_ns(const char *str, int32_t data) |
| 865 | +{ |
| 866 | + pal_uart_pl011_print(str, data); |
| 867 | + return PAL_STATUS_SUCCESS; |
| 868 | +} |
| 869 | + |
| 870 | +/** |
| 871 | + @brief - Initializes an hardware watchdog timer |
| 872 | + @param - base_addr : Base address of the watchdog module |
| 873 | + - time_us : Time in micro seconds |
| 874 | + - timer_tick_us : Number of ticks per micro second |
| 875 | + @return - SUCCESS/FAILURE |
| 876 | +**/ |
| 877 | +int pal_wd_timer_init_ns(addr_t base_addr, uint32_t time_us, uint32_t timer_tick_us) |
| 878 | +{ |
| 879 | + return(pal_wd_rpi_init(base_addr,time_us, timer_tick_us)); |
| 880 | +} |
| 881 | + |
| 882 | +/** |
| 883 | + @brief - Enables a hardware watchdog timer |
| 884 | + @param - base_addr : Base address of the watchdog module |
| 885 | + @return - SUCCESS/FAILURE |
| 886 | +**/ |
| 887 | +int pal_wd_timer_enable_ns(addr_t base_addr) |
| 888 | +{ |
| 889 | + return(pal_wd_rpi_enable(base_addr)); |
| 890 | +} |
| 891 | + |
| 892 | +/** |
| 893 | + @brief - Disables a hardware watchdog timer |
| 894 | + @param - base_addr : Base address of the watchdog module |
| 895 | + @return - SUCCESS/FAILURE |
| 896 | +**/ |
| 897 | +int pal_wd_timer_disable_ns(addr_t base_addr) |
| 898 | +{ |
| 899 | + return (pal_wd_rpi_disable(base_addr)); |
| 900 | +} |
| 901 | + |
| 902 | +/** |
| 903 | + @brief - Reads from given non-volatile address. |
| 904 | + @param - base : Base address of nvmem |
| 905 | + offset : Offset |
| 906 | + buffer : Pointer to source address |
| 907 | + size : Number of bytes |
| 908 | + @return - SUCCESS/FAILURE |
| 909 | +**/ |
| 910 | +int pal_nvmem_read_ns(addr_t base, uint32_t offset, void *buffer, int size) |
| 911 | +{ |
| 912 | + if (nvmem_read(base, offset, buffer, size)) |
| 913 | + { |
| 914 | + return PAL_STATUS_SUCCESS; |
| 915 | + } |
| 916 | + else |
| 917 | + { |
| 918 | + return PAL_STATUS_ERROR; |
| 919 | + } |
| 920 | +} |
| 921 | + |
| 922 | +/** |
| 923 | + @brief - Writes into given non-volatile address. |
| 924 | + @param - base : Base address of nvmem |
| 925 | + offset : Offset |
| 926 | + buffer : Pointer to source address |
| 927 | + size : Number of bytes |
| 928 | + @return - SUCCESS/FAILURE |
| 929 | +**/ |
| 930 | +int pal_nvmem_write_ns(addr_t base, uint32_t offset, void *buffer, int size) |
| 931 | +{ |
| 932 | + if (nvmem_write(base, offset, buffer, size)) |
| 933 | + { |
| 934 | + return PAL_STATUS_SUCCESS; |
| 935 | + } |
| 936 | + else |
| 937 | + { |
| 938 | + return PAL_STATUS_ERROR; |
| 939 | + } |
| 940 | +} |
| 941 | + |
| 942 | +/** |
| 943 | + * @brief - Terminates the simulation at the end of all tests completion. |
| 944 | + * By default, it put cpus into power down mode. |
| 945 | + * @param - void |
| 946 | + * @return - void |
| 947 | +**/ |
| 948 | +void pal_terminate_simulation(void) |
| 949 | +{ |
| 950 | + /* Add logic to terminate the simluation */ |
| 951 | + |
| 952 | + while(1) |
| 953 | + { |
| 954 | + __asm volatile("WFI"); |
| 955 | + } |
| 956 | +} |
| 957 | + |
| 958 | +/** |
| 959 | + * @brief - Resets the system. |
| 960 | + * @param - void |
| 961 | + * @return - SUCCESS/FAILURE |
| 962 | +**/ |
| 963 | +int pal_system_reset(void) |
| 964 | +{ |
| 965 | + return PAL_STATUS_UNSUPPORTED_FUNC; |
| 966 | +} |
| 967 | diff --git a/api-tests/platform/targets/tgt_dev_apis_tfm_rp2350/nspe/pal_storage_config.h b/api-tests/platform/targets/tgt_dev_apis_tfm_rp2350/nspe/pal_storage_config.h |
| 968 | new file mode 100644 |
| 969 | index 0000000..bbb3741 |
| 970 | --- /dev/null |
| 971 | +++ b/api-tests/platform/targets/tgt_dev_apis_tfm_rp2350/nspe/pal_storage_config.h |
| 972 | @@ -0,0 +1,24 @@ |
| 973 | +/** @file |
| 974 | + * Copyright (c) 2020, Arm Limited or its affiliates. All rights reserved. |
| 975 | + * SPDX-License-Identifier : Apache-2.0 |
| 976 | + * |
| 977 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 978 | + * you may not use this file except in compliance with the License. |
| 979 | + * You may obtain a copy of the License at |
| 980 | + * |
| 981 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 982 | + * |
| 983 | + * Unless required by applicable law or agreed to in writing, software |
| 984 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 985 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 986 | + * See the License for the specific language governing permissions and |
| 987 | + * limitations under the License. |
| 988 | +**/ |
| 989 | + |
| 990 | +#ifndef _PAL_STORAGE_CONFIG_H_ |
| 991 | +#define _PAL_STORAGE_CONFIG_H_ |
| 992 | + |
| 993 | +/* Platform specific max UID's size */ |
| 994 | +#define ARCH_TEST_STORAGE_UID_MAX_SIZE 512 |
| 995 | + |
| 996 | +#endif /* _PAL_STORAGE_CONFIG_H_ */ |
| 997 | diff --git a/api-tests/platform/targets/tgt_dev_apis_tfm_rp2350/target.cfg b/api-tests/platform/targets/tgt_dev_apis_tfm_rp2350/target.cfg |
| 998 | new file mode 100644 |
| 999 | index 0000000..3cacc7c |
| 1000 | --- /dev/null |
| 1001 | +++ b/api-tests/platform/targets/tgt_dev_apis_tfm_rp2350/target.cfg |
| 1002 | @@ -0,0 +1,41 @@ |
| 1003 | +///** @file |
| 1004 | +// * Copyright (c) 2019-2024, Arm Limited or its affiliates. All rights reserved. |
| 1005 | +// * SPDX-License-Identifier : Apache-2.0 |
| 1006 | +// * |
| 1007 | +// * Licensed under the Apache License, Version 2.0 (the "License"); |
| 1008 | +// * you may not use this file except in compliance with the License. |
| 1009 | +// * You may obtain a copy of the License at |
| 1010 | +// * |
| 1011 | +// * http://www.apache.org/licenses/LICENSE-2.0 |
| 1012 | +// * |
| 1013 | +// * Unless required by applicable law or agreed to in writing, software |
| 1014 | +// * distributed under the License is distributed on an "AS IS" BASIS, |
| 1015 | +// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 1016 | +// * See the License for the specific language governing permissions and |
| 1017 | +// * limitations under the License. |
| 1018 | +//**/ |
| 1019 | + |
| 1020 | +// UART device info |
| 1021 | +uart.num=1; |
| 1022 | +uart.0.base = 0x40070000; // UART0_NS |
| 1023 | +uart.0.size = 0x3FFF; |
| 1024 | +uart.0.intr_id = 0xFF; |
| 1025 | +uart.0.permission = TYPE_READ_WRITE; |
| 1026 | + |
| 1027 | +// Watchdog device info |
| 1028 | +watchdog.num = 1; |
| 1029 | +watchdog.0.base = 0x400d8000; |
| 1030 | +watchdog.0.size = 0x3FFF; |
| 1031 | +watchdog.0.intr_id = 0xFF; |
| 1032 | +watchdog.0.permission = TYPE_READ_WRITE; |
| 1033 | +watchdog.0.num_of_tick_per_micro_sec = 0x1; |
| 1034 | +watchdog.0.timeout_in_micro_sec_low = 0xF4240; //1.0 sec : 1 * 1000 * 1000 |
| 1035 | +watchdog.0.timeout_in_micro_sec_medium = 0x1E8480; //2.0 sec : 2 * 1000 * 1000 |
| 1036 | +watchdog.0.timeout_in_micro_sec_high = 0x895440; //9.0 sec : 9 * 1000 * 1000 |
| 1037 | +watchdog.0.timeout_in_micro_sec_crypto = 0xFFFFFF; //~16.7 sec : MAX supported |
| 1038 | + |
| 1039 | +// Range of 1KB Non-volatile memory to preserve data over reset. Ex, NVRAM and FLASH |
| 1040 | +nvmem.num =1; |
| 1041 | +nvmem.0.start = 0x2005EC00; |
| 1042 | +nvmem.0.end = 0x2005EFFF; |
| 1043 | +nvmem.0.permission = TYPE_READ_WRITE; |
| 1044 | diff --git a/api-tests/platform/targets/tgt_dev_apis_tfm_rp2350/target.cmake b/api-tests/platform/targets/tgt_dev_apis_tfm_rp2350/target.cmake |
| 1045 | new file mode 100644 |
| 1046 | index 0000000..0f591eb |
| 1047 | --- /dev/null |
| 1048 | +++ b/api-tests/platform/targets/tgt_dev_apis_tfm_rp2350/target.cmake |
| 1049 | @@ -0,0 +1,97 @@ |
| 1050 | +#/** @file |
| 1051 | +# * Copyright (c) 2019-2024, Arm Limited or its affiliates. All rights reserved. |
| 1052 | +# * SPDX-License-Identifier : Apache-2.0 |
| 1053 | +# * |
| 1054 | +# * Licensed under the Apache License, Version 2.0 (the "License"); |
| 1055 | +# * you may not use this file except in compliance with the License. |
| 1056 | +# * You may obtain a copy of the License at |
| 1057 | +# * |
| 1058 | +# * http://www.apache.org/licenses/LICENSE-2.0 |
| 1059 | +# * |
| 1060 | +# * Unless required by applicable law or agreed to in writing, software |
| 1061 | +# * distributed under the License is distributed on an "AS IS" BASIS, |
| 1062 | +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 1063 | +# * See the License for the specific language governing permissions and |
| 1064 | +# * limitations under the License. |
| 1065 | +#**/ |
| 1066 | + |
| 1067 | +# PAL C source files part of NSPE library |
| 1068 | +list(APPEND PAL_SRC_C_NSPE ) |
| 1069 | + |
| 1070 | +# PAL ASM source files part of NSPE library |
| 1071 | +list(APPEND PAL_SRC_ASM_NSPE ) |
| 1072 | + |
| 1073 | +# PAL C source files part of SPE library - driver partition |
| 1074 | +list(APPEND PAL_SRC_C_DRIVER_SP ) |
| 1075 | + |
| 1076 | +# PAL ASM source files part of SPE library - driver partition |
| 1077 | +list(APPEND PAL_SRC_ASM_DRIVER_SP ) |
| 1078 | + |
| 1079 | +# Listing all the sources required for given target |
| 1080 | +if(${SUITE} STREQUAL "IPC") |
| 1081 | + message(FATAL_ERROR "IPC not supported") |
| 1082 | +else() |
| 1083 | + list(APPEND PAL_SRC_C_NSPE |
| 1084 | + # driver files will be compiled as part of NSPE |
| 1085 | + ${PSA_ROOT_DIR}/platform/targets/${TARGET}/nspe/pal_driver_intf.c |
| 1086 | + ${PSA_ROOT_DIR}/platform/drivers/nvmem/pal_nvmem.c |
| 1087 | + ${PSA_ROOT_DIR}/platform/drivers/uart/pl011/pal_uart.c |
| 1088 | + ${PSA_ROOT_DIR}/platform/drivers/watchdog/rpi/pal_wd_rpi.c |
| 1089 | + ) |
| 1090 | +endif() |
| 1091 | + |
| 1092 | +if(${SUITE} STREQUAL "CRYPTO") |
| 1093 | + list(APPEND PAL_SRC_C_NSPE |
| 1094 | + ${PSA_ROOT_DIR}/platform/targets/common/nspe/crypto/pal_crypto_intf.c |
| 1095 | + ) |
| 1096 | +endif() |
| 1097 | +if((${SUITE} STREQUAL "PROTECTED_STORAGE") OR (${SUITE} STREQUAL "STORAGE")) |
| 1098 | + list(APPEND PAL_SRC_C_NSPE |
| 1099 | + ${PSA_ROOT_DIR}/platform/targets/common/nspe/protected_storage/pal_protected_storage_intf.c |
| 1100 | + ) |
| 1101 | +endif() |
| 1102 | +if((${SUITE} STREQUAL "INTERNAL_TRUSTED_STORAGE") OR (${SUITE} STREQUAL "STORAGE")) |
| 1103 | + list(APPEND PAL_SRC_C_NSPE |
| 1104 | + ${PSA_ROOT_DIR}/platform/targets/common/nspe/internal_trusted_storage/pal_internal_trusted_storage_intf.c |
| 1105 | + ) |
| 1106 | +endif() |
| 1107 | +if(${SUITE} STREQUAL "INITIAL_ATTESTATION") |
| 1108 | + list(APPEND PAL_SRC_C_NSPE |
| 1109 | + ${PSA_ROOT_DIR}/platform/targets/common/nspe/initial_attestation/pal_attestation_intf.c |
| 1110 | + ${PSA_ROOT_DIR}/platform/targets/common/nspe/initial_attestation/pal_attestation_crypto.c |
| 1111 | + ${PSA_TARGET_QCBOR}/src/UsefulBuf.c |
| 1112 | + ${PSA_TARGET_QCBOR}/src/ieee754.c |
| 1113 | + ${PSA_TARGET_QCBOR}/src/qcbor_decode.c |
| 1114 | + ${PSA_TARGET_QCBOR}/src/qcbor_encode.c |
| 1115 | + ) |
| 1116 | +endif() |
| 1117 | + |
| 1118 | +# Create NSPE library |
| 1119 | +add_library(${PSA_TARGET_PAL_NSPE_LIB} STATIC ${PAL_SRC_C_NSPE} ${PAL_SRC_ASM_NSPE}) |
| 1120 | + |
| 1121 | +# PSA Include directories |
| 1122 | +foreach(psa_inc_path ${PSA_INCLUDE_PATHS}) |
| 1123 | + target_include_directories(${PSA_TARGET_PAL_NSPE_LIB} PRIVATE ${psa_inc_path}) |
| 1124 | +endforeach() |
| 1125 | + |
| 1126 | +list(APPEND PAL_DRIVER_INCLUDE_PATHS |
| 1127 | + ${PSA_ROOT_DIR}/platform/drivers/nvmem |
| 1128 | + ${PSA_ROOT_DIR}/platform/drivers/uart/pl011 |
| 1129 | + ${PSA_ROOT_DIR}/platform/drivers/watchdog/rpi |
| 1130 | +) |
| 1131 | + |
| 1132 | +target_include_directories(${PSA_TARGET_PAL_NSPE_LIB} PRIVATE |
| 1133 | + ${PAL_DRIVER_INCLUDE_PATHS} |
| 1134 | + ${PSA_ROOT_DIR}/platform/targets/common/nspe |
| 1135 | + ${PSA_ROOT_DIR}/platform/targets/common/nspe/crypto |
| 1136 | + ${PSA_ROOT_DIR}/platform/targets/common/nspe/protected_storage |
| 1137 | + ${PSA_ROOT_DIR}/platform/targets/common/nspe/internal_trusted_storage |
| 1138 | + ${PSA_ROOT_DIR}/platform/targets/common/nspe/initial_attestation |
| 1139 | + ${PSA_ROOT_DIR}/platform/targets/${TARGET}/nspe |
| 1140 | +) |
| 1141 | + |
| 1142 | +if(${SUITE} STREQUAL "INITIAL_ATTESTATION") |
| 1143 | +target_include_directories(${PSA_TARGET_PAL_NSPE_LIB} PRIVATE |
| 1144 | + ${PSA_QCBOR_INCLUDE_PATH} |
| 1145 | +) |
| 1146 | +endif() |
| 1147 | diff --git a/api-tests/platform/targets/tgt_ff_tfm_rp2350/nspe/pal_config.h b/api-tests/platform/targets/tgt_ff_tfm_rp2350/nspe/pal_config.h |
| 1148 | new file mode 100644 |
| 1149 | index 0000000..e5578d9 |
| 1150 | --- /dev/null |
| 1151 | +++ b/api-tests/platform/targets/tgt_ff_tfm_rp2350/nspe/pal_config.h |
| 1152 | @@ -0,0 +1,71 @@ |
| 1153 | +/** @file |
| 1154 | + * Copyright (c) 2019-2021, Arm Limited or its affiliates. All rights reserved. |
| 1155 | + * SPDX-License-Identifier : Apache-2.0 |
| 1156 | + * |
| 1157 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 1158 | + * you may not use this file except in compliance with the License. |
| 1159 | + * You may obtain a copy of the License at |
| 1160 | + * |
| 1161 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 1162 | + * |
| 1163 | + * Unless required by applicable law or agreed to in writing, software |
| 1164 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 1165 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 1166 | + * See the License for the specific language governing permissions and |
| 1167 | + * limitations under the License. |
| 1168 | +**/ |
| 1169 | + |
| 1170 | +#ifndef _PAL_CONFIG_H_ |
| 1171 | +#define _PAL_CONFIG_H_ |
| 1172 | + |
| 1173 | +/* Define PSA test suite dependent macros for non-cmake build */ |
| 1174 | +#if !defined(PSA_CMAKE_BUILD) |
| 1175 | + |
| 1176 | +/* Print verbosity = TEST */ |
| 1177 | +#define VERBOSE 3 |
| 1178 | + |
| 1179 | +/* NSPE or SPE VAL build? */ |
| 1180 | +#define VAL_NSPE_BUILD |
| 1181 | + |
| 1182 | +/* NSPE or SPE TEST build? */ |
| 1183 | +#define NONSECURE_TEST_BUILD |
| 1184 | + |
| 1185 | +/* If not defined, skip watchdog programming */ |
| 1186 | +#define WATCHDOG_AVAILABLE |
| 1187 | + |
| 1188 | +/* Are Dynamic memory APIs available to secure partition? */ |
| 1189 | +#define SP_HEAP_MEM_SUPP |
| 1190 | + |
| 1191 | +/* PSA Isolation level supported by platform */ |
| 1192 | +#define PLATFORM_PSA_ISOLATION_LEVEL 3 |
| 1193 | +#endif /* PSA_CMAKE_BUILD */ |
| 1194 | + |
| 1195 | +/* Version of crypto spec used in attestation */ |
| 1196 | +#define CRYPTO_VERSION_BETA3 |
| 1197 | + |
| 1198 | +/* Use hardcoded public key */ |
| 1199 | +#define PLATFORM_OVERRIDE_ATTEST_PK |
| 1200 | + |
| 1201 | +/* |
| 1202 | + * Include of PSA defined Header files |
| 1203 | + */ |
| 1204 | +#ifdef IPC |
| 1205 | +/* psa/client.h: Contains the PSA Client API elements */ |
| 1206 | +#include "psa/client.h" |
| 1207 | + |
| 1208 | +/* |
| 1209 | + * psa_manifest/sid.h: Macro definitions derived from manifest files that map from RoT Service |
| 1210 | + * names to Service IDs (SIDs). Partition manifest parse build tool must provide the implementation |
| 1211 | + * of this file. |
| 1212 | +*/ |
| 1213 | +#include "psa_manifest/sid.h" |
| 1214 | + |
| 1215 | +/* |
| 1216 | + * psa_manifest/pid.h: Secure Partition IDs |
| 1217 | + * Macro definitions that map from Secure Partition names to Secure Partition IDs. |
| 1218 | + * Partition manifest parse build tool must provide the implementation of this file. |
| 1219 | +*/ |
| 1220 | +#include "psa_manifest/pid.h" |
| 1221 | +#endif |
| 1222 | + |
| 1223 | +#endif /* _PAL_CONFIG_H_ */ |
| 1224 | diff --git a/api-tests/platform/targets/tgt_ff_tfm_rp2350/nspe/pal_driver_ipc_intf.c b/api-tests/platform/targets/tgt_ff_tfm_rp2350/nspe/pal_driver_ipc_intf.c |
| 1225 | new file mode 100644 |
Antonio de Angelis | 75024f0 | 2024-11-02 22:46:23 +0000 | [diff] [blame] | 1226 | index 0000000..f2d819f |
Gabor Abonyi | 0a32b4e | 2024-10-25 09:34:08 +0200 | [diff] [blame] | 1227 | --- /dev/null |
| 1228 | +++ b/api-tests/platform/targets/tgt_ff_tfm_rp2350/nspe/pal_driver_ipc_intf.c |
| 1229 | @@ -0,0 +1,338 @@ |
| 1230 | +/** @file |
| 1231 | + * Copyright (c) 2019-2021, Arm Limited or its affiliates. All rights reserved. |
| 1232 | + * SPDX-License-Identifier : Apache-2.0 |
| 1233 | + * |
| 1234 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 1235 | + * you may not use this file except in compliance with the License. |
| 1236 | + * You may obtain a copy of the License at |
| 1237 | + * |
| 1238 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 1239 | + * |
| 1240 | + * Unless required by applicable law or agreed to in writing, software |
| 1241 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 1242 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 1243 | + * See the License for the specific language governing permissions and |
| 1244 | + * limitations under the License. |
| 1245 | +**/ |
| 1246 | + |
| 1247 | +#include "pal_common.h" |
| 1248 | + |
| 1249 | +/** |
| 1250 | + @brief - This function initializes the UART |
| 1251 | + @param - uart base addr |
| 1252 | + @return - SUCCESS/FAILURE |
| 1253 | +**/ |
| 1254 | +int pal_uart_init_ns(uint32_t uart_base_addr) |
| 1255 | +{ |
| 1256 | + psa_status_t status_of_call = PSA_SUCCESS; |
| 1257 | + uart_fn_type_t uart_fn = UART_INIT; |
| 1258 | + |
| 1259 | + psa_invec data[3] = {{&uart_fn, sizeof(uart_fn)}, |
| 1260 | + {&uart_base_addr, sizeof(uart_base_addr)}, |
| 1261 | + {NULL, 0}}; |
| 1262 | + |
| 1263 | +#if STATELESS_ROT == 1 |
| 1264 | + status_of_call = psa_call(DRIVER_UART_HANDLE, 0, data, 3, NULL, 0); |
| 1265 | + if (status_of_call != PSA_SUCCESS) |
Antonio de Angelis | 75024f0 | 2024-11-02 22:46:23 +0000 | [diff] [blame] | 1266 | + return PAL_STATUS_ERROR; |
Gabor Abonyi | 0a32b4e | 2024-10-25 09:34:08 +0200 | [diff] [blame] | 1267 | + |
| 1268 | + return PAL_STATUS_SUCCESS; |
| 1269 | +#else |
| 1270 | + psa_handle_t print_handle = 0; |
| 1271 | + print_handle = psa_connect(DRIVER_UART_SID, DRIVER_UART_VERSION); |
| 1272 | + if (PSA_HANDLE_IS_VALID(print_handle)) |
| 1273 | + { |
Antonio de Angelis | 75024f0 | 2024-11-02 22:46:23 +0000 | [diff] [blame] | 1274 | + status_of_call = psa_call(print_handle, 0, data, 3, NULL, 0); |
| 1275 | + psa_close(print_handle); |
| 1276 | + if (status_of_call != PSA_SUCCESS) |
| 1277 | + return PAL_STATUS_ERROR; |
Gabor Abonyi | 0a32b4e | 2024-10-25 09:34:08 +0200 | [diff] [blame] | 1278 | + |
| 1279 | + return PAL_STATUS_SUCCESS; |
| 1280 | + } |
| 1281 | + else |
| 1282 | + { |
| 1283 | + return PAL_STATUS_ERROR; |
| 1284 | + } |
| 1285 | +#endif |
| 1286 | +} |
| 1287 | + |
| 1288 | +/** |
| 1289 | + @brief - This function parses the input string and writes bytes into UART TX FIFO |
| 1290 | + @param - str : Input String |
| 1291 | + - data : Value for format specifier |
| 1292 | + @return - SUCCESS/FAILURE |
| 1293 | +**/ |
| 1294 | + |
| 1295 | +int pal_print_ns(const char *str, int32_t data) |
| 1296 | +{ |
| 1297 | + int string_len = 0; |
| 1298 | + const char *p = str; |
| 1299 | + psa_status_t status_of_call = PSA_SUCCESS; |
| 1300 | + uart_fn_type_t uart_fn = UART_PRINT; |
| 1301 | + |
| 1302 | + while (*p != '\0') |
| 1303 | + { |
| 1304 | + string_len++; |
| 1305 | + p++; |
| 1306 | + } |
| 1307 | + |
| 1308 | + psa_invec data1[3] = {{&uart_fn, sizeof(uart_fn)}, |
| 1309 | + {str, string_len+1}, |
| 1310 | + {&data, sizeof(data)}}; |
| 1311 | +#if STATELESS_ROT == 1 |
| 1312 | + status_of_call = psa_call(DRIVER_UART_HANDLE, 0, data1, 3, NULL, 0); |
| 1313 | + if (status_of_call != PSA_SUCCESS) |
Antonio de Angelis | 75024f0 | 2024-11-02 22:46:23 +0000 | [diff] [blame] | 1314 | + return PAL_STATUS_ERROR; |
Gabor Abonyi | 0a32b4e | 2024-10-25 09:34:08 +0200 | [diff] [blame] | 1315 | + |
| 1316 | + return PAL_STATUS_SUCCESS; |
| 1317 | +#else |
| 1318 | + psa_handle_t print_handle = 0; |
| 1319 | + print_handle = psa_connect(DRIVER_UART_SID, DRIVER_UART_VERSION); |
| 1320 | + if (PSA_HANDLE_IS_VALID(print_handle)) |
| 1321 | + { |
| 1322 | + status_of_call = psa_call(print_handle, 0, data1, 3, NULL, 0); |
| 1323 | + psa_close(print_handle); |
| 1324 | + if (status_of_call != PSA_SUCCESS) |
| 1325 | + return PAL_STATUS_ERROR; |
| 1326 | + |
| 1327 | + return PAL_STATUS_SUCCESS; |
| 1328 | + } |
| 1329 | + else |
| 1330 | + { |
| 1331 | + return PAL_STATUS_ERROR; |
| 1332 | + } |
| 1333 | +#endif |
| 1334 | +} |
| 1335 | + |
| 1336 | +/** |
| 1337 | + @brief - Initializes an hardware watchdog timer |
| 1338 | + @param - base_addr : Base address of the watchdog module |
| 1339 | + - time_us : Time in micro seconds |
| 1340 | + - timer_tick_us : Number of ticks per micro second |
| 1341 | + @return - SUCCESS/FAILURE |
| 1342 | +**/ |
| 1343 | +int pal_wd_timer_init_ns(addr_t base_addr, uint32_t time_us, uint32_t timer_tick_us) |
| 1344 | +{ |
| 1345 | + wd_param_t wd_param; |
| 1346 | + psa_status_t status_of_call = PSA_SUCCESS; |
| 1347 | + |
| 1348 | + wd_param.wd_fn_type = WD_INIT_SEQ; |
| 1349 | + wd_param.wd_base_addr = base_addr; |
| 1350 | + wd_param.wd_time_us = time_us; |
| 1351 | + wd_param.wd_timer_tick_us = timer_tick_us; |
| 1352 | + psa_invec invec[1] = {{&wd_param, sizeof(wd_param)}}; |
| 1353 | + |
| 1354 | +#if STATELESS_ROT == 1 |
| 1355 | + status_of_call = psa_call(DRIVER_WATCHDOG_HANDLE, 0, invec, 1, NULL, 0); |
| 1356 | + if (status_of_call != PSA_SUCCESS) |
Antonio de Angelis | 75024f0 | 2024-11-02 22:46:23 +0000 | [diff] [blame] | 1357 | + return PAL_STATUS_ERROR; |
Gabor Abonyi | 0a32b4e | 2024-10-25 09:34:08 +0200 | [diff] [blame] | 1358 | + |
| 1359 | + return PAL_STATUS_SUCCESS; |
| 1360 | +#else |
| 1361 | + |
| 1362 | + psa_handle_t handle = 0; |
| 1363 | + handle = psa_connect(DRIVER_WATCHDOG_SID, DRIVER_WATCHDOG_VERSION); |
| 1364 | + if (PSA_HANDLE_IS_VALID(handle)) |
| 1365 | + { |
| 1366 | + status_of_call = psa_call(handle, 0, invec, 1, NULL, 0); |
| 1367 | + psa_close(handle); |
| 1368 | + if (status_of_call != PSA_SUCCESS) |
| 1369 | + return PAL_STATUS_ERROR; |
| 1370 | + |
| 1371 | + return PAL_STATUS_SUCCESS; |
| 1372 | + } |
| 1373 | + else |
| 1374 | + { |
| 1375 | + return PAL_STATUS_ERROR; |
| 1376 | + } |
| 1377 | +#endif |
| 1378 | + |
| 1379 | +} |
| 1380 | + |
| 1381 | +/** |
| 1382 | + @brief - Enables a hardware watchdog timer |
| 1383 | + @param - base_addr : Base address of the watchdog module |
| 1384 | + @return - SUCCESS/FAILURE |
| 1385 | +**/ |
| 1386 | +int pal_wd_timer_enable_ns(addr_t base_addr) |
| 1387 | +{ |
| 1388 | + wd_param_t wd_param; |
| 1389 | + psa_status_t status_of_call = PSA_SUCCESS; |
| 1390 | + |
| 1391 | + wd_param.wd_fn_type = WD_ENABLE_SEQ; |
| 1392 | + wd_param.wd_base_addr = base_addr; |
| 1393 | + wd_param.wd_time_us = 0; |
| 1394 | + wd_param.wd_timer_tick_us = 0; |
| 1395 | + psa_invec invec[1] = {{&wd_param, sizeof(wd_param)}}; |
| 1396 | + |
| 1397 | +#if STATELESS_ROT == 1 |
| 1398 | + status_of_call = psa_call(DRIVER_WATCHDOG_HANDLE, 0, invec, 1, NULL, 0); |
| 1399 | + if (status_of_call != PSA_SUCCESS) |
Antonio de Angelis | 75024f0 | 2024-11-02 22:46:23 +0000 | [diff] [blame] | 1400 | + return PAL_STATUS_ERROR; |
Gabor Abonyi | 0a32b4e | 2024-10-25 09:34:08 +0200 | [diff] [blame] | 1401 | + |
| 1402 | + return PAL_STATUS_SUCCESS; |
| 1403 | +#else |
| 1404 | + psa_handle_t handle = 0; |
| 1405 | + handle = psa_connect(DRIVER_WATCHDOG_SID, DRIVER_WATCHDOG_VERSION); |
| 1406 | + if (PSA_HANDLE_IS_VALID(handle)) |
| 1407 | + { |
| 1408 | + status_of_call = psa_call(handle, 0, invec, 1, NULL, 0); |
| 1409 | + psa_close(handle); |
| 1410 | + if (status_of_call != PSA_SUCCESS) |
| 1411 | + return PAL_STATUS_ERROR; |
| 1412 | + |
| 1413 | + return PAL_STATUS_SUCCESS; |
| 1414 | + } |
| 1415 | + else |
| 1416 | + { |
| 1417 | + return PAL_STATUS_ERROR; |
| 1418 | + } |
| 1419 | +#endif |
| 1420 | +} |
| 1421 | + |
| 1422 | +/** |
| 1423 | + @brief - Disables a hardware watchdog timer |
| 1424 | + @param - base_addr : Base address of the watchdog module |
| 1425 | + @return - SUCCESS/FAILURE |
| 1426 | +**/ |
| 1427 | +int pal_wd_timer_disable_ns(addr_t base_addr) |
| 1428 | +{ |
| 1429 | + wd_param_t wd_param; |
| 1430 | + psa_status_t status_of_call = PSA_SUCCESS; |
| 1431 | + |
| 1432 | + wd_param.wd_fn_type = WD_DISABLE_SEQ; |
| 1433 | + wd_param.wd_base_addr = base_addr; |
| 1434 | + wd_param.wd_time_us = 0; |
| 1435 | + wd_param.wd_timer_tick_us = 0; |
| 1436 | + psa_invec invec[1] = {{&wd_param, sizeof(wd_param)}}; |
| 1437 | +#if STATELESS_ROT == 1 |
| 1438 | + status_of_call = psa_call(DRIVER_WATCHDOG_HANDLE, 0, invec, 1, NULL, 0); |
| 1439 | + if (status_of_call != PSA_SUCCESS) |
Antonio de Angelis | 75024f0 | 2024-11-02 22:46:23 +0000 | [diff] [blame] | 1440 | + return PAL_STATUS_ERROR; |
Gabor Abonyi | 0a32b4e | 2024-10-25 09:34:08 +0200 | [diff] [blame] | 1441 | + |
| 1442 | + return PAL_STATUS_SUCCESS; |
| 1443 | +#else |
| 1444 | + psa_handle_t handle = 0; |
| 1445 | + |
| 1446 | + handle = psa_connect(DRIVER_WATCHDOG_SID, DRIVER_WATCHDOG_VERSION); |
| 1447 | + if (PSA_HANDLE_IS_VALID(handle)) |
| 1448 | + { |
| 1449 | + status_of_call = psa_call(handle, 0, invec, 1, NULL, 0); |
| 1450 | + psa_close(handle); |
| 1451 | + if (status_of_call != PSA_SUCCESS) |
| 1452 | + return PAL_STATUS_ERROR; |
| 1453 | + |
| 1454 | + return PAL_STATUS_SUCCESS; |
| 1455 | + } |
| 1456 | + else |
| 1457 | + { |
| 1458 | + return PAL_STATUS_ERROR; |
| 1459 | + } |
| 1460 | +#endif |
| 1461 | + |
| 1462 | +} |
| 1463 | + |
| 1464 | +/** |
| 1465 | + @brief - Reads from given non-volatile address. |
| 1466 | + @param - base : Base address of nvmem |
| 1467 | + offset : Offset |
| 1468 | + buffer : Pointer to source address |
| 1469 | + size : Number of bytes |
| 1470 | + @return - SUCCESS/FAILURE |
| 1471 | +**/ |
| 1472 | +int pal_nvmem_read_ns(addr_t base, uint32_t offset, void *buffer, int size) |
| 1473 | +{ |
| 1474 | + nvmem_param_t nvmem_param; |
| 1475 | + psa_status_t status_of_call = PSA_SUCCESS; |
| 1476 | + |
| 1477 | + nvmem_param.nvmem_fn_type = NVMEM_READ; |
| 1478 | + nvmem_param.base = base; |
| 1479 | + nvmem_param.offset = offset; |
| 1480 | + nvmem_param.size = size; |
| 1481 | + psa_invec invec[1] = {{&nvmem_param, sizeof(nvmem_param)}}; |
| 1482 | + psa_outvec outvec[1] = {{buffer, size}}; |
| 1483 | +#if STATELESS_ROT == 1 |
| 1484 | + status_of_call = psa_call(DRIVER_NVMEM_HANDLE, 0, invec, 1, outvec, 1); |
| 1485 | + if (status_of_call != PSA_SUCCESS) |
Antonio de Angelis | 75024f0 | 2024-11-02 22:46:23 +0000 | [diff] [blame] | 1486 | + return PAL_STATUS_ERROR; |
Gabor Abonyi | 0a32b4e | 2024-10-25 09:34:08 +0200 | [diff] [blame] | 1487 | + |
| 1488 | + return PAL_STATUS_SUCCESS; |
| 1489 | +#else |
| 1490 | + psa_handle_t handle = 0; |
| 1491 | + handle = psa_connect(DRIVER_NVMEM_SID, DRIVER_NVMEM_VERSION); |
| 1492 | + if (PSA_HANDLE_IS_VALID(handle)) |
| 1493 | + { |
| 1494 | + status_of_call = psa_call(handle, 0, invec, 1, outvec, 1); |
| 1495 | + psa_close(handle); |
| 1496 | + if (status_of_call != PSA_SUCCESS) |
| 1497 | + return PAL_STATUS_ERROR; |
| 1498 | + |
| 1499 | + return PAL_STATUS_SUCCESS; |
| 1500 | + } |
| 1501 | + else |
| 1502 | + { |
| 1503 | + return PAL_STATUS_ERROR; |
| 1504 | + } |
| 1505 | +#endif |
| 1506 | + |
| 1507 | +} |
| 1508 | + |
| 1509 | +/** |
| 1510 | + @brief - Writes into given non-volatile address. |
| 1511 | + @param - base : Base address of nvmem |
| 1512 | + offset : Offset |
| 1513 | + buffer : Pointer to source address |
| 1514 | + size : Number of bytes |
| 1515 | + @return - SUCCESS/FAILURE |
| 1516 | +**/ |
| 1517 | +int pal_nvmem_write_ns(addr_t base, uint32_t offset, void *buffer, int size) |
| 1518 | +{ |
| 1519 | + nvmem_param_t nvmem_param; |
| 1520 | + |
| 1521 | + psa_status_t status_of_call = PSA_SUCCESS; |
| 1522 | + |
| 1523 | + nvmem_param.nvmem_fn_type = NVMEM_WRITE; |
| 1524 | + nvmem_param.base = base; |
| 1525 | + nvmem_param.offset = offset; |
| 1526 | + nvmem_param.size = size; |
| 1527 | + psa_invec invec[2] = {{&nvmem_param, sizeof(nvmem_param)}, {buffer, size}}; |
| 1528 | +#if STATELESS_ROT == 1 |
| 1529 | + status_of_call = psa_call(DRIVER_NVMEM_HANDLE, 0, invec, 2, NULL, 0); |
| 1530 | + if (status_of_call != PSA_SUCCESS) |
Antonio de Angelis | 75024f0 | 2024-11-02 22:46:23 +0000 | [diff] [blame] | 1531 | + return PAL_STATUS_ERROR; |
Gabor Abonyi | 0a32b4e | 2024-10-25 09:34:08 +0200 | [diff] [blame] | 1532 | + |
| 1533 | + return PAL_STATUS_SUCCESS; |
| 1534 | +#else |
| 1535 | + psa_handle_t handle = 0; |
| 1536 | + handle = psa_connect(DRIVER_NVMEM_SID, DRIVER_NVMEM_VERSION); |
| 1537 | + if (PSA_HANDLE_IS_VALID(handle)) |
| 1538 | + { |
| 1539 | + status_of_call = psa_call(handle, 0, invec, 2, NULL, 0); |
| 1540 | + psa_close(handle); |
| 1541 | + if (status_of_call != PSA_SUCCESS) |
| 1542 | + return PAL_STATUS_ERROR; |
| 1543 | + |
| 1544 | + return PAL_STATUS_SUCCESS; |
| 1545 | + } |
| 1546 | + else |
| 1547 | + { |
| 1548 | + return PAL_STATUS_ERROR; |
| 1549 | + } |
| 1550 | +#endif |
| 1551 | +} |
| 1552 | + |
| 1553 | +/** |
| 1554 | + * @brief - Terminates the simulation at the end of all tests completion. |
| 1555 | + * By default, it put cpus into power down mode. |
| 1556 | + * @param - void |
| 1557 | + * @return - void |
| 1558 | +**/ |
| 1559 | +void pal_terminate_simulation(void) |
| 1560 | +{ |
| 1561 | + /* Add logic to terminate the simluation */ |
| 1562 | + |
| 1563 | + while(1) |
| 1564 | + { |
| 1565 | + __asm volatile("WFI"); |
| 1566 | + } |
| 1567 | +} |
| 1568 | diff --git a/api-tests/platform/targets/tgt_ff_tfm_rp2350/spe/pal_driver_intf.c b/api-tests/platform/targets/tgt_ff_tfm_rp2350/spe/pal_driver_intf.c |
| 1569 | new file mode 100644 |
| 1570 | index 0000000..093b7d2 |
| 1571 | --- /dev/null |
| 1572 | +++ b/api-tests/platform/targets/tgt_ff_tfm_rp2350/spe/pal_driver_intf.c |
| 1573 | @@ -0,0 +1,132 @@ |
| 1574 | + /** @file |
| 1575 | + * Copyright (c) 2019-2024, Arm Limited or its affiliates. All rights reserved. |
| 1576 | + * SPDX-License-Identifier : Apache-2.0 |
| 1577 | + * |
| 1578 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 1579 | + * you may not use this file except in compliance with the License. |
| 1580 | + * You may obtain a copy of the License at |
| 1581 | + * |
| 1582 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 1583 | + * |
| 1584 | + * Unless required by applicable law or agreed to in writing, software |
| 1585 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 1586 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 1587 | + * See the License for the specific language governing permissions and |
| 1588 | + * limitations under the License. |
| 1589 | + **/ |
| 1590 | + |
| 1591 | +#include "pal_driver_intf.h" |
| 1592 | + |
| 1593 | +/** |
| 1594 | + @brief - This function initializes the UART |
| 1595 | + @param - uart base addr |
| 1596 | + @return - void |
| 1597 | +**/ |
| 1598 | +void pal_uart_init(uint32_t uart_base_addr) |
| 1599 | +{ |
| 1600 | + pal_uart_pl011_init(uart_base_addr); |
| 1601 | +} |
| 1602 | + |
| 1603 | +/** |
| 1604 | + @brief - This function parses the input string and writes bytes into UART TX FIFO |
| 1605 | + @param - str : Input String |
| 1606 | + - data : Value for format specifier |
| 1607 | +**/ |
| 1608 | + |
| 1609 | +void pal_print(const char *str, int32_t data) |
| 1610 | +{ |
| 1611 | + pal_uart_pl011_print(str,data); |
| 1612 | + |
| 1613 | +} |
| 1614 | + |
| 1615 | + |
| 1616 | +/** |
| 1617 | + @brief - Writes into given non-volatile address. |
| 1618 | + @param - base : Base address of nvmem |
| 1619 | + offset : Offset |
| 1620 | + buffer : Pointer to source address |
| 1621 | + size : Number of bytes |
| 1622 | + @return - 1/0 |
| 1623 | +**/ |
| 1624 | +int pal_nvmem_write(addr_t base, uint32_t offset, void *buffer, int size) |
| 1625 | +{ |
| 1626 | + return nvmem_write(base, offset, buffer, size); |
| 1627 | +} |
| 1628 | + |
| 1629 | +/** |
| 1630 | + @brief - Reads from given non-volatile address. |
| 1631 | + @param - base : Base address of nvmem |
| 1632 | + offset : Offset |
| 1633 | + buffer : Pointer to source address |
| 1634 | + size : Number of bytes |
| 1635 | + @return - 1/0 |
| 1636 | +**/ |
| 1637 | +int pal_nvmem_read(addr_t base, uint32_t offset, void *buffer, int size) |
| 1638 | +{ |
| 1639 | + return nvmem_read(base, offset, buffer, size); |
| 1640 | +} |
| 1641 | + |
| 1642 | + |
| 1643 | +/** |
| 1644 | + @brief - Initializes an hardware watchdog timer |
| 1645 | + @param - base_addr : Base address of the watchdog module |
| 1646 | + - time_us : Time in micro seconds |
| 1647 | + - timer_tick_us : Number of ticks per micro second |
| 1648 | + @return - SUCCESS/FAILURE |
| 1649 | +**/ |
| 1650 | +int pal_wd_timer_init(addr_t base_addr, uint32_t time_us, uint32_t timer_tick_us) |
| 1651 | +{ |
| 1652 | + return(pal_wd_rpi_init(base_addr,time_us, timer_tick_us)); |
| 1653 | + |
| 1654 | +} |
| 1655 | + |
| 1656 | +/** |
| 1657 | + @brief - Enables a hardware watchdog timer |
| 1658 | + @param - base_addr : Base address of the watchdog module |
| 1659 | + @return - SUCCESS/FAILURE |
| 1660 | +**/ |
| 1661 | +int pal_wd_timer_enable(addr_t base_addr) |
| 1662 | +{ |
| 1663 | + return(pal_wd_rpi_enable(base_addr)); |
| 1664 | +} |
| 1665 | + |
| 1666 | +/** |
| 1667 | + @brief - Disables a hardware watchdog timer |
| 1668 | + @param - base_addr : Base address of the watchdog module |
| 1669 | + @return - SUCCESS/FAILURE |
| 1670 | +**/ |
| 1671 | +int pal_wd_timer_disable(addr_t base_addr) |
| 1672 | +{ |
| 1673 | + return (pal_wd_rpi_disable(base_addr)); |
| 1674 | +} |
| 1675 | + |
| 1676 | +/** |
| 1677 | + @brief - Checks whether hardware watchdog timer is enabled |
| 1678 | + @param - base_addr : Base address of the watchdog module |
| 1679 | + @return - Enabled : 1, Disabled : 0 |
| 1680 | +**/ |
| 1681 | +int pal_wd_timer_is_enabled(addr_t base_addr) |
| 1682 | +{ |
| 1683 | + return (pal_wd_rpi_is_enabled(base_addr)); |
| 1684 | +} |
| 1685 | + |
| 1686 | +/** |
| 1687 | + @brief - Trigger interrupt for irq signal assigned to driver partition |
| 1688 | + before return to caller. |
| 1689 | + @param - void |
| 1690 | + @return - void |
| 1691 | +**/ |
| 1692 | +void pal_generate_interrupt(void) |
| 1693 | +{ |
| 1694 | + pal_uart_pl011_generate_irq(); |
| 1695 | +} |
| 1696 | + |
| 1697 | +/** |
| 1698 | + @brief - Disable interrupt that was generated using pal_generate_interrupt API. |
| 1699 | + @param - void |
| 1700 | + @return - void |
| 1701 | +**/ |
| 1702 | +void pal_disable_interrupt(void) |
| 1703 | +{ |
| 1704 | + pal_uart_pl011_disable_irq(); |
| 1705 | +} |
| 1706 | diff --git a/api-tests/platform/targets/tgt_ff_tfm_rp2350/spe/pal_driver_intf.h b/api-tests/platform/targets/tgt_ff_tfm_rp2350/spe/pal_driver_intf.h |
| 1707 | new file mode 100644 |
| 1708 | index 0000000..adbdb4c |
| 1709 | --- /dev/null |
| 1710 | +++ b/api-tests/platform/targets/tgt_ff_tfm_rp2350/spe/pal_driver_intf.h |
| 1711 | @@ -0,0 +1,35 @@ |
| 1712 | + /** @file |
| 1713 | + * Copyright (c) 2019-2024, Arm Limited or its affiliates. All rights reserved. |
| 1714 | + * SPDX-License-Identifier : Apache-2.0 |
| 1715 | + * |
| 1716 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 1717 | + * you may not use this file except in compliance with the License. |
| 1718 | + * You may obtain a copy of the License at |
| 1719 | + * |
| 1720 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 1721 | + * |
| 1722 | + * Unless required by applicable law or agreed to in writing, software |
| 1723 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 1724 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 1725 | + * See the License for the specific language governing permissions and |
| 1726 | + * limitations under the License. |
| 1727 | + **/ |
| 1728 | + |
| 1729 | +#ifndef _PAL_DRIVER_INTF_H_ |
| 1730 | +#define _PAL_DRIVER_INTF_H_ |
| 1731 | + |
| 1732 | +#include "pal_uart.h" |
| 1733 | +#include "pal_nvmem.h" |
| 1734 | +#include "pal_wd_rpi.h" |
| 1735 | + |
| 1736 | +void pal_uart_init(uint32_t uart_base_addr); |
| 1737 | +void pal_print(const char *str, int32_t data); |
| 1738 | +int pal_nvmem_write(addr_t base, uint32_t offset, void *buffer, int size); |
| 1739 | +int pal_nvmem_read(addr_t base, uint32_t offset, void *buffer, int size); |
| 1740 | +int pal_wd_timer_init(addr_t base_addr, uint32_t time_us, uint32_t timer_tick_us); |
| 1741 | +int pal_wd_timer_enable(addr_t base_addr); |
| 1742 | +int pal_wd_timer_disable(addr_t base_addr); |
| 1743 | +int pal_wd_timer_is_enabled(addr_t base_addr); |
| 1744 | +void pal_generate_interrupt(void); |
| 1745 | +void pal_disable_interrupt(void); |
| 1746 | +#endif /* _PAL_DRIVER_INTF_H_ */ |
| 1747 | diff --git a/api-tests/platform/targets/tgt_ff_tfm_rp2350/target.cfg b/api-tests/platform/targets/tgt_ff_tfm_rp2350/target.cfg |
| 1748 | new file mode 100644 |
| 1749 | index 0000000..fa04f8a |
| 1750 | --- /dev/null |
| 1751 | +++ b/api-tests/platform/targets/tgt_ff_tfm_rp2350/target.cfg |
| 1752 | @@ -0,0 +1,64 @@ |
| 1753 | +///** @file |
| 1754 | +// * Copyright (c) 2019-2024, Arm Limited or its affiliates. All rights reserved. |
| 1755 | +// * SPDX-License-Identifier : Apache-2.0 |
| 1756 | +// * |
| 1757 | +// * Licensed under the Apache License, Version 2.0 (the "License"); |
| 1758 | +// * you may not use this file except in compliance with the License. |
| 1759 | +// * You may obtain a copy of the License at |
| 1760 | +// * |
| 1761 | +// * http://www.apache.org/licenses/LICENSE-2.0 |
| 1762 | +// * |
| 1763 | +// * Unless required by applicable law or agreed to in writing, software |
| 1764 | +// * distributed under the License is distributed on an "AS IS" BASIS, |
| 1765 | +// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 1766 | +// * See the License for the specific language governing permissions and |
| 1767 | +// * limitations under the License. |
| 1768 | +//**/ |
| 1769 | + |
| 1770 | +// UART device info |
| 1771 | +uart.num=1; |
| 1772 | +uart.0.base = 0x40070000; // UART0_NS |
| 1773 | +uart.0.size = 0x3FFF; |
| 1774 | +uart.0.intr_id = 0xFF; |
| 1775 | +uart.0.permission = TYPE_READ_WRITE; |
| 1776 | + |
| 1777 | +// Watchdog device info |
| 1778 | +watchdog.num = 1; |
| 1779 | +watchdog.0.base = 0x400d8000; |
| 1780 | +watchdog.0.size = 0x3FFF; |
| 1781 | +watchdog.0.intr_id = 0xFF; |
| 1782 | +watchdog.0.permission = TYPE_READ_WRITE; |
| 1783 | +watchdog.0.num_of_tick_per_micro_sec = 0x1; |
| 1784 | +watchdog.0.timeout_in_micro_sec_low = 0xF4240; //1.0 sec : 1 * 1000 * 1000 |
| 1785 | +watchdog.0.timeout_in_micro_sec_medium = 0x1E8480; //2.0 sec : 2 * 1000 * 1000 |
| 1786 | +watchdog.0.timeout_in_micro_sec_high = 0x895440; //9.0 sec : 9 * 1000 * 1000 |
| 1787 | +watchdog.0.timeout_in_micro_sec_crypto = 0xFFFFFF; //~16.7 sec : MAX supported |
| 1788 | + |
| 1789 | +// Range of 1KB Non-volatile memory to preserve data over reset. Ex, NVRAM and FLASH |
| 1790 | +nvmem.num =1; |
| 1791 | +nvmem.0.start = 0x2005EC00; |
| 1792 | +nvmem.0.end = 0x2005EFFF; |
| 1793 | +nvmem.0.permission = TYPE_READ_WRITE; |
| 1794 | + |
| 1795 | +// ################################################################### |
| 1796 | +// Following Target configuration parameters are required for IPC tests |
| 1797 | +// only. Avoid updating them if you are running dev_apis tests. |
| 1798 | +// ################################################################### |
| 1799 | + |
| 1800 | +// Assign free memory range for isolation testing. Choose the addresses |
| 1801 | +// for these memory regions such that it follows below condition: |
| 1802 | +// nspe_mmio.0.start < server_partition_mmio.0.start < driver_partition_mmio.0.start. |
| 1803 | +nspe_mmio.num=1; |
| 1804 | +nspe_mmio.0.start = 0x2005E000; |
| 1805 | +nspe_mmio.0.end = 0x2005E3FF; |
| 1806 | +nspe_mmio.0.permission = TYPE_READ_WRITE; |
| 1807 | + |
| 1808 | +server_partition_mmio.num=1; |
| 1809 | +server_partition_mmio.0.start = 0x2005E400; |
| 1810 | +server_partition_mmio.0.end = 0x2005E4FF; |
| 1811 | +server_partition_mmio.0.permission = TYPE_READ_WRITE; |
| 1812 | + |
| 1813 | +driver_partition_mmio.num=1; |
| 1814 | +driver_partition_mmio.0.start = 0x2005E600; |
| 1815 | +driver_partition_mmio.0.end = 0x2005E6FF; |
| 1816 | +driver_partition_mmio.0.permission = TYPE_READ_WRITE; |
| 1817 | diff --git a/api-tests/platform/targets/tgt_ff_tfm_rp2350/target.cmake b/api-tests/platform/targets/tgt_ff_tfm_rp2350/target.cmake |
| 1818 | new file mode 100644 |
| 1819 | index 0000000..7f64359 |
| 1820 | --- /dev/null |
| 1821 | +++ b/api-tests/platform/targets/tgt_ff_tfm_rp2350/target.cmake |
| 1822 | @@ -0,0 +1,74 @@ |
| 1823 | +#/** @file |
| 1824 | +# * Copyright (c) 2019-2024, Arm Limited or its affiliates. All rights reserved. |
| 1825 | +# * SPDX-License-Identifier : Apache-2.0 |
| 1826 | +# * |
| 1827 | +# * Licensed under the Apache License, Version 2.0 (the "License"); |
| 1828 | +# * you may not use this file except in compliance with the License. |
| 1829 | +# * You may obtain a copy of the License at |
| 1830 | +# * |
| 1831 | +# * http://www.apache.org/licenses/LICENSE-2.0 |
| 1832 | +# * |
| 1833 | +# * Unless required by applicable law or agreed to in writing, software |
| 1834 | +# * distributed under the License is distributed on an "AS IS" BASIS, |
| 1835 | +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 1836 | +# * See the License for the specific language governing permissions and |
| 1837 | +# * limitations under the License. |
| 1838 | +#**/ |
| 1839 | + |
| 1840 | +# PAL C source files part of NSPE library |
| 1841 | +list(APPEND PAL_SRC_C_NSPE ) |
| 1842 | + |
| 1843 | +# PAL ASM source files part of NSPE library |
| 1844 | +list(APPEND PAL_SRC_ASM_NSPE ) |
| 1845 | + |
| 1846 | +# PAL C source files part of SPE library - driver partition |
| 1847 | +list(APPEND PAL_SRC_C_DRIVER_SP ) |
| 1848 | + |
| 1849 | +# PAL ASM source files part of SPE library - driver partition |
| 1850 | +list(APPEND PAL_SRC_ASM_DRIVER_SP ) |
| 1851 | + |
| 1852 | + |
| 1853 | +# Listing all the sources required for given target |
| 1854 | +if(${SUITE} STREQUAL "IPC") |
| 1855 | + list(APPEND PAL_SRC_C_NSPE |
| 1856 | + # driver functionalities are implemented as RoT-services |
| 1857 | + # and secure and non-secure clients will call to these RoT-services to get appropriate driver services. |
| 1858 | + ${PSA_ROOT_DIR}/platform/targets/${TARGET}/nspe/pal_driver_ipc_intf.c |
| 1859 | + ) |
| 1860 | + list(APPEND PAL_SRC_C_DRIVER_SP |
| 1861 | + # Driver files will be compiled as part of driver partition |
| 1862 | + ${PSA_ROOT_DIR}/platform/targets/${TARGET}/spe/pal_driver_intf.c |
| 1863 | + ${PSA_ROOT_DIR}/platform/drivers/nvmem/pal_nvmem.c |
| 1864 | + ${PSA_ROOT_DIR}/platform/drivers/uart/pl011/pal_uart.c |
| 1865 | + ${PSA_ROOT_DIR}/platform/drivers/watchdog/rpi/pal_wd_rpi.c |
| 1866 | + ) |
| 1867 | +endif() |
| 1868 | + |
| 1869 | +if((${SUITE} STREQUAL "CRYPTO") OR |
| 1870 | + (${SUITE} STREQUAL "STORAGE") OR |
| 1871 | + (${SUITE} STREQUAL "PROTECTED_STORAGE") OR |
| 1872 | + (${SUITE} STREQUAL "INTERNAL_TRUSTED_STORAGE") OR |
| 1873 | + (${SUITE} STREQUAL "INITIAL_ATTESTATION")) |
| 1874 | + message(FATAL_ERROR "For PSA API - use -DTARGET=tgt_dev_apis_tfm_rp2350 instead") |
| 1875 | +endif() |
| 1876 | + |
| 1877 | +# Create NSPE library |
| 1878 | +add_library(${PSA_TARGET_PAL_NSPE_LIB} STATIC ${PAL_SRC_C_NSPE} ${PAL_SRC_ASM_NSPE}) |
| 1879 | + |
| 1880 | +# PSA Include directories |
| 1881 | +foreach(psa_inc_path ${PSA_INCLUDE_PATHS}) |
| 1882 | + target_include_directories(${PSA_TARGET_PAL_NSPE_LIB} PRIVATE ${psa_inc_path}) |
| 1883 | +endforeach() |
| 1884 | + |
| 1885 | +list(APPEND PAL_DRIVER_INCLUDE_PATHS |
| 1886 | + ${PSA_ROOT_DIR}/platform/drivers/nvmem |
| 1887 | + ${PSA_ROOT_DIR}/platform/drivers/uart/pl011 |
| 1888 | + ${PSA_ROOT_DIR}/platform/drivers/watchdog/rpi |
| 1889 | +) |
| 1890 | + |
| 1891 | +target_include_directories(${PSA_TARGET_PAL_NSPE_LIB} PRIVATE |
| 1892 | + ${PAL_DRIVER_INCLUDE_PATHS} |
| 1893 | + ${PSA_ROOT_DIR}/platform/targets/common/nspe |
| 1894 | + ${PSA_ROOT_DIR}/platform/targets/common/nspe/crypto |
| 1895 | + ${PSA_ROOT_DIR}/platform/targets/${TARGET}/nspe |
| 1896 | +) |
| 1897 | -- |
Antonio de Angelis | 75024f0 | 2024-11-02 22:46:23 +0000 | [diff] [blame] | 1898 | 2.47.0 |
Gabor Abonyi | 0a32b4e | 2024-10-25 09:34:08 +0200 | [diff] [blame] | 1899 | |