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_dmpu
9  @{
10  */
11 
12 /*!
13  @file
14  @brief This file contains all of the OEM production library APIs, their enums
15  and definitions.
16  */
17 
18 #ifndef _DMPU_H
19 #define _DMPU_H
20 
21 #include "cc_pal_types_plat.h"
22 #include "cc_prod.h"
23 
24 /************************ Defines ******************************/
25 
26 /*! The size of the OEM production library workspace in bytes. This workspace
27 is required by the library for internal use. */
28 #define DMPU_WORKSPACE_MINIMUM_SIZE  1536
29 
30 /*! The size of the Hbk1 buffer in words. */
31 #define DMPU_HBK1_SIZE_IN_WORDS  4
32 
33 /*! The size of the Hbk buffer in words. */
34 #define DMPU_HBK_SIZE_IN_WORDS  8
35 
36 /************************ Enums ********************************/
37 
38 /*! The type of the unique data. */
39 typedef enum {
40     /*! The device uses Hbk1. */
41         DMPU_HBK_TYPE_HBK1 = 1,
42     /*! The device uses a full Hbk. */
43         DMPU_HBK_TYPE_HBK = 2,
44     /*! Reserved. */
45         DMPU_HBK_TYPE_RESERVED  = 0x7FFFFFFF,
46 } CCDmpuHBKType_t;
47 
48 /************************ Typedefs  ****************************/
49 
50 
51 /************************ Structs  ******************************/
52 
53 /*!
54   The device use of the Hbk buffer.
55 
56   If the device uses Hbk0 and Hbk1, then the Hbk1 field is used.
57   Otherwise, the Hbk field is used.
58  */
59 typedef union {
60         /*! The Hbk1 buffer, if used by the device. */
61         uint8_t hbk1[DMPU_HBK1_SIZE_IN_WORDS*CC_PROD_32BIT_WORD_SIZE];
62         /*! The full 256-bit Hbk buffer. */
63         uint8_t hbk[DMPU_HBK_SIZE_IN_WORDS*CC_PROD_32BIT_WORD_SIZE];
64 } CCDmpuHbkBuff_t;
65 
66 
67 
68 /*! The OEM production library input defines .*/
69 typedef struct {
70         /*! The type of Hbk: Hbk1 - 128 bits. Hbk - 256 bits. */
71         CCDmpuHBKType_t   hbkType;
72         /*! The Hbk buffer. */
73         CCDmpuHbkBuff_t   hbkBuff;
74         /*! The Kcp asset type: Not used, Plain-asset, or Package. */
75         CCAssetType_t     kcpDataType;
76         /*! The Kcp buffer, if \p kcpDataType is Plain-asset or package. */
77         CCAssetBuff_t     kcp;
78         /*! The Kce asset type: Not used, Plain-asset, or Package. */
79         CCAssetType_t     kceDataType;
80         /*! The Kce buffer, if \p kceDataType is Plain-asset or package. */
81         CCAssetBuff_t     kce;
82         /*! The minimal SW version of the OEM. */
83         uint32_t          oemMinVersion;
84         /*! The default DCU lock bits of the OEM. */
85         uint32_t          oemDcuDefaultLock[PROD_DCU_LOCK_WORD_SIZE];
86 }CCDmpuData_t;
87 
88 
89 
90 /************************ Functions *****************************/
91 
92 /*!
93  @brief This function burns all OEM assets into the OTP of the device.
94 
95  The user must perform a power-on-reset (PoR) to trigger LCS change to Secure.
96 
97  @return \c CC_OK on success.
98  @return A non-zero value from cc_prod_error.h on failure.
99 */
100 CIMPORT_C CCError_t  CCProd_Dmpu(
101         /*! [in] The base address of CrytoCell HW registers. */
102         unsigned long   ccHwRegBaseAddr,
103         /*! [in] A pointer to the defines structure of the OEM. */
104         CCDmpuData_t    *pDmpuData,
105         /*! [in] The base address of the workspace for internal use. */
106         unsigned long   workspaceBaseAddr,
107         /*! [in] The size of provided workspace. Must be at least
108         \p DMPU_WORKSPACE_MINIMUM_SIZE. */
109         uint32_t        workspaceSize
110 ) ;
111 
112 
113 /*!
114  @}
115  */
116 #endif  //_DMPU_H
117