diff options
Diffstat (limited to 'firmware/drivers')
-rw-r--r-- | firmware/drivers/ata.c | 62 | ||||
-rw-r--r-- | firmware/drivers/ata_mmc.c | 7 | ||||
-rw-r--r-- | firmware/drivers/button.c | 6 | ||||
-rw-r--r-- | firmware/drivers/fat.c | 2 |
4 files changed, 39 insertions, 38 deletions
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c index 2c8033a533..2119216234 100644 --- a/firmware/drivers/ata.c +++ b/firmware/drivers/ata.c | |||
@@ -66,7 +66,7 @@ | |||
66 | #define ATA_POWER_OFF_TIMEOUT 2*HZ | 66 | #define ATA_POWER_OFF_TIMEOUT 2*HZ |
67 | #endif | 67 | #endif |
68 | 68 | ||
69 | static struct mutex ata_mtx; | 69 | static struct spinlock ata_spinlock NOCACHEBSS_ATTR; |
70 | int ata_device; /* device 0 (master) or 1 (slave) */ | 70 | int ata_device; /* device 0 (master) or 1 (slave) */ |
71 | 71 | ||
72 | int ata_spinup_time = 0; | 72 | int ata_spinup_time = 0; |
@@ -83,7 +83,7 @@ static bool lba48 = false; /* set for 48 bit addressing */ | |||
83 | #endif | 83 | #endif |
84 | static long ata_stack[(DEFAULT_STACK_SIZE*3)/sizeof(long)]; | 84 | static long ata_stack[(DEFAULT_STACK_SIZE*3)/sizeof(long)]; |
85 | static const char ata_thread_name[] = "ata"; | 85 | static const char ata_thread_name[] = "ata"; |
86 | static struct event_queue ata_queue; | 86 | static struct event_queue ata_queue NOCACHEBSS_ATTR; |
87 | static bool initialized = false; | 87 | static bool initialized = false; |
88 | 88 | ||
89 | static long last_user_activity = -1; | 89 | static long last_user_activity = -1; |
@@ -234,7 +234,7 @@ int ata_read_sectors(IF_MV2(int drive,) | |||
234 | #ifdef HAVE_MULTIVOLUME | 234 | #ifdef HAVE_MULTIVOLUME |
235 | (void)drive; /* unused for now */ | 235 | (void)drive; /* unused for now */ |
236 | #endif | 236 | #endif |
237 | spinlock_lock(&ata_mtx); | 237 | spinlock_lock(&ata_spinlock); |
238 | #endif | 238 | #endif |
239 | 239 | ||
240 | last_disk_activity = current_tick; | 240 | last_disk_activity = current_tick; |
@@ -246,14 +246,14 @@ int ata_read_sectors(IF_MV2(int drive,) | |||
246 | spinup = true; | 246 | spinup = true; |
247 | if (poweroff) { | 247 | if (poweroff) { |
248 | if (ata_power_on()) { | 248 | if (ata_power_on()) { |
249 | spinlock_unlock(&ata_mtx); | 249 | spinlock_unlock(&ata_spinlock); |
250 | ata_led(false); | 250 | ata_led(false); |
251 | return -1; | 251 | return -1; |
252 | } | 252 | } |
253 | } | 253 | } |
254 | else { | 254 | else { |
255 | if (perform_soft_reset()) { | 255 | if (perform_soft_reset()) { |
256 | spinlock_unlock(&ata_mtx); | 256 | spinlock_unlock(&ata_spinlock); |
257 | ata_led(false); | 257 | ata_led(false); |
258 | return -1; | 258 | return -1; |
259 | } | 259 | } |
@@ -265,7 +265,7 @@ int ata_read_sectors(IF_MV2(int drive,) | |||
265 | SET_REG(ATA_SELECT, ata_device); | 265 | SET_REG(ATA_SELECT, ata_device); |
266 | if (!wait_for_rdy()) | 266 | if (!wait_for_rdy()) |
267 | { | 267 | { |
268 | spinlock_unlock(&ata_mtx); | 268 | spinlock_unlock(&ata_spinlock); |
269 | ata_led(false); | 269 | ata_led(false); |
270 | return -2; | 270 | return -2; |
271 | } | 271 | } |
@@ -376,7 +376,7 @@ int ata_read_sectors(IF_MV2(int drive,) | |||
376 | ata_led(false); | 376 | ata_led(false); |
377 | 377 | ||
378 | #ifndef MAX_PHYS_SECTOR_SIZE | 378 | #ifndef MAX_PHYS_SECTOR_SIZE |
379 | spinlock_unlock(&ata_mtx); | 379 | spinlock_unlock(&ata_spinlock); |
380 | #endif | 380 | #endif |
381 | 381 | ||
382 | return ret; | 382 | return ret; |
@@ -442,7 +442,7 @@ int ata_write_sectors(IF_MV2(int drive,) | |||
442 | #ifdef HAVE_MULTIVOLUME | 442 | #ifdef HAVE_MULTIVOLUME |
443 | (void)drive; /* unused for now */ | 443 | (void)drive; /* unused for now */ |
444 | #endif | 444 | #endif |
445 | spinlock_lock(&ata_mtx); | 445 | spinlock_lock(&ata_spinlock); |
446 | #endif | 446 | #endif |
447 | 447 | ||
448 | last_disk_activity = current_tick; | 448 | last_disk_activity = current_tick; |
@@ -454,14 +454,14 @@ int ata_write_sectors(IF_MV2(int drive,) | |||
454 | spinup = true; | 454 | spinup = true; |
455 | if (poweroff) { | 455 | if (poweroff) { |
456 | if (ata_power_on()) { | 456 | if (ata_power_on()) { |
457 | spinlock_unlock(&ata_mtx); | 457 | spinlock_unlock(&ata_spinlock); |
458 | ata_led(false); | 458 | ata_led(false); |
459 | return -1; | 459 | return -1; |
460 | } | 460 | } |
461 | } | 461 | } |
462 | else { | 462 | else { |
463 | if (perform_soft_reset()) { | 463 | if (perform_soft_reset()) { |
464 | spinlock_unlock(&ata_mtx); | 464 | spinlock_unlock(&ata_spinlock); |
465 | ata_led(false); | 465 | ata_led(false); |
466 | return -1; | 466 | return -1; |
467 | } | 467 | } |
@@ -471,7 +471,7 @@ int ata_write_sectors(IF_MV2(int drive,) | |||
471 | SET_REG(ATA_SELECT, ata_device); | 471 | SET_REG(ATA_SELECT, ata_device); |
472 | if (!wait_for_rdy()) | 472 | if (!wait_for_rdy()) |
473 | { | 473 | { |
474 | spinlock_unlock(&ata_mtx); | 474 | spinlock_unlock(&ata_spinlock); |
475 | ata_led(false); | 475 | ata_led(false); |
476 | return -2; | 476 | return -2; |
477 | } | 477 | } |
@@ -534,7 +534,7 @@ int ata_write_sectors(IF_MV2(int drive,) | |||
534 | ata_led(false); | 534 | ata_led(false); |
535 | 535 | ||
536 | #ifndef MAX_PHYS_SECTOR_SIZE | 536 | #ifndef MAX_PHYS_SECTOR_SIZE |
537 | spinlock_unlock(&ata_mtx); | 537 | spinlock_unlock(&ata_spinlock); |
538 | #endif | 538 | #endif |
539 | 539 | ||
540 | return ret; | 540 | return ret; |
@@ -580,7 +580,7 @@ int ata_read_sectors(IF_MV2(int drive,) | |||
580 | #ifdef HAVE_MULTIVOLUME | 580 | #ifdef HAVE_MULTIVOLUME |
581 | (void)drive; /* unused for now */ | 581 | (void)drive; /* unused for now */ |
582 | #endif | 582 | #endif |
583 | spinlock_lock(&ata_mtx); | 583 | spinlock_lock(&ata_spinlock); |
584 | 584 | ||
585 | offset = start & (phys_sector_mult - 1); | 585 | offset = start & (phys_sector_mult - 1); |
586 | 586 | ||
@@ -630,7 +630,7 @@ int ata_read_sectors(IF_MV2(int drive,) | |||
630 | } | 630 | } |
631 | 631 | ||
632 | error: | 632 | error: |
633 | spinlock_unlock(&ata_mtx); | 633 | spinlock_unlock(&ata_spinlock); |
634 | 634 | ||
635 | return rc; | 635 | return rc; |
636 | } | 636 | } |
@@ -646,7 +646,7 @@ int ata_write_sectors(IF_MV2(int drive,) | |||
646 | #ifdef HAVE_MULTIVOLUME | 646 | #ifdef HAVE_MULTIVOLUME |
647 | (void)drive; /* unused for now */ | 647 | (void)drive; /* unused for now */ |
648 | #endif | 648 | #endif |
649 | spinlock_lock(&ata_mtx); | 649 | spinlock_lock(&ata_spinlock); |
650 | 650 | ||
651 | offset = start & (phys_sector_mult - 1); | 651 | offset = start & (phys_sector_mult - 1); |
652 | 652 | ||
@@ -707,7 +707,7 @@ int ata_write_sectors(IF_MV2(int drive,) | |||
707 | } | 707 | } |
708 | 708 | ||
709 | error: | 709 | error: |
710 | spinlock_unlock(&ata_mtx); | 710 | spinlock_unlock(&ata_spinlock); |
711 | 711 | ||
712 | return rc; | 712 | return rc; |
713 | } | 713 | } |
@@ -767,13 +767,13 @@ static int ata_perform_sleep(void) | |||
767 | { | 767 | { |
768 | int ret = 0; | 768 | int ret = 0; |
769 | 769 | ||
770 | spinlock_lock(&ata_mtx); | 770 | spinlock_lock(&ata_spinlock); |
771 | 771 | ||
772 | SET_REG(ATA_SELECT, ata_device); | 772 | SET_REG(ATA_SELECT, ata_device); |
773 | 773 | ||
774 | if(!wait_for_rdy()) { | 774 | if(!wait_for_rdy()) { |
775 | DEBUGF("ata_perform_sleep() - not RDY\n"); | 775 | DEBUGF("ata_perform_sleep() - not RDY\n"); |
776 | spinlock_unlock(&ata_mtx); | 776 | spinlock_unlock(&ata_spinlock); |
777 | return -1; | 777 | return -1; |
778 | } | 778 | } |
779 | 779 | ||
@@ -786,7 +786,7 @@ static int ata_perform_sleep(void) | |||
786 | } | 786 | } |
787 | 787 | ||
788 | sleeping = true; | 788 | sleeping = true; |
789 | spinlock_unlock(&ata_mtx); | 789 | spinlock_unlock(&ata_spinlock); |
790 | return ret; | 790 | return ret; |
791 | } | 791 | } |
792 | 792 | ||
@@ -797,7 +797,7 @@ void ata_sleep(void) | |||
797 | 797 | ||
798 | void ata_sleepnow(void) | 798 | void ata_sleepnow(void) |
799 | { | 799 | { |
800 | if (!spinup && !sleeping && !ata_mtx.locked && initialized) | 800 | if (!spinup && !sleeping && !ata_spinlock.locked && initialized) |
801 | { | 801 | { |
802 | call_ata_idle_notifys(false); | 802 | call_ata_idle_notifys(false); |
803 | ata_perform_sleep(); | 803 | ata_perform_sleep(); |
@@ -812,14 +812,14 @@ void ata_spin(void) | |||
812 | static void ata_thread(void) | 812 | static void ata_thread(void) |
813 | { | 813 | { |
814 | static long last_sleep = 0; | 814 | static long last_sleep = 0; |
815 | struct event ev; | 815 | struct queue_event ev; |
816 | static long last_seen_mtx_unlock = 0; | 816 | static long last_seen_mtx_unlock = 0; |
817 | 817 | ||
818 | while (1) { | 818 | while (1) { |
819 | while ( queue_empty( &ata_queue ) ) { | 819 | while ( queue_empty( &ata_queue ) ) { |
820 | if (!spinup && !sleeping) | 820 | if (!spinup && !sleeping) |
821 | { | 821 | { |
822 | if (!ata_mtx.locked) | 822 | if (!ata_spinlock.locked) |
823 | { | 823 | { |
824 | if (!last_seen_mtx_unlock) | 824 | if (!last_seen_mtx_unlock) |
825 | last_seen_mtx_unlock = current_tick; | 825 | last_seen_mtx_unlock = current_tick; |
@@ -844,9 +844,9 @@ static void ata_thread(void) | |||
844 | if ( !spinup && sleeping && !poweroff && | 844 | if ( !spinup && sleeping && !poweroff && |
845 | TIME_AFTER( current_tick, last_sleep + ATA_POWER_OFF_TIMEOUT )) | 845 | TIME_AFTER( current_tick, last_sleep + ATA_POWER_OFF_TIMEOUT )) |
846 | { | 846 | { |
847 | spinlock_lock(&ata_mtx); | 847 | spinlock_lock(&ata_spinlock); |
848 | ide_power_enable(false); | 848 | ide_power_enable(false); |
849 | spinlock_unlock(&ata_mtx); | 849 | spinlock_unlock(&ata_spinlock); |
850 | poweroff = true; | 850 | poweroff = true; |
851 | } | 851 | } |
852 | #endif | 852 | #endif |
@@ -858,11 +858,11 @@ static void ata_thread(void) | |||
858 | #ifndef USB_NONE | 858 | #ifndef USB_NONE |
859 | case SYS_USB_CONNECTED: | 859 | case SYS_USB_CONNECTED: |
860 | if (poweroff) { | 860 | if (poweroff) { |
861 | spinlock_lock(&ata_mtx); | 861 | spinlock_lock(&ata_spinlock); |
862 | ata_led(true); | 862 | ata_led(true); |
863 | ata_power_on(); | 863 | ata_power_on(); |
864 | ata_led(false); | 864 | ata_led(false); |
865 | spinlock_unlock(&ata_mtx); | 865 | spinlock_unlock(&ata_spinlock); |
866 | } | 866 | } |
867 | 867 | ||
868 | /* Tell the USB thread that we are safe */ | 868 | /* Tell the USB thread that we are safe */ |
@@ -936,11 +936,11 @@ int ata_soft_reset(void) | |||
936 | { | 936 | { |
937 | int ret; | 937 | int ret; |
938 | 938 | ||
939 | spinlock_lock(&ata_mtx); | 939 | spinlock_lock(&ata_spinlock); |
940 | 940 | ||
941 | ret = perform_soft_reset(); | 941 | ret = perform_soft_reset(); |
942 | 942 | ||
943 | spinlock_unlock(&ata_mtx); | 943 | spinlock_unlock(&ata_spinlock); |
944 | return ret; | 944 | return ret; |
945 | } | 945 | } |
946 | 946 | ||
@@ -1131,7 +1131,7 @@ int ata_init(void) | |||
1131 | bool coldstart = ata_is_coldstart(); | 1131 | bool coldstart = ata_is_coldstart(); |
1132 | /* must be called before ata_device_init() */ | 1132 | /* must be called before ata_device_init() */ |
1133 | 1133 | ||
1134 | spinlock_init(&ata_mtx); | 1134 | spinlock_init(&ata_spinlock IF_COP(, SPINLOCK_TASK_SWITCH)); |
1135 | 1135 | ||
1136 | ata_led(false); | 1136 | ata_led(false); |
1137 | ata_device_init(); | 1137 | ata_device_init(); |
@@ -1205,9 +1205,9 @@ int ata_init(void) | |||
1205 | 1205 | ||
1206 | last_disk_activity = current_tick; | 1206 | last_disk_activity = current_tick; |
1207 | create_thread(ata_thread, ata_stack, | 1207 | create_thread(ata_thread, ata_stack, |
1208 | sizeof(ata_stack), ata_thread_name | 1208 | sizeof(ata_stack), 0, ata_thread_name |
1209 | IF_PRIO(, PRIORITY_SYSTEM) | 1209 | IF_PRIO(, PRIORITY_SYSTEM) |
1210 | IF_COP(, CPU, false)); | 1210 | IF_COP(, CPU)); |
1211 | initialized = true; | 1211 | initialized = true; |
1212 | 1212 | ||
1213 | } | 1213 | } |
diff --git a/firmware/drivers/ata_mmc.c b/firmware/drivers/ata_mmc.c index 66e60ead1d..604d1dde34 100644 --- a/firmware/drivers/ata_mmc.c +++ b/firmware/drivers/ata_mmc.c | |||
@@ -959,7 +959,7 @@ void ata_spin(void) | |||
959 | 959 | ||
960 | static void mmc_thread(void) | 960 | static void mmc_thread(void) |
961 | { | 961 | { |
962 | struct event ev; | 962 | struct queue_event ev; |
963 | bool idle_notified = false; | 963 | bool idle_notified = false; |
964 | 964 | ||
965 | while (1) { | 965 | while (1) { |
@@ -1153,8 +1153,9 @@ int ata_init(void) | |||
1153 | 1153 | ||
1154 | queue_init(&mmc_queue, true); | 1154 | queue_init(&mmc_queue, true); |
1155 | create_thread(mmc_thread, mmc_stack, | 1155 | create_thread(mmc_thread, mmc_stack, |
1156 | sizeof(mmc_stack), mmc_thread_name IF_PRIO(, PRIORITY_SYSTEM) | 1156 | sizeof(mmc_stack), 0, mmc_thread_name |
1157 | IF_COP(, CPU, false)); | 1157 | IF_PRIO(, PRIORITY_SYSTEM) |
1158 | IF_COP(, CPU)); | ||
1158 | tick_add_task(mmc_tick); | 1159 | tick_add_task(mmc_tick); |
1159 | initialized = true; | 1160 | initialized = true; |
1160 | } | 1161 | } |
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c index 851b5b9b20..25c590323a 100644 --- a/firmware/drivers/button.c +++ b/firmware/drivers/button.c | |||
@@ -46,7 +46,7 @@ | |||
46 | #define MAX_EVENT_AGE HZ | 46 | #define MAX_EVENT_AGE HZ |
47 | #endif | 47 | #endif |
48 | 48 | ||
49 | struct event_queue button_queue; | 49 | struct event_queue button_queue NOCACHEBSS_ATTR; |
50 | 50 | ||
51 | static long lastbtn; /* Last valid button status */ | 51 | static long lastbtn; /* Last valid button status */ |
52 | static long last_read; /* Last button status, for debouncing/filtering */ | 52 | static long last_read; /* Last button status, for debouncing/filtering */ |
@@ -300,7 +300,7 @@ int button_queue_count( void ) | |||
300 | 300 | ||
301 | long button_get(bool block) | 301 | long button_get(bool block) |
302 | { | 302 | { |
303 | struct event ev; | 303 | struct queue_event ev; |
304 | int pending_count = queue_count(&button_queue); | 304 | int pending_count = queue_count(&button_queue); |
305 | 305 | ||
306 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | 306 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ |
@@ -330,7 +330,7 @@ long button_get(bool block) | |||
330 | 330 | ||
331 | long button_get_w_tmo(int ticks) | 331 | long button_get_w_tmo(int ticks) |
332 | { | 332 | { |
333 | struct event ev; | 333 | struct queue_event ev; |
334 | 334 | ||
335 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | 335 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ |
336 | /* Be sure to keep boosted state. */ | 336 | /* Be sure to keep boosted state. */ |
diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c index a4fa7aa933..cfd4767032 100644 --- a/firmware/drivers/fat.c +++ b/firmware/drivers/fat.c | |||
@@ -197,7 +197,7 @@ struct fat_cache_entry | |||
197 | 197 | ||
198 | static char fat_cache_sectors[FAT_CACHE_SIZE][SECTOR_SIZE]; | 198 | static char fat_cache_sectors[FAT_CACHE_SIZE][SECTOR_SIZE]; |
199 | static struct fat_cache_entry fat_cache[FAT_CACHE_SIZE]; | 199 | static struct fat_cache_entry fat_cache[FAT_CACHE_SIZE]; |
200 | static struct mutex cache_mutex; | 200 | static struct mutex cache_mutex NOCACHEBSS_ATTR; |
201 | 201 | ||
202 | static long cluster2sec(IF_MV2(struct bpb* fat_bpb,) long cluster) | 202 | static long cluster2sec(IF_MV2(struct bpb* fat_bpb,) long cluster) |
203 | { | 203 | { |