
#ifndef NVM_PRV_SIZE_RAM_MIRROR_H
#define NVM_PRV_SIZE_RAM_MIRROR_H

#include "NvM_Cfg.h"

#if (NVM_DEM_BLOCK_LENGTH_STRING_USED == STD_ON)
#include "Dem_FwdToNvm.h"
#endif

#if (DEM_NVM_CFG_NUM_BLOCKS_TOTAL != 0)

typedef union UnionDemBlockType {
        Dem_GenericNvDataType  Dem_GenericNvData;

        Dem_EvMemEventMemoryType Dem_EvMemEventMemory;

#ifdef DEM_CFG_PRESTORED_FREEZEFRAME_NVMIDS
        Dem_EvBuffEvent Dem_EvBuffEvent;
#endif

#if( DEM_BFM_ENABLED == DEM_BFM_ON )
    rba_DemBfm_Record bfmRecord;
#if(RBA_DEMBFM_EXTENDED_DEBUG_DATA_SUPPORTED == DEM_BFM_ON)
    rba_DemBfm_ExtendedDebugDataRecord bfmExtDbgDataRecord;
#endif
    rba_DemBfm_RecordManagementDataNvm bfmManagementData;
#if (RBA_DEMBFM_COUNTER_IN_NVM_ENABLED == DEM_BFM_ON)
    rba_DemBfm_CounterNvm bfmCounterData;
#endif
#endif

#if (DEM_CFG_EVT_INDICATOR == DEM_CFG_EVT_INDICATOR_ON)
        DEM_ARRAY_DEFINE(Dem_EvtIndicatorAttributeState, Dem_AllEventsIndicatorState, DEM_INDICATOR_ATTRIBUTE_ARRAYLENGTH);
#endif

#if(DEM_CFG_ALLOW_HISTORY == DEM_CFG_ALLOW_HISTORY_ON)
        DEM_BITARRAY_DEFINE(Dem_AllEventsHistoryStatus, DEM_EVENTID_ARRAYLENGTH);
#endif

#if(DEM_CFG_DISTURBANCE_MEMORY == DEM_CFG_DISTURBANCE_MEMORY_ON)
        DEM_ARRAY_DEFINE( Dem_DistMemLocationType, Dem_DistMemLocations, DEM_CFG_DISTURBANCE_MEMORY_ARRAYLENGTH);
#endif

        DEM_ARRAY_DEFINE(      uint8, Dem_AllEventsStatusByte, DEM_EVENTID_ARRAYLENGTH);

#if (DEM_CFG_ERASE_ALL_DATA_SUPPORTED == DEM_CFG_ERASE_ALL_WITH_HASHID_CHECK)
        DEM_ARRAY_DEFINE(Dem_NvmHashIdType, Dem_HashIdInNvm, DEM_NVM_HASH_ID_SIZE);
#endif
#if (DEM_CFG_OBD != DEM_CFG_OBD_OFF)
        rba_DemObdBasic_PdtcMemType obdPdtcMemData[DEM_CFG_PERMANENT_MEMORY_SIZE];
#endif
#if DEM_CFG_OBD_IUMPR
        rba_DemObdBasic_IumprNvDataType rba_DemObdBasic_IumprNvData;
#endif
#if DEM_CFG_OBD_DTR
        rba_DemObdBasic_DtrDataType rba_DemObdBasic_DtrData;
#endif

}UnionDemBlockType;

#define NVM_PRV_SIZE_RAM_MIRROR_LENGTH_STRING (DEM_SIZEOF_TYPE(UnionDemBlockType) + NVM_PRV_CFG_SIZE_ADDING_LENGTH_STRING)

#else

#define NVM_PRV_SIZE_RAM_MIRROR_LENGTH_STRING 0


#endif

#define NVM_PRV_SIZE_RAM_MIRROR  (NVM_PRV_SIZE_RAM_MIRROR_LENGTH_STRING > NVM_PRV_SIZE_RAM_MIRROR_USER_CONF?\
                NVM_PRV_SIZE_RAM_MIRROR_LENGTH_STRING : NVM_PRV_SIZE_RAM_MIRROR_USER_CONF)

#if (NVM_CRYPTO_USED == STD_ON)

#define NVM_PRV_CFG_SIZE_CRYPTO_BUFFER (NVM_PRV_SIZE_RAM_MIRROR_LENGTH_STRING > NVM_PRV_CFG_SIZE_CRYPTO_BUFFER_CFG?\
                NVM_PRV_SIZE_RAM_MIRROR_LENGTH_STRING : NVM_PRV_CFG_SIZE_CRYPTO_BUFFER_CFG)
#else

#define NVM_PRV_CFG_SIZE_CRYPTO_BUFFER NVM_PRV_CFG_SIZE_CRYPTO_BUFFER_CFG

#endif

#endif /* NVM_PRV_SIZE_RAM_MIRROR_H */
