2 * PeeCeeI.c: The emerging standard...
4 * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu)
7 #include <linux/module.h>
10 #include <asm/byteorder.h>
12 void outsb(unsigned long __addr
, const void *src
, unsigned long count
)
14 void __iomem
*addr
= (void __iomem
*) __addr
;
18 __raw_writeb(*p
++, addr
);
22 void outsw(unsigned long __addr
, const void *src
, unsigned long count
)
24 void __iomem
*addr
= (void __iomem
*) __addr
;
27 __raw_writew(*(u16
*)src
, addr
);
33 void outsl(unsigned long __addr
, const void *src
, unsigned long count
)
35 void __iomem
*addr
= (void __iomem
*) __addr
;
41 switch (((unsigned long)src
) & 0x3) {
43 /* src is naturally aligned */
45 __raw_writel(*(u32
*)src
, addr
);
50 /* 2-byte alignment */
52 l
= (*(u16
*)src
) << 16;
53 l
|= *(u16
*)(src
+ sizeof(u16
));
54 __raw_writel(l
, addr
);
59 /* Hold three bytes in l each time, grab a byte from l2 */
60 l
= (*(u8
*)src
) << 24;
61 l
|= (*(u16
*)(src
+ sizeof(u8
))) << 8;
62 src
+= sizeof(u8
) + sizeof(u16
);
66 __raw_writel(l
, addr
);
72 /* Hold a byte in l each time, grab 3 bytes from l2 */
73 l
= (*(u8
*)src
) << 24;
78 __raw_writel(l
, addr
);
87 void insb(unsigned long __addr
, void *dst
, unsigned long count
)
89 void __iomem
*addr
= (void __iomem
*) __addr
;
95 while ((((unsigned long)pb
) & 0x3) && count
--)
96 *pb
++ = __raw_readb(addr
);
101 w
= (__raw_readb(addr
) << 24);
102 w
|= (__raw_readb(addr
) << 16);
103 w
|= (__raw_readb(addr
) << 8);
104 w
|= (__raw_readb(addr
) << 0);
110 *pb
++ = __raw_readb(addr
);
115 void insw(unsigned long __addr
, void *dst
, unsigned long count
)
117 void __iomem
*addr
= (void __iomem
*) __addr
;
123 if (((unsigned long)ps
) & 0x2) {
124 *ps
++ = __raw_readw(addr
);
131 w
= __raw_readw(addr
) << 16;
132 w
|= __raw_readw(addr
) << 0;
138 *ps
= __raw_readw(addr
);
143 void insl(unsigned long __addr
, void *dst
, unsigned long count
)
145 void __iomem
*addr
= (void __iomem
*) __addr
;
148 if ((((unsigned long)dst
) & 0x3) == 0) {
151 *pi
++ = __raw_readl(addr
);
157 switch (((unsigned long)dst
) & 3) {
161 l
= __raw_readl(addr
);
165 l2
= __raw_readl(addr
);
166 *pi
++ = (l
<< 16) | (l2
>> 16);
176 l
= __raw_readl(addr
);
179 *ps
++ = ((l
>> 8) & 0xffff);
182 l2
= __raw_readl(addr
);
183 *pi
++ = (l
<< 24) | (l2
>> 8);
193 l
= __raw_readl(addr
);
197 l2
= __raw_readl(addr
);
198 *pi
++ = (l
<< 8) | (l2
>> 24);
202 *ps
++ = ((l
>> 8) & 0xffff);