iomap.h 2.25 KB

/*************************************************************************
 *
 *  File: iomap.h
 *
 *  This file contains definitions for all I/O address segments and 
 *  registers.
 *
 *  $Header: /root/leakn64/depot/rf/sw/bbplayer/iosim/src/iomap.h,v 1.8 2002/11/08 01:32:02 apatti Exp $
 *
 */

#ifndef _IO_MAP_H_
#define _IO_MAP_H_

/*
 * The register map is in here
 */
#include <PR/bcp.h>

/*
 * Definitions for segments are here
 */
#include <PR/R4300.h>

/* reset */
#ifdef __sgi__
    #define PI_RESET()	{ *(vu_int *)PHYS_TO_K1(PI_STATUS_REG)=PI_SET_RESET; }
#else
    void   linux_io_write(unsigned long addr, unsigned int data);
    #define PI_RESET() linux_io_write((PI_STATUS_REG), PI_SET_RESET)
#endif

/* Define types for SI DMA operation */
/* Values 1/2 were used for cancelled 4B operations */
#define SI_RD64B		3
#define SI_WR64B		4

/*************************************************************************
 * Common definitions
 */
#define	DIR_FROM_RAM		1	/* Direction of data: -> DRAM */
#define DIR_TO_RAM		2	/* Direction of data: <- DRAM */


/*************************************************************************
 * Common macros
 */
#ifdef _LANGUAGE_C
#ifdef __sgi__
    #define IO_READ(addr)		(*(vu_int *)PHYS_TO_K1(addr))
    #define IO_WRITE(addr,data)	(*(vu_int *)PHYS_TO_K1(addr)=(unsigned)(data))
#else
    unsigned int linux_io_read(unsigned long addr);
    void   linux_io_write(unsigned long addr, unsigned int data);
    #define IO_READ(addr)         linux_io_read(addr)
    #define IO_WRITE(addr, data)  linux_io_write((addr), data)
    /* IDE_READ()s return u16 quantities */
    #define IDE_READ(addr)        ( (addr)&2 ? (u16)(IO_READ(addr)&0xffff) : \
                                    (u16)(IO_READ(addr)>>16) ) 
    #define IDE_READ_FLUSH()      (IDE_READ(PI_IDE_FC_BASE_REG))
    /* IDE_WRITE_()s take u16 data */
    #define IDE_WRITE_NB(addr,data) ( (addr)&2 ? IO_WRITE((addr),(u32)(data)) :\
                                      IO_WRITE((addr),((u32)(data))<<16) )
    #define IDE_WRITE(addr,data)  (IDE_WRITE_NB(addr,data), IDE_READ_FLUSH())
    #define ENDIAN_SWAP(data)	  ( ((data & 0xff) << 24) | \
				    ((data & 0xff00) << 8) | \
				    ((data & 0xff0000) >> 8) | \
				    ((data >> 24) & 0xff) )
#endif
#endif

#endif  /* _IO_MAP_H_ */