summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2007-07-15 18:25:39 +0000
committerMichael Sevakis <jethead71@rockbox.org>2007-07-15 18:25:39 +0000
commita16035d3dd0679d12d6c77231a50523ba3f6295a (patch)
tree8f952b01a012f1f97225bd57b9287a065c828bf4 /apps
parentd4b484663c0c1ce7be30939f10edfbbd246d8f55 (diff)
downloadrockbox-a16035d3dd0679d12d6c77231a50523ba3f6295a.tar.gz
rockbox-a16035d3dd0679d12d6c77231a50523ba3f6295a.zip
Hopefully get the rest of the quirks out of the debug menus and save some size too.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13908 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/debug_menu.c359
1 files changed, 215 insertions, 144 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index 736c2054d1..dfd8ef3b2f 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -91,7 +91,31 @@
91#if defined(HAVE_DIRCACHE) || defined(HAVE_TAGCACHE) || CONFIG_TUNER 91#if defined(HAVE_DIRCACHE) || defined(HAVE_TAGCACHE) || CONFIG_TUNER
92#define MAX_DEBUG_MESSAGES 16 92#define MAX_DEBUG_MESSAGES 16
93#define DEBUG_MSG_LEN 32 93#define DEBUG_MSG_LEN 32
94int debug_listmessage_lines;
94char debug_list_messages[MAX_DEBUG_MESSAGES][DEBUG_MSG_LEN]; 95char debug_list_messages[MAX_DEBUG_MESSAGES][DEBUG_MSG_LEN];
96static void dbg_listmessage_setlines(int lines)
97{
98 if (lines < 0)
99 lines = 0;
100 else if (lines > MAX_DEBUG_MESSAGES)
101 lines = MAX_DEBUG_MESSAGES;
102 debug_listmessage_lines = lines;
103}
104static int dbg_listmessage_getlines(void)
105{
106 return debug_listmessage_lines;
107}
108static void dbg_listmessage_addline(const char *fmt, ...)
109{
110 va_list ap;
111
112 if (debug_listmessage_lines >= MAX_DEBUG_MESSAGES)
113 return;
114
115 va_start(ap, fmt);
116 vsnprintf(debug_list_messages[debug_listmessage_lines++], DEBUG_MSG_LEN, fmt, ap);
117 va_end(ap);
118}
95static char* dbg_listmessage_getname(int item, void * data, char *buffer) 119static char* dbg_listmessage_getname(int item, void * data, char *buffer)
96{ 120{
97 (void)buffer; (void)data; 121 (void)buffer; (void)data;
@@ -99,33 +123,48 @@ static char* dbg_listmessage_getname(int item, void * data, char *buffer)
99} 123}
100#endif 124#endif
101 125
126struct action_callback_info;
127struct action_callback_info
128{
129 char *title;
130 int count;
131 int selection_size;
132 int (*action_callback)(int btn, struct action_callback_info *info);
133 char* (*dbg_getname)(int item, void * data, char *buffer);
134 intptr_t cbdata; /* extra callback data (pointer, int, whatever) */
135 struct gui_synclist *lists; /* passed back to the callback */
136};
137
102static char* dbg_menu_getname(int item, void * data, char *buffer); 138static char* dbg_menu_getname(int item, void * data, char *buffer);
103static bool dbg_list(char *title, int count, int selection_size, 139static bool dbg_list(struct action_callback_info *info)
104 int (*action_callback)(int btn, struct gui_synclist *lists),
105 char* (*dbg_getname)(int item, void * data, char *buffer))
106{ 140{
107 struct gui_synclist lists; 141 struct gui_synclist lists;
108 int action; 142 int action;
143
144 info->lists = &lists;
109 145
110 gui_synclist_init(&lists, dbg_getname, NULL, false, selection_size); 146 gui_synclist_init(&lists, info->dbg_getname, NULL, false,
111 gui_synclist_set_title(&lists, title, NOICON); 147 info->selection_size);
148 gui_synclist_set_title(&lists, info->title, NOICON);
112 gui_synclist_set_icon_callback(&lists, NULL); 149 gui_synclist_set_icon_callback(&lists, NULL);
113 gui_synclist_set_nb_items(&lists, count*selection_size); 150 gui_synclist_set_nb_items(&lists, info->count*info->selection_size);
114 if (dbg_getname != dbg_menu_getname) 151 if (info->dbg_getname != dbg_menu_getname)
115 gui_synclist_hide_selection_marker(&lists, true); 152 gui_synclist_hide_selection_marker(&lists, true);
116 action_signalscreenchange(); 153 action_signalscreenchange();
117 154
118 if (action_callback) 155 if (info->action_callback)
119 action_callback(ACTION_REDRAW, &lists); 156 info->action_callback(ACTION_REDRAW, info);
157
120 gui_synclist_draw(&lists); 158 gui_synclist_draw(&lists);
159
121 while(1) 160 while(1)
122 { 161 {
123 gui_syncstatusbar_draw(&statusbars, true); 162 gui_syncstatusbar_draw(&statusbars, true);
124 action = get_action(CONTEXT_STD, HZ/5); 163 action = get_action(CONTEXT_STD, HZ/5);
125 if (gui_synclist_do_button(&lists, action, LIST_WRAP_UNLESS_HELD)) 164 if (gui_synclist_do_button(&lists, action, LIST_WRAP_UNLESS_HELD))
126 continue; 165 continue;
127 if (action_callback) 166 if (info->action_callback)
128 action = action_callback(action, &lists); 167 action = info->action_callback(action, info);
129 if (action == ACTION_STD_CANCEL) 168 if (action == ACTION_STD_CANCEL)
130 break; 169 break;
131 else if (action == ACTION_REDRAW) 170 else if (action == ACTION_REDRAW)
@@ -193,24 +232,29 @@ static char* threads_getname(int selected_item, void * data, char *buffer)
193#endif 232#endif
194 return buffer; 233 return buffer;
195} 234}
196static int dbg_threads_action_callback(int action, struct gui_synclist *lists) 235static int dbg_threads_action_callback(int action, struct action_callback_info *info)
197{ 236{
198#ifdef ROCKBOX_HAS_LOGF 237#ifdef ROCKBOX_HAS_LOGF
199 if (action == ACTION_STD_OK) 238 if (action == ACTION_STD_OK)
200 { 239 {
201 struct thread_entry *thread = &threads[gui_synclist_get_sel_pos(lists)]; 240 struct thread_entry *thread = &threads[gui_synclist_get_sel_pos(info->lists)];
202 if (thread->name != NULL) 241 if (thread->name != NULL)
203 remove_thread(thread); 242 remove_thread(thread);
204 } 243 }
205#endif 244#endif
206 gui_synclist_draw(lists); 245 gui_synclist_draw(info->lists);
207 return action; 246 return action;
208} 247}
209/* Test code!!! */ 248/* Test code!!! */
210static bool dbg_os(void) 249static bool dbg_os(void)
211{ 250{
212 return dbg_list(IF_COP2("Core and ") "Stack usage:", MAXTHREADS, 1, 251 struct action_callback_info info;
213 dbg_threads_action_callback, threads_getname); 252 info.title = IF_COP2("Core and ") "Stack usage:";
253 info.count = MAXTHREADS;
254 info.selection_size = 1;
255 info.action_callback = dbg_threads_action_callback;
256 info.dbg_getname = threads_getname;
257 return dbg_list(&info);
214} 258}
215#endif /* !SIMULATOR */ 259#endif /* !SIMULATOR */
216 260
@@ -729,8 +773,14 @@ static char* dbg_partitions_getname(int selected_item, void * data, char *buffer
729 773
730bool dbg_partitions(void) 774bool dbg_partitions(void)
731{ 775{
732 return dbg_list("Partition Info", 4, 2, 776 struct action_callback_info info;
733 NULL, dbg_partitions_getname); 777 info.title = "Partition Info";
778 info.count = 4;
779 info.selection_size = 2;
780 info.action_callback = NULL;
781 info.dbg_getname = dbg_partitions_getname;
782 dbg_list(&info);
783 return false;
734} 784}
735#endif 785#endif
736 786
@@ -1617,139 +1667,143 @@ static bool view_battery(void)
1617#else 1667#else
1618#define CARDTYPE "microSD" 1668#define CARDTYPE "microSD"
1619#endif 1669#endif
1620static int cardinfo_lines = 0, 1670static int cardinfo_callback(int btn, struct action_callback_info *info)
1621 current_card = 1; /* the first call changes this card to 0 */
1622static int cardinfo_callback(int btn, struct gui_synclist *lists)
1623{ 1671{
1624 tCardInfo *card; 1672 tCardInfo *card;
1625 unsigned char card_name[7]; 1673 unsigned char card_name[7];
1626 unsigned char pbuf[32]; 1674 unsigned char pbuf[32];
1627 static char listtitle[16];
1628 static const unsigned char i_vmin[] = { 0, 1, 5, 10, 25, 35, 60, 100 }; 1675 static const unsigned char i_vmin[] = { 0, 1, 5, 10, 25, 35, 60, 100 };
1629 static const unsigned char i_vmax[] = { 1, 5, 10, 25, 35, 45, 80, 200 }; 1676 static const unsigned char i_vmax[] = { 1, 5, 10, 25, 35, 45, 80, 200 };
1630 static const unsigned char *kbit_units[] = { "kBit/s", "MBit/s", "GBit/s" }; 1677 static const unsigned char *kbit_units[] = { "kBit/s", "MBit/s", "GBit/s" };
1631 static const unsigned char *nsec_units[] = { "ns", "µs", "ms" }; 1678 static const unsigned char *nsec_units[] = { "ns", "µs", "ms" };
1632 static const char *spec_vers[] = { "1.0-1.2", "1.4", "2.0-2.2", 1679 static const char *spec_vers[] = { "1.0-1.2", "1.4", "2.0-2.2",
1633 "3.1-3.31", "4.0" }; 1680 "3.1-3.31", "4.0" };
1634 if ((btn == ACTION_STD_OK) || (btn == SYS_FS_CHANGED))/* change cards */ 1681 if ((btn == ACTION_STD_OK) || (btn == SYS_FS_CHANGED) || (btn == ACTION_REDRAW))
1635 { 1682 {
1636 if (btn == ACTION_STD_OK) 1683 if (btn == ACTION_STD_OK)
1637 current_card ^= 0x1; 1684 info->cbdata ^= 0x1; /* change cards */
1638 cardinfo_lines = 0; 1685
1639 card = card_get_info(current_card); 1686 dbg_listmessage_setlines(0);
1687
1688 card = card_get_info(info->cbdata);
1689
1640 if (card->initialized) 1690 if (card->initialized)
1641 { 1691 {
1642 card_name[6] = '\0'; 1692 card_name[6] = '\0';
1643 strncpy(card_name, ((unsigned char*)card->cid) + 3, 6); 1693 strncpy(card_name, ((unsigned char*)card->cid) + 3, 6);
1644 snprintf(debug_list_messages[cardinfo_lines++], DEBUG_MSG_LEN, 1694 dbg_listmessage_addline(
1645 "%s Rev %d.%d", card_name, 1695 "%s Rev %d.%d", card_name,
1646 (int) card_extract_bits(card->cid, 72, 4), 1696 (int) card_extract_bits(card->cid, 72, 4),
1647 (int) card_extract_bits(card->cid, 76, 4)); 1697 (int) card_extract_bits(card->cid, 76, 4));
1648 snprintf(debug_list_messages[cardinfo_lines++], DEBUG_MSG_LEN, 1698 dbg_listmessage_addline(
1649 "Prod: %d/%d", 1699 "Prod: %d/%d",
1650 (int) card_extract_bits(card->cid, 112, 4), 1700 (int) card_extract_bits(card->cid, 112, 4),
1651 (int) card_extract_bits(card->cid, 116, 4) + 1997); 1701 (int) card_extract_bits(card->cid, 116, 4) + 1997);
1652 snprintf(debug_list_messages[cardinfo_lines++], DEBUG_MSG_LEN, 1702 dbg_listmessage_addline(
1653 "Ser#: 0x%08lx", 1703 "Ser#: 0x%08lx",
1654 card_extract_bits(card->cid, 80, 32)); 1704 card_extract_bits(card->cid, 80, 32));
1655 snprintf(debug_list_messages[cardinfo_lines++], DEBUG_MSG_LEN, 1705 dbg_listmessage_addline(
1656 "M=%02x, O=%04x", 1706 "M=%02x, O=%04x",
1657 (int) card_extract_bits(card->cid, 0, 8), 1707 (int) card_extract_bits(card->cid, 0, 8),
1658 (int) card_extract_bits(card->cid, 8, 16)); 1708 (int) card_extract_bits(card->cid, 8, 16));
1659 int temp = card_extract_bits(card->csd, 2, 4); 1709 int temp = card_extract_bits(card->csd, 2, 4);
1660 snprintf(debug_list_messages[cardinfo_lines++], DEBUG_MSG_LEN, 1710 dbg_listmessage_addline(
1661 CARDTYPE " v%s", temp < 5 ? 1711 CARDTYPE " v%s", temp < 5 ?
1662 spec_vers[temp] : "?.?"); 1712 spec_vers[temp] : "?.?");
1663 snprintf(debug_list_messages[cardinfo_lines++], DEBUG_MSG_LEN, 1713 dbg_listmessage_addline(
1664 "Blocks: 0x%06lx", card->numblocks); 1714 "Blocks: 0x%06lx", card->numblocks);
1665 snprintf(debug_list_messages[cardinfo_lines++], DEBUG_MSG_LEN, 1715 dbg_listmessage_addline(
1666 "Blksz.: %d P:%c%c", card->blocksize, 1716 "Blksz.: %d P:%c%c", card->blocksize,
1667 card_extract_bits(card->csd, 48, 1) ? 'R' : '-', 1717 card_extract_bits(card->csd, 48, 1) ? 'R' : '-',
1668 card_extract_bits(card->csd, 106, 1) ? 'W' : '-'); 1718 card_extract_bits(card->csd, 106, 1) ? 'W' : '-');
1669 output_dyn_value(pbuf, sizeof pbuf, card->speed / 1000, 1719 output_dyn_value(pbuf, sizeof pbuf, card->speed / 1000,
1670 kbit_units, false); 1720 kbit_units, false);
1671 snprintf(debug_list_messages[cardinfo_lines++], DEBUG_MSG_LEN, 1721 dbg_listmessage_addline(
1672 "Speed: %s", pbuf); 1722 "Speed: %s", pbuf);
1673 output_dyn_value(pbuf, sizeof pbuf, card->tsac, 1723 output_dyn_value(pbuf, sizeof pbuf, card->tsac,
1674 nsec_units, false); 1724 nsec_units, false);
1675 snprintf(debug_list_messages[cardinfo_lines++], DEBUG_MSG_LEN, 1725 dbg_listmessage_addline(
1676 "Tsac: %s", pbuf); 1726 "Tsac: %s", pbuf);
1677 snprintf(debug_list_messages[cardinfo_lines++], DEBUG_MSG_LEN, 1727 dbg_listmessage_addline(
1678 "Nsac: %d clk", card->nsac); 1728 "Nsac: %d clk", card->nsac);
1679 snprintf(debug_list_messages[cardinfo_lines++], DEBUG_MSG_LEN, 1729 dbg_listmessage_addline(
1680 "R2W: *%d", card->r2w_factor); 1730 "R2W: *%d", card->r2w_factor);
1681 snprintf(debug_list_messages[cardinfo_lines++], DEBUG_MSG_LEN, 1731 dbg_listmessage_addline(
1682 "IRmax: %d..%d mA", 1732 "IRmax: %d..%d mA",
1683 i_vmin[card_extract_bits(card->csd, 66, 3)], 1733 i_vmin[card_extract_bits(card->csd, 66, 3)],
1684 i_vmax[card_extract_bits(card->csd, 69, 3)]); 1734 i_vmax[card_extract_bits(card->csd, 69, 3)]);
1685 snprintf(debug_list_messages[cardinfo_lines++], DEBUG_MSG_LEN, 1735 dbg_listmessage_addline(
1686 "IWmax: %d..%d mA", 1736 "IWmax: %d..%d mA",
1687 i_vmin[card_extract_bits(card->csd, 72, 3)], 1737 i_vmin[card_extract_bits(card->csd, 72, 3)],
1688 i_vmax[card_extract_bits(card->csd, 75, 3)]); 1738 i_vmax[card_extract_bits(card->csd, 75, 3)]);
1689 } 1739 }
1690 else 1740 else
1691 { 1741 {
1692 snprintf(debug_list_messages[cardinfo_lines++], DEBUG_MSG_LEN, 1742 dbg_listmessage_addline("Not Found!");
1693 "Not Found!");
1694 } 1743 }
1695 snprintf(listtitle, sizeof listtitle, 1744 snprintf(info->title, 16, "[" CARDTYPE " %d]", (int)info->cbdata);
1696 "[" CARDTYPE " %d]", current_card); 1745 gui_synclist_set_nb_items(info->lists, dbg_listmessage_getlines());
1697 gui_synclist_set_title(lists, listtitle, NOICON); 1746 gui_synclist_select_item(info->lists, 0);
1698 gui_synclist_select_item(lists, 0);
1699 gui_synclist_set_nb_items(lists, cardinfo_lines);
1700 btn = ACTION_REDRAW; 1747 btn = ACTION_REDRAW;
1701 } 1748 }
1702 return btn; 1749 return btn;
1703} 1750}
1704static bool dbg_disk_info(void) 1751static bool dbg_disk_info(void)
1705{ 1752{
1706 current_card = 1; /* the callback changes this to 0 */ 1753 char listtitle[16];
1707 dbg_list("[" CARDTYPE " 0]", cardinfo_lines, 1, 1754 struct action_callback_info info;
1708 cardinfo_callback, dbg_listmessage_getname); 1755 info.title = listtitle;
1756 info.count = 1;
1757 info.selection_size = 1;
1758 info.action_callback = cardinfo_callback;
1759 info.dbg_getname = dbg_listmessage_getname;
1760 info.cbdata = 0;
1761 dbg_list(&info);
1709 return false; 1762 return false;
1710} 1763}
1711#else /* !defined(HAVE_MMC) && !defined(HAVE_HOTSWAP) */ 1764#else /* !defined(HAVE_MMC) && !defined(HAVE_HOTSWAP) */
1712static int disklines = 0; 1765static int disk_callback(int btn, struct action_callback_info *info)
1713static int disk_callback(int btn, struct gui_synclist *lists)
1714{ 1766{
1715 int i; 1767 int i;
1716 char buf[128]; 1768 char buf[128];
1717 unsigned short* identify_info = ata_get_identify(); 1769 unsigned short* identify_info = ata_get_identify();
1718 bool timing_info_present = false; 1770 bool timing_info_present = false;
1719 (void)btn; (void)lists; 1771 (void)btn;
1720 disklines = 0; 1772
1773 dbg_listmessage_setlines(0);
1774
1721 for (i=0; i < 20; i++) 1775 for (i=0; i < 20; i++)
1722 ((unsigned short*)buf)[i]=htobe16(identify_info[i+27]); 1776 ((unsigned short*)buf)[i]=htobe16(identify_info[i+27]);
1723 buf[40]=0; 1777 buf[40]=0;
1724 /* kill trailing space */ 1778 /* kill trailing space */
1725 for (i=39; i && buf[i]==' '; i--) 1779 for (i=39; i && buf[i]==' '; i--)
1726 buf[i] = 0; 1780 buf[i] = 0;
1727 snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN, 1781 dbg_listmessage_addline(
1728 "Model: %s", buf); 1782 "Model: %s", buf);
1729 for (i=0; i < 4; i++) 1783 for (i=0; i < 4; i++)
1730 ((unsigned short*)buf)[i]=htobe16(identify_info[i+23]); 1784 ((unsigned short*)buf)[i]=htobe16(identify_info[i+23]);
1731 buf[8]=0; 1785 buf[8]=0;
1732 snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN, 1786 dbg_listmessage_addline(
1733 "Firmware: %s", buf); 1787 "Firmware: %s", buf);
1734 snprintf(buf, sizeof buf, "%ld MB", 1788 snprintf(buf, sizeof buf, "%ld MB",
1735 ((unsigned long)identify_info[61] << 16 | 1789 ((unsigned long)identify_info[61] << 16 |
1736 (unsigned long)identify_info[60]) / 2048 ); 1790 (unsigned long)identify_info[60]) / 2048 );
1737 snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN, 1791 dbg_listmessage_addline(
1738 "Size: %s", buf); 1792 "Size: %s", buf);
1739 unsigned long free; 1793 unsigned long free;
1740 fat_size( IF_MV2(0,) NULL, &free ); 1794 fat_size( IF_MV2(0,) NULL, &free );
1741 snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN, 1795 dbg_listmessage_addline(
1742 "Free: %ld MB", free / 1024); 1796 "Free: %ld MB", free / 1024);
1743 snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN, 1797 dbg_listmessage_addline(
1744 "Spinup time: %d ms", ata_spinup_time * (1000/HZ)); 1798 "Spinup time: %d ms", ata_spinup_time * (1000/HZ));
1745 i = identify_info[83] & (1<<3); 1799 i = identify_info[83] & (1<<3);
1746 snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN, 1800 dbg_listmessage_addline(
1747 "Power mgmt: %s", i ? "enabled" : "unsupported"); 1801 "Power mgmt: %s", i ? "enabled" : "unsupported");
1748 i = identify_info[83] & (1<<9); 1802 i = identify_info[83] & (1<<9);
1749 snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN, 1803 dbg_listmessage_addline(
1750 "Noise mgmt: %s", i ? "enabled" : "unsupported"); 1804 "Noise mgmt: %s", i ? "enabled" : "unsupported");
1751 i = identify_info[82] & (1<<6); 1805 i = identify_info[82] & (1<<6);
1752 snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN, 1806 dbg_listmessage_addline(
1753 "Read-ahead: %s", i ? "enabled" : "unsupported"); 1807 "Read-ahead: %s", i ? "enabled" : "unsupported");
1754 timing_info_present = identify_info[53] & (1<<1); 1808 timing_info_present = identify_info[53] & (1<<1);
1755 if(timing_info_present) { 1809 if(timing_info_present) {
@@ -1757,100 +1811,121 @@ static int disk_callback(int btn, struct gui_synclist *lists)
1757 pio4[1] = 0; 1811 pio4[1] = 0;
1758 pio3[0] = (identify_info[64] & (1<<0)) ? '3' : 0; 1812 pio3[0] = (identify_info[64] & (1<<0)) ? '3' : 0;
1759 pio4[0] = (identify_info[64] & (1<<1)) ? '4' : 0; 1813 pio4[0] = (identify_info[64] & (1<<1)) ? '4' : 0;
1760 snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN, 1814 dbg_listmessage_addline(
1761 "PIO modes: 0 1 2 %s %s", pio3, pio4); 1815 "PIO modes: 0 1 2 %s %s", pio3, pio4);
1762 } 1816 }
1763 else { 1817 else {
1764 snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN, 1818 dbg_listmessage_addline(
1765 "No PIO mode info"); 1819 "No PIO mode info");
1766 } 1820 }
1767 timing_info_present = identify_info[53] & (1<<1); 1821 timing_info_present = identify_info[53] & (1<<1);
1768 if(timing_info_present) { 1822 if(timing_info_present) {
1769 snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN, 1823 dbg_listmessage_addline(
1770 "Cycle times %dns/%dns", 1824 "Cycle times %dns/%dns",
1771 identify_info[67], 1825 identify_info[67],
1772 identify_info[68] ); 1826 identify_info[68] );
1773 } else { 1827 } else {
1774 snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN, 1828 dbg_listmessage_addline(
1775 "No timing info"); 1829 "No timing info");
1776 } 1830 }
1777 timing_info_present = identify_info[53] & (1<<1); 1831 timing_info_present = identify_info[53] & (1<<1);
1778 if(timing_info_present) { 1832 if(timing_info_present) {
1779 i = identify_info[49] & (1<<11); 1833 i = identify_info[49] & (1<<11);
1780 snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN, 1834 dbg_listmessage_addline(
1781 "IORDY support: %s", i ? "yes" : "no"); 1835 "IORDY support: %s", i ? "yes" : "no");
1782 i = identify_info[49] & (1<<10); 1836 i = identify_info[49] & (1<<10);
1783 snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN, 1837 dbg_listmessage_addline(
1784 "IORDY disable: %s", i ? "yes" : "no"); 1838 "IORDY disable: %s", i ? "yes" : "no");
1785 } else { 1839 } else {
1786 snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN, 1840 dbg_listmessage_addline(
1787 "No timing info"); 1841 "No timing info");
1788 } 1842 }
1789 snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN, 1843 dbg_listmessage_addline(
1790 "Cluster size: %d bytes", fat_get_cluster_size(IF_MV(0))); 1844 "Cluster size: %d bytes", fat_get_cluster_size(IF_MV(0)));
1845 gui_synclist_set_nb_items(info->lists, dbg_listmessage_getlines());
1791 return btn; 1846 return btn;
1792} 1847}
1793static bool dbg_disk_info(void) 1848static bool dbg_disk_info(void)
1794{ 1849{
1795 dbg_list("Disk Info",disklines, 1, disk_callback, dbg_listmessage_getname); 1850 struct action_callback_info info;
1851 info.title = "Disk Info";
1852 info.count = 1;
1853 info.selection_size = 1;
1854 info.action_callback = disk_callback;
1855 info.dbg_getname = dbg_listmessage_getname;
1856 dbg_list(&info);
1796 return false; 1857 return false;
1797} 1858}
1798#endif /* !defined(HAVE_MMC) && !defined(HAVE_HOTSWAP) */ 1859#endif /* !defined(HAVE_MMC) && !defined(HAVE_HOTSWAP) */
1799#endif /* !SIMULATOR */ 1860#endif /* !SIMULATOR */
1800 1861
1801#ifdef HAVE_DIRCACHE 1862#ifdef HAVE_DIRCACHE
1802static int dircache_callback(int btn, struct gui_synclist *lists) 1863static int dircache_callback(int btn, struct action_callback_info *info)
1803{ 1864{
1804 (void)btn; (void)lists; 1865 (void)btn; (void)info;
1805 snprintf(debug_list_messages[0], DEBUG_MSG_LEN, "Cache initialized: %s", 1866 dbg_listmessage_setlines(0);
1867 dbg_listmessage_addline("Cache initialized: %s",
1806 dircache_is_enabled() ? "Yes" : "No"); 1868 dircache_is_enabled() ? "Yes" : "No");
1807 snprintf(debug_list_messages[1], DEBUG_MSG_LEN, "Cache size: %d B", 1869 dbg_listmessage_addline("Cache size: %d B",
1808 dircache_get_cache_size()); 1870 dircache_get_cache_size());
1809 snprintf(debug_list_messages[2], DEBUG_MSG_LEN, "Last size: %d B", 1871 dbg_listmessage_addline("Last size: %d B",
1810 global_status.dircache_size); 1872 global_status.dircache_size);
1811 snprintf(debug_list_messages[3], DEBUG_MSG_LEN, "Limit: %d B", 1873 dbg_listmessage_addline("Limit: %d B",
1812 DIRCACHE_LIMIT); 1874 DIRCACHE_LIMIT);
1813 snprintf(debug_list_messages[4], DEBUG_MSG_LEN, "Reserve: %d/%d B", 1875 dbg_listmessage_addline("Reserve: %d/%d B",
1814 dircache_get_reserve_used(), DIRCACHE_RESERVE); 1876 dircache_get_reserve_used(), DIRCACHE_RESERVE);
1815 snprintf(debug_list_messages[5], DEBUG_MSG_LEN, "Scanning took: %d s", 1877 dbg_listmessage_addline("Scanning took: %d s",
1816 dircache_get_build_ticks() / HZ); 1878 dircache_get_build_ticks() / HZ);
1817 snprintf(debug_list_messages[6], DEBUG_MSG_LEN, "Entry count: %d", 1879 dbg_listmessage_addline("Entry count: %d",
1818 dircache_get_entry_count()); 1880 dircache_get_entry_count());
1819 return btn; 1881 return btn;
1820} 1882}
1821 1883
1822static bool dbg_dircache_info(void) 1884static bool dbg_dircache_info(void)
1823{ 1885{
1824 dbg_list("Dircache Info",7, 1, dircache_callback, dbg_listmessage_getname); 1886 struct action_callback_info info;
1887 info.title = "Dircache Info";
1888 info.count = 7;
1889 info.selection_size = 1;
1890 info.action_callback = dircache_callback;
1891 info.dbg_getname = dbg_listmessage_getname;
1892 dbg_list(&info);
1825 return false; 1893 return false;
1826} 1894}
1827 1895
1828#endif /* HAVE_DIRCACHE */ 1896#endif /* HAVE_DIRCACHE */
1829 1897
1830#ifdef HAVE_TAGCACHE 1898#ifdef HAVE_TAGCACHE
1831static int database_callback(int btn, struct gui_synclist *lists) 1899static int database_callback(int btn, struct action_callback_info *info)
1832{ 1900{
1833 (void)btn; (void)lists; 1901 (void)btn; (void)info;
1834 struct tagcache_stat *stat = tagcache_get_stat(); 1902 struct tagcache_stat *stat = tagcache_get_stat();
1835 snprintf(debug_list_messages[0], DEBUG_MSG_LEN, "Initialized: %s", 1903 dbg_listmessage_setlines(0);
1904 dbg_listmessage_addline("Initialized: %s",
1836 stat->initialized ? "Yes" : "No"); 1905 stat->initialized ? "Yes" : "No");
1837 snprintf(debug_list_messages[1], DEBUG_MSG_LEN, "DB Ready: %s", 1906 dbg_listmessage_addline("DB Ready: %s",
1838 stat->ready ? "Yes" : "No"); 1907 stat->ready ? "Yes" : "No");
1839 snprintf(debug_list_messages[2], DEBUG_MSG_LEN, "RAM Cache: %s", 1908 dbg_listmessage_addline("RAM Cache: %s",
1840 stat->ramcache ? "Yes" : "No"); 1909 stat->ramcache ? "Yes" : "No");
1841 snprintf(debug_list_messages[3], DEBUG_MSG_LEN, "RAM: %d/%d B", 1910 dbg_listmessage_addline("RAM: %d/%d B",
1842 stat->ramcache_used, stat->ramcache_allocated); 1911 stat->ramcache_used, stat->ramcache_allocated);
1843 snprintf(debug_list_messages[4], DEBUG_MSG_LEN, "Progress: %d%% (%d entries)", 1912 dbg_listmessage_addline("Progress: %d%% (%d entries)",
1844 stat->progress, stat->processed_entries); 1913 stat->progress, stat->processed_entries);
1845 snprintf(debug_list_messages[5], DEBUG_MSG_LEN, "Commit step: %d", 1914 dbg_listmessage_addline("Commit step: %d",
1846 stat->commit_step); 1915 stat->commit_step);
1847 snprintf(debug_list_messages[6], DEBUG_MSG_LEN, "Commit delayed: %s", 1916 dbg_listmessage_addline("Commit delayed: %s",
1848 stat->commit_delayed ? "Yes" : "No"); 1917 stat->commit_delayed ? "Yes" : "No");
1849 return btn; 1918 return btn;
1850} 1919}
1851static bool dbg_tagcache_info(void) 1920static bool dbg_tagcache_info(void)
1852{ 1921{
1853 dbg_list("Database Info",7, 1, database_callback, dbg_listmessage_getname); 1922 struct action_callback_info info;
1923 info.title = "Database Info";
1924 info.count = 7;
1925 info.selection_size = 1;
1926 info.action_callback = database_callback;
1927 info.dbg_getname = dbg_listmessage_getname;
1928 dbg_list(&info);
1854 return false; 1929 return false;
1855} 1930}
1856#endif 1931#endif
@@ -1942,68 +2017,60 @@ static bool dbg_save_roms(void)
1942 2017
1943#ifndef SIMULATOR 2018#ifndef SIMULATOR
1944#if CONFIG_TUNER 2019#if CONFIG_TUNER
1945static int radio_callback(int btn, struct gui_synclist *lists) 2020static int radio_callback(int btn, struct action_callback_info *info)
1946{ 2021{
1947 int radio_lines = 0; 2022 dbg_listmessage_setlines(1);
1948 2023
1949 if (radio_hardware_present())
1950 {
1951 snprintf(debug_list_messages[radio_lines++], DEBUG_MSG_LEN,
1952 "HW detected: yes");
1953#if (CONFIG_TUNER & LV24020LP) 2024#if (CONFIG_TUNER & LV24020LP)
1954 snprintf(debug_list_messages[radio_lines++], DEBUG_MSG_LEN, 2025 dbg_listmessage_addline("CTRL_STAT: %02X", lv24020lp_get(LV24020LP_CTRL_STAT) );
1955 "CTRL_STAT: %02X", lv24020lp_get(LV24020LP_CTRL_STAT) ); 2026 dbg_listmessage_addline("RADIO_STAT: %02X", lv24020lp_get(LV24020LP_REG_STAT) );
1956 snprintf(debug_list_messages[radio_lines++], DEBUG_MSG_LEN, 2027 dbg_listmessage_addline("MSS_FM: %d kHz", lv24020lp_get(LV24020LP_MSS_FM) );
1957 "RADIO_STAT: %02X", lv24020lp_get(LV24020LP_REG_STAT)); 2028 dbg_listmessage_addline("MSS_IF: %d Hz", lv24020lp_get(LV24020LP_MSS_IF) );
1958 snprintf(debug_list_messages[radio_lines++], DEBUG_MSG_LEN, 2029 dbg_listmessage_addline("MSS_SD: %d Hz", lv24020lp_get(LV24020LP_MSS_SD) );
1959 "MSS_FM: %d kHz", lv24020lp_get(LV24020LP_MSS_FM) ); 2030 dbg_listmessage_addline("if_set: %d Hz", lv24020lp_get(LV24020LP_IF_SET) );
1960 snprintf(debug_list_messages[radio_lines++], DEBUG_MSG_LEN, 2031 dbg_listmessage_addline("sd_set: %d Hz", lv24020lp_get(LV24020LP_SD_SET) );
1961 "MSS_IF: %d Hz", (lv24020lp_get(LV24020LP_MSS_IF) ) );
1962 snprintf(debug_list_messages[radio_lines++], DEBUG_MSG_LEN,
1963 "MSS_SD: %d Hz", (lv24020lp_get(LV24020LP_MSS_SD) ) );
1964 snprintf(debug_list_messages[radio_lines++], DEBUG_MSG_LEN,
1965 "if_set: %d Hz", (lv24020lp_get(LV24020LP_IF_SET) ) );
1966 snprintf(debug_list_messages[radio_lines++], DEBUG_MSG_LEN,
1967 "sd_set: %d Hz", (lv24020lp_get(LV24020LP_SD_SET) ) );
1968
1969 if (btn != ACTION_STD_CANCEL)
1970 btn = ACTION_REDRAW;
1971#endif 2032#endif
1972#if (CONFIG_TUNER & S1A0903X01) 2033#if (CONFIG_TUNER & S1A0903X01)
1973 snprintf(debug_list_messages[radio_lines++], DEBUG_MSG_LEN, 2034 dbg_listmessage_addline("Samsung regs: %08X", s1a0903x01_get(RADIO_ALL));
1974 "Samsung regs: %08X", s1a0903x01_get(RADIO_ALL)); 2035 /* This one doesn't return dynamic data atm */
1975 /* This one doesn't return dynamic data atm */
1976#endif 2036#endif
1977#if (CONFIG_TUNER & TEA5767) 2037#if (CONFIG_TUNER & TEA5767)
1978 struct tea5767_dbg_info info; 2038 struct tea5767_dbg_info nfo;
1979 tea5767_dbg_info(&info); 2039 tea5767_dbg_info(&nfo);
1980 snprintf(debug_list_messages[radio_lines++], DEBUG_MSG_LEN, "Philips regs:"); 2040 dbg_listmessage_addline("Philips regs:");
1981 snprintf(debug_list_messages[radio_lines++], DEBUG_MSG_LEN, 2041 dbg_listmessage_addline(
1982 " Read: %02X %02X %02X %02X %02X", 2042 " Read: %02X %02X %02X %02X %02X",
1983 (unsigned)info.read_regs[0], (unsigned)info.read_regs[1], 2043 (unsigned)nfo.read_regs[0], (unsigned)nfo.read_regs[1],
1984 (unsigned)info.read_regs[2], (unsigned)info.read_regs[3], 2044 (unsigned)nfo.read_regs[2], (unsigned)nfo.read_regs[3],
1985 (unsigned)info.read_regs[4]); 2045 (unsigned)nfo.read_regs[4]);
1986 snprintf(debug_list_messages[radio_lines++], DEBUG_MSG_LEN, 2046 dbg_listmessage_addline(
1987 " Write: %02X %02X %02X %02X %02X", 2047 " Write: %02X %02X %02X %02X %02X",
1988 (unsigned)info.write_regs[0], (unsigned)info.write_regs[1], 2048 (unsigned)nfo.write_regs[0], (unsigned)nfo.write_regs[1],
1989 (unsigned)info.write_regs[2], (unsigned)info.write_regs[3], 2049 (unsigned)nfo.write_regs[2], (unsigned)nfo.write_regs[3],
1990 (unsigned)info.write_regs[4]); 2050 (unsigned)nfo.write_regs[4]);
1991
1992 if (btn != ACTION_STD_CANCEL)
1993 btn = ACTION_REDRAW;
1994#endif 2051#endif
1995 2052
1996 gui_synclist_set_nb_items(lists, radio_lines); 2053 if (btn != ACTION_STD_CANCEL)
1997 } 2054 btn = ACTION_REDRAW;
1998 else
1999 snprintf(debug_list_messages[0], DEBUG_MSG_LEN, "HW detected: no");
2000 2055
2056 gui_synclist_set_nb_items(info->lists, dbg_listmessage_getlines());
2001 return btn; 2057 return btn;
2002} 2058}
2003static bool dbg_fm_radio(void) 2059static bool dbg_fm_radio(void)
2004{ 2060{
2005 dbg_list("FM Radio", 1, 1, 2061 struct action_callback_info info;
2006 radio_callback, dbg_listmessage_getname); 2062
2063 info.title = "FM Radio";
2064 info.count = 1;
2065 info.selection_size = 1;
2066 info.cbdata = radio_hardware_present();
2067 info.action_callback = info.cbdata ? radio_callback : NULL;
2068 info.dbg_getname = dbg_listmessage_getname;
2069
2070 dbg_listmessage_setlines(0);
2071 dbg_listmessage_addline("HW detected: %s", info.cbdata ? "yes" : "no");
2072
2073 dbg_list(&info);
2007 return false; 2074 return false;
2008} 2075}
2009#endif /* CONFIG_TUNER */ 2076#endif /* CONFIG_TUNER */
@@ -2245,12 +2312,12 @@ static const struct the_menu_item menuitems[] = {
2245 {"cpu_boost log",cpu_boost_log}, 2312 {"cpu_boost log",cpu_boost_log},
2246#endif 2313#endif
2247 }; 2314 };
2248static int menu_action_callback(int btn, struct gui_synclist *lists) 2315static int menu_action_callback(int btn, struct action_callback_info *info)
2249{ 2316{
2250 if (btn == ACTION_STD_OK) 2317 if (btn == ACTION_STD_OK)
2251 { 2318 {
2252 menuitems[gui_synclist_get_sel_pos(lists)].function(); 2319 menuitems[gui_synclist_get_sel_pos(info->lists)].function();
2253 gui_synclist_draw(lists); 2320 gui_synclist_draw(info->lists);
2254 } 2321 }
2255 return btn; 2322 return btn;
2256} 2323}
@@ -2261,8 +2328,12 @@ static char* dbg_menu_getname(int item, void * data, char *buffer)
2261} 2328}
2262bool debug_menu(void) 2329bool debug_menu(void)
2263{ 2330{
2264 dbg_list("Debug Menu",ARRAYLEN(menuitems) , 1, 2331 struct action_callback_info info;
2265 menu_action_callback, 2332 info.title = "Debug Menu";
2266 dbg_menu_getname); 2333 info.count = ARRAYLEN(menuitems);
2334 info.selection_size = 1;
2335 info.action_callback = menu_action_callback;
2336 info.dbg_getname = dbg_menu_getname;
2337 dbg_list(&info);
2267 return false; 2338 return false;
2268} 2339}