/*******************************************************************************
 * DISCLAIMER
 * This software is supplied by Renesas Electronics Corporation and is only
 * intended for use with Renesas products. No other uses are authorized. This
 * software is owned by Renesas Electronics Corporation and is protected under
 * all applicable laws, including copyright laws.
 * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
 * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
 * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
 * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
 * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
 * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
 * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
 * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
 * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
 * Renesas reserves the right, without notice, to make changes to this software
 * and to discontinue the availability of this software. By using this software,
 * you agree to the additional terms and conditions found by accessing the
 * following link:
 * http://www.renesas.com/disclaimer
 * Copyright 2023-2025 Renesas Electronics Corporation All rights reserved.
 *******************************************************************************/

/*******************************************************************************
 * DESCRIPTION   : dummy flash data for sector 9(0x240000)
 ******************************************************************************/

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

#define FLASH_BOOT  (0U)
#define EMMC_BOOT  (1U)
#define CA_IPL  (0U)
#define BL31    (1U)

#define RTOS_LOAD_NUM_1     (1U)
#define RTOS_LOAD_NUM_3     (3U)

/* CA program load num */
#if (OPTEE_LOAD_ENABLE == OPTEE_DISABLE)
#define CA_IMAGE_NUM                (0x00000002U)
#else
#define CA_IMAGE_NUM                (0x00000003U)
#endif /* OPTEE_LOAD_ENABLE == OPTEE_DISABLE */
/* Source address on flash for Secure FW */
#define SECURE_FW_SRC_ADDRESS       (0x00280000U)
/* Source address on flash for RTOS#0 */
#define RTOS_SRC_ADDRESS            (0x00000000U)
#if (RTOS_LOAD_NUM == RTOS_LOAD_NUM_3)
/* Source address on eMMC for RTOS#1 */
#define RTOS1_SRC_ADDRESS           (0x01000000U)
/* Source address on eMMC for RTOS#2 */
#define RTOS2_SRC_ADDRESS           (0x01200000U)
#endif /* RTOS_LOAD_NUM == RTOS_LOAD_NUM_3 */

#if (CA_LOAD_TYPE == CA_IPL)
/* Source address on flash for CX IPL */
#define CX_IPL_SRC_ADDRESS          (0x00480000U)
#else
/* Reserved */
#define CX_IPL_SRC_ADDRESS          (0x00000000U)
#endif
/* ----------- customized ----------- */
/* Source address on flash for BL31 */
#define CA_PROG_01_SRC_ADDRESS      (0x01400000U)
/* Source address on flash for U-Boot */
#define CA_PROG_02_SRC_ADDRESS      (0x01580000U)
#if (OPTEE_LOAD_ENABLE == OPTEE_DISABLE)
/* Reserved */
#define CA_PROG_03_SRC_ADDRESS      (0x00000000U)
#else
/* Source address on flash for OP-TEE */
#define CA_PROG_03_SRC_ADDRESS      (0x01480000U)
#endif /* OPTEE_LOAD_ENABLE == OPTEE_DISABLE */
/* Reserved */
#define CA_PROG_04_SRC_ADDRESS      (0x00000000U)
/* Reserved */
#define CA_PROG_05_SRC_ADDRESS      (0x00000000U)
/* Reserved */
#define CA_PROG_06_SRC_ADDRESS      (0x00000000U)
/* Reserved */
#define CA_PROG_07_SRC_ADDRESS      (0x00000000U)
/* Reserved */
#define CA_PROG_08_SRC_ADDRESS      (0x00000000U)
/* ----------- customized ----------- */

#if (RCAR_SA9_TYPE == FLASH_BOOT)
#define SECURE_FW_PARTITION         (0x00000000U)
#define CX_IPL_PARTITION            (0x00000000U)
 #if (CA_LOAD_TYPE == CA_IPL)
#define RTOS_PARTITION              (0x00000001U)
#define CA_PROG_01_PARTITION        (0x00000001U)
#define CA_PROG_02_PARTITION        (0x00000001U)
  #if (OPTEE_LOAD_ENABLE == OPTEE_DISABLE)
#define CA_PROG_03_PARTITION        (0x00000000U)
  #else
#define CA_PROG_03_PARTITION        (0x00000001U)
  #endif /* OPTEE_LOAD_ENABLE == OPTEE_DISABLE */
