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

@ -158,7 +158,7 @@ static int save_config_buffer( void )
#else #else
if(battery_level_safe() && (fat_startsector()!=0)) if(battery_level_safe() && (fat_startsector()!=0))
return !ata_write_sectors( 61, 1, rtc_config_block); ata_delayed_write( 61, rtc_config_block);
else else
return -1; return -1;

View file

@ -89,6 +89,9 @@ static char ata_stack[DEFAULT_STACK_SIZE];
static char ata_thread_name[] = "ata"; static char ata_thread_name[] = "ata";
static struct event_queue ata_queue; static struct event_queue ata_queue;
static bool initialized = false; static bool initialized = false;
static bool delayed_write = false;
static unsigned char delayed_sector[SECTOR_SIZE];
static int delayed_sector_num;
#ifdef USE_POWEROFF #ifdef USE_POWEROFF
static int ata_power_on(void); static int ata_power_on(void);
@ -215,6 +218,10 @@ int ata_read_sectors(unsigned long start,
ret = -1; ret = -1;
mutex_unlock(&ata_mtx); mutex_unlock(&ata_mtx);
if ( delayed_write )
ata_flush();
return ret; return ret;
} }
@ -279,9 +286,30 @@ int ata_write_sectors(unsigned long start,
i = wait_for_end_of_transfer(); i = wait_for_end_of_transfer();
mutex_unlock(&ata_mtx); mutex_unlock(&ata_mtx);
if ( delayed_write )
ata_flush();
return i; 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) static int check_registers(void)
{ {
if ( ATA_STATUS & STATUS_BSY ) if ( ATA_STATUS & STATUS_BSY )

View file

@ -39,11 +39,9 @@ extern bool ata_disk_is_active(void);
extern int ata_hard_reset(void); extern int ata_hard_reset(void);
extern int ata_soft_reset(void); extern int ata_soft_reset(void);
extern int ata_init(void); extern int ata_init(void);
extern int ata_read_sectors(unsigned long start, extern int ata_read_sectors(unsigned long start, int count, void* buf);
int count, extern int ata_write_sectors(unsigned long start, int count, void* buf);
void* buf); extern void ata_delayed_write(unsigned long sector, void* buf);
extern int ata_write_sectors(unsigned long start, extern void ata_flush(void);
int count,
void* buf);
#endif #endif

View file

@ -75,3 +75,8 @@ int ata_read_sectors(unsigned long start,
} }
return 1; return 1;
} }
void ata_delayed_write(unsigned long sector, void* buf)
{
ata_write_sectors(sector,1,buf);
}