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 void             _writeb(unsigned char b, unsigned long addr);
  98 extern void             _writew(unsigned short b, unsigned long addr);
  99 
 100 /*
 101  * The platform header files may define some of these macros to use
 102  * the inlined versions where appropriate.  These macros may also be
 103  * redefined by userlevel programs.
 104  */
 105 #ifndef inb
 106 # define inb(p)         _inb((p))
 107 #endif
 108 #ifndef inw
 109 # define inw(p)         _inw((p))
 110 #endif
 111 #ifndef inl
 112 # define inl(p)         _inl((p))
 113 #endif
 114 #ifndef outb
 115 # define outb(b,p)      _outb((b),(p))
 116 #endif
 117 #ifndef outw
 118 # define outw(w,p)      _outw((w),(p))
 119 #endif
 120 #ifndef outl
 121 # define outl(l,p)      _outl((l),(p))
 122 #endif
 123 
 124 #ifndef inb_p
 125 # define inb_p          inb
 126 #endif
 127 #ifndef outb_p
 128 # define outb_p         outb
 129 #endif
 130 
 131 #ifndef inw_p
 132 # define inw_p          inw
 133 #endif
 134 #ifndef outw_p
 135 # define outw_p         outw
 136 #endif
 137 
 138 #ifndef inl_p
 139 # define inl_p          inl
 140 #endif
 141 #ifndef outl_p
 142 # define outl_p         outl
 143 #endif
 144 
 145 /*
 146  * The "address" in IO memory space is not clearly either a integer or a
 147  * pointer. We will accept both, thus the casts.
 148  */
 149 #ifndef readb
 150 # define readb(a)       _readb((unsigned long)(a))
 151 #endif
 152 #ifndef readw
 153 # define readw(a)       _readw((unsigned long)(a))
 154 #endif
 155 #ifndef readl
 156 # define readl(a)       _readl((unsigned long)(a))
 157 #endif
 158 #ifndef writeb
 159 # define writeb(v,a)    _writeb((v),(unsigned long)(a))
 160 #endif
 161 #ifndef writew
 162 # define writew(v,a)    _writew((v),(unsigned long)(a))
 163 #endif
 164 #ifndef writel
 165 # define writel(v,a)    _writel((v),(unsigned long)(a))
 166 #endif
 167 
 168 #ifdef __KERNEL__
 169 
 170 /*
 171  * String version of IO memory access ops:
 172  */
 173 extern void _memcpy_fromio(void *, unsigned long, unsigned long);
 174 extern void _memcpy_toio(unsigned long, void *, unsigned long);
 175 extern void _memset_io(unsigned long, int, unsigned long);
 176 
 177 #define memcpy_fromio(to,from,len)      _memcpy_fromio((to),(unsigned long)(from),(len))
 178 #define memcpy_toio(to,from,len)        _memcpy_toio((unsigned long)(to),(from),(len))
 179 #define memset_io(addr,c,len)           _memset_io((unsigned long)(addr),(c),(len))
 180 
 181 /*
 182  * String versions of in/out ops:
 183  */
 184 extern void insb (unsigned long port, void *dst, unsigned long count);
 185 extern void insw (unsigned long port, void *dst, unsigned long count);
 186 extern void insl (unsigned long port, void *dst, unsigned long count);
 187 extern void outsb (unsigned long port, const void *src, unsigned long count);
 188 extern void outsw (unsigned long port, const void *src, unsigned long count);
 189 extern void outsl (unsigned long port, const void *src, unsigned long count);
 190 
 191 /*
 192  * XXX - We don't have csum_partial_copy_fromio() yet, so we cheat here and 
 193  * just copy it. The net code will then do the checksum later. Presently 
 194  * only used by some shared memory 8390 ethernet cards anyway.
 195  */
 196 
 197 #define eth_io_copy_and_sum(skb,src,len,unused) memcpy_fromio((skb)->data,(src),(len))
 198 
 199 #endif /* __KERNEL__ */
 200 
 201 #endif

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