summaryrefslogtreecommitdiff
path: root/firmware/drivers/ata.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/ata.c')
-rw-r--r--firmware/drivers/ata.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c
index 76c0090a12..d2c80e0ae0 100644
--- a/firmware/drivers/ata.c
+++ b/firmware/drivers/ata.c
@@ -104,7 +104,7 @@ STATICIRAM int wait_for_bsy(void)
104 long timeout = current_tick + HZ*30; 104 long timeout = current_tick + HZ*30;
105 while (TIME_BEFORE(current_tick, timeout) && (ATA_STATUS & STATUS_BSY)) { 105 while (TIME_BEFORE(current_tick, timeout) && (ATA_STATUS & STATUS_BSY)) {
106 last_disk_activity = current_tick; 106 last_disk_activity = current_tick;
107 yield(); 107 priority_yield();
108 } 108 }
109 109
110 if (TIME_BEFORE(current_tick, timeout)) 110 if (TIME_BEFORE(current_tick, timeout))
@@ -126,7 +126,7 @@ STATICIRAM int wait_for_rdy(void)
126 while (TIME_BEFORE(current_tick, timeout) && 126 while (TIME_BEFORE(current_tick, timeout) &&
127 !(ATA_ALT_STATUS & STATUS_RDY)) { 127 !(ATA_ALT_STATUS & STATUS_RDY)) {
128 last_disk_activity = current_tick; 128 last_disk_activity = current_tick;
129 yield(); 129 priority_yield();
130 } 130 }
131 131
132 if (TIME_BEFORE(current_tick, timeout)) 132 if (TIME_BEFORE(current_tick, timeout))
@@ -216,7 +216,7 @@ int ata_read_sectors(IF_MV2(int drive,)
216#ifdef HAVE_MULTIVOLUME 216#ifdef HAVE_MULTIVOLUME
217 (void)drive; /* unused for now */ 217 (void)drive; /* unused for now */
218#endif 218#endif
219 mutex_lock(&ata_mtx); 219 spinlock_lock(&ata_mtx);
220 220
221 last_disk_activity = current_tick; 221 last_disk_activity = current_tick;
222 spinup_start = current_tick; 222 spinup_start = current_tick;
@@ -227,14 +227,14 @@ int ata_read_sectors(IF_MV2(int drive,)
227 spinup = true; 227 spinup = true;
228 if (poweroff) { 228 if (poweroff) {
229 if (ata_power_on()) { 229 if (ata_power_on()) {
230 mutex_unlock(&ata_mtx); 230 spinlock_unlock(&ata_mtx);
231 ata_led(false); 231 ata_led(false);
232 return -1; 232 return -1;
233 } 233 }
234 } 234 }
235 else { 235 else {
236 if (perform_soft_reset()) { 236 if (perform_soft_reset()) {
237 mutex_unlock(&ata_mtx); 237 spinlock_unlock(&ata_mtx);
238 ata_led(false); 238 ata_led(false);
239 return -1; 239 return -1;
240 } 240 }
@@ -246,7 +246,7 @@ int ata_read_sectors(IF_MV2(int drive,)
246 SET_REG(ATA_SELECT, ata_device); 246 SET_REG(ATA_SELECT, ata_device);
247 if (!wait_for_rdy()) 247 if (!wait_for_rdy())
248 { 248 {
249 mutex_unlock(&ata_mtx); 249 spinlock_unlock(&ata_mtx);
250 ata_led(false); 250 ata_led(false);
251 return -2; 251 return -2;
252 } 252 }
@@ -359,7 +359,7 @@ int ata_read_sectors(IF_MV2(int drive,)
359 } 359 }
360 ata_led(false); 360 ata_led(false);
361 361
362 mutex_unlock(&ata_mtx); 362 spinlock_unlock(&ata_mtx);
363 363
364 return ret; 364 return ret;
365} 365}
@@ -417,7 +417,7 @@ int ata_write_sectors(IF_MV2(int drive,)
417 if (start == 0) 417 if (start == 0)
418 panicf("Writing on sector 0\n"); 418 panicf("Writing on sector 0\n");
419 419
420 mutex_lock(&ata_mtx); 420 spinlock_lock(&ata_mtx);
421 421
422 last_disk_activity = current_tick; 422 last_disk_activity = current_tick;
423 spinup_start = current_tick; 423 spinup_start = current_tick;
@@ -428,14 +428,14 @@ int ata_write_sectors(IF_MV2(int drive,)
428 spinup = true; 428 spinup = true;
429 if (poweroff) { 429 if (poweroff) {
430 if (ata_power_on()) { 430 if (ata_power_on()) {
431 mutex_unlock(&ata_mtx); 431 spinlock_unlock(&ata_mtx);
432 ata_led(false); 432 ata_led(false);
433 return -1; 433 return -1;
434 } 434 }
435 } 435 }
436 else { 436 else {
437 if (perform_soft_reset()) { 437 if (perform_soft_reset()) {
438 mutex_unlock(&ata_mtx); 438 spinlock_unlock(&ata_mtx);
439 ata_led(false); 439 ata_led(false);
440 return -1; 440 return -1;
441 } 441 }
@@ -445,7 +445,7 @@ int ata_write_sectors(IF_MV2(int drive,)
445 SET_REG(ATA_SELECT, ata_device); 445 SET_REG(ATA_SELECT, ata_device);
446 if (!wait_for_rdy()) 446 if (!wait_for_rdy())
447 { 447 {
448 mutex_unlock(&ata_mtx); 448 spinlock_unlock(&ata_mtx);
449 ata_led(false); 449 ata_led(false);
450 return -2; 450 return -2;
451 } 451 }
@@ -507,7 +507,7 @@ int ata_write_sectors(IF_MV2(int drive,)
507 507
508 ata_led(false); 508 ata_led(false);
509 509
510 mutex_unlock(&ata_mtx); 510 spinlock_unlock(&ata_mtx);
511 511
512 return ret; 512 return ret;
513} 513}
@@ -572,13 +572,13 @@ static int ata_perform_sleep(void)
572{ 572{
573 int ret = 0; 573 int ret = 0;
574 574
575 mutex_lock(&ata_mtx); 575 spinlock_lock(&ata_mtx);
576 576
577 SET_REG(ATA_SELECT, ata_device); 577 SET_REG(ATA_SELECT, ata_device);
578 578
579 if(!wait_for_rdy()) { 579 if(!wait_for_rdy()) {
580 DEBUGF("ata_perform_sleep() - not RDY\n"); 580 DEBUGF("ata_perform_sleep() - not RDY\n");
581 mutex_unlock(&ata_mtx); 581 spinlock_unlock(&ata_mtx);
582 return -1; 582 return -1;
583 } 583 }
584 584
@@ -591,7 +591,7 @@ static int ata_perform_sleep(void)
591 } 591 }
592 592
593 sleeping = true; 593 sleeping = true;
594 mutex_unlock(&ata_mtx); 594 spinlock_unlock(&ata_mtx);
595 return ret; 595 return ret;
596} 596}
597 597
@@ -649,9 +649,9 @@ static void ata_thread(void)
649 if ( !spinup && sleeping && !poweroff && 649 if ( !spinup && sleeping && !poweroff &&
650 TIME_AFTER( current_tick, last_sleep + ATA_POWER_OFF_TIMEOUT )) 650 TIME_AFTER( current_tick, last_sleep + ATA_POWER_OFF_TIMEOUT ))
651 { 651 {
652 mutex_lock(&ata_mtx); 652 spinlock_lock(&ata_mtx);
653 ide_power_enable(false); 653 ide_power_enable(false);
654 mutex_unlock(&ata_mtx); 654 spinlock_unlock(&ata_mtx);
655 poweroff = true; 655 poweroff = true;
656 } 656 }
657#endif 657#endif
@@ -663,11 +663,11 @@ static void ata_thread(void)
663#ifndef USB_NONE 663#ifndef USB_NONE
664 case SYS_USB_CONNECTED: 664 case SYS_USB_CONNECTED:
665 if (poweroff) { 665 if (poweroff) {
666 mutex_lock(&ata_mtx); 666 spinlock_lock(&ata_mtx);
667 ata_led(true); 667 ata_led(true);
668 ata_power_on(); 668 ata_power_on();
669 ata_led(false); 669 ata_led(false);
670 mutex_unlock(&ata_mtx); 670 spinlock_unlock(&ata_mtx);
671 } 671 }
672 672
673 /* Tell the USB thread that we are safe */ 673 /* Tell the USB thread that we are safe */
@@ -741,11 +741,11 @@ int ata_soft_reset(void)
741{ 741{
742 int ret; 742 int ret;
743 743
744 mutex_lock(&ata_mtx); 744 spinlock_lock(&ata_mtx);
745 745
746 ret = perform_soft_reset(); 746 ret = perform_soft_reset();
747 747
748 mutex_unlock(&ata_mtx); 748 spinlock_unlock(&ata_mtx);
749 return ret; 749 return ret;
750} 750}
751 751
@@ -936,7 +936,7 @@ int ata_init(void)
936 bool coldstart = ata_is_coldstart(); 936 bool coldstart = ata_is_coldstart();
937 /* must be called before ata_device_init() */ 937 /* must be called before ata_device_init() */
938 938
939 mutex_init(&ata_mtx); 939 spinlock_init(&ata_mtx);
940 940
941 ata_led(false); 941 ata_led(false);
942 ata_device_init(); 942 ata_device_init();