2 * Copyright (C) 2000 David J. Mckay (david.mckay@st.com)
4 * May be copied or modified under the terms of the GNU General Public
5 * License. See linux/COPYING for more information.
7 * This file contains the I/O routines for use on the overdrive board
11 #include <linux/kernel.h>
12 #include <linux/types.h>
13 #include <linux/delay.h>
14 #include <linux/module.h>
15 #include <asm/system.h>
16 #include <asm/processor.h>
19 /* Now for the string version of these functions */
20 void outsb(unsigned long port, const void *addr, unsigned long count)
23 unsigned char *p = (unsigned char *) addr;
25 for (i = 0; i < count; i++, p++) {
31 void insb(unsigned long port, void *addr, unsigned long count)
34 unsigned char *p = (unsigned char *) addr;
36 for (i = 0; i < count; i++, p++) {
42 /* For the 16 and 32 bit string functions, we have to worry about alignment.
43 * The SH does not do unaligned accesses, so we have to read as bytes and
44 * then write as a word or dword.
45 * This can be optimised a lot more, especially in the case where the data
49 void outsw(unsigned long port, const void *addr, unsigned long count)
53 unsigned char *p = (unsigned char *) addr;
55 for (i = 0; i < count; i++, p += 2) {
56 tmp = (*p) | ((*(p + 1)) << 8);
62 void insw(unsigned long port, void *addr, unsigned long count)
66 unsigned char *p = (unsigned char *) addr;
68 for (i = 0; i < count; i++, p += 2) {
71 p[1] = (tmp >> 8) & 0xff;
76 void outsl(unsigned long port, const void *addr, unsigned long count)
80 unsigned char *p = (unsigned char *) addr;
82 for (i = 0; i < count; i++, p += 4) {
83 tmp = (*p) | ((*(p + 1)) << 8) | ((*(p + 2)) << 16) |
90 void insl(unsigned long port, void *addr, unsigned long count)
94 unsigned char *p = (unsigned char *) addr;
96 for (i = 0; i < count; i++, p += 4) {
99 p[1] = (tmp >> 8) & 0xff;
100 p[2] = (tmp >> 16) & 0xff;
101 p[3] = (tmp >> 24) & 0xff;
107 void memcpy_toio(void __iomem *to, const void *from, long count)
109 unsigned char *p = (unsigned char *) from;
116 EXPORT_SYMBOL(memcpy_toio);
118 void memcpy_fromio(void *to, void __iomem *from, long count)
121 unsigned char *p = (unsigned char *) to;
123 for (i = 0; i < count; i++) {
128 EXPORT_SYMBOL(memcpy_fromio);