/*                                                                          */
/* File Name   : mbdr_dsp_system_utils.h                                    */
/*                                                                          */
/* Written By  : 79556                                                      */
/*                                                                          */
/* versions    :                                                            */
/*+--------+-----------+---------------------------------------------------+*/
/*| Version| Date      | Change content                                    |*/
/*+--------+-----------+---------------------------------------------------+*/
/*|        |21/Feb/2007| Creation                                          |*/
/*+--------+-----------+---------------------------------------------------+*/
/*| 0.02.08|16/Sep/2009|- MBDR_DSP_SYSTEM_UTILS_                           |*/
/*|        |           |     WRITE_32BIT_TO_FPGA_AND_COPY_IMAGE_M          |*/
/*+--------+-----------+---------------------------------------------------+*/
/*| 0.02.34|11/Feb/2010|- split mbdr_dsp_platform_proc_ptrs_t to           |*/
/*|        |           |   mbdr_dsp_platform_external_io_access_proc_ptrs_t|*/
/*|        |           |   mbdr_dsp_platform_core_process_proc_ptrs_t      |*/
/*+--------+-----------+---------------------------------------------------+*/
/*| 0.02.94|20/Dec/2011|- replace programmer name by code                  |*/
/*+--------+-----------+---------------------------------------------------+*/
/*                                                                          */
/* Function    : define system utils that are  common for a few projects    */
/*                                                                          */
/* Macros      1)                                                           */
/*                                                                          */
/*                                                                          */

#include  "windef.h"
#include  "string.h"
#include  "mbdr_dsp_cpu_common_hwimage.h"
#include  "mbdr_dsp_platform_proc_ptrs.h"
#include  "mbdr_dsp_pci_utils_base_tbl.h"

#ifndef _MBDR_DSP_SYSTEM_UTILS_H
#define _MBDR_DSP_SYSTEM_UTILS_H

/* convert input data parameter to 32 bit and store it */
#define MBDR_DSP_UTILS_WRITE_32BIT_TO_DSP_AND_CPU_M(PI_DATA, PO_LOCAL_MEM_P, PO_FAR_CPU_MEM_P)\
        *((LONG *)(PO_LOCAL_MEM_P)) = (LONG)(PI_DATA);\
		 mbdr_dsp_platform_external_io_access_proc_ptrs.cpu_write_dw(PI_DATA, (LONG *)(PO_FAR_CPU_MEM_P), 0)

#define  MBDR_DSP_SYSTEM_UTILS_LIFE_SIGN_ECHO_M(\
                  MBDR_DSP_CPU_COMMON_INTERFACE_DSP_IMAGE_P,\
                  MBDR_DSP_CPU_COMMON_INTERFACE_CPU_IMAGE_P)\
         if(MBDR_DSP_CPU_COMMON_INTERFACE_DSP_IMAGE_P->dsp_life_sign_value\
		    !=\
			MBDR_DSP_CPU_COMMON_INTERFACE_DSP_IMAGE_P->dsp_life_sign_echo)\
         {\
 		   MBDR_DSP_UTILS_WRITE_32BIT_TO_DSP_AND_CPU_M(\
 		     MBDR_DSP_CPU_COMMON_INTERFACE_DSP_IMAGE_P->dsp_life_sign_value,\
 		    &MBDR_DSP_CPU_COMMON_INTERFACE_DSP_IMAGE_P->dsp_life_sign_echo,\
 		    &MBDR_DSP_CPU_COMMON_INTERFACE_CPU_IMAGE_P->dsp_life_sign_echo);\
		 }

/* writes input 32bit parameter to:  */
/*                                   */
#define MBDR_DSP_SYSTEM_UTILS_WRITE_32BIT_TO_FPGA_AND_COPY_IMAGE_IN_GIVEN_BOFS_M(\
                 PI_MBDR_DSP_PCI_UTILS_BASE_TBL_INDEX,\
                 PI_DESTINATON_BOFS,\
                 PI_32BIT_DATA)\
  *( (LONG *)(((ULONG)mbdr_dsp_copy_hwimage_p_tbl[PI_MBDR_DSP_PCI_UTILS_BASE_TBL_INDEX])\
              +PI_DESTINATON_BOFS))\
            = (LONG )(PI_32BIT_DATA);\
  mbdr_dsp_platform_external_io_access_proc_ptrs.fpga_write_dw(PI_32BIT_DATA,\
	     (LONG *)\
	     ( mbdr_dsp_pci_utils_base_tbl[PI_MBDR_DSP_PCI_UTILS_BASE_TBL_INDEX]\
	      +PI_DESTINATON_BOFS),\
	      0)

/* writes input 32bit parameter to: fpga, copy_image */
#define MBDR_DSP_SYSTEM_UTILS_WRITE_32BIT_TO_FPGA_AND_COPY_IMAGE_M(\
                 PI_32BIT_DATA,\
				 PI_PCI_MEMCPY_CODE,\
                 PO_FPGA_P,\
                 PO_COPY_IMAGE_P)\
  *PO_COPY_IMAGE_P = (LONG)(PI_32BIT_DATA);\
  mbdr_dsp_platform_external_io_access_proc_ptrs.fpga_write_dw(PI_32BIT_DATA,(LONG *)(PO_FPGA_P),\
                                            PI_PCI_MEMCPY_CODE)


#endif
