The PSA APIs Architecture test suite contains a platform abstraction layer (PAL) which abstracts platform specific information from the tests.
This document provides details on the porting steps and the PAL APIs.
You must populate your system configuration and provide it as an input to test suite.
This is captured in a single static input configuration file that is named as target.cfg. This file is available at api-tests/platform/targets/<platform_name>/.
An example of the input configuration file is as shown.
// UART device info uart.num=1; uart.0.base = 0x40004000; uart.0.size = 0xFFF; uart.0.intr_id = 0xFF; uart.0.permission = TYPE_READ_WRITE; // Watchdog device info watchdog.num = 1; watchdog.0.base = 0x40008000; watchdog.0.size = 0xFFF; watchdog.0.intr_id = 0xFF; watchdog.0.permission = TYPE_READ_WRITE;
More details on the structure of the input can be obtained from val/common/val_target.h.
Note: Test suite needs access to the following peripherals. For IPC tests, the services of these peripherals are implemented as RoT services in the driver partition. If you are compiling crypto tests, you must set PSA_IPC_IMPLEMENTED to 0 in the platform/targets/<platform_name>/Makefile. This selects the non-secure PAL instances for the driver services and eliminates IPC dependancy for crypto tests.
Since Test suite is agnostic to various system targets, before building the tests, you must port the files mentioned in the following steps.
These functions will require implementation for the target platform.
No | Prototype | Description | Parameters |
---|---|---|---|
01 | int pal_spi_read(addr_t addr, uint8_t *data, uint32_t len); | This function will read peripherals using SPI commands | addr : address of the peripheral data : read buffer len : length of the read buffer in bytes |
02 | uint32_t pal_ipc_framework_version(void); | Retrieve the version of the PSA Framework API that is implemented. | void |
03 | uint32_t pal_ipc_version(uint32_t sid); | Retrieve the minor version of a Root of Trust Service by its SID. | sid The Root of Trust Service ID |
04 | psa_handle_t pal_ipc_connect(uint32_t sid, uint32_t minor_version); | Connect to given sid. | sid : RoT service id minor_version : minor_version of RoT service |
05 | psa_status_t pal_ipc_call(psa_handle_t handle, const psa_invec *in_vec, size_t in_len, psa_outvec *out_vec, size_t out_len); | Call a connected Root of Trust Service. | handle: Handle for the connection. in_vec: Array of psa_invec structures. in_len: Number of psa_invec structures in in_vec. out_vec: Array of psa_outvec structures for optional Root of Trust Service response. out_len: Number of psa_outvec structures in out_vec. |
06 | void pal_ipc_close(psa_handle_t handle); | Close a connection to a Root of Trust Service. | handle Handle for the connection. |
07 | int pal_uart_init_ns(uint32_t uart_base_addr); | This function initializes the UART | uart base addr |
08 | int pal_print_ns(char *str, uint32_t data); | This function parses the input string and writes bytes into UART TX FIFO | str : Input String data : Value for format specifier |
09 | int pal_wd_timer_init_ns(addr_t base_addr, uint32_t time_us, uint32_t timer_tick_us); | Initializes an hardware watchdog timer | base_addr : Base address of the watchdog module time_us : Time in micro seconds timer_tick_us : Number of ticks per micro second |
10 | int pal_wd_timer_enable_ns(addr_t base_addr); | Enables a hardware watchdog timer | base_addr : Base address of the watchdog module |
11 | int pal_wd_timer_disable_ns(addr_t base_addr); | Disables a hardware watchdog timer | base_addr : Base address of the watchdog module |
12 | int pal_nvmem_read_ns(addr_t base, uint32_t offset, void *buffer, int size); | Reads from given non-volatile address. | base : Base address of nvmem offset : Offset buffer : Pointer to source address size : Number of bytes |
13 | int pal_nvmem_write_ns(addr_t base, uint32_t offset, void *buffer, int size); | Writes into given non-volatile address. | base : Base address of nvmem offset : Offset buffer : Pointer to source address size : Number of bytes |
14 | uint32_t pal_crypto_function(int type, va_list valist); | This API will call the requested crypto function | type : function code valist : variable argument list |
No | Prototype | Description | Parameters |
---|---|---|---|
01 | void pal_uart_init(addr_t uart_base_addr); | This function initializes the uart | uart_base_addr : Base address of the UART |
02 | void pal_print(char *str, uint32_t data); | This function parses the input string and writes byte by byte to print | str : Input String data : Value for Format specifier |
03 | int pal_wd_timer_init(addr_t base_addr, uint32_t time_us, uint32_t timer_tick_us); | Initializes an hardware watchdog timer | base_addr : Base address of the watchdog module time_us : Time in micro seconds timer_tick_us : Number of ticks per micro second |
04 | int pal_wd_timer_enable(addr_t base_addr); | Enables a hardware watchdog timer | base_addr : Base address of the watchdog module |
05 | int pal_wd_timer_disable(addr_t base_addr); | Disables a hardware watchdog timer | base_addr : Base address of the watchdog module |
06 | int pal_wd_timer_is_enabled(addr_t base_addr); | Checks whether hardware watchdog timer is enabled | base_addr : Base address of the watchdog module |
07 | int pal_nvmem_write(addr_t base, uint32_t offset, void *buffer, int size); | Writes 'size' bytes from buffer into non-volatile memory at a given 'base + offset' | base : Base address of NV MEM offset : Offset buffer : Pointer to source address size : Number of bytes |
08 | int pal_nvmem_read(addr_t base, uint32_t offset, void *buffer, int size); | Reads 'size' bytes from non-volatile memory at a given | base : Base address of NV MEM offset : Offset buffer : Pointer to source address size : Number of bytes |
Arm PSA test suite is distributed under Apache v2.0 License.
Copyright (c) 2018, Arm Limited and Contributors. All rights reserved.