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
;
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
--)
101 w
= (inb(addr
) << 24);
102 w
|= (inb(addr
) << 16);
103 w
|= (inb(addr
) << 8);
104 w
|= (inb(addr
) << 0);
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
++ = le16_to_cpu(inw(addr
));
131 w
= (le16_to_cpu(inw(addr
)) << 16);
132 w
|= (le16_to_cpu(inw(addr
)) << 0);
138 *ps
= le16_to_cpu(inw(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
++ = le32_to_cpu(inl(addr
));
157 switch (((unsigned long)dst
) & 3) {
161 l
= le32_to_cpu(inl(addr
));
165 l2
= le32_to_cpu(inl(addr
));
166 *pi
++ = (l
<< 16) | (l2
>> 16);
176 l
= le32_to_cpu(inl(addr
));
179 *ps
++ = ((l
>> 8) & 0xffff);
182 l2
= le32_to_cpu(inl(addr
));
183 *pi
++ = (l
<< 24) | (l2
>> 8);
193 l
= le32_to_cpu(inl(addr
));
197 l2
= le32_to_cpu(inl(addr
));
198 *pi
++ = (l
<< 8) | (l2
>> 24);
202 *ps
++ = ((l
>> 8) & 0xffff);