/*                                                                          */
/* File Name   : mbdr_dsp_debug_prob.c                                      */
/*                                                                          */
/* Written By  : 79556                                                      */
/*                                                                          */
/* versions    :                                                            */
/* +-------+-----------+---------------------------------------------------+*/
/* |Version| Date      | Change content                                    |*/
/* +-------+-----------+---------------------------------------------------+*/
/* |       |       2006| Creation                                          |*/
/* +-------+-----------+---------------------------------------------------+*/
/* |       |23/Sep/2006| mbdr_dsp_dbg_read_and_split_prob_dw_buf           |*/
/* +-------+-----------+---------------------------------------------------+*/
/*| 0.02.65|24/Jan/2011|- mbdr_dsp_debug_prob_read_dw_buffer_repeated_times|*/
/*+--------+-----------+---------------------------------------------------+*/
/*                                                                          */
/* Function    : define prob/read write utilities                           */
/*                                                                          */

#include "windef.h"
#include "mbdr_dsp_debug_prob.h"


void mbdr_dsp_dbg_read_prob_dw_buf(volatile LONG  *pi_prob_read_fp,
                                   int             pi_buf_byte_size,
                                   void           *po_buf_p)
{/* mbdr_dsp_dbg_read_prob_dw_buf */
 int i;
 LONG *output_buf_p;

 output_buf_p = (LONG *)po_buf_p;


 for (i=0; i<pi_buf_byte_size/4; i++)
     *output_buf_p++ = *pi_prob_read_fp;

}/* mbdr_dsp_dbg_read_prob_dw_buf */

void mbdr_dsp_dbg_read_and_split_prob_dw_buf(
                        volatile LONG  *pi_prob_read_fp,
                        int             pi_buf_byte_size,
                        void           *po_dw_buf_0_p,
                        void           *po_dw_buf_1_p)
{/* mbdr_dsp_dbg_read_and_split_prob_dw_buf */
 int i;
 LONG *output_buf_0_p, *output_buf_1_p;

 output_buf_0_p = (LONG *)po_dw_buf_0_p;
 output_buf_1_p = (LONG *)po_dw_buf_1_p;

 for (i=0; i<pi_buf_byte_size/8; i++)
 {
   *output_buf_0_p++ = *pi_prob_read_fp;
   *output_buf_1_p++ = *pi_prob_read_fp;
 }
}/* mbdr_dsp_dbg_read_and_split_prob_dw_buf */


void mbdr_dsp_dbg_read_prob_word_buf(volatile SHORT  *pi_prob_read_fp,
                                     int              pi_buf_byte_size,
                                     void            *po_buf_p)
{/* mbdr_dsp_dbg_read_prob_word_buf */
 int i;
 SHORT *output_buf_p;

 output_buf_p = (SHORT *)po_buf_p;


 for (i=0; i<pi_buf_byte_size/sizeof(SHORT); i++)
     *output_buf_p++ = *pi_prob_read_fp;

}/* mbdr_dsp_dbg_read_prob_word_buf */


extern  LONG mbdr_dsp_debug_prob_read_dw_dw_count;
        LONG mbdr_dsp_debug_prob_read_dw_dw_count;


void mbdr_dsp_debug_prob_read_dw_buffer_repeated_times(
                         SHORT           pi_repeat_count,
                         volatile LONG  *pi_source_prob_p,
                         LONG           *po_destination_buf_p)
{/* mbdr_dsp_debug_prob_read_dw_buffer_repeated_times */

 SHORT i;

 /* derives file DW size */
 mbdr_dsp_dbg_read_prob_dw_buf(
        pi_source_prob_p,
        sizeof(LONG),
        &mbdr_dsp_debug_prob_read_dw_dw_count);

 /* reads rest file to output buffer */
 mbdr_dsp_dbg_read_prob_dw_buf(
        pi_source_prob_p,
        mbdr_dsp_debug_prob_read_dw_dw_count*sizeof(LONG),
        po_destination_buf_p);

 /* first iteration is self copy, repeats copy up to user request */
 for(i=0; i<pi_repeat_count; i++)
     memcpy(&po_destination_buf_p[i*mbdr_dsp_debug_prob_read_dw_dw_count],
            po_destination_buf_p,
            mbdr_dsp_debug_prob_read_dw_dw_count*sizeof(LONG));

}/* mbdr_dsp_debug_prob_read_dw_buffer_repeated_times */
