~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/sh/kernel/io.c

Version: ~ [ linux-5.13-rc1 ] ~ [ linux-5.12.2 ] ~ [ linux-5.11.19 ] ~ [ linux-5.10.35 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.117 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.190 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.232 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.268 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.268 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.18.140 ] ~ [ linux-3.16.85 ] ~ [ linux-3.14.79 ] ~ [ linux-3.12.74 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * arch/sh/kernel/io.c - Machine independent I/O functions.
  3  *
  4  * Copyright (C) 2000 - 2009  Stuart Menefy
  5  * Copyright (C) 2005  Paul Mundt
  6  *
  7  * This file is subject to the terms and conditions of the GNU General Public
  8  * License.  See the file "COPYING" in the main directory of this archive
  9  * for more details.
 10  */
 11 #include <linux/module.h>
 12 #include <linux/pci.h>
 13 #include <asm/machvec.h>
 14 #include <asm/io.h>
 15 
 16 /*
 17  * Copy data from IO memory space to "real" memory space.
 18  */
 19 void memcpy_fromio(void *to, const volatile void __iomem *from, unsigned long count)
 20 {
 21         /*
 22          * Would it be worthwhile doing byte and long transfers first
 23          * to try and get aligned?
 24          */
 25 #ifdef CONFIG_CPU_SH4
 26         if ((count >= 0x20) &&
 27              (((u32)to & 0x1f) == 0) && (((u32)from & 0x3) == 0)) {
 28                 int tmp2, tmp3, tmp4, tmp5, tmp6;
 29 
 30                 __asm__ __volatile__(
 31                         "1:                     \n\t"
 32                         "mov.l  @%7+, r0        \n\t"
 33                         "mov.l  @%7+, %2        \n\t"
 34                         "movca.l r0, @%0        \n\t"
 35                         "mov.l  @%7+, %3        \n\t"
 36                         "mov.l  @%7+, %4        \n\t"
 37                         "mov.l  @%7+, %5        \n\t"
 38                         "mov.l  @%7+, %6        \n\t"
 39                         "mov.l  @%7+, r7        \n\t"
 40                         "mov.l  @%7+, r0        \n\t"
 41                         "mov.l  %2, @(0x04,%0)  \n\t"
 42                         "mov    #0x20, %2       \n\t"
 43                         "mov.l  %3, @(0x08,%0)  \n\t"
 44                         "sub    %2, %1          \n\t"
 45                         "mov.l  %4, @(0x0c,%0)  \n\t"
 46                         "cmp/hi %1, %2          ! T if 32 > count       \n\t"
 47                         "mov.l  %5, @(0x10,%0)  \n\t"
 48                         "mov.l  %6, @(0x14,%0)  \n\t"
 49                         "mov.l  r7, @(0x18,%0)  \n\t"
 50                         "mov.l  r0, @(0x1c,%0)  \n\t"
 51                         "bf.s   1b              \n\t"
 52                         " add   #0x20, %0       \n\t"
 53                         : "=&r" (to), "=&r" (count),
 54                           "=&r" (tmp2), "=&r" (tmp3), "=&r" (tmp4),
 55                           "=&r" (tmp5), "=&r" (tmp6), "=&r" (from)
 56                         : "7"(from), "" (to), "1" (count)
 57                         : "r0", "r7", "t", "memory");
 58         }
 59 #endif
 60 
 61         if ((((u32)to | (u32)from) & 0x3) == 0) {
 62                 for (; count > 3; count -= 4) {
 63                         *(u32 *)to = *(volatile u32 *)from;
 64                         to += 4;
 65                         from += 4;
 66                 }
 67         }
 68 
 69         for (; count > 0; count--) {
 70                 *(u8 *)to = *(volatile u8 *)from;
 71                 to++;
 72                 from++;
 73         }
 74 
 75         mb();
 76 }
 77 EXPORT_SYMBOL(memcpy_fromio);
 78 
 79 /*
 80  * Copy data from "real" memory space to IO memory space.
 81  */
 82 void memcpy_toio(volatile void __iomem *to, const void *from, unsigned long count)
 83 {
 84         if ((((u32)to | (u32)from) & 0x3) == 0) {
 85                 for ( ; count > 3; count -= 4) {
 86                         *(volatile u32 *)to = *(u32 *)from;
 87                         to += 4;
 88                         from += 4;
 89                 }
 90         }
 91 
 92         for (; count > 0; count--) {
 93                 *(volatile u8 *)to = *(u8 *)from;
 94                 to++;
 95                 from++;
 96         }
 97 
 98         mb();
 99 }
100 EXPORT_SYMBOL(memcpy_toio);
101 
102 /*
103  * "memset" on IO memory space.
104  * This needs to be optimized.
105  */
106 void memset_io(volatile void __iomem *dst, int c, unsigned long count)
107 {
108         while (count) {
109                 count--;
110                 writeb(c, dst);
111                 dst++;
112         }
113 }
114 EXPORT_SYMBOL(memset_io);
115 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp