/**     io_drivers_npa_56x4.h
 **
 ** Author: Ted Schmitz
 ** Date of original creation February 13, 2009
 **
 **     This I/O drivers header file for the NPA-56x4 AMC board.
 **
 **
 **/

extern int kbhit(void);
extern char readch(void);
extern int bist_read_seeprom(unsigned char * buffer, 
                             unsigned int offset, int length);
extern int bist_write_seeprom(unsigned char * buffer, 
                              unsigned int offset, int length);

extern int bist_read_i2c_device(unsigned char * buffer, 
                                unsigned char i2c_adrs,
                                unsigned int reg_no, 
                                int length,
                                int err_msg_flag);
extern int bist_write_i2c_device(unsigned char * buffer, 
                                 unsigned char i2c_adrs,
                                 unsigned int reg_no, 
                                 int length);

//extern unsigned long bist_get_sys_time(void);
extern uint64_t bist_get_sys_time(void);
extern void bist_set_sys_time(uint64_t val);

extern int send_bist_cmd_to_h8(unsigned short cmd, unsigned short length,
                               unsigned char * data_ptr,
                               unsigned char * rcvd_msg_ptr);
extern void h8_reset_octeon(void);
extern void h8_config_xaui_mux(unsigned char mux_mode);

extern uint8_t bist_rx_msg[]; /* bist msg, received from h8, working space */

/**  The following structure defines all of the elements that can be sent
 ** to the Octeon, in the payload section of an H8 response message, if an 
 ** error is detected with the last command received from the Octeon.
 **
 ** NOTE:  This is a stripped down version of the error information structure
 **        used in the BIST monitor on the Octeon.
 **
 ** ALSO NOTE:  For some reason byte fields in structures do not always align
 **             correctly.  So make some things longer to make it work.
 **/
struct h8_error_info
{
  unsigned short err_type;        /* what type of information is available */
  unsigned short error_stop;	  /* upper 16 bits of error code */
  unsigned short sup_error_stop;  /* lower 16 bits of error code */
  unsigned short severity;		  /* Severity of call: fatal, warning...*/
  unsigned long data_exp;         /* up to 32-bits of exp data */
  unsigned long data_rec;         /* up to 32-bits of data rec */
  unsigned long fail_adrs;        /* address of failure */
  unsigned short disp_size;       /* size of failure data */
  unsigned short fru_list[MAX_FRUS]; /* FRU list term with 0xff */
};

/* max attempts to send a BIST command to the H8 before returning an
   error status to the calling code. */
#define MAX_H8_RETRY_COUNT 10
