/*                                                                          */
/* Function    : define header of cyclic buffer module                      */
/*                                                                          */
/*               Buffer Features:                                           */
/*                 1) Entries number is a power of 2                        */
/*                 2) Entries size is DW align                              */
/*                 2) Buffer start address is DW align                      */
/*                 3) Read and Write process can be asychronous             */
/*                 4) buffer data area and buffer header area are supplied  */
/*                    by user                                               */
/*                 5) no protection against write to full buffer            */
/*                 6) no protection against read from empty buffer          */
/*                                                                          */
/*                                +---------+                               */
/*                                |         |                               */
/*                                |         |                               */
/*                                |         |                               */
/*   +------------+               |         |                               */
/*   |            |     +-------->|         |                               */
/*   |            |     |         |         |                               */
/*   | read_index |-----+         |         |                               */
/*   |            |               |         |                               */
/*   | write_index|-------------->|         |                               */
/*   |            |               |         |                               */
/*   | Header     |               |         |                               */
/*   | Area       |               |         |                               */
/*   +------------+               |         |                               */
/*                                |Data     |                               */
/*                                |Area     |                               */
/*                                +---------+                               */
/*                                                                          */
#include  "mbdr_dsp_common_type_def.h"
#include  "windef.h"

#ifndef  __MBDR_DSP_COMMON_CYCLIC_BUFFER_HEADER_H
#define  __MBDR_DSP_COMMON_CYCLIC_BUFFER_HEADER_H

typedef struct _mbdr_dsp_cyclic_buf_hdr_t
{                                      /*DW bits                             */
 volatile SHORT write_index;           /* 0 15...0                           */
 CHAR           dbg_smash_indication_f;/* 0 23..16 overwrite indication      */
 UCHAR          dbg_write_roll_count;  /* 0 31..24 full write rolls counter  */
 volatile SHORT read_index;            /* 1 15...0                           */
 CHAR           dummy_0;              /* 1 23..16 padding since PCI DW access*/
 UCHAR          dbg_read_roll_count;   /* 1 31..24 full write rolls counter  */
 SHORT          entry_byte_size;       /* 2 15...0                           */
 SHORT          entries_number;        /* 2 31..16                           */

 /* In multi processor implementation, the creator(receiver) CPU initialize  */
 /* buffer_base_p to byte offset of buffer in its memory, the transmitter    */
 /* has to update these feild to consider PCI base before writing data to    */
 /* cyclic buffer.                                                           */
 UCHAR         *buffer_base_p;         /* 3 31...0                           */

 /* 4        pysical layer copy memcpy */
 void* (*write_memcpy_proc_p)(void       *po_destination_p,
                              const void *pi_source_p,
                              USHORT      pi_buffer_byte_size,
                              USHORT      pi_user_application);

 /* pi_user_application of write_memcpy_proc_p for data copy call            */
 USHORT data_memcpy_code;         /* 5 15..0      */
 /* pi_user_application of write_memcpy_proc_p for var CPU header update call*/
 USHORT header_memcpy_code; /* 5 31.16      */

 SHORT  synchronized_access_occupied_entries; /* 6 15..0      */
 SHORT  synchronized_access_free_entries;     /* 6 31.16      */
 LONG   spare_7;                              /*              7*/
}mbdr_dsp_cyclic_buf_hdr_t;

#endif
