1 /*
2  * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 
8 #ifndef _BSV_DEFS_H
9 #define _BSV_DEFS_H
10 
11 #ifdef __cplusplus
12 extern "C"
13 {
14 #endif
15 
16 /*! @file
17 @brief This file contains definitions used for the Boot Services APIs.
18 */
19 
20 /*! Defines the maximal hash boot key size in words. */
21 #define CC_BSV_MAX_HASH_SIZE_IN_WORDS       8
22 /*! Defines the maximal hash boot key size in bytes. */
23 #define CC_BSV_MAX_HASH_SIZE_IN_BYTES       (CC_BSV_MAX_HASH_SIZE_IN_WORDS*sizeof(uint32_t))
24 /*! Defines the maximal full-hash boot key size in words. */
25 #define CC_BSV_256B_HASH_SIZE_IN_WORDS      CC_BSV_MAX_HASH_SIZE_IN_WORDS
26 /*! Defines the maximal dual-hash boot key size in words. */
27 #define CC_BSV_128B_HASH_SIZE_IN_WORDS      CC_BSV_MAX_HASH_SIZE_IN_WORDS/2
28 
29 /*! ICV Firmware minimal version maximal size. */
30 #define CC_BSV_MAX_HBK0_VERSION_COUNTER     64
31 /*! OEM Firmware minimal version maximal size. */
32 #define CC_BSV_MAX_HBK1_VERSION_COUNTER     96
33 /*! OEM Firmware minimal version maximal size (no ICV). */
34 #define CC_BSV_MAX_HBK_VERSION_COUNTER      160
35 
36 /*! HUK status bit definition. */
37 #define DX_BSV_STAUS_HUK_ERR_BIT_SHIFT         0x0UL
38 /*! HUK status size bit definition. */
39 #define DX_BSV_STAUS_HUK_ERR_BIT_SIZE          0x1UL
40 /*! Kpicv status bit definition. */
41 #define DX_BSV_STAUS_KPICV_ERR_BIT_SHIFT         0x1UL
42 /*! Kpicv status size bit definition. */
43 #define DX_BSV_STAUS_KPICV_ERR_BIT_SIZE          0x1UL
44 /*! Kceicv status bit definition. */
45 #define DX_BSV_STAUS_KCEICV_ERR_BIT_SHIFT         0x2UL
46 /*! Kceicv status size bit definition. */
47 #define DX_BSV_STAUS_KCEICV_ERR_BIT_SIZE          0x1UL
48 /*! Kcp status bit definition. */
49 #define DX_BSV_STAUS_KCP_ERR_BIT_SHIFT         0x3UL
50 /*! Kcp status size bit definition. */
51 #define DX_BSV_STAUS_KCP_ERR_BIT_SIZE          0x1UL
52 /*! Kce status bit definition. */
53 #define DX_BSV_STAUS_KCE_ERR_BIT_SHIFT         0x4UL
54 /*! Kce status size bit definition. */
55 #define DX_BSV_STAUS_KCE_ERR_BIT_SIZE          0x1UL
56 
57 /*! Definition for all ones word. */
58 #define CC_BSV_ALL_ONES_VALUE   0xffffffffUL
59 /*! Definition for number of bits in a 32bit word. */
60 #define CC_BSV_ALL_ONES_NUM_BITS 32
61 
62 /* ********************** Macros ******************************* */
63 /*! This macro counts the number of zeroes in a 32bits word. */
64 #define CC_BSV_COUNT_ZEROES(regVal, regZero)                    \
65     do {                                    \
66         uint32_t val = regVal;                                          \
67         val = val - ((val >> 1) & 0x55555555);                          \
68         val = (val & 0x33333333) + ((val >> 2) & 0x33333333);           \
69         val = ((((val + (val >> 4)) & 0xF0F0F0F) * 0x1010101) >> 24);   \
70         regZero += (32 - val);                      \
71     }while(0)
72 
73 
74 #ifdef __cplusplus
75 }
76 #endif
77 
78 #endif
79 
80 
81 
82