/******************************************************************************/
/*                       Copyright 2001 Broadcom Corporation                  */
/*                                                                            */
/* This material is the confidential trade secret and proprietary information */
/* of Broadcom Corp.  It may not be reproduced, used, sold or transferred to  */
/* any third party without the prior written consent of Broadcom Corp.        */
/* All rights reserved.                                                       */
/******************************************************************************/
/*   FileName        : bcm_SharedControlQueue.h                               */
/*   Purpose         : Definition of the SharedQueue types                    */
/*   Limitations     : None                                                   */
/*   Author          : Emmanuel Hanssens                                      */
/*   Creation Date   : 13-Sep-2001                                            */
/*   History         : Compiled by CVS                                        */
/******************************************************************************/
/*   $Id: bcm_SharedControlQueue.h,v 1.2 2004/06/22 13:51:03 hanssens Exp $  */
/******************************************************************************/
#ifndef SHARED_CONTROL_QUEUE_H
# define SHARED_CONTROL_QUEUE_H

# include "bcm_userdef.h"
# include "bcm_layout.h"

typedef struct SharedQueueGeometry SharedQueueGeometry;
struct SharedQueueGeometry 
{
  uint16  queue_offset;         /* indicates the queue positions, information
                                 * gives the offset in bytes compared to start
                                 * of the page */
  uint16  queue_size;           /* number of slot in the queue */
  uint16  element_size;         /* size of the queue slots */
  uint16  reserved;
};
extern typeLayout SharedQueueGeometryLayout[];

typedef struct SharedQueueControl SharedQueueControl;
struct SharedQueueControl
{/* the queue is empty when head == tail,
  * the head points to the first message to read
  * the tail points to the first free position in the queue */
  uint8 head;                   /* read-only for the "queue writer" */
  uint8 reservedA[3];
  uint8 tail;                   /* read-only for the "queue reader" */
  uint8 reservedB[3];
};
extern typeLayout SharedQueueControlLayout[];

# define QUEUE_EMPTY(q) ((q)->tail == (q)->head)
# define QUEUE_FULL(q,s) (((q)->tail+1)%(s) == (q)->head)

# define HEAD_OFFSET   0
# define TAIL_OFFSET   4
# define GEOMETRY_SIZE 8

#endif

