2 * Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved.
4 * SPDX-License-Identifier: BSD-3-Clause
16 * Store a new non-volatile counter value. On some FVP versions, the
17 * non-volatile counters are RO. On these versions we expect the values in the
18 * certificates to always match the RO values so that this function is never
21 * Return: 0 = success, Otherwise = error
23 int plat_set_nv_ctr(void *cookie
, unsigned int nv_ctr
)
26 uint32_t *nv_ctr_addr
;
28 assert(cookie
!= NULL
);
30 oid
= (const char *)cookie
;
31 if (strcmp(oid
, TRUSTED_FW_NVCOUNTER_OID
) == 0) {
32 nv_ctr_addr
= (uint32_t *)TFW_NVCTR_BASE
;
33 } else if (strcmp(oid
, NON_TRUSTED_FW_NVCOUNTER_OID
) == 0) {
34 nv_ctr_addr
= (uint32_t *)NTFW_CTR_BASE
;
39 *(unsigned int *)nv_ctr_addr
= nv_ctr
;
41 /* Verify that the current value is the one we just wrote. */
42 if (nv_ctr
!= (unsigned int)(*nv_ctr_addr
))