root/include/asm-alpha/io.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. set_hae
  2. virt_to_phys
  3. phys_to_virt

   1 #ifndef __ALPHA_IO_H
   2 #define __ALPHA_IO_H
   3 
   4 #include <linux/config.h>
   5 
   6 #include <asm/system.h>
   7 
   8 /*
   9  * The hae (hardware address extension) register is used to
  10  * access high IO addresses. To avoid doing an external cycle
  11  * every time we need to set the hae, we have a hae cache in
  12  * memory. The kernel entry code makes sure that the hae is
  13  * preserved across interrupts, so it is safe to set the hae
  14  * once and then depend on it staying the same in kernel code.
  15  */
  16 extern struct hae {
  17         unsigned long   cache;
  18         unsigned long   *reg;
  19 } hae;
  20 
  21 /*
  22  * Virtual -> physical identity mapping starts at this offset
  23  */
  24 #define IDENT_ADDR      (0xfffffc0000000000UL)
  25 
  26 #ifdef __KERNEL__
  27 
  28 /*
  29  * We try to avoid hae updates (thus the cache), but when we
  30  * do need to update the hae, we need to do it atomically, so
  31  * that any interrupts wouldn't get confused with the hae
  32  * register not being up-to-date with respect to the hardware
  33  * value.
  34  */
  35 extern inline void set_hae(unsigned long new_hae)
     /* [previous][next][first][last][top][bottom][index][help] */
  36 {
  37         unsigned long ipl = swpipl(7);
  38         hae.cache = new_hae;
  39         *hae.reg = new_hae;
  40         mb();
  41         setipl(ipl);
  42 }
  43 
  44 /*
  45  * Change virtual addresses to physical addresses and vv.
  46  */
  47 extern inline unsigned long virt_to_phys(volatile void * address)
     /* [previous][next][first][last][top][bottom][index][help] */
  48 {
  49         return 0xffffffffUL & (unsigned long) address;
  50 }
  51 
  52 extern inline void * phys_to_virt(unsigned long address)
     /* [previous][next][first][last][top][bottom][index][help] */
  53 {
  54         return (void *) (address + IDENT_ADDR);
  55 }
  56 
  57 #else /* !__KERNEL__ */
  58 
  59 /*
  60  * Define actual functions in private name-space so it's easier to
  61  * accomodate things like XFree or svgalib that like to define their
  62  * own versions of inb etc.
  63  */
  64 extern void __sethae (unsigned long addr);      /* syscall */
  65 extern void _sethae (unsigned long addr);       /* cached version */
  66 
  67 #endif /* !__KERNEL__ */
  68 
  69 /*
  70  * There are different version of the Alpha PC motherboards:
  71  */
  72 #if defined(CONFIG_ALPHA_LCA)
  73 # include <asm/lca.h>           /* get chip-specific definitions */
  74 #elif defined(CONFIG_ALPHA_APECS)
  75 # include <asm/apecs.h>         /* get chip-specific definitions */
  76 #else
  77 # include <asm/jensen.h>
  78 #endif
  79 
  80 /*
  81  * The convention used for inb/outb etc. is that names starting with
  82  * two underscores are the inline versions, names starting with a
  83  * single underscore are proper functions, and names starting with a
  84  * letter are macros that map in some way to inline or proper function
  85  * versions.  Not all that pretty, but before you change it, be sure
  86  * to convince yourself that it won't break anything (in particular
  87  * module support).
  88  */
  89 extern unsigned int     _inb (unsigned long port);
  90 extern unsigned int     _inw (unsigned long port);
  91 extern unsigned int     _inl (unsigned long port);
  92 extern void             _outb (unsigned char b,unsigned long port);
  93 extern void             _outw (unsigned short w,unsigned long port);
  94 extern void             _outl (unsigned int l,unsigned long port);
  95 extern unsigned long    _readb(unsigned long addr);
  96 extern unsigned long    _readw(unsigned long addr);
  97 extern unsigned long    _readl(unsigned long addr);
  98 extern void             _writeb(unsigned char b, unsigned long addr);
  99 extern void             _writew(unsigned short b, unsigned long addr);
 100 extern void             _writel(unsigned int b, unsigned long addr);
 101 
 102 /*
 103  * The platform header files may define some of these macros to use
 104  * the inlined versions where appropriate.  These macros may also be
 105  * redefined by userlevel programs.
 106  */
 107 #ifndef inb
 108 # define inb(p)         _inb((p))
 109 #endif
 110 #ifndef inw
 111 # define inw(p)         _inw((p))
 112 #endif
 113 #ifndef inl
 114 # define inl(p)         _inl((p))
 115 #endif
 116 #ifndef outb
 117 # define outb(b,p)      _outb((b),(p))
 118 #endif
 119 #ifndef outw
 120 # define outw(w,p)      _outw((w),(p))
 121 #endif
 122 #ifndef outl
 123 # define outl(l,p)      _outl((l),(p))
 124 #endif
 125 
 126 #ifndef inb_p
 127 # define inb_p          inb
 128 #endif
 129 #ifndef inw_p
 130 # define inw_p          inw
 131 #endif
 132 #ifndef inl_p
 133 # define inl_p          inl
 134 #endif
 135 #ifndef outb_p
 136 # define outb_p         outb
 137 #endif
 138 #ifndef outw_p
 139 # define outw_p         outw
 140 #endif
 141 #ifndef outl_p
 142 # define outl_p         outl
 143 #endif
 144 
 145 #ifndef inw_p
 146 # define inw_p          inw
 147 #endif
 148 #ifndef outw_p
 149 # define outw_p         outw
 150 #endif
 151 
 152 #ifndef inl_p
 153 # define inl_p          inl
 154 #endif
 155 #ifndef outl_p
 156 # define outl_p         outl
 157 #endif
 158 
 159 /*
 160  * The "address" in IO memory space is not clearly either a integer or a
 161  * pointer. We will accept both, thus the casts.
 162  */
 163 #ifndef readb
 164 # define readb(a)       _readb((unsigned long)(a))
 165 #endif
 166 #ifndef readw
 167 # define readw(a)       _readw((unsigned long)(a))
 168 #endif
 169 #ifndef readl
 170 # define readl(a)       _readl((unsigned long)(a))
 171 #endif
 172 #ifndef writeb
 173 # define writeb(v,a)    _writeb((v),(unsigned long)(a))
 174 #endif
 175 #ifndef writew
 176 # define writew(v,a)    _writew((v),(unsigned long)(a))
 177 #endif
 178 #ifndef writel
 179 # define writel(v,a)    _writel((v),(unsigned long)(a))
 180 #endif
 181 
 182 #ifdef __KERNEL__
 183 
 184 /*
 185  * String version of IO memory access ops:
 186  */
 187 extern void _memcpy_fromio(void *, unsigned long, unsigned long);
 188 extern void _memcpy_toio(unsigned long, void *, unsigned long);
 189 extern void _memset_io(unsigned long, int, unsigned long);
 190 
 191 #define memcpy_fromio(to,from,len)      _memcpy_fromio((to),(unsigned long)(from),(len))
 192 #define memcpy_toio(to,from,len)        _memcpy_toio((unsigned long)(to),(from),(len))
 193 #define memset_io(addr,c,len)           _memset_io((unsigned long)(addr),(c),(len))
 194 
 195 /*
 196  * String versions of in/out ops:
 197  */
 198 extern void insb (unsigned long port, void *dst, unsigned long count);
 199 extern void insw (unsigned long port, void *dst, unsigned long count);
 200 extern void insl (unsigned long port, void *dst, unsigned long count);
 201 extern void outsb (unsigned long port, const void *src, unsigned long count);
 202 extern void outsw (unsigned long port, const void *src, unsigned long count);
 203 extern void outsl (unsigned long port, const void *src, unsigned long count);
 204 
 205 /*
 206  * XXX - We don't have csum_partial_copy_fromio() yet, so we cheat here and 
 207  * just copy it. The net code will then do the checksum later. Presently 
 208  * only used by some shared memory 8390 ethernet cards anyway.
 209  */
 210 
 211 #define eth_io_copy_and_sum(skb,src,len,unused) memcpy_fromio((skb)->data,(src),(len))
 212 
 213 #endif /* __KERNEL__ */
 214 
 215 #endif

/* [previous][next][first][last][top][bottom][index][help] */