diff -Naur orig/apps/settings.c modified/apps/settings.c --- orig/apps/settings.c Thu Jul 25 17:55:21 2002 +++ modified/apps/settings.c Sun Jul 28 16:18:01 2002 @@ -28,10 +28,10 @@ #include "lcd.h" #include "mpeg.h" #include "string.h" +#include "ata.h" struct user_settings global_settings; -#ifdef HAVE_RTC /******************************************** @@ -113,6 +113,7 @@ rtc_config_block[3] = 0x0; /* config block version number */ } +#ifdef HAVE_RTC /* * save the config block buffer on the RTC RAM */ @@ -184,8 +185,60 @@ return 1; } +#else /* HAVE_RTC */ +/* + * save the config block buffer on the 61 Sector + */ +static int save_config_buffer( void ) +{ + int r; + + DEBUGF( "save_config_buffer()\n" ); + + /* update the checksum in the end of the block before saving */ + calculate_config_checksum(rtc_config_block + sizeof(rtc_config_block) - 2); + + r = ata_write_sectors( 61, 1, rtc_config_block); + return r; +} + +/* + * load the config block buffer from the RTC RAM + */ +static int load_config_buffer( void ) +{ + unsigned char addr = 0x14; + unsigned char cksum[2]; + unsigned char *p; + int r; + + DEBUGF( "load_config_buffer()\n" ); + + r = ata_read_sectors( 61, 1, rtc_config_block); + + /* calculate the checksum, check it and the header */ + calculate_config_checksum(cksum); + + if (rtc_config_block[0x0] == 'R' + && rtc_config_block[0x1] == 'o' + && rtc_config_block[0x2] == 'c' + && rtc_config_block[0x3] == 0x0 + && cksum[0] == rtc_config_block[0x2a] + && cksum[1] == rtc_config_block[0x2b]) { + DEBUGF( "load_config_buffer: header & checksum test ok\n" ); + return 0; /* header and checksum is valid */ + } + + /* if checksum is not valid, initialize the config buffer to all-unused */ + DEBUGF( "load_config_buffer: header & checksum test failed\n" ); + init_config_buffer(); + return 1; +} + + #endif /* HAVE_RTC */ + /* * persist all runtime user settings to disk or RTC RAM */ @@ -193,7 +246,7 @@ { DEBUGF( "settings_save()\n" ); -#ifdef HAVE_RTC +//#ifdef HAVE_RTC /* update the config block buffer with current settings and save the block in the RTC */ rtc_config_block[0x4] = (unsigned char)global_settings.volume; @@ -223,7 +276,7 @@ memcpy(&rtc_config_block[0x28], &global_settings.total_boots, 2); save_config_buffer(); -#endif /* HAVE_RTC */ +//#endif /* HAVE_RTC */ return 1; } @@ -233,16 +286,16 @@ */ void settings_load(void) { -#ifdef HAVE_RTC +//#ifdef HAVE_RTC unsigned char c; -#endif +//#endif DEBUGF( "reload_all_settings()\n" ); /* populate settings with default values */ settings_reset(); -#ifdef HAVE_RTC +//#ifdef HAVE_RTC /* load the buffer from the RTC (resets it to all-unused if the block is invalid) and decode the settings which are set in the block */ if (!load_config_buffer()) { @@ -290,7 +343,7 @@ memcpy(&global_settings.total_boots, &rtc_config_block[0x28], 2); } -#endif /* HAVE_RTC */ +//#endif /* HAVE_RTC */ } /* @@ -313,7 +366,7 @@ global_settings.wps_display = DEFAULT_WPS_DISPLAY; global_settings.mp3filter = true; global_settings.sort_case = false; - global_settings.playlist_shuffle = false; + global_settings.playlist_shuffle = true; global_settings.total_boots = 0; global_settings.total_uptime = 0; global_settings.scroll_speed = 8; diff -Naur orig/firmware/drivers/ata.c modified/firmware/drivers/ata.c --- orig/firmware/drivers/ata.c Sun Jul 28 00:44:52 2002 +++ modified/firmware/drivers/ata.c Sun Jul 28 16:17:45 2002 @@ -174,7 +174,7 @@ return ret; } -#ifdef DISK_WRITE +//#ifdef DISK_WRITE int ata_write_sectors(unsigned long start, unsigned char count, void* buf) @@ -230,7 +230,7 @@ mutex_unlock(&ata_mtx); return i; } -#endif +//#endif static int check_registers(void) {