1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Björn Stenberg 2002-08-15 12:42:37 +00:00
parent 5917e8157a
commit c9d98ca927
4 changed files with 38 additions and 7 deletions

View file

@ -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 )