1 /* 2 * linux/arch/sh/kernel/io.c 3 * 4 * Copyright (C) 2000 Stuart Menefy 5 * Copyright (C) 2005 Paul Mundt 6 * 7 * Provide real functions which expand to whatever the header file defined. 8 * Also definitions of machine independent IO functions. 9 * 10 * This file is subject to the terms and conditions of the GNU General Public 11 * License. See the file "COPYING" in the main directory of this archive 12 * for more details. 13 */ 14 #include <linux/module.h> 15 #include <asm/machvec.h> 16 #include <asm/io.h> 17 18 /* 19 * Copy data from IO memory space to "real" memory space. 20 * This needs to be optimized. 21 */ 22 void memcpy_fromio(void *to, volatile void __iomem *from, unsigned long count) 23 { 24 char *p = to; 25 while (count) { 26 count--; 27 *p = readb((void __iomem *)from); 28 p++; 29 from++; 30 } 31 } 32 EXPORT_SYMBOL(memcpy_fromio); 33 34 /* 35 * Copy data from "real" memory space to IO memory space. 36 * This needs to be optimized. 37 */ 38 void memcpy_toio(volatile void __iomem *to, const void *from, unsigned long count) 39 { 40 const char *p = from; 41 while (count) { 42 count--; 43 writeb(*p, (void __iomem *)to); 44 p++; 45 to++; 46 } 47 } 48 EXPORT_SYMBOL(memcpy_toio); 49 50 /* 51 * "memset" on IO memory space. 52 * This needs to be optimized. 53 */ 54 void memset_io(volatile void __iomem *dst, int c, unsigned long count) 55 { 56 while (count) { 57 count--; 58 writeb(c, (void __iomem *)dst); 59 dst++; 60 } 61 } 62 EXPORT_SYMBOL(memset_io); 63 64 void __iomem *ioport_map(unsigned long port, unsigned int nr) 65 { 66 void __iomem *ret; 67 68 ret = __ioport_map_trapped(port, nr); 69 if (ret) 70 return ret; 71 72 return __ioport_map(port, nr); 73 } 74 EXPORT_SYMBOL(ioport_map); 75 76 void ioport_unmap(void __iomem *addr) 77 { 78 sh_mv.mv_ioport_unmap(addr); 79 } 80 EXPORT_SYMBOL(ioport_unmap); 81