home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / src / linux-headers-2.6.17-6 / include / asm-v850 / io.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-08-11  |  4.2 KB  |  145 lines

  1. /*
  2.  * include/asm-v850/io.h -- Misc I/O operations
  3.  *
  4.  *  Copyright (C) 2001,02,03,04,05  NEC Electronics Corporation
  5.  *  Copyright (C) 2001,02,03,04,05  Miles Bader <miles@gnu.org>
  6.  *
  7.  * This file is subject to the terms and conditions of the GNU General
  8.  * Public License.  See the file COPYING in the main directory of this
  9.  * archive for more details.
  10.  *
  11.  * Written by Miles Bader <miles@gnu.org>
  12.  */
  13.  
  14. #ifndef __V850_IO_H__
  15. #define __V850_IO_H__
  16.  
  17. #define IO_SPACE_LIMIT 0xFFFFFFFF
  18.  
  19. #define readb(addr) \
  20.   ({ unsigned char __v = (*(volatile unsigned char *) (addr)); __v; })
  21. #define readw(addr) \
  22.   ({ unsigned short __v = (*(volatile unsigned short *) (addr)); __v; })
  23. #define readl(addr) \
  24.   ({ unsigned long __v = (*(volatile unsigned long *) (addr)); __v; })
  25.  
  26. #define readb_relaxed(a) readb(a)
  27. #define readw_relaxed(a) readw(a)
  28. #define readl_relaxed(a) readl(a)
  29.  
  30. #define writeb(val, addr) \
  31.   (void)((*(volatile unsigned char *) (addr)) = (val))
  32. #define writew(val, addr) \
  33.   (void)((*(volatile unsigned short *) (addr)) = (val))
  34. #define writel(val, addr) \
  35.   (void)((*(volatile unsigned int *) (addr)) = (val))
  36.  
  37. #define __raw_readb readb
  38. #define __raw_readw readw
  39. #define __raw_readl readl
  40. #define __raw_writeb writeb
  41. #define __raw_writew writew
  42. #define __raw_writel writel
  43.  
  44. #define inb(addr)    readb (addr)
  45. #define inw(addr)    readw (addr)
  46. #define inl(addr)    readl (addr)
  47. #define outb(x, addr)    ((void) writeb (x, addr))
  48. #define outw(x, addr)    ((void) writew (x, addr))
  49. #define outl(x, addr)    ((void) writel (x, addr))
  50.  
  51. #define inb_p(port)        inb((port))
  52. #define outb_p(val, port)    outb((val), (port))
  53. #define inw_p(port)        inw((port))
  54. #define outw_p(val, port)    outw((val), (port))
  55. #define inl_p(port)        inl((port))
  56. #define outl_p(val, port)    outl((val), (port))
  57.  
  58. static inline void insb (unsigned long port, void *dst, unsigned long count)
  59. {
  60.     unsigned char *p = dst;
  61.     while (count--)
  62.         *p++ = inb (port);
  63. }
  64. static inline void insw (unsigned long port, void *dst, unsigned long count)
  65. {
  66.     unsigned short *p = dst;
  67.     while (count--)
  68.         *p++ = inw (port);
  69. }
  70. static inline void insl (unsigned long port, void *dst, unsigned long count)
  71. {
  72.     unsigned long *p = dst;
  73.     while (count--)
  74.         *p++ = inl (port);
  75. }
  76.  
  77. static inline void
  78. outsb (unsigned long port, const void *src, unsigned long count)
  79. {
  80.     const unsigned char *p = src;
  81.     while (count--)
  82.         outb (*p++, port);
  83. }
  84. static inline void
  85. outsw (unsigned long port, const void *src, unsigned long count)
  86. {
  87.     const unsigned short *p = src;
  88.     while (count--)
  89.         outw (*p++, port);
  90. }
  91. static inline void
  92. outsl (unsigned long port, const void *src, unsigned long count)
  93. {
  94.     const unsigned long *p = src;
  95.     while (count--)
  96.         outl (*p++, port);
  97. }
  98.  
  99.  
  100. /* Some places try to pass in an loff_t for PHYSADDR (?!), so we cast it to
  101.    long before casting it to a pointer to avoid compiler warnings.  */
  102. #define ioremap(physaddr, size)    ((void __iomem *)(unsigned long)(physaddr))
  103. #define iounmap(addr)        ((void)0)
  104.  
  105. #define ioremap_nocache(physaddr, size)        ioremap (physaddr, size)
  106. #define ioremap_writethrough(physaddr, size)    ioremap (physaddr, size)
  107. #define ioremap_fullcache(physaddr, size)    ioremap (physaddr, size)
  108.  
  109. #define ioread8(addr)        readb (addr)
  110. #define ioread16(addr)        readw (addr)
  111. #define ioread32(addr)        readl (addr)
  112. #define iowrite8(val, addr)    writeb (val, addr)
  113. #define iowrite16(val, addr)    writew (val, addr)
  114. #define iowrite32(val, addr)    writel (val, addr)
  115.  
  116. #define mmiowb()
  117.  
  118. #define page_to_phys(page)      ((page - mem_map) << PAGE_SHIFT)
  119. #if 0
  120. /* This is really stupid; don't define it.  */
  121. #define page_to_bus(page)       page_to_phys (page)
  122. #endif
  123.  
  124. /* Conversion between virtual and physical mappings.  */
  125. #define mm_ptov(addr)        ((void *)__phys_to_virt (addr))
  126. #define mm_vtop(addr)        ((unsigned long)__virt_to_phys (addr))
  127. #define phys_to_virt(addr)    ((void *)__phys_to_virt (addr))
  128. #define virt_to_phys(addr)    ((unsigned long)__virt_to_phys (addr))
  129.  
  130. #define memcpy_fromio(dst, src, len) memcpy (dst, (void *)src, len)
  131. #define memcpy_toio(dst, src, len) memcpy ((void *)dst, src, len)
  132.  
  133. /*
  134.  * Convert a physical pointer to a virtual kernel pointer for /dev/mem
  135.  * access
  136.  */
  137. #define xlate_dev_mem_ptr(p)    __va(p)
  138.  
  139. /*
  140.  * Convert a virtual cached pointer to an uncached pointer
  141.  */
  142. #define xlate_dev_kmem_ptr(p)    p
  143.  
  144. #endif /* __V850_IO_H__ */
  145.