/**     ll_post_utils_npa_56x4.h
 **
 **   This file contains the definitions to support the low-level post
 ** utility module.
 **
 ** Author: Ted Schmitz
 **
 ** Created: December 16, 2008
 **
 **/
#include "diag_mon/errhand.h"

extern void save_error_info_in_nv_storage(struct save_fail * sf);
extern int get_prod_id(void);
extern int should_diags_be_executed(unsigned short test_modes);
extern void hl_spin_wheel(void);
extern void tbl_delay_with_wheel(unsigned long count);
extern void write_pci_conf_reg(unsigned long dev_no, unsigned long bus_no,
                               unsigned long reg_offset, unsigned long func,
                               unsigned long wrt_len, unsigned long data);
extern unsigned long read_pci_conf_reg(unsigned long dev_no, 
                                       unsigned long bus_no,
                                       unsigned long reg_offset, 
                                       unsigned long func,
                                       unsigned long wrt_len);
extern int this_hw_is_available_c(unsigned long hw_mask);
extern void hl_pci_init(void);
extern void set_phy_reg(void);
extern void mon_dump_phy_regs(void);
extern void set_eswitch_reg(void);
extern void mon_dump_eswitch_regs(void);
extern void disp_h8_sensors(void);

/**  Code to build "mtdcr" and "mfdcr" assembly language command to be
 ** called from "C" code.
 **/
#define stringify(s)   tostring(s)
#define tostring(s) #s

#define mtdcr(rn, v)   asm volatile("mtdcr " stringify(rn) ",%0" : : "r" (v))
#define mfdcr(rn)   ({unsigned int rval; \
                    asm volatile("mfdcr %0," stringify(rn) \
                    : "=r" (rval)); rval;})

/*
 * Macros for accessing the sdr controller registers
 */
#ifndef mtsdr
#define mtsdr(reg, data)  mtdcr(SDR_REG_SEL_ADRS,reg);mtdcr(SDR_REG_DATA_ADRS,data)
#define mfsdr(reg, data)  mtdcr(SDR_REG_SEL_ADRS,reg);data = mfdcr(SDR_REG_DATA_ADRS)
#endif

/* macros to force write to complete */
#define syncs() asm volatile("syncs")
#define syncw() asm volatile("syncw")
#define syncws() asm volatile("syncws")