#define CA_PROG_04_PARTITION        (0x00000000U)
#define CA_PROG_05_PARTITION        (0x00000000U)
#define CA_PROG_06_PARTITION        (0x00000000U)
#define CA_PROG_07_PARTITION        (0x00000000U)
#define CA_PROG_08_PARTITION        (0x00000000U)
  #if (RTOS_LOAD_NUM == RTOS_LOAD_NUM_3)
#define RTOS1_PARTITION             (0x00000001U)
#define RTOS2_PARTITION             (0x00000001U)
  #endif /* RTOS_LOAD_NUM == RTOS_LOAD_NUM_3 */
 #else /* #if (CA_LOAD_TYPE == CA_IPL) */
#define RTOS_PARTITION              (0x00000000U)
#define CA_PROG_01_PARTITION        (0x00000000U)
#define CA_PROG_02_PARTITION        (0x00000000U)
#define CA_PROG_03_PARTITION        (0x00000000U)
#define CA_PROG_04_PARTITION        (0x00000000U)
#define CA_PROG_05_PARTITION        (0x00000000U)
#define CA_PROG_06_PARTITION        (0x00000000U)
#define CA_PROG_07_PARTITION        (0x00000000U)
#define CA_PROG_08_PARTITION        (0x00000000U)
 #endif /* #if (CA_LOAD_TYPE == CA_IPL) */
#else /* #if (RCAR_SA9_TYPE == FLASH_BOOT) */
#define SECURE_FW_PARTITION         (0x00000001U)
#define RTOS_PARTITION              (0x00000001U)
#define CX_IPL_PARTITION            (0x00000001U)
#define CA_PROG_01_PARTITION        (0x00000001U)
#define CA_PROG_02_PARTITION        (0x00000001U)
  #if (OPTEE_LOAD_ENABLE == OPTEE_DISABLE)
#define CA_PROG_03_PARTITION        (0x00000000U)
  #else
#define CA_PROG_03_PARTITION        (0x00000001U)
  #endif /* OPTEE_LOAD_ENABLE == OPTEE_DISABLE */
#define CA_PROG_04_PARTITION        (0x00000000U)
#define CA_PROG_05_PARTITION        (0x00000000U)
#define CA_PROG_06_PARTITION        (0x00000000U)
#define CA_PROG_07_PARTITION        (0x00000000U)
#define CA_PROG_08_PARTITION        (0x00000000U)
#endif

#if (RCAR_SA9_TYPE != EMMC_BOOT)
/* Test data for QSPI DDR mode */
#define QSPI_TESTDATA           (0x5A5AA5A5U)
#else
#define QSPI_TESTDATA           (0x00000000U)
#endif /* (RCAR_SA9_TYPE == FLASH_BOOT) */

/* Destination address for Secure FW */
#define SECURE_FW_ADDRESS       (0xEB240000U)
#define SECURE_FW_ADDRESSH      (0x00000000U)
/* Destination size for Secure FW */
#define SECURE_FW_DST_SIZE      (0x00028000U)   /* 640KiB / 4 */
/* Destination address for RTOS#0 */
#define RTOS_ADDRESS            (0xE2100000U)
#define RTOS_ADDRESSH           (0x00000000U)
/* Destination size for RTOS#0 */
#define RTOS_DST_SIZE           (0x00400000U)   /* 16MiB / 4 */
#if (RTOS_LOAD_NUM == RTOS_LOAD_NUM_3)
/* Destination address for RTOS#1 */
#define RTOS1_ADDRESS           (0xE3100000U)
#define RTOS1_ADDRESSH          (0x00000000U)
/* Destination size for RTOS#1 */
#define RTOS1_DST_SIZE          (0x00080000U)   /* 2MiB / 4 */
/* Destination address for RTOS#2 */
#define RTOS2_ADDRESS           (0xE2000000U)
#define RTOS2_ADDRESSH          (0x00000000U)
/* Destination size for RTOS#2 */
#define RTOS2_DST_SIZE          (0x00004000U)   /* 64KiB / 4 */
#endif /* RTOS_LOAD_NUM == RTOS_LOAD_NUM_3 */

