OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [rc203soc/] [sw/] [uClinux/] [include/] [asm-armnommu/] [io.h] - Diff between revs 1765 and 1782

Only display areas with differences | Details | Blame | View Log

Rev 1765 Rev 1782
/*
/*
 * linux/include/asm-arm/io.h
 * linux/include/asm-arm/io.h
 *
 *
 * Copyright (C) 1996 Russell King
 * Copyright (C) 1996 Russell King
 *
 *
 * Modifications:
 * Modifications:
 *  16-Sep-1996 RMK     Inlined the inx/outx functions & optimised for both
 *  16-Sep-1996 RMK     Inlined the inx/outx functions & optimised for both
 *                      constant addresses and variable addresses.
 *                      constant addresses and variable addresses.
 *  04-Dec-1997 RMK     Moved a lot of this stuff to the new architecture
 *  04-Dec-1997 RMK     Moved a lot of this stuff to the new architecture
 *                      specific IO header files.
 *                      specific IO header files.
 */
 */
#ifndef __ASM_ARM_IO_H
#ifndef __ASM_ARM_IO_H
#define __ASM_ARM_IO_H
#define __ASM_ARM_IO_H
 
 
#include <asm/hardware.h>
#include <asm/hardware.h>
#include <asm/arch/mmu.h>
#include <asm/arch/mmu.h>
#include <asm/arch/io.h>
#include <asm/arch/io.h>
 
 
/* unsigned long virt_to_phys(void *x) */
/* unsigned long virt_to_phys(void *x) */
#define virt_to_phys(x) (__virt_to_phys((unsigned long)(x)))
#define virt_to_phys(x) (__virt_to_phys((unsigned long)(x)))
 
 
/* void *phys_to_virt(unsigned long x) */
/* void *phys_to_virt(unsigned long x) */
#define phys_to_virt(x) ((void *)(__phys_to_virt((unsigned long)(x))))
#define phys_to_virt(x) ((void *)(__phys_to_virt((unsigned long)(x))))
 
 
/*
/*
 * Virtual view <-> DMA view memory address translations
 * Virtual view <-> DMA view memory address translations
 * virt_to_bus: Used to translate the virtual address to an
 * virt_to_bus: Used to translate the virtual address to an
 *              address suitable to be passed to set_dma_addr
 *              address suitable to be passed to set_dma_addr
 * bus_to_virt: Used to convert an address for DMA operations
 * bus_to_virt: Used to convert an address for DMA operations
 *              to an address that the kernel can use.
 *              to an address that the kernel can use.
 */
 */
#define virt_to_bus(x)  (__virt_to_bus((unsigned long)(x)))
#define virt_to_bus(x)  (__virt_to_bus((unsigned long)(x)))
#define bus_to_virt(x)  ((void *)(__bus_to_virt(x)))
#define bus_to_virt(x)  ((void *)(__bus_to_virt(x)))
 
 
/*
/*
 * These macros actually build the multi-value IO function prototypes
 * These macros actually build the multi-value IO function prototypes
 */
 */
#define __OUTS(s,i,x)   extern void outs##s(unsigned int port, const void *from, int len);
#define __OUTS(s,i,x)   extern void outs##s(unsigned int port, const void *from, int len);
#define __INS(s,i,x)    extern void ins##s(unsigned int port, void *to, int len);
#define __INS(s,i,x)    extern void ins##s(unsigned int port, void *to, int len);
 
 
#define __IO(s,i,x) \
#define __IO(s,i,x) \
  __OUTS(s,i,x) \
  __OUTS(s,i,x) \
  __INS(s,i,x)
  __INS(s,i,x)
 
 
__IO(b,"b",char)
__IO(b,"b",char)
__IO(w,"h",short)
__IO(w,"h",short)
__IO(l,"",long)
__IO(l,"",long)
 
 
/*
/*
 * Note that due to the way __builtin_constant_t() works, you
 * Note that due to the way __builtin_constant_t() works, you
 *  - can't use it inside an inline function (it will never be true)
 *  - can't use it inside an inline function (it will never be true)
 *  - you don't have to worry about side effects withing the __builtin..
 *  - you don't have to worry about side effects withing the __builtin..
 */
 */
#ifdef __outbc
#ifdef __outbc
#define outb(val,port)  \
#define outb(val,port)  \
  (__builtin_constant_p((port)) ? __outbc((val),(port)) : __outb((val),(port)))
  (__builtin_constant_p((port)) ? __outbc((val),(port)) : __outb((val),(port)))
#else
#else
#define outb(val,port) __outb((val),(port))
#define outb(val,port) __outb((val),(port))
#endif
#endif
 
 
#ifdef __outwc
#ifdef __outwc
#define outw(val,port)  \
#define outw(val,port)  \
  (__builtin_constant_p((port)) ? __outwc((val),(port)) : __outw((val),(port)))
  (__builtin_constant_p((port)) ? __outwc((val),(port)) : __outw((val),(port)))
