laurenw-arm | 4fc77a7 | 2022-08-11 15:29:56 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2023, Arm Limited. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | #include <stdint.h> |
| 9 | |
| 10 | #include <psa/client.h> |
| 11 | #include <psa_manifest/sid.h> |
| 12 | #include <rss_platform_api.h> |
| 13 | |
| 14 | psa_status_t |
| 15 | rss_platform_nv_counter_increment(uint32_t counter_id) |
| 16 | { |
| 17 | struct psa_invec in_vec[1]; |
| 18 | |
| 19 | in_vec[0].base = &counter_id; |
| 20 | in_vec[0].len = sizeof(counter_id); |
| 21 | |
| 22 | return psa_call(RSS_PLATFORM_SERVICE_HANDLE, |
| 23 | RSS_PLATFORM_API_ID_NV_INCREMENT, |
| 24 | in_vec, 1, NULL, 0); |
| 25 | } |
| 26 | |
| 27 | psa_status_t |
| 28 | rss_platform_nv_counter_read(uint32_t counter_id, |
| 29 | uint32_t size, uint8_t *val) |
| 30 | { |
| 31 | struct psa_invec in_vec[1]; |
| 32 | struct psa_outvec out_vec[1]; |
| 33 | |
| 34 | in_vec[0].base = &counter_id; |
| 35 | in_vec[0].len = sizeof(counter_id); |
| 36 | |
| 37 | out_vec[0].base = val; |
| 38 | out_vec[0].len = size; |
| 39 | |
| 40 | return psa_call(RSS_PLATFORM_SERVICE_HANDLE, |
| 41 | RSS_PLATFORM_API_ID_NV_READ, |
| 42 | in_vec, 1, out_vec, 1); |
| 43 | } |