summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/drivers/ata.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c
index 8e9ec942cd..11ce50bc1f 100644
--- a/firmware/drivers/ata.c
+++ b/firmware/drivers/ata.c
@@ -165,11 +165,13 @@ int ata_read_sectors(unsigned long start,
165 int count, 165 int count,
166 void* buf) __attribute__ ((section (".icode"))); 166 void* buf) __attribute__ ((section (".icode")));
167int ata_read_sectors(unsigned long start, 167int ata_read_sectors(unsigned long start,
168 int count, 168 int incount,
169 void* buf) 169 void* inbuf)
170{ 170{
171 int ret = 0; 171 int ret = 0;
172 int timeout; 172 int timeout;
173 int count;
174 void* buf;
173 175
174 last_disk_activity = current_tick; 176 last_disk_activity = current_tick;
175 177
@@ -201,6 +203,10 @@ int ata_read_sectors(unsigned long start,
201 led(true); 203 led(true);
202 204
203 timeout = current_tick + READ_TIMEOUT; 205 timeout = current_tick + READ_TIMEOUT;
206
207 retry:
208 buf = inbuf;
209 count = incount;
204 while (TIME_BEFORE(current_tick, timeout)) { 210 while (TIME_BEFORE(current_tick, timeout)) {
205 211
206 if ( count == 256 ) 212 if ( count == 256 )
@@ -221,11 +227,11 @@ int ata_read_sectors(unsigned long start,
221 227
222 if (!wait_for_start_of_transfer()) { 228 if (!wait_for_start_of_transfer()) {
223 ret = -4; 229 ret = -4;
224 continue; 230 goto retry;
225 } 231 }
226 232
227 if ( ATA_ALT_STATUS & (STATUS_ERR | STATUS_DF) ) 233 if ( ATA_ALT_STATUS & (STATUS_ERR | STATUS_DF) )
228 continue; 234 goto retry;
229 235
230 /* if destination address is odd, use byte copying, 236 /* if destination address is odd, use byte copying,
231 otherwise use word copying */ 237 otherwise use word copying */
@@ -259,9 +265,10 @@ int ata_read_sectors(unsigned long start,
259 265
260 if(!wait_for_end_of_transfer()) { 266 if(!wait_for_end_of_transfer()) {
261 ret = -3; 267 ret = -3;
262 continue; 268 goto retry;
263 } 269 }
264 270
271 ret = 0;
265 break; 272 break;
266 } 273 }
267 led(false); 274 led(false);