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  @addtogroup cc_cmpu
9  @{
10  */
11 
12 /*!
13  @file
14  @brief This file contains all of the ICV production library APIs, their
15  enums and definitions.
16 */
17 
18 
19 #ifndef _CMPU_H
20 #define _CMPU_H
21 
22 #include "cc_pal_types_plat.h"
23 #include "cc_prod.h"
24 
25 /************************ Defines ******************************/
26 
27 /*! The size of the ICV production library workspace in bytes. This workspace
28 is needed by the library for internal use. */
29 #define CMPU_WORKSPACE_MINIMUM_SIZE  4096
30 
31 /*! The size of the ICV production library unique buffer in bytes:
32 Hbk0 or user data. */
33 #define PROD_UNIQUE_BUFF_SIZE   16
34 /************************ Enums ********************************/
35 
36 /*! The unique data type. */
37 typedef enum {
38         /*! The device uses the unique data as Hbk0. */
39         CMPU_UNIQUE_IS_HBK0 = 1,
40         /*! The device uses the unique data as a random value. Hbk0 is not
41         used for the device. */
42         CMPU_UNIQUE_IS_USER_DATA = 2,
43         /*! Reserved. */
44         CMPU_UNIQUE_RESERVED    = 0x7FFFFFFF,
45 } CCCmpuUniqueDataType_t;
46 
47 /************************ Typedefs  ****************************/
48 
49 
50 /************************ Structs  ******************************/
51 
52 /*!
53   @brief The device use of the unique buffer.
54 
55   If the device uses Hbk0, then the \p hbk0 field is used.
56   Otherwise, a random buffer for the \p userData field is used.
57  */
58 typedef union {
59         /*! The Hbk0 buffer, if used by the device. */
60         uint8_t hbk0[PROD_UNIQUE_BUFF_SIZE];
61         /*! Any random value, if Hbk0 is not used by the device. */
62         uint8_t userData[PROD_UNIQUE_BUFF_SIZE];
63 } CCCmpuUniqueBuff_t;
64 
65 
66 /*! The ICV production library input options. */
67 typedef struct {
68         /*! The unique data type: Hbk0 or a random user-defined data. */
69         CCCmpuUniqueDataType_t  uniqueDataType;
70         /*! The unique data buffer. */
71         CCCmpuUniqueBuff_t      uniqueBuff;
72         /*! The Kpicv asset type. Allowed values are: Not used,
73         Plain-asset, or Package. */
74         CCAssetType_t           kpicvDataType;
75         /*! The Kpicv buffer, if its type is Plain-asset or Package. */
76         CCAssetBuff_t           kpicv;
77         /*! The asset type of the Kceicv. Allowed values are: Not used,
78         Plain-asset, or Package. */
79         CCAssetType_t           kceicvDataType;
80         /*! The Kceicv buffer, if its type is Plain-asset or Package. */
81         CCAssetBuff_t           kceicv;
82         /*! The minimal SW version of the ICV. Valid only if Hbk0 is used. */
83         uint32_t                icvMinVersion;
84         /*! The ICV configuration word. */
85         uint32_t                icvConfigWord;
86         /*! The default DCU lock bits of the ICV. Valid only if Hbk0 is used.*/
87         uint32_t                icvDcuDefaultLock[PROD_DCU_LOCK_WORD_SIZE];
88 }CCCmpuData_t;
89 
90 
91 
92 /************************ Functions *****************************/
93 
94 /*!
95  @brief This function burns all ICV assets into the OTP of the device.
96 
97  The user must perform a power-on-reset (PoR) to trigger LCS change to DM LCS.
98 
99  @return \c CC_OK on success.
100  @return A non-zero value from cc_prod_error.h on failure.
101 */
102 CIMPORT_C CCError_t  CCProd_Cmpu(
103         /*! [in] The base address of CrytoCell HW registers. */
104         unsigned long    ccHwRegBaseAddr,
105         /*! [in] A pointer to the ICV defines structure. */
106         CCCmpuData_t     *pCmpuData,
107         /*! [in] The base address of the workspace for internal use. */
108         unsigned long    workspaceBaseAddr,
109         /*! [in] The size of the provided workspace. Must be at least
110         #CMPU_WORKSPACE_MINIMUM_SIZE. */
111         uint32_t         workspaceSize
112                                     );
113 
114 
115 /*!
116  @}
117  */
118 #endif  //_CMPU_H
119