#if (CA_LOAD_TYPE == CA_IPL)
/* Destination address for CA Loader */
#define CX_IPL_ADDRESS          (0xE6300000U)
#define CX_UPL_ADDRESSH         (0x00000000U)
/* Destination size for CA Loader */
#define CX_IPL_SIZE             (0x0000C000U)   /* 192KiB / 4 */
#else
/* CX IPL Reserved */
#define CX_IPL_ADDRESS          (0x00000000U)
#define CX_UPL_ADDRESSH         (0x00000000U)
#define CX_IPL_SIZE             (0x00000000U)
#endif
/* ----------- customized ----------- */
/* Destination address for BL31 */
#define CA_PROG_01_ADDRESS    (0x46400000U)
#define CA_PROG_01_ADDRESSH   (0x00000000U)
#define CA_PROG_01_SIZE       (0x00008800U)   /* 136KiB / 4 */
/* Destination address for U-Boot */
#define CA_PROG_02_ADDRESS    (0x50000000U)
#define CA_PROG_02_ADDRESSH   (0x00000000U)
#define CA_PROG_02_SIZE       (0x00080000U)   /* 2MiB / 4 */
#if (OPTEE_LOAD_ENABLE == OPTEE_DISABLE)
/* Reserved */
#define CA_PROG_03_ADDRESS    (0x00000000U)
#define CA_PROG_03_ADDRESSH   (0x00000000U)
#define CA_PROG_03_SIZE       (0x00000000U)
#else
/* Destination address for OP-TEE */
#define CA_PROG_03_ADDRESS    (0x44100000U)
#define CA_PROG_03_ADDRESSH   (0x00000000U)
#define CA_PROG_03_SIZE       (0x00040000U)   /* 1MiB / 4 */
#endif /* OPTEE_LOAD_ENABLE == OPTEE_DISABLE */
/* Reserved */
#define CA_PROG_04_ADDRESS    (0x00000000U)
#define CA_PROG_04_ADDRESSH   (0x00000000U)
#define CA_PROG_04_SIZE       (0x00000000U)
/* Reserved */
#define CA_PROG_05_ADDRESS    (0x00000000U)
#define CA_PROG_05_ADDRESSH   (0x00000000U)
#define CA_PROG_05_SIZE       (0x00000000U)
/* Reserved */
#define CA_PROG_06_ADDRESS    (0x00000000U)
#define CA_PROG_06_ADDRESSH   (0x00000000U)
#define CA_PROG_06_SIZE       (0x00000000U)
/* Reserved */
#define CA_PROG_07_ADDRESS    (0x00000000U)
#define CA_PROG_07_ADDRESSH   (0x00000000U)
#define CA_PROG_07_SIZE       (0x00000000U)
/* Reserved */
#define CA_PROG_08_ADDRESS    (0x00000000U)
#define CA_PROG_08_ADDRESSH   (0x00000000U)
#define CA_PROG_08_SIZE       (0x00000000U)
/* ----------- customized ----------- */

/* sa9 */
__attribute__ ((section (".sa9_top"))) const uint32_t top_cert[1024 / 4] = {
    [0x0000 / 4] = CA_IMAGE_NUM,
    [0x0008 / 4] = SECURE_FW_SRC_ADDRESS,
    [0x0010 / 4] = SECURE_FW_PARTITION,
    [0x0018 / 4] = RTOS_SRC_ADDRESS,
    [0x0020 / 4] = RTOS_PARTITION,
    [0x0028 / 4] = CX_IPL_SRC_ADDRESS,
    [0x0030 / 4] = CX_IPL_PARTITION,
    [0x0068 / 4] = CA_PROG_01_SRC_ADDRESS,
    [0x0070 / 4] = CA_PROG_01_PARTITION,
    [0x0078 / 4] = CA_PROG_02_SRC_ADDRESS,
    [0x0080 / 4] = CA_PROG_02_PARTITION,
    [0x0088 / 4] = CA_PROG_03_SRC_ADDRESS,
    [0x0090 / 4] = CA_PROG_03_PARTITION,
    [0x0098 / 4] = CA_PROG_04_SRC_ADDRESS,
    [0x00A0 / 4] = CA_PROG_04_PARTITION,
    [0x00A8 / 4] = CA_PROG_05_SRC_ADDRESS,
    [0x00B0 / 4] = CA_PROG_05_PARTITION,
    [0x00B8 / 4] = CA_PROG_06_SRC_ADDRESS,
    [0x00C0 / 4] = CA_PROG_06_PARTITION,
    [0x00C8 / 4] = CA_PROG_07_SRC_ADDRESS,
    [0x00D0 / 4] = CA_PROG_07_PARTITION,
    [0x00D8 / 4] = CA_PROG_08_SRC_ADDRESS,
    [0x00E0 / 4] = CA_PROG_08_PARTITION,
#if (RTOS_LOAD_NUM == RTOS_LOAD_NUM_3)
    [0x0108 / 4] = RTOS1_SRC_ADDRESS,
    [0x0110 / 4] = RTOS1_PARTITION,
    [0x0118 / 4] = RTOS2_SRC_ADDRESS,
    [0x0120 / 4] = RTOS2_PARTITION,
#endif /* RTOS_LOAD_NUM == RTOS_LOAD_NUM_3 */
};
__attribute__ ((section (".qspi_test_data"))) const uint32_t test_data[1] = {
    QSPI_TESTDATA
};
__attribute__ ((section (".sa9_firm"))) const uint32_t firm_cert[2048 / 4] = {
    [0x0154 / 4] = SECURE_FW_ADDRESS,
    [0x0264 / 4] = SECURE_FW_DST_SIZE,
};
__attribute__ ((section (".sa9_rtos"))) const uint32_t rtos_cert[2048 / 4] = {
    [0x0154 / 4] = RTOS_ADDRESS,
    [0x0264 / 4] = RTOS_DST_SIZE,
};
__attribute__ ((section (".sa9_cx_ipl"))) const uint32_t cx_ipl_cert[2048 / 4] = {
    [0x0154 / 4] = CX_IPL_ADDRESS,
    [0x0264 / 4] = CX_IPL_SIZE,
};
__attribute__ ((section (".sa9_ca_01"))) const uint32_t ca_01_cert[2048 / 4] = {
    [0x0154 / 4] = CA_PROG_01_ADDRESS,
    [0x0264 / 4] = CA_PROG_01_SIZE,
};

