diff options
-rw-r--r-- | firmware/target/coldfire/mpio/ata-as-mpio.S | 50 | ||||
-rw-r--r-- | firmware/target/coldfire/mpio/ata-target.h | 4 |
2 files changed, 23 insertions, 31 deletions
diff --git a/firmware/target/coldfire/mpio/ata-as-mpio.S b/firmware/target/coldfire/mpio/ata-as-mpio.S index 2a76072918..63bda5ee19 100644 --- a/firmware/target/coldfire/mpio/ata-as-mpio.S +++ b/firmware/target/coldfire/mpio/ata-as-mpio.S | |||
@@ -23,7 +23,7 @@ | |||
23 | 23 | ||
24 | .equ .ata_port, 0x20000020 | 24 | .equ .ata_port, 0x20000020 |
25 | .equ .swapmask, 0x00FF00FF | 25 | .equ .swapmask, 0x00FF00FF |
26 | #if 0 | 26 | |
27 | .align 2 | 27 | .align 2 |
28 | .global copy_read_sectors | 28 | .global copy_read_sectors |
29 | .type copy_read_sectors,@function | 29 | .type copy_read_sectors,@function |
@@ -69,23 +69,19 @@ copy_read_sectors: | |||
69 | move.b %d2, (%a0)+ /* write high byte of it, aligns dest addr */ | 69 | move.b %d2, (%a0)+ /* write high byte of it, aligns dest addr */ |
70 | /* we have byte swapped */ | 70 | /* we have byte swapped */ |
71 | 71 | ||
72 | lsr.l #8, %d2 | ||
72 | btst.l #1, %d0 /* longword aligned? (testing old d0 value!) */ | 73 | btst.l #1, %d0 /* longword aligned? (testing old d0 value!) */ |
73 | bne.b .r_end_u_w1 /* yes, skip leading word handling */ | 74 | bne.b .r_end_u_w1 /* yes, skip leading word handling */ |
74 | 75 | ||
75 | swap %d2 /* move initial word up */ | 76 | move.w (%a2), %d3 |
76 | move.w (%a2), %d2 /* combine with second word */ | 77 | move.l %d3, %d0 |
77 | 78 | lsl.l #8, %d2 | |
78 | /* byte swap d2 */ | 79 | and.l #0xff, %d0 |
79 | move.l %a3, %d7 /* d7 = 0x00FF00FF */ | 80 | or.l %d0, %d2 |
80 | and.l %d2, %d7 /* d7 = .B.D */ | 81 | |
81 | eor.l %d7, %d2 /* d2 = A.C. */ | 82 | move.w %d2, (%a0)+ /* write bytes 2 and 3 as word */ |
82 | lsl.l #8, %d7 /* d7 = B.D. */ | 83 | move.l %d3, %d2 |
83 | lsr.l #8, %d2 /* d2 = .A.C */ | 84 | lsr.l #8, %d2 |
84 | or.l %d7, %d2 /* d2 = BADC */ | ||
85 | |||
86 | move.l %d2, %d3 | ||
87 | lsr.l #8, %d3 | ||
88 | move.w %d3, (%a0)+ /* write bytes 2 and 3 as word */ | ||
89 | 85 | ||
90 | .r_end_u_w1: | 86 | .r_end_u_w1: |
91 | moveq.l #12, %d0 | 87 | moveq.l #12, %d0 |
@@ -108,6 +104,7 @@ copy_read_sectors: | |||
108 | or.l %d7, %d3 /* d3 = BADC */ | 104 | or.l %d7, %d3 /* d3 = BADC */ |
109 | 105 | ||
110 | move.l %d3, %d4 | 106 | move.l %d3, %d4 |
107 | |||
111 | lsl.l %d1, %d2 | 108 | lsl.l %d1, %d2 |
112 | lsr.l #8, %d3 | 109 | lsr.l #8, %d3 |
113 | or.l %d3, %d2 /* combine old low byte with new top 3 bytes */ | 110 | or.l %d3, %d2 /* combine old low byte with new top 3 bytes */ |
@@ -133,6 +130,7 @@ copy_read_sectors: | |||
133 | or.l %d7, %d3 /* d3 = BADC */ | 130 | or.l %d7, %d3 /* d3 = BADC */ |
134 | 131 | ||
135 | move.l %d3, %d0 | 132 | move.l %d3, %d0 |
133 | |||
136 | lsl.l %d1, %d2 | 134 | lsl.l %d1, %d2 |
137 | lsr.l #8, %d0 | 135 | lsr.l #8, %d0 |
138 | or.l %d0, %d2 /* combine old low byte with new top 3 bytes */ | 136 | or.l %d0, %d2 /* combine old low byte with new top 3 bytes */ |
@@ -221,21 +219,16 @@ copy_read_sectors: | |||
221 | cmp.l %a0, %a1 /* one word left? */ | 219 | cmp.l %a0, %a1 /* one word left? */ |
222 | bls.b .r_end_u_w2 | 220 | bls.b .r_end_u_w2 |
223 | 221 | ||
224 | swap %d2 /* move old word to upper 16 bits */ | 222 | move.w (%a2), %d3 |
225 | move.w (%a2), %d2 /* load final word */ | 223 | move.l %d3, %d0 |
226 | 224 | lsl.l #8, %d2 | |
227 | /* byte swap d2 */ | 225 | and.l #0xff, %d0 |
228 | move.l %a3, %d7 /* d7 = 0x00FF00FF */ | 226 | or.l %d0, %d2 |
229 | and.l %d2, %d7 /* d7 = .B.D */ | ||
230 | eor.l %d7, %d2 /* d2 = A.C. */ | ||
231 | lsl.l #8, %d7 /* d7 = B.D. */ | ||
232 | lsr.l #8, %d2 /* d2 = .A.C */ | ||
233 | or.l %d7, %d2 /* d2 = BADC */ | ||
234 | 227 | ||
235 | move.l %d2, %d3 | 228 | move.w %d2, (%a0)+ /* write bytes 2 and 3 as word */ |
236 | lsr.l #8, %d3 | ||
237 | move.w %d3, (%a0)+ /* write bytes 2 and 3 as word */ | ||
238 | 229 | ||
230 | move.l %d3, %d2 | ||
231 | lsr.l #8, %d2 | ||
239 | .r_end_u_w2: | 232 | .r_end_u_w2: |
240 | move.b %d2, (%a0)+ /* store final byte */ | 233 | move.b %d2, (%a0)+ /* store final byte */ |
241 | bra.w .r_exit | 234 | bra.w .r_exit |
@@ -375,7 +368,6 @@ copy_read_sectors: | |||
375 | 368 | ||
376 | .r_end: | 369 | .r_end: |
377 | .size copy_read_sectors,.r_end-copy_read_sectors | 370 | .size copy_read_sectors,.r_end-copy_read_sectors |
378 | #endif | ||
379 | 371 | ||
380 | .align 2 | 372 | .align 2 |
381 | .global copy_write_sectors | 373 | .global copy_write_sectors |
diff --git a/firmware/target/coldfire/mpio/ata-target.h b/firmware/target/coldfire/mpio/ata-target.h index 32e97ff56e..ec4fd91a6e 100644 --- a/firmware/target/coldfire/mpio/ata-target.h +++ b/firmware/target/coldfire/mpio/ata-target.h | |||
@@ -21,7 +21,7 @@ | |||
21 | #ifndef ATA_TARGET_H | 21 | #ifndef ATA_TARGET_H |
22 | #define ATA_TARGET_H | 22 | #define ATA_TARGET_H |
23 | 23 | ||
24 | /* #define ATA_OPTIMIZED_READING */ | 24 | #define ATA_OPTIMIZED_READING |
25 | #define ATA_OPTIMIZED_WRITING | 25 | #define ATA_OPTIMIZED_WRITING |
26 | 26 | ||
27 | #define SWAP_WORDS | 27 | #define SWAP_WORDS |
@@ -71,6 +71,6 @@ void ata_enable(bool on); | |||
71 | void ata_device_init(void); | 71 | void ata_device_init(void); |
72 | bool ata_is_coldstart(void); | 72 | bool ata_is_coldstart(void); |
73 | 73 | ||
74 | /* void copy_read_sectors(unsigned char* buf, int wordcount); */ | 74 | void copy_read_sectors(unsigned char* buf, int wordcount); |
75 | void copy_write_sectors(const unsigned char* buf, int wordcount); | 75 | void copy_write_sectors(const unsigned char* buf, int wordcount); |
76 | #endif | 76 | #endif |