1 /* 2 * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #ifndef _BSV_INTEGRATION_OTP_H_ 8 #define _BSV_INTEGRATION_OTP_H_ 9 10 #include <stdint.h> 11 #include "run_integration_test.h" 12 #include "test_proj_otp.h" 13 14 #define RUNIT_ENV_OTP_START_OFFSET 0x2000UL 15 #define RUNIT_TEST_OTP_SIZE_IN_WORDS 0x2C 16 #define RUNIT_MAX_OTP_SIZE_IN_WORDS 0x7FF 17 18 /** 19 * @brief Retrieves the current life cycles based on the OTP values. 20 * 21 * @param lcs [output] the returned LCS. 22 * 23 * @return RUNIT_ERROR__OK on success. RUNIT_ERROR__FAIL otherwise 24 */ 25 RunItError_t runIt_getLcs(unsigned int *lcs); 26 27 /** 28 * @brief Verifies that the current life cycle is lcs 29 * 30 * @param lcs [input] the life cycle to expect 31 * 32 * @return RUNIT_ERROR__OK on success. RUNIT_ERROR__FAIL otherwise 33 */ 34 RunItError_t runIt_checkLcs(unsigned int lcs); 35 36 /** 37 * @brief Sets the appropriate fields on the OTP buffer to correspond with a specific Kceicv 38 * 39 * @param otp [output] The OTP image to alter 40 * @param kceicvBuff [input] the Kceicv to use 41 * 42 * @return RUNIT_ERROR__OK on success. RUNIT_ERROR__FAIL otherwise 43 */ 44 RunItError_t runIt_setKceicvInOtpBuff(unsigned int *otp, unsigned int *kceicvBuff); 45 46 /** 47 * @brief Sets the appropriate fields on the OTP buffer to correspond with a specific Kce 48 * 49 * @param otp [output] The OTP image to alter 50 * @param kceBuff [input] the Kce to use 51 * 52 * @return RUNIT_ERROR__OK on success. RUNIT_ERROR__FAIL otherwise 53 */ 54 RunItError_t runIt_setKceInOtpBuff(unsigned int *otp, unsigned int *kceBuff); 55 56 /** 57 * @brief Assign a new Kicv key into opt image. Also adjusts all the needed validation fields. 58 * 59 * @param otp [ouput] The image to burn to NVM 60 * @param kpicvBuff [input] New Kicv to use 61 * 62 * @return RUNIT_ERROR__OK on success. RUNIT_ERROR__FAIL otherwise 63 */ 64 RunItError_t runIt_setKpicvInOtpBuff(unsigned int *otp, unsigned int *kpicvBuff); 65 66 /** 67 * @brief Assign a new Kcp key into opt image. Also adjusts all the needed validation fields. 68 * 69 * @param otp [ouput] The image to burn to NVM 70 * @param kpicvBuff [input] New Kcp to use 71 * 72 * @return RUNIT_ERROR__OK on success. RUNIT_ERROR__FAIL otherwise 73 */ 74 RunItError_t runIt_setKpcInOtpBuff(unsigned int *otp, unsigned int *kcpBuff); 75 76 /** 77 # @brief Sets the appropriate fields on the OTP buffer to correspond with a specific Hbk 78 79 * @param otp [output] The OTP image to alter 80 * @param hbkBuff [input] The Hbk to use. 32 bytes of key. 81 * in case Hbk0 4 lower words will be used 82 * in case Hbk1 4 upper words will be used 83 * in case full Hbk all 8 words will be used 84 * @param isFullHbk [input] Defines in which manner to write the hbkBuff to otp 85 * 86 * @return RUNIT_ERROR__OK on success. RUNIT_ERROR__FAIL otherwise 87 */ 88 RunItError_t runIt_setHbkOtpBuff(uint32_t *otp, uint32_t *hbkBuff, uint8_t isFullHbk); 89 90 /** 91 # @brief Sets the appropriate fields on the OTP buffer to correspond with a specific SW version 92 93 * @param otp [output] The OTP image to alter 94 * @param isFullHbk [input] Defines in which manner to write the hbkBuff to otp 95 * 96 * @return RUNIT_ERROR__OK on success. RUNIT_ERROR__FAIL otherwise 97 */ 98 RunItError_t runIt_setSwVerInOtpBuff(uint32_t *otp, uint8_t isFullHbk); 99 100 /** 101 * @brief read OTP image 102 * 103 * @param otpBuf [output] The image read from 104 * 105 * @return RUNIT_ERROR__OK on success. RUNIT_ERROR__FAIL otherwise 106 */ 107 RunItError_t runIt_printOtp(uint32_t otpBuf[TEST_OTP_SIZE_IN_WORDS]); 108 109 /** 110 * @brief Burn the byte array in otpBuf to otp. 111 * nextLcs is provided to perform sanity check after burn and powerOnReset. 112 * 113 * @param otpBuf [input] The image to burn to NVM 114 * @param nextLcs [input] The expected life cycle after boot 115 * 116 * @return RUNIT_ERROR__OK on success. RUNIT_ERROR__FAIL otherwise 117 */ 118 RunItError_t runIt_burnOtp(unsigned int *otpBuf, unsigned int nextLcs); 119 120 121 #endif //_BSV_INTEGRATION_OTP_H_ 122