/* Remark: Not crutial for board testing or board integration               */
/*                                                                          */
/*                                                                          */
/* Function    : fascility to link PCIe write messages through QDMA         */
/*               All routines are not reentrant, at most single routine is  */
/*               active,                                                    */
/*               Each core will have its own driver instance, by nature user*/ 
/*               application is responsible to avoid resource(DMA cahnnel,  */
/*               temporary memory, collision                                */
/*               It will use the pparam transfer mechanism                  */
/*               It has to supports at most 2 lists, generally the prior    */
/*               requests list delivery is expected to terminate before     */
/*               requesting to send the currently build list.               */
/*               Rarely if user instructs to send the latest list before    */
/*               the previous exaussted driver waits in place for the       */
/*               previous to terminate                                      */
/*               In a similiar manner if there is no room in temporary      */
/*               driver works in place till end of previous transaction     */
/*               for free place                                             */
/* +-------------+                          +-----------------------------+ */
/* | application |                          |                             | */
/* |             +--Init------------------->|                             | */
/* |             | (supply:temporary data buffer                          | */
/* |             |         DMA channel      |                             | */
/* |             |         status structure |                             | */
/* |             |         pparam elements  |                             | */
/* |             |         first_ppram_index|                             | */
/* |             |                          |                             | */
/* |             +--Link_next_message------>|                             | */
/* |             |  (buffer)                |                             | */
/* |             +--Send linked list------->|                             | */
/* |             |                          |                             | */
/* |             +--Wait for finish-------->|                             | */
/* |             |                          |    +----------+             | */
/* |             |--------data------------------\|Temporary |             | */
/* |             |------------------------------/|cyclic    |             | */
/* |             |                          |    |buffer    |             | */
/* |             |                          |    +----------+             | */
/* |             |                          |        | |                  | */
/* +-------------+                          +--------| |------------------+ */
/*                                                   | |         ||         */
/*                                                   \ /         \/         */
/*                                          +------------------------------+*/
/*                                          |    DMA            +----+     |*/
/*                                          |                   +----+     |*/
/*                                          |                   +----+     |*/
/*                                          |                   PaRam      |*/
/*                                          |                   links queue|*/
/*                                          +------------------------------+*/
/*                                                                          */
/* All transactins are DW memory aligned                                    */
/*                                                                          */
/*                                                                          */
/*                                                                          */
/*                                                                          */
#include  "windef.h"
#include  "string.h"
#include  "dsp_qdma_link_driver_control.h"
#ifndef _MBDR_DSP_QDMA_LINK_DRIVER_H__
#define _MBDR_DSP_QDMA_LINK_DRIVER_H__

/* Performs initialization                                                  */
/*                                                                          */
/*                                                                          */
extern void dsp_qdma_link_driver_config(
                    LONG                              *pio_temporary_buffer_p,
                    LONG                               pi_temporary_buffer_byte_size,
                    SHORT                              pi_channel_number,              
                    SHORT                              pi_first_param_index,
                    SHORT                              pi_param_entries,
                    dsp_qdma_link_driver_control_t    *pio_dsp_qdma_link_driver_control_p);
					
/* Add next message to deliveries linked list                              */
/* If there is no room in temporary memory' wait till it is free           */
extern void dsp_qdma_link_driver_link_next_message(
                    LONG                              *pi_data_buffer_p,
                    SHORT                              pi_data_baffer_byte_size,
                    dsp_qdma_link_driver_control_t    *pio_dsp_qdma_link_driver_control_p);
					
/* return free memory byte size */
extern LONG  dsp_qdma_get_free_memory_byte_size(
                      dsp_qdma_link_driver_control_t *pi_dsp_qdma_link_driver_control_p);					
					
					
/* Send the last built linked list, no need to wait for end of transmission */
/* but every thing has to be informed to HW                                 */
/* If nothing waits just return                                             */
extern void dsp_qdma_link_driver_send_list(
                     dsp_qdma_link_driver_control_t  *pio_dsp_qdma_link_driver_control_p);
					
/* Send all and waits till DMA takes everything */
extern void dsp_qdma_link_driver_flush(
                     dsp_qdma_link_driver_control_t *pio_dsp_qdma_link_driver_control_p);

#endif
