From c9d98ca9271d1e2045a1ca21215701f3fb2aaa37 Mon Sep 17 00:00:00 2001 From: Björn Stenberg Date: Thu, 15 Aug 2002 12:42:37 +0000 Subject: Added delayed write for settings. Doesn't write until someone else accesses the disk. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1762 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/ata.c | 28 ++++++++++++++++++++++++++++ firmware/drivers/ata.h | 10 ++++------ 2 files changed, 32 insertions(+), 6 deletions(-) (limited to 'firmware/drivers') 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]; static char ata_thread_name[] = "ata"; static struct event_queue ata_queue; static bool initialized = false; +static bool delayed_write = false; +static unsigned char delayed_sector[SECTOR_SIZE]; +static int delayed_sector_num; #ifdef USE_POWEROFF static int ata_power_on(void); @@ -215,6 +218,10 @@ int ata_read_sectors(unsigned long start, ret = -1; mutex_unlock(&ata_mtx); + + if ( delayed_write ) + ata_flush(); + return ret; } @@ -279,9 +286,30 @@ int ata_write_sectors(unsigned long start, i = wait_for_end_of_transfer(); mutex_unlock(&ata_mtx); + + if ( delayed_write ) + ata_flush(); + return i; } +extern void ata_delayed_write(unsigned long sector, void* buf) +{ + memcpy(delayed_sector, buf, SECTOR_SIZE); + delayed_sector_num = sector; + delayed_write = true; +} + +extern void ata_flush(void) +{ + if ( delayed_write ) { + delayed_write = false; + ata_write_sectors(delayed_sector_num, 1, delayed_sector); + } +} + + + static int check_registers(void) { if ( ATA_STATUS & STATUS_BSY ) diff --git a/firmware/drivers/ata.h b/firmware/drivers/ata.h index 4209fdcd1e..244ec63777 100644 --- a/firmware/drivers/ata.h +++ b/firmware/drivers/ata.h @@ -39,11 +39,9 @@ extern bool ata_disk_is_active(void); extern int ata_hard_reset(void); extern int ata_soft_reset(void); extern int ata_init(void); -extern int ata_read_sectors(unsigned long start, - int count, - void* buf); -extern int ata_write_sectors(unsigned long start, - int count, - void* buf); +extern int ata_read_sectors(unsigned long start, int count, void* buf); +extern int ata_write_sectors(unsigned long start, int count, void* buf); +extern void ata_delayed_write(unsigned long sector, void* buf); +extern void ata_flush(void); #endif -- cgit v1.2.3