//#@+leo-ver=4
//#@+node:@file host/helpers.h
/**
 * The maximum number of host addresses supported by the driver.
 */
#define MAX_LUD_ADDRS	32

extern int copy_to_user_fromio(void *dst, void *src, register int len);
extern int copy_from_user_toio(void *dst, void *src, register int len);
extern int strncpy_fromio(void *dest, const void *src, register int n);
extern int strcpy_toio(void *dest, const void *src);

#ifndef __sparc__
#define addr_to_token(addr)	(int)(void*)(addr)
#define token_to_addr(token)	(void*)(int)(token)
#define token_free(token)
#else
int addr_to_token(void *addr);
void* token_to_addr(int token);
void token_free(int token);
#endif

#ifdef __arm__
/*
 *  Copy data from IO memory space to "real" memory space. We call this from
 *  copy_to_user_fromio: to is an page aligned bounce buffer
 */
static inline void fast_memcpy_fromio(void *to, void __iomem *from, size_t count)
{
	if ((((unsigned long)from) & 3) == 0) {
		while (count > 3) {
			count -= 4;
			*((unsigned long *)to) = readl(from);
			from += 4 ;
			to += 4 ;
		}
	}

	while (count) {
		count--;
		*((unsigned char *)to) = readb(from);
		to++;
		from++;
	}
}
/*
 *  Copy data from "real" memory space to IO memory space. We call this from
 *  copy_from_user_toio: from is an page aligned bounce buffer
 */
static inline void fast_memcpy_toio(void __iomem *to, const void *from, size_t count)
{
	if ((((unsigned long)to) & 3) == 0) {
		while (count > 3) {
			count -= 4;
			writel(*((unsigned long *)from), to);
			from += 4 ;
			to += 4;
		}
	}

        while (count) {
                count--;
                writeb(*((unsigned char *)from), to);
                from++;
                to++;
        }
}
#else
/*
 *  Just use normal kernel memcpy io function
 */
#define fast_memcpy_fromio(to,from,count)	memcpy_fromio(to,from,count)
#define fast_memcpy_toio(to,from,count)		memcpy_toio(to,from,count)
#endif
	

//#@-node:@file host/helpers.h
//#@-leo
