mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-27 07:15:20 +00:00
feat(psa): interface with RSS for NV counters
Adding AP/RSS interface for retrieving and incrementing non-volatile counters. The read interface implements the psa_call: psa_call(RSS_PLATFORM_SERVICE_HANDLE, RSS_PLATFORM_API_ID_NV_READ, in_vec, 1, out_vec, 1); where the in_vec indicates which of the 3 counters we want, and the out_vec stores the counter value we get back from RSS. The increment interface implements the psa_call: psa_call(RSS_PLATFORM_SERVICE_HANDLE, RSS_PLATFORM_API_ID_NV_INCREMENT, in_vec, 1, (psa_outvec *)NULL, 0); where, again, in_vec indicates the counter to increment, and we don't get any output parameter from RSS. Through this service, we will be able to get/increment any of the 3 NV counters used on a CCA platform: - NV counter for CCA firmware (BL2, BL31, RMM). - NV counter for secure firmware. - NV counter for non-secure firmware. Signed-off-by: Lauren Wehrmeister <lauren.wehrmeister@arm.com> Signed-off-by: Raef Coles <raef.coles@arm.com> Change-Id: I4c1c7f4837ebff30de16bb0ce7ecd416b70b1f62
This commit is contained in:
parent
5a53c6c667
commit
8374508b00
3 changed files with 91 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019-2022, Arm Limited. All rights reserved.
|
* Copyright (c) 2019-2023, Arm Limited. All rights reserved.
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
*
|
*
|
||||||
|
@ -8,6 +8,9 @@
|
||||||
#ifndef PSA_MANIFEST_SID_H
|
#ifndef PSA_MANIFEST_SID_H
|
||||||
#define PSA_MANIFEST_SID_H
|
#define PSA_MANIFEST_SID_H
|
||||||
|
|
||||||
|
/******** RSS_SP_PLATFORM ********/
|
||||||
|
#define RSS_PLATFORM_SERVICE_HANDLE (0x40000105U)
|
||||||
|
|
||||||
/******** PSA_SP_MEASURED_BOOT ********/
|
/******** PSA_SP_MEASURED_BOOT ********/
|
||||||
#define RSS_MEASURED_BOOT_HANDLE (0x40000110U)
|
#define RSS_MEASURED_BOOT_HANDLE (0x40000110U)
|
||||||
|
|
||||||
|
|
44
include/lib/psa/rss_platform_api.h
Normal file
44
include/lib/psa/rss_platform_api.h
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2023, Arm Limited. All rights reserved.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef RSS_PLATFORM_API_H
|
||||||
|
#define RSS_PLATFORM_API_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "psa/error.h"
|
||||||
|
|
||||||
|
#define RSS_PLATFORM_API_ID_NV_READ (1010)
|
||||||
|
#define RSS_PLATFORM_API_ID_NV_INCREMENT (1011)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Increments the given non-volatile (NV) counter by one
|
||||||
|
*
|
||||||
|
* counter_id NV counter ID.
|
||||||
|
*
|
||||||
|
* PSA_SUCCESS if the value is read correctly. Otherwise,
|
||||||
|
* it returns a PSA_ERROR.
|
||||||
|
*/
|
||||||
|
psa_status_t
|
||||||
|
rss_platform_nv_counter_increment(uint32_t counter_id);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Reads the given non-volatile (NV) counter
|
||||||
|
*
|
||||||
|
* counter_id NV counter ID.
|
||||||
|
* size Size of the buffer to store NV counter value
|
||||||
|
* in bytes.
|
||||||
|
* val Pointer to store the current NV counter value.
|
||||||
|
*
|
||||||
|
* PSA_SUCCESS if the value is read correctly. Otherwise,
|
||||||
|
* it returns a PSA_ERROR.
|
||||||
|
*/
|
||||||
|
psa_status_t
|
||||||
|
rss_platform_nv_counter_read(uint32_t counter_id,
|
||||||
|
uint32_t size, uint8_t *val);
|
||||||
|
|
||||||
|
#endif /* RSS_PLATFORM_API_H */
|
43
lib/psa/rss_platform.c
Normal file
43
lib/psa/rss_platform.c
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2023, Arm Limited. All rights reserved.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include <psa/client.h>
|
||||||
|
#include <psa_manifest/sid.h>
|
||||||
|
#include <rss_platform_api.h>
|
||||||
|
|
||||||
|
psa_status_t
|
||||||
|
rss_platform_nv_counter_increment(uint32_t counter_id)
|
||||||
|
{
|
||||||
|
struct psa_invec in_vec[1];
|
||||||
|
|
||||||
|
in_vec[0].base = &counter_id;
|
||||||
|
in_vec[0].len = sizeof(counter_id);
|
||||||
|
|
||||||
|
return psa_call(RSS_PLATFORM_SERVICE_HANDLE,
|
||||||
|
RSS_PLATFORM_API_ID_NV_INCREMENT,
|
||||||
|
in_vec, 1, NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
psa_status_t
|
||||||
|
rss_platform_nv_counter_read(uint32_t counter_id,
|
||||||
|
uint32_t size, uint8_t *val)
|
||||||
|
{
|
||||||
|
struct psa_invec in_vec[1];
|
||||||
|
struct psa_outvec out_vec[1];
|
||||||
|
|
||||||
|
in_vec[0].base = &counter_id;
|
||||||
|
in_vec[0].len = sizeof(counter_id);
|
||||||
|
|
||||||
|
out_vec[0].base = val;
|
||||||
|
out_vec[0].len = size;
|
||||||
|
|
||||||
|
return psa_call(RSS_PLATFORM_SERVICE_HANDLE,
|
||||||
|
RSS_PLATFORM_API_ID_NV_READ,
|
||||||
|
in_vec, 1, out_vec, 1);
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue