/******************************************************************************/
/*                 Copyright C 1998-2002 Broadcom Corporation                 */
/*                                                                            */
/* This material is the confidential trade secret and proprietary information */
/* of Broadcom Corporation.  It may not be reproduced, used, sold or          */
/* transferred to any third party without the prior written consent of        */
/* Broadcom Corporation.   All rights reserved.                               */
/******************************************************************************/
/*   FileName        : bcm_hmiDebugMsg.h                                      */
/*   Purpose         : Header for all supported debug HMI message types       */
/*   Limitations     : None                                                   */
/*   Author          : Emmanuel Hanssens                                      */
/*   Creation Date   : 27-Jun-2002                                            */
/*   History         : Compiled by CVS                                        */
/******************************************************************************/
/*   $Id: bcm_hmiDebugMsg.h,v 1.12 2004/09/29 08:10:14 hanssens Exp $  */
/******************************************************************************/
#ifndef HMI_DEBUG_MSG_H
# define HMI_DEBUG_MSG_H

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

/* {{{ Application ID */

# define DEBUG_MANAGER_ID(line) (0x300+(BCM_LINE_2_CORE(line)%2))

/* }}} */
/* {{{ Available services */

# define GET_LOG_AND_DEBUG_INFO                  0x8006
# define GET_DEBUG_PRINT_LEVEL                   0x8007
# define SET_DEBUG_PRINT_LEVEL                   0x8008
# define GET_DEBUG_DATA_DUMP                     0x8004
# define GET_DEBUG_DUMP_MASK                     0x8009
# define SET_DEBUG_DUMP_MASK                     0x800A

/* }}} */

/* {{{ GetLogAndDebugInfo service */

typedef struct GetLogAndDebugInfoMsgReq GetLogAndDebugInfoMsgReq;
struct GetLogAndDebugInfoMsgReq
{ 
  uint32 type;                  /* Type of debug print requested:
                                 * 0: General Error Handler calls
                                 * 1: Error Handler calls at line reset
                                 * 2: Error Handler calls at device reset
                                 * 3: Debug print calls */
} BCM_PACKING_ATTRIBUTE ;

typedef struct LogAndDebugPacket LogAndDebugPacket;
struct LogAndDebugPacket
{
  uint32 rxSymbolNb;            /* Rx DMT symbol number within a phase */
  uint32 txSymbolNb;            /* Tx DMT symbol number within a phase */
  uint16 rxPhaseNb;             /* Rx phase number */
  uint16 txPhaseNb;             /* Tx phase number */
  uint32 traceAndLineId;        /* 24 MSB is a trace id, 8 LSB a line id */
  uint32 arg1LSB;               /* LSB of first debug string argument */
  uint32 arg1MSB;               /* MSB of first debug string argument */
  uint32 arg2LSB;               /* LSB of second debug string argument */
  uint32 arg2MSB;               /* MSB of second debug string argument */
} BCM_PACKING_ATTRIBUTE ;

# define MAX_LOG_AND_DEBUG_PACKETS MAX_HMI_PACKET_SIZE/sizeof(LogAndDebugPacket)

typedef struct GetLogAndDebugInfoMsgRep GetLogAndDebugInfoMsgRep;
struct GetLogAndDebugInfoMsgRep
{
  LogAndDebugPacket packets[MAX_LOG_AND_DEBUG_PACKETS];
} BCM_PACKING_ATTRIBUTE ;

extern typeLayout LogAndDebugPacketLayout[];
extern MsgLayout  GetLogAndDebugInfoLayout;

# ifndef BCM_LOG_DATA_CACHE_SIZE
#  define BCM_LOG_DATA_CACHE_SIZE 2048
# endif

/* additional structure for local debug packet cache */
typedef struct
{
  LogAndDebugPacket         data[BCM_LOG_DATA_CACHE_SIZE];
  uint8                     coreId[BCM_LOG_DATA_CACHE_SIZE];
  uint32                    rdPtr;
  uint32                    wrPtr;
} LogAndDebugPacketCache;

# define BCM_LOG_DATA_CACHE_FULL(buf) \
         (((buf)->wrPtr+1)%BCM_LOG_DATA_CACHE_SIZE == (buf)->rdPtr)
# define BCM_LOG_DATA_CACHE_EMPTY(buf) ((buf)->wrPtr == (buf)->rdPtr)

/* }}} */
/* {{{ GetDebugPrintLevel service */

typedef struct GetDebugPrintLevelMsgReq GetDebugPrintLevelMsgReq;
struct GetDebugPrintLevelMsgReq
{
  uint16 lineId;                /* id per core (lineId<BCM_DEV_NB_LINES/2) */
} BCM_PACKING_ATTRIBUTE ;

typedef struct GetDebugPrintLevelMsgRep GetDebugPrintLevelMsgRep;
struct GetDebugPrintLevelMsgRep
{
  uint8 level;
} BCM_PACKING_ATTRIBUTE ;

extern  MsgLayout GetDebugPrintLevelLayout;

/* }}} */
/* {{{ SetDebugPrintLevel service */

typedef struct SetDebugPrintLevelMsgReq SetDebugPrintLevelMsgReq;
struct SetDebugPrintLevelMsgReq
{
  uint16 lineId;                /* id per core (lineId<BCM_DEV_NB_LINES/2) */
  uint8  level;
  uint8  reserved;
} BCM_PACKING_ATTRIBUTE ;

extern  MsgLayout SetDebugPrintLevelLayout;

/* }}} */
/* {{{ GetDebugDataDump service */

typedef struct GetDebugDataDumpMsgReq GetDebugDataDumpMsgReq;
struct GetDebugDataDumpMsgReq
{
  int32  transId;               /* transaction Id */
} BCM_PACKING_ATTRIBUTE ;

typedef struct GetDebugDataDumpMsgRep GetDebugDataDumpMsgRep;
struct GetDebugDataDumpMsgRep
{
  int32  transId;               /* transaction Id */
  uint32 dataSize;              /* size of data payload */
  uint8  data;
} BCM_PACKING_ATTRIBUTE ;

extern  MsgLayout GetDebugDataDumpLayout;

/* }}} */
/* {{{ GetDebugDumpMask service */

# define BCM_NBR_OF_DUMPS 256

typedef struct GetDebugDumpMaskMsgReq GetDebugDumpMaskMsgReq;
struct GetDebugDumpMaskMsgReq
{
  uint8 lineId;
} BCM_PACKING_ATTRIBUTE ;

typedef struct GetDebugDumpMaskMsgRep GetDebugDumpMaskMsgRep;
struct GetDebugDumpMaskMsgRep
{
  uint8 dumpMask[((BCM_NBR_OF_DUMPS-1)>>3) + 1];
} BCM_PACKING_ATTRIBUTE ;

extern  MsgLayout GetDebugDumpMaskLayout;

/* }}} */
/* {{{ SetDebugDumpMask service */

typedef struct SetDebugDumpMaskMsgReq SetDebugDumpMaskMsgReq;
struct SetDebugDumpMaskMsgReq
{
  uint8 lineId;
  uint8 dumpMask[((BCM_NBR_OF_DUMPS-1)>>3) + 1];
} BCM_PACKING_ATTRIBUTE ;

extern  MsgLayout SetDebugDumpMaskLayout;

/* }}} */

#endif
