]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/pdk.git/commitdiff
KEYWRITER: sciclient fn for keywriter API call, opcode, and msg struct
authorAnuraag Tummanapally <anuraagt@ti.com>
Wed, 25 Nov 2020 16:18:48 +0000 (16:18 +0000)
committerPiyali Goswami <piyali_g@ti.com>
Mon, 21 Dec 2020 03:56:41 +0000 (09:26 +0530)
Fixes: SYSFW-4164
Signed-off-by: Anuraag Tummanapally <anuraagt@ti.com>
packages/ti/drv/sciclient/include/sciclient_keywriter.h [new file with mode: 0644]
packages/ti/drv/sciclient/sciclient.h
packages/ti/drv/sciclient/soc/sysfw/include/tisci/security/tisci_keywriter.h [new file with mode: 0644]
packages/ti/drv/sciclient/soc/sysfw/include/tisci/tisci_protocol.h
packages/ti/drv/sciclient/src/sciclient/sciclient_keywriter.c [new file with mode: 0644]
packages/ti/drv/sciclient/src/sciclient_direct_makefile
packages/ti/drv/sciclient/src/sciclient_indirect_makefile

diff --git a/packages/ti/drv/sciclient/include/sciclient_keywriter.h b/packages/ti/drv/sciclient/include/sciclient_keywriter.h
new file mode 100644 (file)
index 0000000..0e19fb9
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ *  Copyright (C) 2020 Texas Instruments Incorporated
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+/**
+ * \ingroup DRV_SCICLIENT_MODULE
+ * \defgroup SCICLIENT_FMW_OTP_IF Sciclient OTP API Interface
+ *
+ * OTP programming is done using the DMSC. This is needed to convert a
+ * field securable device into a HS device.
+ *
+ * @{
+ */
+/**
+ *  \file   sciclient_keywriter.h
+ *
+ *  \brief  This file contains the definition of all the message IDs, message
+ *          formats to be able to interact with the System Controller firmware
+ *          for OTP Key programming.
+ *
+ */
+
+#ifndef SCICLIENT_KEYWRITER_H_
+#define SCICLIENT_KEYWRITER_H_
+
+/* ========================================================================== */
+/*                             Include Files                                  */
+/* ========================================================================== */
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* ========================================================================== */
+/*                           Macros & Typedefs                                */
+/* ========================================================================== */
+
+/* None */
+
+/* ========================================================================== */
+/*                         Structure Declarations                             */
+/* ========================================================================== */
+
+/* None */
+
+/* ========================================================================== */
+/*                          Function Declarations                             */
+/* ========================================================================== */
+
+/**
+ *  \brief    Message to request a processor
+ *  Provides a means for either the “recovery master” host or another host in
+ *  the permitted access list to request for a physical processor control.
+ *
+ *  \n<b>Message</b>:    #TISCI_MSG_KEY_WRITER
+ *  \n<b>Request</b>:    #tisci_otp_process_key_cfg_req
+ *  \n<b>Response</b>:   #tisci_otp_process_key_cfg_resp
+ *
+ *  \param  otpKeyCfgAddr   Address of otp writer key config structure
+ *                          Refer \ref Sciclient_ProcessorIds.
+ *  \param  timeout         Gives a sense of how long to wait for the operation.
+ *                          Refer \ref Sciclient_ServiceOperationTimeout.
+ *  \return CSL_PASS on success, else failure
+ */
+int32_t Sciclient_otpProcessKeyCfg(uint32_t *otpKeyCfgAddr,
+                                           uint32_t timeout, uint32_t *debug_response);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* #ifndef SCICLIENT_KEYWRITER_H_ */
+
+/* @} */
index d6e4ee66b31b96b9ef6932449d8765ef842deb56..4d0dbe0ab43914547afc4897fa67c4291db5cbd7 100755 (executable)
@@ -321,6 +321,8 @@ typedef uint8_t devgrp_t;
 #include <ti/drv/sciclient/soc/sysfw/include/tisci/security/tisci_sec_handover.h>
 #include <ti/drv/sciclient/soc/sysfw/include/tisci/security/tisci_secure_jtag.h>
 #include <ti/drv/sciclient/soc/sysfw/include/tisci/security/tisci_soc_uid.h>
+#include <ti/drv/sciclient/soc/sysfw/include/tisci/security/tisci_keywriter.h>
+#include <ti/drv/sciclient/soc/sysfw/include/tisci/security/tisci_dkek.h>
 #include <ti/drv/sciclient/soc/sysfw/include/tisci/pm/tisci_pm_clock.h>
 #include <ti/drv/sciclient/soc/sysfw/include/tisci/pm/tisci_pm_device.h>
 #include <ti/drv/sciclient/soc/sysfw/include/tisci/pm/tisci_pm_core.h>
