/**   phase1_error_handler.h
 **
 **   This module includes definitions to support the error handler and error logic
 ** for the built-in BIST tests.
 **
 ** Created by Ted Schmitz, October 15, 2008
 **
 **/
#include <common.h>

/**   The following symbols define the various flags used in the "call_type"
 ** field of the "error_data" structure.
 **
 **               /  B I T \
 ** +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
 ** |15|14|13|12|11|10| 9| 8| 7| 6| 5| 4| 3| 2| 1| 0|        Call Type
 ** +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ ------------------------
 ** |  |  |  |  |  |  |  |  |  |  |  |X |X |X |  |X | EH_DISP_TYP_INFO
 ** +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
 ** |  |  |  |  |  |  |  |  |  |  |  |X |X |X |X |X | EH_DISP_TYP_INFO_MSG
 ** +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
 ** |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |
 ** +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
 **   |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |
 **   |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Display Error code
 **   |  |  |  |  |  |  |  |  |  |  |  |  |  |  Display User supplied message
 **   |  |  |  |  |  |  |  |  |  |  |  |  |  Display failure address
 **   |  |  |  |  |  |  |  |  |  |  |  |  Display expected data
 **   |  |  |  |  |  |  |  |  |  |  |  Display bad data received
 **   |  |  |  |  |  |  |  |  |  |  Display "Warning" not "Fail"
 **          RESERVED
 **                                          
 **/
#define EH_DISP_EC     0x0001       /* display error code */
#define EH_DISP_MSG    0x0002       /* display user supplied ASCII message */
#define EH_DISP_ADRS   0x0004       /* disp failure address */
#define EH_DISP_EXP    0x0008       /* display expected data */
#define EH_DISP_REC    0x0010       /* display received data */
#define EH_DISP_WARN   0x0020       /* this is a warning. Displ "Warning!" not
                                       "Fail!".  Do not set error flag. */

#define EH_DISP_TYP_INFO (EH_DISP_EC | EH_DISP_ADRS | EH_DISP_EXP | \
                          EH_DISP_REC)

#define EH_DISP_TYP_INFO_MSG (EH_DISP_EC | EH_DISP_ADRS | EH_DISP_EXP | \
                              EH_DISP_REC | EH_DISP_MSG)

/* end of "call_type" parameter definitions */

/**   The following sumbols define the values used for the "length"
 ** parameter for the "error_data" structure.
 **/
#define BYTES_1 1         /* 1 byte exp & received data */
#define BYTES_2 2         /* 2 byte exp & received data */
#define BYTES_4 3         /* 4 byte exp & received data */
#define BYTES_8 4         /* 8 byte exp & received data */
/* end of "length" parameter definitions */

/**   The following structure defines all the elements of data used by the
 ** error handler to report and save the error information for any given
 ** failure.
 **/
struct error_data 
  {
  u16 error_stop;              /* 16-bit unique error stop */
  u16 sup_error_stop;          /* 16-bit supplimental error stop */
  char * msgp;                 /* pointer to user defined error message */
  u64 fail_adrs;               /* 64-bit address where failure was detected */
  u64 exp_data;                /* 64-bit good data expected */
  u64 rec_data;                /* 64-bit bad data received */
  int length;                  /* display length (in bytes) of exp & rec data */
  u16 call_type;               /* type of call to error handler: display message
                                  only, display address at fault, etc. */
  int test_no;                 /* subtest number that failed */
  int exec_count;              /* execution count at time of failure */
  };

extern void p1_error_handler(struct error_data * eh);

extern struct error_data glob_eh; /* global error hander structure */
