/*
 *	Given a symbol name, return its address by reading the
 *	ELF information from "fepfile".  If the symbol can't
 *	be found, try to interpret it as a hex address.
 *
 *	Return 0 on error (which implies that zero can't be
 *	the value of a symbol - not a problem in practice).
 */
unsigned long fep_addr(char *fepfile, char *symname);

/*
 *	Map the entire FEP memory into the process.
 *
 *	Return the virtual address or NULL if an error occurred.
 */
void * fep_map_ram(char *device);

/*
 *	Map from an offset of memory of a certain length into the process.
 *
 *	This also can be used to map device memory from /dev/kmem, etc.
 *
 *	Return the virtual address or NULL if an error occurred.
 */
void * fep_internal_map(char *device, unsigned long offset, size_t length);

/*
 *	Unmap memory mapped by function fep_internal_map().
 */
void fep_internal_unmap(char *device, void *va);

/*
 *	Map only the debug area into the process
 *
 *	Return the virtual address or NULL if an error occurred.
 */
void * fep_map_debug(char *device);

/*
 *	Map the 64011 registers into the process
 *
 *	Return the virtual address or NULL if an error occurred.
 */
void * fep_map_64011(char *device);

/*
 *	Using the RW interface, read/write FEP memory
 *
 *	Especially usefull for writing FEP memory to avoid
 *	cache effects.
 *
 *	Returns -1 on error, else len. 
 */
int fep_read(char *va, unsigned long addr, void *buf, int len);

int fep_write(char *va, unsigned long addr, void *buf, int len);

/*
 *	Init the error printing subsystem
 */
void error_init(char *progname, void (*exitfunc)(void));

/*
 *	Print an error
 */
void error(int fatal, char *fmt, ...);

/*
 *	Print a system error
 */
void syserror(int fatal, char *fmt, ...);

/* 
 *      Endian flags
 */
#define ME_LITTLE_ENDIAN 0
#define ME_BIG_ENDIAN    1

#if __BYTE_ORDER == __BIG_ENDIAN
#	define ENDIAN_SAYS ME_BIG_ENDIAN
#else
#	define ENDIAN_SAYS ME_LITTLE_ENDIAN
#endif

extern int host_endian;    /* initialized to ENDIAN_SAYS */
extern int global_endian;  /* re-initialized with fep_internal_map */

/*
 *	Get the global endianess flag
 */
void	fep_get_global_endian(void *va);

/* 
 *      Swap native opposite-endian offsets like board data structures
 */
unsigned int host_swap4(unsigned int);

/* 
 *      Swap global offsets that were tailored for an other-endian host
 *
 *      e.g. blackbox which has a board_uint32 type
 */
unsigned int global_swap4(unsigned int);

