diff options
Diffstat (limited to 'firmware/drivers/ata.c')
-rw-r--r-- | firmware/drivers/ata.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c index 2dca17512e..87dacc3ed0 100644 --- a/firmware/drivers/ata.c +++ b/firmware/drivers/ata.c | |||
@@ -59,6 +59,7 @@ | |||
59 | #define CMD_SECURITY_FREEZE_LOCK 0xF5 | 59 | #define CMD_SECURITY_FREEZE_LOCK 0xF5 |
60 | 60 | ||
61 | #define Q_SLEEP 0 | 61 | #define Q_SLEEP 0 |
62 | #define Q_CLOSE 1 | ||
62 | 63 | ||
63 | #define READ_TIMEOUT 5*HZ | 64 | #define READ_TIMEOUT 5*HZ |
64 | 65 | ||
@@ -66,6 +67,10 @@ | |||
66 | #define ATA_POWER_OFF_TIMEOUT 2*HZ | 67 | #define ATA_POWER_OFF_TIMEOUT 2*HZ |
67 | #endif | 68 | #endif |
68 | 69 | ||
70 | #ifdef ATA_DRIVER_CLOSE | ||
71 | static struct thread_entry *ata_thread_p = NULL; | ||
72 | #endif | ||
73 | |||
69 | #if defined(MAX_PHYS_SECTOR_SIZE) && MEM == 64 | 74 | #if defined(MAX_PHYS_SECTOR_SIZE) && MEM == 64 |
70 | /* Hack - what's the deal with 5g? */ | 75 | /* Hack - what's the deal with 5g? */ |
71 | struct ata_lock | 76 | struct ata_lock |
@@ -941,6 +946,11 @@ static void ata_thread(void) | |||
941 | call_ata_idle_notifys(false); | 946 | call_ata_idle_notifys(false); |
942 | last_disk_activity = current_tick - sleep_timeout + (HZ/2); | 947 | last_disk_activity = current_tick - sleep_timeout + (HZ/2); |
943 | break; | 948 | break; |
949 | |||
950 | #ifdef ATA_DRIVER_CLOSE | ||
951 | case Q_CLOSE: | ||
952 | return; | ||
953 | #endif | ||
944 | } | 954 | } |
945 | } | 955 | } |
946 | } | 956 | } |
@@ -1307,6 +1317,9 @@ int ata_init(void) | |||
1307 | mutex_lock(&ata_mtx); /* Balance unlock below */ | 1317 | mutex_lock(&ata_mtx); /* Balance unlock below */ |
1308 | 1318 | ||
1309 | last_disk_activity = current_tick; | 1319 | last_disk_activity = current_tick; |
1320 | #ifdef ATA_DRIVER_CLOSE | ||
1321 | ata_thread_p = | ||
1322 | #endif | ||
1310 | create_thread(ata_thread, ata_stack, | 1323 | create_thread(ata_thread, ata_stack, |
1311 | sizeof(ata_stack), 0, ata_thread_name | 1324 | sizeof(ata_stack), 0, ata_thread_name |
1312 | IF_PRIO(, PRIORITY_USER_INTERFACE) | 1325 | IF_PRIO(, PRIORITY_USER_INTERFACE) |
@@ -1322,6 +1335,21 @@ int ata_init(void) | |||
1322 | return rc; | 1335 | return rc; |
1323 | } | 1336 | } |
1324 | 1337 | ||
1338 | #ifdef ATA_DRIVER_CLOSE | ||
1339 | void ata_close(void) | ||
1340 | { | ||
1341 | struct thread_entry *thread = ata_thread_p; | ||
1342 | |||
1343 | if (thread == NULL) | ||
1344 | return; | ||
1345 | |||
1346 | ata_thread_p = NULL; | ||
1347 | |||
1348 | queue_post(&ata_queue, Q_CLOSE, 0); | ||
1349 | thread_wait(thread); | ||
1350 | } | ||
1351 | #endif /* ATA_DRIVER_CLOSE */ | ||
1352 | |||
1325 | #if (CONFIG_LED == LED_REAL) | 1353 | #if (CONFIG_LED == LED_REAL) |
1326 | void ata_set_led_enabled(bool enabled) | 1354 | void ata_set_led_enabled(bool enabled) |
1327 | { | 1355 | { |