/*******************************************************************************
 * Copyright (c) 2018-2021 Renesas Electronics Corporation. All rights reserved.
 *
 *     RENESAS ELECTRONICS CONFIDENTIAL AND PROPRIETARY
 *
 * This software is provided as reference/sample code under the license
 * agreement between Renesas Electronics Corporation and licensee (the
 * "License Agreement") and shall be treated as specified in the License
 * Agreement.
 * These instructions, statements, and software are the confidential
 * information of Renesas Electronics Corporation. They must be used and
 * modified solely for the purpose for which it was furnished by Renesas
 * Electronics Corporation. All or part of these instructions, statements and
 * software must not be reproduced nor disclosed to any third party in any
 * form, unless permitted by the License Agreement.
 *
 * THIS SOFTWARE IS PROVIDED BY RENESAS ELEOCTRONICS CORPORATION "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
 * SATISFACTORY QUALITY, ACCURACY, TITLE AND NON-INFRINGEMENT ARE DISCLAIMED.
 * IN NO EVENT SHALL RENESAS ELECTRONICS CORPORATION BE LIABLE FOR ANY DIRECT,
 * INDIRECT, INCIDENTAL, SPECIAL, PUNITIVE, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * 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.
 ******************************************************************************/

/*******************************************************************************
 * DESCRIPTION   : boot ROM API header
 ******************************************************************************/
#ifndef ROM_API_H__
#define ROM_API_H__

#include <stdint.h>
#include <image_load.h>

#define SBROM_OK                                (0x00000000U)
#define SBROM_ILLEGAL_INPUT_PARAM_ERR           (0x0B000001U)
#define SBROM_ILLEGAL_OEM_HASH_VALUE_ERR        (0x0B000008U)
#define SBROM_ILLEGAL_LCS_FOR_OPERATION_ERR     (0x0B000010U)
#define SBROM_HASH_NOT_PROGRAMMED_ERR           (0x0B000100U)
#define SBROM_PUB_KEY_HASH_VALIDATION_FAILURE   (0xF1000006U)
#define SBROM_RSA_SIG_VERIFICATION_FAILED       (0xF1000007U)

#define GETLCS_OK               (0x00000000U)
#define LCS_CM                  (0x00000000U)   /* CM */
#define LCS_DM                  (0x00000001U)   /* DM */
#define LCS_SD                  (0x00000003U)   /* SD */
#define LCS_SE                  (0x00000005U)   /* SE */
#define LCS_FA                  (0x00000007U)   /* FA */

/* Certificate Logical address */
#define LOGICAL_BOOT_KEY_ADDR       (uint32_t)(KEY_CERT_DEST_ADDR)
#define LOGICAL_CONTENT_CERT_ADDR(x)    (uint32_t)(CONTENT_CERT_DEST_ADDR + CONTENT_CERT_INFO_SIZE + CERT_OFFSET(x))
#define CERT_OFFSET(x)          (uint32_t)((uint32_t)(x) * CONTENT_CERT_DST_SIZE)

/* BOOTROM API address for V3H */
#define ROM_SECUREBOOT_API_V3H  (0x01104400U)
#define ROM_GET_LCS_V3H         (0x01104418U)

typedef uint32_t (*ROM_SECURE_BOOT_API)(uint32_t *pKeyCert,
                    uint32_t *pContentCert,
                    void *param);
typedef uint32_t (*ROM_GETLCS_API)(uint32_t *pLcs);

uint32_t ROM_SecureBootAPI(uint32_t *pContentCert);
uint32_t ROM_GetLcs(uint32_t *pLcs);

extern uint32_t rom_api_wrap(uint32_t a, uint32_t b, uint32_t c, uint32_t d);

#endif /* ROM_API_H__ */