__attribute__ ((section (".sa9_ca_02"))) const uint32_t ca_02_cert[2048 / 4] = {
    [0x0154 / 4] = CA_PROG_02_ADDRESS,
    [0x0264 / 4] = CA_PROG_02_SIZE,
};
__attribute__ ((section (".sa9_ca_03"))) const uint32_t ca_03_cert[2048 / 4] = {
    [0x0154 / 4] = CA_PROG_03_ADDRESS,
    [0x0264 / 4] = CA_PROG_03_SIZE,
};
__attribute__ ((section (".sa9_ca_04"))) const uint32_t ca_04_cert[2048 / 4] = {
    [0x0154 / 4] = CA_PROG_04_ADDRESS,
    [0x0264 / 4] = CA_PROG_04_SIZE,
};
__attribute__ ((section (".sa9_ca_05"))) const uint32_t ca_05_cert[2048 / 4] = {
    [0x0154 / 4] = CA_PROG_05_ADDRESS,
    [0x0264 / 4] = CA_PROG_05_SIZE,
};
__attribute__ ((section (".sa9_ca_06"))) const uint32_t ca_06_cert[2048 / 4] = {
    [0x0154 / 4] = CA_PROG_06_ADDRESS,
    [0x0264 / 4] = CA_PROG_06_SIZE,
};
__attribute__ ((section (".sa9_ca_07"))) const uint32_t ca_07_cert[2048 / 4] = {
    [0x0154 / 4] = CA_PROG_07_ADDRESS,
    [0x0264 / 4] = CA_PROG_07_SIZE,
};
__attribute__ ((section (".sa9_ca_08"))) const uint32_t ca_08_cert[2048 / 4] = {
    [0x0154 / 4] = CA_PROG_08_ADDRESS,
    [0x0264 / 4] = CA_PROG_08_SIZE,
};

#if (RTOS_LOAD_NUM == RTOS_LOAD_NUM_3)
__attribute__ ((section (".sa9_rtos_01"))) const uint32_t rtos1_cert[2048 / 4] = {
    [0x0154 / 4] = RTOS1_ADDRESS,
    [0x0264 / 4] = RTOS1_DST_SIZE,
};
__attribute__ ((section (".sa9_rtos_02"))) const uint32_t rtos2_cert[2048 / 4] = {
    [0x0154 / 4] = RTOS2_ADDRESS,
    [0x0264 / 4] = RTOS2_DST_SIZE,
};
#endif /* RTOS_LOAD_NUM == RTOS_LOAD_NUM_3 */

/* TFMV key(8KB) + NTFMV key(8KB) + minimum version table(4KB) */
__attribute__ ((section (".reserved"))) const uint32_t reserved[20480 / 4] = {0};
/* G4MH cert * 2 + ICUMH Cert */
__attribute__ ((section (".reserved2"))) const uint32_t reserved2[6144 / 4] = {0};