#else
#else
#define outw(val,port) __outw((val),(port))
#define outw(val,port) __outw((val),(port))
#endif
#endif
 
 
#ifdef __outlc
#ifdef __outlc
#define outl(val,port)  \
#define outl(val,port)  \
  (__builtin_constant_p((port)) ? __outlc((val),(port)) : __outl((val),(port)))
  (__builtin_constant_p((port)) ? __outlc((val),(port)) : __outl((val),(port)))
#else
#else
#define outl(val,port) __outl((val),(port))
#define outl(val,port) __outl((val),(port))
#endif
#endif
 
 
#ifdef __inbc
#ifdef __inbc
#define inb(port)       \
#define inb(port)       \
  (__builtin_constant_p((port)) ? __inbc((port)) : __inb((port)))
  (__builtin_constant_p((port)) ? __inbc((port)) : __inb((port)))
#else
#else
#define inb(port) __inb((port))
#define inb(port) __inb((port))
#endif
#endif
 
 
#ifdef __inwc
#ifdef __inwc
#define inw(port)       \
#define inw(port)       \
  (__builtin_constant_p((port)) ? __inwc((port)) : __inw((port)))
  (__builtin_constant_p((port)) ? __inwc((port)) : __inw((port)))
#else
#else
#define inw(port) __inw((port))
#define inw(port) __inw((port))
#endif
#endif
 
 
#ifdef __inlc
#ifdef __inlc
#define inl(port)       \
#define inl(port)       \
  (__builtin_constant_p((port)) ? __inlc((port)) : __inl((port)))
  (__builtin_constant_p((port)) ? __inlc((port)) : __inl((port)))
#else
#else
#define inl(port) __inl((port))
#define inl(port) __inl((port))
#endif
#endif
 
 
/*
/*
 * This macro will give you the translated IO address for this particular
 * This macro will give you the translated IO address for this particular
 * architecture, which can be used with the out_t... functions.
 * architecture, which can be used with the out_t... functions.
 */
 */
#define ioaddr(port)    \
#define ioaddr(port)    \
  (__builtin_constant_p((port)) ? __ioaddrc((port)) : __ioaddr((port)))
  (__builtin_constant_p((port)) ? __ioaddrc((port)) : __ioaddr((port)))
 
 
#ifndef ARCH_IO_DELAY
#ifndef ARCH_IO_DELAY
/*
/*
 * This architecture does not require any delayed IO.
 * This architecture does not require any delayed IO.
 * It is handled in the hardware.
 * It is handled in the hardware.
 */
 */
#define outb_p(val,port)        outb((val),(port))
#define outb_p(val,port)        outb((val),(port))
#define outw_p(val,port)        outw((val),(port))
#define outw_p(val,port)        outw((val),(port))
#define outl_p(val,port)        outl((val),(port))
#define outl_p(val,port)        outl((val),(port))
#define inb_p(port)             inb((port))
#define inb_p(port)             inb((port))
#define inw_p(port)             inw((port))
#define inw_p(port)             inw((port))
#define inl_p(port)             inl((port))
#define inl_p(port)             inl((port))
#define outsb_p(port,from,len)  outsb(port,from,len)
#define outsb_p(port,from,len)  outsb(port,from,len)
#define outsw_p(port,from,len)  outsw(port,from,len)
#define outsw_p(port,from,len)  outsw(port,from,len)
#define outsl_p(port,from,len)  outsl(port,from,len)
#define outsl_p(port,from,len)  outsl(port,from,len)
#define insb_p(port,to,len)     insb(port,to,len)
#define insb_p(port,to,len)     insb(port,to,len)
#define insw_p(port,to,len)     insw(port,to,len)
#define insw_p(port,to,len)     insw(port,to,len)
#define insl_p(port,to,len)     insl(port,to,len)
#define insl_p(port,to,len)     insl(port,to,len)
 
 
#else
#else
 
 
/*
/*
 * We have to delay the IO...
 * We have to delay the IO...
 */
 */
#ifdef __outbc_p
#ifdef __outbc_p
#define outb_p(val,port)        \
#define outb_p(val,port)        \
  (__builtin_constant_p((port)) ? __outbc_p((val),(port)) : __outb_p((val),(port)))
  (__builtin_constant_p((port)) ? __outbc_p((val),(port)) : __outb_p((val),(port)))
#else
#else
#define outb_p(val,port) __outb_p((val),(port))
#define outb_p(val,port) __outb_p((val),(port))
#endif
#endif
 
 
#ifdef __outwc_p
#ifdef __outwc_p
#define outw_p(val,port)        \
#define outw_p(val,port)        \
  (__builtin_constant_p((port)) ? __outwc_p((val),(port)) : __outw_p((val),(port)))
  (__builtin_constant_p((port)) ? __outwc_p((val),(port)) : __outw_p((val),(port)))
#else
#else
#define outw_p(val,port) __outw_p((val),(port))
#define outw_p(val,port) __outw_p((val),(port))
#endif
#endif
 
 
#ifdef __outlc_p
#ifdef __outlc_p
#define outl_p(val,port)        \
#define outl_p(val,port)        \
  (__builtin_constant_p((port)) ? __outlc_p((val),(port)) : __outl_p((val),(port)))
  (__builtin_constant_p((port)) ? __outlc_p((val),(port)) : __outl_p((val),(port)))