@@ -340,6 +342,7 @@ typedef uint8_t devgrp_t;
 #include <ti/drv/sciclient/include/sciclient_genericMsgs.h>
 #include <ti/drv/sciclient/include/sciclient_procboot.h>
 #include <ti/drv/sciclient/include/sciclient_boardcfg.h>
+#include <ti/drv/sciclient/include/sciclient_keywriter.h>
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/packages/ti/drv/sciclient/soc/sysfw/include/tisci/security/tisci_keywriter.h b/packages/ti/drv/sciclient/soc/sysfw/include/tisci/security/tisci_keywriter.h
new file mode 100644 (file)
index 0000000..4f40f70
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ *  Copyright (C) 2017-2020 Texas Instruments Incorporated
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+/**
+ * \ingroup TISCI
+ * \defgroup tisci_keywriter tisci_keywriter
+ *
+ * DMSC controls the power management, security and resource management
+ * of the device.
+ *
+ *
+ * @{
+ */
+/**
+ *
+ *  \brief  This file contains:
+ *
+ *          WARNING!!: Autogenerated file from SYSFW. DO NOT MODIFY!!
+ * Copyright (C) 2019-2020 Texas Instruments Incorporated - http://www.ti.com/
+ */
+#ifndef KEYWRITER_H
+#define KEYWRTIER_H
+
+/**
+ *
+ *  \brief Declarations for all functions dealing with keywriter
+ */
+
+
+/**
+ * \brief Request message for keywriter
+ *
+ * \param hdr                           standard TISCI header
+ * \param image_addr_lo        Lower 32 bit address (in LE format) of the certificate
+ * \param image_addr_hi        Higher 32 bit address (in LE format) of the certificate
+ * \param key_prog_mask        Reserved for future use
+ */
+struct tisci_msg_keywriter_req {
+    struct tisci_header    hdr;
+    uint32_t            image_addr_lo;
+    uint32_t            image_addr_hi;
+    uint32_t            key_prog_mask[2];
+} __attribute__((__packed__));
+
+/**
+ * \brief Response message for keywriter
+ *
+ * \param hdr        standard TISCI header
+ * \param debug_response  debug code for success/failure
+ */
+struct tisci_msg_keywriter_resp {
+    struct tisci_header    hdr;
+    uint32_t            debug_response;
+} __attribute__((__packed__));
+
+/**
+ * \brief Bit positions for debug response
+ * */
+enum keywriter_error_codes {
+    KEYWR_ERR_DECRYPT_AES256_KEY = 0,
+    KEYWR_ERR_DECRYPT_BMEK,
+    KEYWR_ERR_DECRYPT_BMPKH,
+    KEYWR_ERR_DECRYPT_SMEK,
+    KEYWR_ERR_DECRYPT_SMPKH,
+    KEYWR_ERR_INTERAL_OP,
+    KEYWR_ERR_INVALID_EXT_COUNT,
+    KEYWR_ERR_PARSE_CERT,
+    KEYWR_ERR_PARSE_FEK,
+    KEYWR_ERR_PARSE_SMPK_CERT,
+    KEYWR_ERR_PROGR_BMEK,
+    KEYWR_ERR_PROGR_BMPKH_PART_1,
+    KEYWR_ERR_PROGR_BMPKH_PART_2,
+    KEYWR_ERR_PROGR_KEYCOUNT,
+    KEYWR_ERR_PROGR_KEYREV,
+    KEYWR_ERR_PROGR_SMEK,
+    KEYWR_ERR_PROGR_SMPKH_PART_1,
+    KEYWR_ERR_PROGR_SMPKH_PART_2,
+    KEYWR_ERR_VALIDATION_CERT,
+    KEYWR_ERR_VALIDATION_SMPK_CERT,
+    KEYWR_ERR_VALIDATION_BMPK_KEY,
+    KEYWR_ERR_VALIDATION_SMPK_KEY,
+    KEYWR_ERR_WRITE_PROT_KEYCOUNT,
+    KEYWR_ERR_WRITE_PROT_KEYREV,
+};
+
+
+#endif
+
+/* @} */
index a665b20f8b22331344aa75b342c4611cef9f4ada..44b5687d771c17c00cc87d372ac92d14929d24b8 100644 (file)
@@ -249,6 +249,9 @@ struct tisci_sec_header {
 /** Message to derive a KEK and return it via TISCI */
 #define TISCI_MSG_SA2UL_GET_DKEK                (0x9029U)
 
+/* Message ID for keywriter */
+#define TISCI_MSG_KEY_WRITER                           (0x9031U)
+
 /******************************************************/
 
 /* Processor Control APIs */
diff --git a/packages/ti/drv/sciclient/src/sciclient/sciclient_keywriter.c b/packages/ti/drv/sciclient/src/sciclient/sciclient_keywriter.c
new file mode 100644 (file)
index 0000000..762a0dc
--- /dev/null
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2020, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/**
+ *  \file sciclient_keywriter.c
+ *
+ *  \brief File containing the SCICLIENT API interfaces to the Keywriter programming
+ *         DMSC services.
+ */
+
+/* ========================================================================== */
+/*                             Include Files                                  */
+/* ========================================================================== */
+
+#include <stdint.h>
+#include <string.h>
+#include <ti/csl/csl_types.h>
+#include <ti/drv/sciclient/sciclient.h>
+
+/* ========================================================================== */
+/*                           Macros & Typedefs                                */
+/* ========================================================================== */
+
+/* None */
+
+/* ========================================================================== */
+/*                         Structure Declarations                             */
+/* ========================================================================== */
+
+/* None */
+
+/* ========================================================================== */
+/*                          Function Declarations                             */
+/* ========================================================================== */
+
+/* None */
+
+/* ========================================================================== */
+/*                            Global Variables                                */
+/* ========================================================================== */
+
+/* None */
+
+/* ========================================================================== */
+/*                          Function Definitions                              */
+/* ========================================================================== */
+
+int32_t Sciclient_otpProcessKeyCfg(uint32_t *otpKeyCfgAddr,
+                                           uint32_t timeout, uint32_t *debug_response)
+{
+    int32_t retVal = CSL_PASS;
+    Sciclient_ReqPrm_t reqParam ;
+    Sciclient_RespPrm_t respParam ;
+    struct tisci_msg_keywriter_req request ;
+    struct tisci_msg_keywriter_resp response ;
+
+    request.image_addr_lo       = (uint32_t) otpKeyCfgAddr;
+    request.image_addr_hi       = 0;
+
+    reqParam.messageType    = (uint16_t) TISCI_MSG_KEY_WRITER;
+    reqParam.flags          = (uint32_t) TISCI_MSG_FLAG_AOP;
+    reqParam.pReqPayload    = (const uint8_t *) &request;
+    reqParam.reqPayloadSize = (uint32_t) sizeof (request);
+    reqParam.timeout        = (uint32_t) timeout;
+
+    respParam.flags           = (uint32_t) 0;   /* Populated by the API */
+    respParam.pRespPayload    = (uint8_t *) &response;
+    respParam.respPayloadSize = (uint32_t) sizeof (response);
+
+    retVal = Sciclient_service(&reqParam, &respParam);
+       *debug_response = response.debug_response;
+    if((retVal != CSL_PASS) ||
+        ((respParam.flags & TISCI_MSG_FLAG_ACK) != TISCI_MSG_FLAG_ACK))
+    {
+        retVal = CSL_EFAIL;
+    }
+    return retVal;
+}
+
+/* -------------------------------------------------------------------------- */
+/*                 Internal Function Definitions                              */
+/* -------------------------------------------------------------------------- */
+
+/* None */
+
index 511966b49f7b5c0cf5e8534e49190dc12787511c..a9e87f3d62cad3cde6dfb1a3d79ca64d736087a9 100644 (file)
@@ -57,6 +57,7 @@ SRCS_COMMON += sciclient_genericMsgs.c
 SRCS_COMMON += sciclient_rom.c
 SRCS_COMMON += sciclient_secureProxyCfg.c
 SRCS_COMMON += sciclient_secureproxy.c
+SRCS_COMMON += sciclient_keywriter.c
 endif
 
 #Use CSL implementation to bypass DMSC
index a35db335b62cf00c52a50d4031945ba39fe80a30..9e8866306c580938365eda89b2e23270761d57ed 100755 (executable)
@@ -57,6 +57,7 @@ SRCS_COMMON += sciclient_genericMsgs.c
 SRCS_COMMON += sciclient_secureProxyCfg.c
 SRCS_COMMON += sciclient_rom.c
 SRCS_COMMON += sciclient_secureproxy.c
+SRCS_COMMON += sciclient_keywriter.c
 endif
 
 #Use CSL implementation to bypass DMSC