/**     errhand.h
 **
 ** Author: Ted Schmitz
 ** Date of original creation: December 8, 2008
 **
 **     This file contains all the references used by the error handler and
 ** the tests to communicate with the error handler.
 **
 **/
#ifndef __ERRHAND_H	/* if not included yet, include one time only */
#define __ERRHAND_H

#include <common.h>
#include "errhand_defs.h" /* get some of the common error handler defs */

#define FAIL 1                          /* failure = non zero  value */
#define PASS 0                          /* test passed = zero */

#define MAX_EXP_REC 4			/* maximum number of elements in the
					   "data_exp[]" & "data_rec[]" arrays
					  used in many structures and routines
					  throughout the monitor code */

/**
 **    The following symbols define all the possible Field Replacable Unit
 ** values that can be used in the "fru_list[]" element in the error handler 
 ** information structure.
 **
 ** NOTE:  This field replacement list is an EXAMPLE ONLY!!!  This list was
 **        created to demonstrate the capabilities of the FRU list.
 **        This list should be disabled in favor of the real list for
 **        the particulat hardware  platform under test.
 **
 ** slot1 - slot8 = define the chassis boards from left to right or top to
 **                  bottom respectively.
 ** ps1 - ps3 = define the chassis power supplies from left to right
 **             respectively.
 ** f1 - f1 = define the fans from left to right or front to back respectively.
 ** dimm1 - dimm2 = SDRAM DIMM modules from lowest to highest address
 **                 respectively.
 **/

enum frus
  {
  slot1, slot2,  slot3,  slot4,  slot5,  slot6,  slot7,  slot8,
  ps1, ps2, ps3, f1, f2, f3, dimm1, dimm2, unit, mb, ha_bd
  };

#define MAX_USR_MSG 256			/* max size of optional user error
					   message */
#define MAX_FRUS 10			/* max number of FRU's that can be 
					   stored in FRU list. */
#define MAX_FRU_ASCII_CHARS 25		/* maximum number for ASCII characters
					   for any FRU name. */

extern struct save_fail first_fail;     /* first failure info */
extern struct save_fail last_fail;      /* last failure info */
extern unsigned char error_mode;        /* current testing error mode */
extern int error_flag;                  /* flag if test failed */

/* error routine to display all error information */
extern void disp_failure(struct save_fail * fdptr);

extern void disp_non_volatile_failure_info(void);

/**	Error Handler Information Structure
 **
 **   This structure defines all the possible information the error handler
 ** may need to properly log and display any errors or other information 
 ** reported to the diagnostic monitor.
 **
 **   Every call to the error handler must include a pointer to a structure of
 ** this type.
 **/
struct errhand_info
  {
  int call_type;			         /* reason for calling error handler */
  unsigned short error_stop;		 /* upper 16 bits of error code */
  unsigned short sup_error_stop;     /* lower 16 bits of error code */
  int severity;				/* Severity of call: fatal, warning...*/
    //unsigned int data_exp[MAX_EXP_REC]; /* up to X 32-bit words of exp data */
    //unsigned int data_rec[MAX_EXP_REC]; /* up to X 32-bit words of data rec */
    //unsigned int fail_adrs;             /* address of failure */
  u64 data_exp[MAX_EXP_REC];         /* up to X 64-bit words of exp data */
  u64 data_rec[MAX_EXP_REC];         /* up to X 64-bit words of data rec */
  u64 fail_adrs;                     /* 64-bit address of failure */
  int disp_size;                     /* size of failure data */
  void * void_ptr;			         /* pointer to msg, data, etc. */
  enum frus fru_list[MAX_FRUS];		 /* FRU list term with 0xff */
  };

/** 	Failure information used by system procedures.  Not all fields are used
 ** for all failures.
 **/
struct save_fail
  {
  struct errhand_info eh;               /* save a copy of fail data */
  int test_no;                          /* subtest number that failed */
  int exec_count;                       /* execution count at time of failure */
  char err_msg[MAX_USR_MSG];		/* optional user defined error msg */
  };

/* common error handler */
extern void error_handler(struct errhand_info * ehi);

#endif /* end "ifndef __ERRHAND_H..."  */