#else
#else
#define outl_p(val,port) __outl_p((val),(port))
#define outl_p(val,port) __outl_p((val),(port))
#endif
#endif
 
 
#ifdef __inbc_p
#ifdef __inbc_p
#define inb_p(port)     \
#define inb_p(port)     \
  (__builtin_constant_p((port)) ? __inbc_p((port)) : __inb_p((port)))
  (__builtin_constant_p((port)) ? __inbc_p((port)) : __inb_p((port)))
#else
#else
#define inb_p(port) __inb_p((port))
#define inb_p(port) __inb_p((port))
#endif
#endif
 
 
#ifdef __inwc_p
#ifdef __inwc_p
#define inw_p(port)     \
#define inw_p(port)     \
  (__builtin_constant_p((port)) ? __inwc_p((port)) : __inw_p((port)))
  (__builtin_constant_p((port)) ? __inwc_p((port)) : __inw_p((port)))
#else
#else
#define inw_p(port) __inw_p((port))
#define inw_p(port) __inw_p((port))
#endif
#endif
 
 
#ifdef __inlc_p
#ifdef __inlc_p
#define inl_p(port)     \
#define inl_p(port)     \
  (__builtin_constant_p((port)) ? __inlc_p((port)) : __inl_p((port)))
  (__builtin_constant_p((port)) ? __inlc_p((port)) : __inl_p((port)))
#else
#else
#define inl_p(port) __inl_p((port))
#define inl_p(port) __inl_p((port))
#endif
#endif
 
 
#endif
#endif
 
 
#undef ARCH_IO_DELAY
#undef ARCH_IO_DELAY
#undef ARCH_IO_CONSTANT
#undef ARCH_IO_CONSTANT
 
 
/*
/*
 * Leftovers...
 * Leftovers...
 */
 */
#if 0
#if 0
#define __outwc(value,port)                                             \
#define __outwc(value,port)                                             \
({                                                                      \
({                                                                      \
        if (port < 256)                                                 \
        if (port < 256)                                                 \
                __asm__ __volatile__(                                   \
                __asm__ __volatile__(                                   \
                "strh   %0, [%1, %2]"                                   \
                "strh   %0, [%1, %2]"                                   \
                : : "r" (value), "r" (PCIO_BASE), "J" (port << 2));     \
                : : "r" (value), "r" (PCIO_BASE), "J" (port << 2));     \
        else if (__PORT_PCIO(port))                                     \
        else if (__PORT_PCIO(port))                                     \
                __asm__ __volatile__(                                   \
                __asm__ __volatile__(                                   \
                "strh   %0, [%1, %2]"                                   \
                "strh   %0, [%1, %2]"                                   \
                : : "r" (value), "r" (PCIO_BASE), "r" (port << 2));     \
                : : "r" (value), "r" (PCIO_BASE), "r" (port << 2));     \
        else                                                            \
        else                                                            \
                __asm__ __volatile__(                                   \
                __asm__ __volatile__(                                   \
                "strh   %0, [%1, %2]"                                   \
                "strh   %0, [%1, %2]"                                   \
                : : "r" (value), "r" (IO_BASE), "r" (port << 2));       \
                : : "r" (value), "r" (IO_BASE), "r" (port << 2));       \
})
})
 
 
#define __inwc(port)                                                    \
#define __inwc(port)                                                    \
({                                                                      \
({                                                                      \
        unsigned short result;                                          \
        unsigned short result;                                          \
        if (port < 256)                                                 \
        if (port < 256)                                                 \
                __asm__ __volatile__(                                   \
                __asm__ __volatile__(                                   \
                "ldrh   %0, [%1, %2]"                                   \
                "ldrh   %0, [%1, %2]"                                   \
                : "=r" (result) : "r" (PCIO_BASE), "J" (port << 2));    \
                : "=r" (result) : "r" (PCIO_BASE), "J" (port << 2));    \
        else                                                            \
        else                                                            \
        if (__PORT_PCIO(port))                                          \
        if (__PORT_PCIO(port))                                          \
                __asm__ __volatile__(                                   \
                __asm__ __volatile__(                                   \
                "ldrh   %0, [%1, %2]"                                   \
                "ldrh   %0, [%1, %2]"                                   \
                : "=r" (result) : "r" (PCIO_BASE), "r" (port << 2));    \
                : "=r" (result) : "r" (PCIO_BASE), "r" (port << 2));    \
        else                                                            \
        else                                                            \
                __asm__ __volatile__(                                   \
                __asm__ __volatile__(                                   \
                "ldrh   %0, [%1, %2]"                                   \
                "ldrh   %0, [%1, %2]"                                   \
                : "=r" (result) : "r" (IO_BASE), "r" (port << 2));      \
                : "=r" (result) : "r" (IO_BASE), "r" (port << 2));      \
        result;                                                         \
        result;                                                         \
})
})
#endif
#endif
#endif
#endif
 
 
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.