summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafaël Carré <rafael.carre@gmail.com>2012-01-04 07:42:03 +0000
committerRafaël Carré <rafael.carre@gmail.com>2012-01-04 07:42:03 +0000
commit127af53c5b2a8b8672b6c8ad089d4d08d6fc5816 (patch)
tree44b8c2761410b36d741055a15882908ebca7691d
parent9274cf3b6ce2cb004b11a92d8565d42a837faaa9 (diff)
downloadrockbox-127af53c5b2a8b8672b6c8ad089d4d08d6fc5816.tar.gz
rockbox-127af53c5b2a8b8672b6c8ad089d4d08d6fc5816.zip
debug_menu.c: cleanup
use c99 for() cosmetics remove the_menu_item struct -> merge with only use merge variables declaration/assignement git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31575 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/debug_menu.c92
1 files changed, 31 insertions, 61 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index cc76d24d18..0435f322de 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -1531,7 +1531,6 @@ static int disk_callback(int btn, struct gui_synclist *lists)
1531#else /* No SD, MMC or ATA */ 1531#else /* No SD, MMC or ATA */
1532static int disk_callback(int btn, struct gui_synclist *lists) 1532static int disk_callback(int btn, struct gui_synclist *lists)
1533{ 1533{
1534 (void)btn;
1535 (void)lists; 1534 (void)lists;
1536 struct storage_info info; 1535 struct storage_info info;
1537 storage_get_info(0,&info); 1536 storage_get_info(0,&info);
@@ -1587,7 +1586,7 @@ static bool dbg_disk_info(void)
1587#ifdef HAVE_DIRCACHE 1586#ifdef HAVE_DIRCACHE
1588static int dircache_callback(int btn, struct gui_synclist *lists) 1587static int dircache_callback(int btn, struct gui_synclist *lists)
1589{ 1588{
1590 (void)btn; (void)lists; 1589 (void)lists;
1591 simplelist_set_line_count(0); 1590 simplelist_set_line_count(0);
1592 simplelist_addline(SIMPLELIST_ADD_LINE, "Cache initialized: %s", 1591 simplelist_addline(SIMPLELIST_ADD_LINE, "Cache initialized: %s",
1593 dircache_is_enabled() ? "Yes" : "No"); 1592 dircache_is_enabled() ? "Yes" : "No");
@@ -1756,9 +1755,7 @@ static bool dbg_save_roms(void)
1756#elif defined(CPU_PP) && !(CONFIG_STORAGE & STORAGE_SD) 1755#elif defined(CPU_PP) && !(CONFIG_STORAGE & STORAGE_SD)
1757static bool dbg_save_roms(void) 1756static bool dbg_save_roms(void)
1758{ 1757{
1759 int fd; 1758 int fd = creat("/internal_rom_000000-0FFFFF.bin", 0666);
1760
1761 fd = creat("/internal_rom_000000-0FFFFF.bin", 0666);
1762 if(fd >= 0) 1759 if(fd >= 0)
1763 { 1760 {
1764 write(fd, (void *)0x20000000, FLASH_SIZE); 1761 write(fd, (void *)0x20000000, FLASH_SIZE);
@@ -1770,9 +1767,7 @@ static bool dbg_save_roms(void)
1770#elif CONFIG_CPU == IMX31L 1767#elif CONFIG_CPU == IMX31L
1771static bool dbg_save_roms(void) 1768static bool dbg_save_roms(void)
1772{ 1769{
1773 int fd; 1770 int fd = creat("/flash_rom_A0000000-A01FFFFF.bin", 0666);
1774
1775 fd = creat("/flash_rom_A0000000-A01FFFFF.bin", 0666);
1776 if (fd >= 0) 1771 if (fd >= 0)
1777 { 1772 {
1778 write(fd, (void*)0xa0000000, FLASH_SIZE); 1773 write(fd, (void*)0xa0000000, FLASH_SIZE);
@@ -1784,9 +1779,7 @@ static bool dbg_save_roms(void)
1784#elif defined(CPU_TCC780X) 1779#elif defined(CPU_TCC780X)
1785static bool dbg_save_roms(void) 1780static bool dbg_save_roms(void)
1786{ 1781{
1787 int fd; 1782 int fd = creat("/eeprom_E0000000-E0001FFF.bin", 0666);
1788
1789 fd = creat("/eeprom_E0000000-E0001FFF.bin", 0666);
1790 if (fd >= 0) 1783 if (fd >= 0)
1791 { 1784 {
1792 write(fd, (void*)0xe0000000, 0x2000); 1785 write(fd, (void*)0xe0000000, 0x2000);
@@ -1854,10 +1847,9 @@ static int radio_callback(int btn, struct gui_synclist *lists)
1854 IF_TUNER_TYPE(SI4700) 1847 IF_TUNER_TYPE(SI4700)
1855 { 1848 {
1856 struct si4700_dbg_info nfo; 1849 struct si4700_dbg_info nfo;
1857 int i;
1858 si4700_dbg_info(&nfo); 1850 si4700_dbg_info(&nfo);
1859 simplelist_addline(SIMPLELIST_ADD_LINE, "SI4700 regs:"); 1851 simplelist_addline(SIMPLELIST_ADD_LINE, "SI4700 regs:");
1860 for (i = 0; i < 16; i += 4) { 1852 for (int i = 0; i < 16; i += 4) {
1861 simplelist_addline(SIMPLELIST_ADD_LINE,"%02X: %04X %04X %04X %04X", 1853 simplelist_addline(SIMPLELIST_ADD_LINE,"%02X: %04X %04X %04X %04X",
1862 i, nfo.regs[i], nfo.regs[i+1], nfo.regs[i+2], nfo.regs[i+3]); 1854 i, nfo.regs[i], nfo.regs[i+1], nfo.regs[i+2], nfo.regs[i+3]);
1863 } 1855 }
@@ -1876,10 +1868,9 @@ static int radio_callback(int btn, struct gui_synclist *lists)
1876 IF_TUNER_TYPE(RDA5802) 1868 IF_TUNER_TYPE(RDA5802)
1877 { 1869 {
1878 struct rda5802_dbg_info nfo; 1870 struct rda5802_dbg_info nfo;
1879 int i;
1880 rda5802_dbg_info(&nfo); 1871 rda5802_dbg_info(&nfo);
1881 simplelist_addline(SIMPLELIST_ADD_LINE, "RDA5802 regs:"); 1872 simplelist_addline(SIMPLELIST_ADD_LINE, "RDA5802 regs:");
1882 for (i = 0; i < 16; i += 4) { 1873 for (int i = 0; i < 16; i += 4) {
1883 simplelist_addline(SIMPLELIST_ADD_LINE,"%02X: %04X %04X %04X %04X", 1874 simplelist_addline(SIMPLELIST_ADD_LINE,"%02X: %04X %04X %04X %04X",
1884 i, nfo.regs[i], nfo.regs[i+1], nfo.regs[i+2], nfo.regs[i+3]); 1875 i, nfo.regs[i], nfo.regs[i+1], nfo.regs[i+2], nfo.regs[i+3]);
1885 } 1876 }
@@ -1912,8 +1903,7 @@ extern bool do_screendump_instead_of_usb;
1912static bool dbg_screendump(void) 1903static bool dbg_screendump(void)
1913{ 1904{
1914 do_screendump_instead_of_usb = !do_screendump_instead_of_usb; 1905 do_screendump_instead_of_usb = !do_screendump_instead_of_usb;
1915 splashf(HZ, "Screendump %s", 1906 splashf(HZ, "Screendump %sabled", do_screendump_instead_of_usb?"en":"dis");
1916 do_screendump_instead_of_usb?"enabled":"disabled");
1917 return false; 1907 return false;
1918} 1908}
1919#endif /* HAVE_LCD_BITMAP */ 1909#endif /* HAVE_LCD_BITMAP */
@@ -1923,8 +1913,7 @@ extern bool write_metadata_log;
1923static bool dbg_metadatalog(void) 1913static bool dbg_metadatalog(void)
1924{ 1914{
1925 write_metadata_log = !write_metadata_log; 1915 write_metadata_log = !write_metadata_log;
1926 splashf(HZ, "Metadata log %s", 1916 splashf(HZ, "Metadata log %sabled", write_metadata_log ? "en" : "dis");
1927 write_metadata_log?"enabled":"disabled");
1928 return false; 1917 return false;
1929} 1918}
1930 1919
@@ -1948,23 +1937,18 @@ static bool dbg_set_memory_guard(void)
1948#if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS) 1937#if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS)
1949static bool dbg_write_eeprom(void) 1938static bool dbg_write_eeprom(void)
1950{ 1939{
1951 int fd; 1940 int fd = open("/internal_eeprom.bin", O_RDONLY);
1952 int rc;
1953 int old_irq_level;
1954 char buf[EEPROM_SIZE];
1955 int err;
1956
1957 fd = open("/internal_eeprom.bin", O_RDONLY);
1958 1941
1959 if (fd >= 0) 1942 if (fd >= 0)
1960 { 1943 {
1961 rc = read(fd, buf, EEPROM_SIZE); 1944 char buf[EEPROM_SIZE];
1945 int rc = read(fd, buf, EEPROM_SIZE);
1962 1946
1963 if(rc == EEPROM_SIZE) 1947 if(rc == EEPROM_SIZE)
1964 { 1948 {
1965 old_irq_level = disable_irq_save(); 1949 int old_irq_level = disable_irq_save();
1966 1950
1967 err = eeprom_24cxx_write(0, buf, sizeof buf); 1951 int err = eeprom_24cxx_write(0, buf, sizeof buf);
1968 if (err) 1952 if (err)
1969 splashf(HZ*3, "Eeprom write failure (%d)", err); 1953 splashf(HZ*3, "Eeprom write failure (%d)", err);
1970 else 1954 else
@@ -1989,17 +1973,14 @@ static bool dbg_write_eeprom(void)
1989#ifdef CPU_BOOST_LOGGING 1973#ifdef CPU_BOOST_LOGGING
1990static bool cpu_boost_log(void) 1974static bool cpu_boost_log(void)
1991{ 1975{
1992 int i = 0,j=0;
1993 int count = cpu_boost_log_getcount(); 1976 int count = cpu_boost_log_getcount();
1994 int lines = LCD_HEIGHT/SYSFONT_HEIGHT; 1977 char *str = cpu_boost_log_getlog_first();
1995 char *str;
1996 bool done; 1978 bool done;
1997 lcd_setfont(FONT_SYSFIXED); 1979 lcd_setfont(FONT_SYSFIXED);
1998 str = cpu_boost_log_getlog_first(); 1980 for (int i = 0; i < count ;)
1999 while (i < count)
2000 { 1981 {
2001 lcd_clear_display(); 1982 lcd_clear_display();
2002 for(j=0; j<lines; j++,i++) 1983 for(int j=0; j<LCD_HEIGHT/SYSFONT_HEIGHT; j++,i++)
2003 { 1984 {
2004 if (!str) 1985 if (!str)
2005 str = cpu_boost_log_getlog_next(); 1986 str = cpu_boost_log_getlog_next();
@@ -2048,8 +2029,6 @@ extern unsigned int wheel_velocity;
2048 2029
2049static bool dbg_scrollwheel(void) 2030static bool dbg_scrollwheel(void)
2050{ 2031{
2051 unsigned int speed;
2052
2053 lcd_setfont(FONT_SYSFIXED); 2032 lcd_setfont(FONT_SYSFIXED);
2054 2033
2055 while (1) 2034 while (1)
@@ -2068,8 +2047,8 @@ static bool dbg_scrollwheel(void)
2068 lcd_putsf(0, 5, "velo [deg/s]: %4d", (int)wheel_velocity); 2047 lcd_putsf(0, 5, "velo [deg/s]: %4d", (int)wheel_velocity);
2069 2048
2070 /* show effective accelerated scrollspeed */ 2049 /* show effective accelerated scrollspeed */
2071 speed = button_apply_acceleration( (1<<31)|(1<<24)|wheel_velocity); 2050 lcd_putsf(0, 6, "accel. speed: %4d",
2072 lcd_putsf(0, 6, "accel. speed: %4d", speed); 2051 button_apply_acceleration( (1<<31)|(1<<24)|wheel_velocity);
2073 2052
2074 lcd_update(); 2053 lcd_update();
2075 } 2054 }
@@ -2078,25 +2057,18 @@ static bool dbg_scrollwheel(void)
2078} 2057}
2079#endif 2058#endif
2080 2059
2081#if defined (HAVE_USBSTACK) 2060#ifdef HAVE_USBSTACK
2082
2083#if defined(ROCKBOX_HAS_LOGF) && defined(USB_ENABLE_SERIAL) 2061#if defined(ROCKBOX_HAS_LOGF) && defined(USB_ENABLE_SERIAL)
2084static bool toggle_usb_core_driver(int driver, char *msg) 2062static bool toggle_usb_serial(void)
2085{ 2063{
2086 bool enabled = !usb_core_driver_enabled(driver); 2064 bool enabled = !usb_core_driver_enabled(USB_DRIVER_SERIAL);
2087 2065
2088 usb_core_enable_driver(driver,enabled); 2066 usb_core_enable_driver(USB_DRIVER_SERIAL, enabled);
2089 splashf(HZ, "%s %s", msg, enabled?"enabled":"disabled"); 2067 splashf(HZ, "USB Serial %sabled", enabled ? "en" : "dis");
2090 2068
2091 return false; 2069 return false;
2092} 2070}
2093
2094static bool toggle_usb_serial(void)
2095{
2096 return toggle_usb_core_driver(USB_DRIVER_SERIAL,"USB Serial");
2097}
2098#endif 2071#endif
2099
2100#endif 2072#endif
2101 2073
2102#if CONFIG_USBOTG == USBOTG_ISP1583 2074#if CONFIG_USBOTG == USBOTG_ISP1583
@@ -2153,11 +2125,10 @@ static bool dbg_pic(void)
2153 2125
2154 2126
2155/****** The menu *********/ 2127/****** The menu *********/
2156struct the_menu_item { 2128static const struct {
2157 unsigned char *desc; /* string or ID */ 2129 unsigned char *desc; /* string or ID */
2158 bool (*function) (void); /* return true if USB was connected */ 2130 bool (*function) (void); /* return true if USB was connected */
2159}; 2131} menuitems[] = {
2160static const struct the_menu_item menuitems[] = {
2161#if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || \ 2132#if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || \
2162 (defined(CPU_PP) && !(CONFIG_STORAGE & STORAGE_SD)) || \ 2133 (defined(CPU_PP) && !(CONFIG_STORAGE & STORAGE_SD)) || \
2163 CONFIG_CPU == IMX31L || defined(CPU_TCC780X) 2134 CONFIG_CPU == IMX31L || defined(CPU_TCC780X)
@@ -2259,7 +2230,8 @@ static const struct the_menu_item menuitems[] = {
2259 && !defined(IPOD_MINI) && !defined(SIMULATOR)) 2230 && !defined(IPOD_MINI) && !defined(SIMULATOR))
2260 {"Debug scrollwheel", dbg_scrollwheel }, 2231 {"Debug scrollwheel", dbg_scrollwheel },
2261#endif 2232#endif
2262 }; 2233};
2234
2263static int menu_action_callback(int btn, struct gui_synclist *lists) 2235static int menu_action_callback(int btn, struct gui_synclist *lists)
2264{ 2236{
2265 int selection = gui_synclist_get_sel_pos(lists); 2237 int selection = gui_synclist_get_sel_pos(lists);
@@ -2282,7 +2254,7 @@ static int menu_action_callback(int btn, struct gui_synclist *lists)
2282 return btn; 2254 return btn;
2283} 2255}
2284 2256
2285static const char* dbg_menu_getname(int item, void * data, 2257static const char* menu_get_name(int item, void * data,
2286 char *buffer, size_t buffer_len) 2258 char *buffer, size_t buffer_len)
2287{ 2259{
2288 (void)data; (void)buffer; (void)buffer_len; 2260 (void)data; (void)buffer; (void)buffer_len;
@@ -2295,15 +2267,13 @@ bool debug_menu(void)
2295 2267
2296 simplelist_info_init(&info, "Debug Menu", ARRAYLEN(menuitems), NULL); 2268 simplelist_info_init(&info, "Debug Menu", ARRAYLEN(menuitems), NULL);
2297 info.action_callback = menu_action_callback; 2269 info.action_callback = menu_action_callback;
2298 info.get_name = dbg_menu_getname; 2270 info.get_name = menu_get_name;
2299 return simplelist_show_list(&info); 2271 return simplelist_show_list(&info);
2300} 2272}
2301 2273
2302bool run_debug_screen(char* screen) 2274bool run_debug_screen(char* screen)
2303{ 2275{
2304 unsigned i; 2276 for (unsigned i=0; i<ARRAYLEN(menuitems); i++)
2305 for (i=0; i<ARRAYLEN(menuitems); i++)
2306 {
2307 if (!strcmp(screen, menuitems[i].desc)) 2277 if (!strcmp(screen, menuitems[i].desc))
2308 { 2278 {
2309 FOR_NB_SCREENS(j) 2279 FOR_NB_SCREENS(j)
@@ -2313,6 +2283,6 @@ bool run_debug_screen(char* screen)
2313 viewportmanager_theme_undo(j, false); 2283 viewportmanager_theme_undo(j, false);
2314 return true; 2284 return true;
2315 } 2285 }
2316 } 2286
2317 return false; 2287 return false;
2318} 2288}