1 // SPDX-License-Identifier: GPL-2.0
3 * PeeCeeI.c: The emerging standard...
5 * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu)
8 #include <linux/module.h>
11 #include <asm/byteorder.h>
13 void outsb(unsigned long __addr, const void *src, unsigned long count)
15 void __iomem *addr = (void __iomem *) __addr;
19 __raw_writeb(*p++, addr);
23 void outsw(unsigned long __addr, const void *src, unsigned long count)
25 void __iomem *addr = (void __iomem *) __addr;
28 __raw_writew(*(u16 *)src, addr);
34 void outsl(unsigned long __addr, const void *src, unsigned long count)
36 void __iomem *addr = (void __iomem *) __addr;
42 switch (((unsigned long)src) & 0x3) {
44 /* src is naturally aligned */
46 __raw_writel(*(u32 *)src, addr);
51 /* 2-byte alignment */
53 l = (*(u16 *)src) << 16;
54 l |= *(u16 *)(src + sizeof(u16));
55 __raw_writel(l, addr);
60 /* Hold three bytes in l each time, grab a byte from l2 */
61 l = (*(u8 *)src) << 24;
62 l |= (*(u16 *)(src + sizeof(u8))) << 8;
63 src += sizeof(u8) + sizeof(u16);
67 __raw_writel(l, addr);
73 /* Hold a byte in l each time, grab 3 bytes from l2 */
74 l = (*(u8 *)src) << 24;
79 __raw_writel(l, addr);
88 void insb(unsigned long __addr, void *dst, unsigned long count)
90 void __iomem *addr = (void __iomem *) __addr;
96 while ((((unsigned long)pb) & 0x3) && count--)
97 *pb++ = __raw_readb(addr);
102 w = (__raw_readb(addr) << 24);
103 w |= (__raw_readb(addr) << 16);
104 w |= (__raw_readb(addr) << 8);
105 w |= (__raw_readb(addr) << 0);
111 *pb++ = __raw_readb(addr);
116 void insw(unsigned long __addr, void *dst, unsigned long count)
118 void __iomem *addr = (void __iomem *) __addr;
124 if (((unsigned long)ps) & 0x2) {
125 *ps++ = __raw_readw(addr);
132 w = __raw_readw(addr) << 16;
133 w |= __raw_readw(addr) << 0;
139 *ps = __raw_readw(addr);
144 void insl(unsigned long __addr, void *dst, unsigned long count)
146 void __iomem *addr = (void __iomem *) __addr;
149 if ((((unsigned long)dst) & 0x3) == 0) {
152 *pi++ = __raw_readl(addr);
158 switch (((unsigned long)dst) & 3) {
162 l = __raw_readl(addr);
166 l2 = __raw_readl(addr);
167 *pi++ = (l << 16) | (l2 >> 16);
177 l = __raw_readl(addr);
180 *ps++ = ((l >> 8) & 0xffff);
183 l2 = __raw_readl(addr);
184 *pi++ = (l << 24) | (l2 >> 8);
194 l = __raw_readl(addr);
198 l2 = __raw_readl(addr);
199 *pi++ = (l << 8) | (l2 >> 24);
203 *ps++ = ((l >> 8) & 0xffff);