The config sector number is now calculated from the lowest partition start sector. Needed for disks with sectors_per_track < 63, e.g. flash cards.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5124 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jens Arnold 2004-09-28 18:09:10 +00:00
parent 90cbd3b06d
commit c12e87d881
3 changed files with 39 additions and 6 deletions

View File

@ -79,6 +79,7 @@ void init(void)
font_init();
show_logo();
settings_reset();
settings_calc_config_sector();
settings_load(SETTINGS_ALL);
settings_apply();
sleep(HZ/2);
@ -224,11 +225,12 @@ void init(void)
}
}
settings_calc_config_sector();
settings_load(SETTINGS_ALL);
settings_apply();
status_init();
playlist_init();
playlist_init();
tree_init();
/* No buffer allocation (see buffer.c) may take place after the call to

View File

@ -82,6 +82,7 @@ const char rec_base_directory[] = REC_BASE_DIR;
#endif
long lasttime = 0;
static int config_sector = 0; /* mark uninitialized */
static unsigned char config_block[CONFIG_BLOCK_SIZE];
@ -481,8 +482,8 @@ static int save_config_buffer( void )
#endif
if (fat_startsector() != 0)
ata_delayed_write( 61, config_block);
if (config_sector != 0)
ata_delayed_write( config_sector, config_block);
else
return -1;
@ -502,8 +503,8 @@ static int load_config_buffer(int which)
if (which & SETTINGS_HD)
{
if (fat_startsector() != 0) {
ata_read_sectors( 61, 1, config_block);
if (config_sector != 0) {
ata_read_sectors( config_sector, 1, config_block);
/* calculate the checksum, check it and the header */
chksum = calculate_config_checksum(config_block);
@ -601,6 +602,35 @@ static void save_bit_table(const struct bit_entry* p_table, int count, int bitst
curr_bit); /* = position after last element */
}
/*
* figure out the config sector from the partition table and the
* mounted file system
*/
void settings_calc_config_sector(void)
{
#ifdef SIMULATOR
config_sector = 61;
#else
int i, partition_start;
int sector = 0;
if (fat_startsector != 0) /* There is a partition table */
{
sector = 61;
for (i = 0; i < 4; i++)
{
partition_start = disk_partinfo(i)->start;
if (partition_start != 0 && (partition_start - 2) < sector)
sector = partition_start - 2;
}
if (sector < 0)
sector = 0;
}
splash(HZ, true, "CfgSec: %d", sector);
config_sector = sector;
#endif
}
/*
* persist all runtime user settings to disk or RTC RAM

View File

@ -281,6 +281,7 @@ struct opt_items {
/* prototypes */
void settings_calc_config_sector(void);
int settings_save(void);
void settings_load(int which);
void settings_reset(void);