|
12 | 12 | #include <linux/module.h>
|
13 | 13 | #include <asm/io.h>
|
14 | 14 |
|
15 |
| -/* |
16 |
| -** Copies a block of memory from a device in an efficient manner. |
17 |
| -** Assumes the device can cope with 32-bit transfers. If it can't, |
18 |
| -** don't use this function. |
19 |
| -** |
20 |
| -** CR16 counts on C3000 reading 256 bytes from Symbios 896 RAM: |
21 |
| -** 27341/64 = 427 cyc per int |
22 |
| -** 61311/128 = 478 cyc per short |
23 |
| -** 122637/256 = 479 cyc per byte |
24 |
| -** Ergo bus latencies dominant (not transfer size). |
25 |
| -** Minimize total number of transfers at cost of CPU cycles. |
26 |
| -** TODO: only look at src alignment and adjust the stores to dest. |
27 |
| -*/ |
28 |
| -void memcpy_fromio(void *dst, const volatile void __iomem *src, int count) |
29 |
| -{ |
30 |
| - /* first compare alignment of src/dst */ |
31 |
| - if ( (((unsigned long)dst ^ (unsigned long)src) & 1) || (count < 2) ) |
32 |
| - goto bytecopy; |
33 |
| - |
34 |
| - if ( (((unsigned long)dst ^ (unsigned long)src) & 2) || (count < 4) ) |
35 |
| - goto shortcopy; |
36 |
| - |
37 |
| - /* Then check for misaligned start address */ |
38 |
| - if ((unsigned long)src & 1) { |
39 |
| - *(u8 *)dst = readb(src); |
40 |
| - src++; |
41 |
| - dst++; |
42 |
| - count--; |
43 |
| - if (count < 2) goto bytecopy; |
44 |
| - } |
45 |
| - |
46 |
| - if ((unsigned long)src & 2) { |
47 |
| - *(u16 *)dst = __raw_readw(src); |
48 |
| - src += 2; |
49 |
| - dst += 2; |
50 |
| - count -= 2; |
51 |
| - } |
52 |
| - |
53 |
| - while (count > 3) { |
54 |
| - *(u32 *)dst = __raw_readl(src); |
55 |
| - dst += 4; |
56 |
| - src += 4; |
57 |
| - count -= 4; |
58 |
| - } |
59 |
| - |
60 |
| - shortcopy: |
61 |
| - while (count > 1) { |
62 |
| - *(u16 *)dst = __raw_readw(src); |
63 |
| - src += 2; |
64 |
| - dst += 2; |
65 |
| - count -= 2; |
66 |
| - } |
67 |
| - |
68 |
| - bytecopy: |
69 |
| - while (count--) { |
70 |
| - *(char *)dst = readb(src); |
71 |
| - src++; |
72 |
| - dst++; |
73 |
| - } |
74 |
| -} |
75 |
| - |
76 | 15 | /*
|
77 | 16 | * Read COUNT 8-bit bytes from port PORT into memory starting at
|
78 | 17 | * SRC.
|
|
0 commit comments