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 ebe9602f01..0795eaf1f8 100644 --- a/firmware/drivers/ata.c +++ b/firmware/drivers/ata.c | |||
@@ -89,6 +89,9 @@ static char ata_stack[DEFAULT_STACK_SIZE]; | |||
89 | static char ata_thread_name[] = "ata"; | 89 | static char ata_thread_name[] = "ata"; |
90 | static struct event_queue ata_queue; | 90 | static struct event_queue ata_queue; |
91 | static bool initialized = false; | 91 | static bool initialized = false; |
92 | static bool delayed_write = false; | ||
93 | static unsigned char delayed_sector[SECTOR_SIZE]; | ||
94 | static int delayed_sector_num; | ||
92 | 95 | ||
93 | #ifdef USE_POWEROFF | 96 | #ifdef USE_POWEROFF |
94 | static int ata_power_on(void); | 97 | static int ata_power_on(void); |
@@ -215,6 +218,10 @@ int ata_read_sectors(unsigned long start, | |||
215 | ret = -1; | 218 | ret = -1; |
216 | 219 | ||
217 | mutex_unlock(&ata_mtx); | 220 | mutex_unlock(&ata_mtx); |
221 | |||
222 | if ( delayed_write ) | ||
223 | ata_flush(); | ||
224 | |||
218 | return ret; | 225 | return ret; |
219 | } | 226 | } |
220 | 227 | ||
@@ -279,9 +286,30 @@ int ata_write_sectors(unsigned long start, | |||
279 | i = wait_for_end_of_transfer(); | 286 | i = wait_for_end_of_transfer(); |
280 | 287 | ||
281 | mutex_unlock(&ata_mtx); | 288 | mutex_unlock(&ata_mtx); |
289 | |||
290 | if ( delayed_write ) | ||
291 | ata_flush(); | ||
292 | |||
282 | return i; | 293 | return i; |
283 | } | 294 | } |
284 | 295 | ||
296 | extern void ata_delayed_write(unsigned long sector, void* buf) | ||
297 | { | ||
298 | memcpy(delayed_sector, buf, SECTOR_SIZE); | ||
299 | delayed_sector_num = sector; | ||
300 | delayed_write = true; | ||
301 | } | ||
302 | |||
303 | extern void ata_flush(void) | ||
304 | { | ||
305 | if ( delayed_write ) { | ||
306 | delayed_write = false; | ||
307 | ata_write_sectors(delayed_sector_num, 1, delayed_sector); | ||
308 | } | ||
309 | } | ||
310 | |||
311 | |||
312 | |||
285 | static int check_registers(void) | 313 | static int check_registers(void) |
286 | { | 314 | { |
287 | if ( ATA_STATUS & STATUS_BSY ) | 315 | if ( ATA_STATUS & STATUS_BSY ) |