summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/debug_menu.c413
1 files changed, 158 insertions, 255 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index f7b022dbb3..d106632a1b 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -89,7 +89,7 @@
89#include "hwcompat.h" 89#include "hwcompat.h"
90 90
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 8 92#define MAX_DEBUG_MESSAGES 16
93#define DEBUG_MSG_LEN 32 93#define DEBUG_MSG_LEN 32
94char debug_list_messages[MAX_DEBUG_MESSAGES][DEBUG_MSG_LEN]; 94char debug_list_messages[MAX_DEBUG_MESSAGES][DEBUG_MSG_LEN];
95static char* dbg_listmessage_getname(int item, void * data, char *buffer) 95static char* dbg_listmessage_getname(int item, void * data, char *buffer)
@@ -1607,278 +1607,187 @@ static bool view_battery(void)
1607 1607
1608#ifndef SIMULATOR 1608#ifndef SIMULATOR
1609#if defined(HAVE_MMC) || defined(HAVE_HOTSWAP) 1609#if defined(HAVE_MMC) || defined(HAVE_HOTSWAP)
1610static bool dbg_card_info(void) 1610static int cardinfo_lines = 0,
1611 current_card = 1; /* the first call changes this card to 0 */
1612static int cardinfo_callback(int btn, struct gui_synclist *lists)
1611{ 1613{
1612 bool done = false;
1613 int currval = 0;
1614 int line;
1615 tCardInfo *card; 1614 tCardInfo *card;
1616 unsigned char pbuf[32], pbuf2[32];
1617 unsigned char card_name[7]; 1615 unsigned char card_name[7];
1618 1616 unsigned char pbuf[32];
1617 static char listtitle[16];
1619 static const unsigned char i_vmin[] = { 0, 1, 5, 10, 25, 35, 60, 100 }; 1618 static const unsigned char i_vmin[] = { 0, 1, 5, 10, 25, 35, 60, 100 };
1620 static const unsigned char i_vmax[] = { 1, 5, 10, 25, 35, 45, 80, 200 }; 1619 static const unsigned char i_vmax[] = { 1, 5, 10, 25, 35, 45, 80, 200 };
1621 static const unsigned char *kbit_units[] = { "kBit/s", "MBit/s", "GBit/s" }; 1620 static const unsigned char *kbit_units[] = { "kBit/s", "MBit/s", "GBit/s" };
1622 static const unsigned char *nsec_units[] = { "ns", "µs", "ms" }; 1621 static const unsigned char *nsec_units[] = { "ns", "µs", "ms" };
1623 static const char *spec_vers[] = { "1.0-1.2", "1.4", "2.0-2.2", 1622 static const char *spec_vers[] = { "1.0-1.2", "1.4", "2.0-2.2",
1624 "3.1-3.31", "4.0" }; 1623 "3.1-3.31", "4.0" };
1625 1624 if ((btn == ACTION_STD_OK) || (btn == SYS_FS_CHANGED))/* change cards */
1626 card_name[6] = '\0';
1627
1628 lcd_setmargins(0, 0);
1629 lcd_setfont(FONT_SYSFIXED);
1630
1631 while (!done)
1632 { 1625 {
1633 card = card_get_info(currval / 2); 1626 if (btn == ACTION_STD_OK)
1634 1627 current_card ^= 0x1;
1635 line = 0; 1628 cardinfo_lines = 0;
1636 lcd_clear_display(); 1629 card = card_get_info(current_card);
1637 snprintf(pbuf, sizeof(pbuf), "[MMC%d p%d]", currval / 2,
1638 (currval % 2) + 1);
1639 lcd_puts(0, line++, pbuf);
1640
1641 if (card->initialized) 1630 if (card->initialized)
1642 { 1631 {
1643 if (!(currval % 2)) /* General info */ 1632 card_name[6] = '\0';
1644 { 1633 strncpy(card_name, ((unsigned char*)card->cid) + 3, 6);
1645 int temp; 1634 snprintf(debug_list_messages[cardinfo_lines++], DEBUG_MSG_LEN,
1646 1635 "%s Rev %d.%d", card_name,
1647 strncpy(card_name, ((unsigned char*)card->cid) + 3, 6); 1636 (int) card_extract_bits(card->cid, 72, 4),
1648 snprintf(pbuf, sizeof(pbuf), "%s Rev %d.%d", card_name, 1637 (int) card_extract_bits(card->cid, 76, 4));
1649 (int) card_extract_bits(card->cid, 72, 4), 1638 snprintf(debug_list_messages[cardinfo_lines++], DEBUG_MSG_LEN,
1650 (int) card_extract_bits(card->cid, 76, 4)); 1639 "Prod: %d/%d",
1651 lcd_puts(0, line++, pbuf); 1640 (int) card_extract_bits(card->cid, 112, 4),
1652 snprintf(pbuf, sizeof(pbuf), "Prod: %d/%d", 1641 (int) card_extract_bits(card->cid, 116, 4) + 1997);
1653 (int) card_extract_bits(card->cid, 112, 4), 1642 snprintf(debug_list_messages[cardinfo_lines++], DEBUG_MSG_LEN,
1654 (int) card_extract_bits(card->cid, 116, 4) + 1997); 1643 "Ser#: 0x%08lx",
1655 lcd_puts(0, line++, pbuf); 1644 card_extract_bits(card->cid, 80, 32));
1656 snprintf(pbuf, sizeof(pbuf), "Ser#: 0x%08lx", 1645 snprintf(debug_list_messages[cardinfo_lines++], DEBUG_MSG_LEN,
1657 card_extract_bits(card->cid, 80, 32)); 1646 "M=%02x, O=%04x",
1658 lcd_puts(0, line++, pbuf); 1647 (int) card_extract_bits(card->cid, 0, 8),
1659 snprintf(pbuf, sizeof(pbuf), "M=%02x, O=%04x", 1648 (int) card_extract_bits(card->cid, 8, 16));
1660 (int) card_extract_bits(card->cid, 0, 8), 1649 int temp = card_extract_bits(card->csd, 2, 4);
1661 (int) card_extract_bits(card->cid, 8, 16)); 1650 snprintf(debug_list_messages[cardinfo_lines++], DEBUG_MSG_LEN,
1662 lcd_puts(0, line++, pbuf); 1651 "MMC v%s", temp < 5 ?
1663 temp = card_extract_bits(card->csd, 2, 4); 1652 spec_vers[temp] : "?.?");
1664 snprintf(pbuf, sizeof(pbuf), "MMC v%s", temp < 5 ? 1653 snprintf(debug_list_messages[cardinfo_lines++], DEBUG_MSG_LEN,
1665 spec_vers[temp] : "?.?"); 1654 "Blocks: 0x%06lx", card->numblocks);
1666 lcd_puts(0, line++, pbuf); 1655 snprintf(debug_list_messages[cardinfo_lines++], DEBUG_MSG_LEN,
1667 snprintf(pbuf, sizeof(pbuf), "Blocks: 0x%06lx", card->numblocks); 1656 "Blksz.: %d P:%c%c", card->blocksize,
1668 lcd_puts(0, line++, pbuf); 1657 card_extract_bits(card->csd, 48, 1) ? 'R' : '-',
1669 snprintf(pbuf, sizeof(pbuf), "Blksz.: %d P:%c%c", card->blocksize, 1658 card_extract_bits(card->csd, 106, 1) ? 'W' : '-');
1670 card_extract_bits(card->csd, 48, 1) ? 'R' : '-', 1659 output_dyn_value(pbuf, sizeof pbuf, card->speed / 1000,
1671 card_extract_bits(card->csd, 106, 1) ? 'W' : '-'); 1660 kbit_units, false);
1672 lcd_puts(0, line++, pbuf); 1661 snprintf(debug_list_messages[cardinfo_lines++], DEBUG_MSG_LEN,
1673 } 1662 "Speed: %s", pbuf);
1674 else /* Technical details */ 1663 output_dyn_value(pbuf, sizeof pbuf, card->tsac,
1675 { 1664 nsec_units, false);
1676 output_dyn_value(pbuf2, sizeof pbuf2, card->speed / 1000, 1665 snprintf(debug_list_messages[cardinfo_lines++], DEBUG_MSG_LEN,
1677 kbit_units, false); 1666 "Tsac: %s", pbuf);
1678 snprintf(pbuf, sizeof pbuf, "Speed: %s", pbuf2); 1667 snprintf(debug_list_messages[cardinfo_lines++], DEBUG_MSG_LEN,
1679 lcd_puts(0, line++, pbuf); 1668 "Nsac: %d clk", card->nsac);
1680 1669 snprintf(debug_list_messages[cardinfo_lines++], DEBUG_MSG_LEN,
1681 output_dyn_value(pbuf2, sizeof pbuf2, card->tsac, 1670 "R2W: *%d", card->r2w_factor);
1682 nsec_units, false); 1671 snprintf(debug_list_messages[cardinfo_lines++], DEBUG_MSG_LEN,
1683 snprintf(pbuf, sizeof pbuf, "Tsac: %s", pbuf2); 1672 "IRmax: %d..%d mA",
1684 lcd_puts(0, line++, pbuf); 1673 i_vmin[card_extract_bits(card->csd, 66, 3)],
1685 1674 i_vmax[card_extract_bits(card->csd, 69, 3)]);
1686 snprintf(pbuf, sizeof(pbuf), "Nsac: %d clk", card->nsac); 1675 snprintf(debug_list_messages[cardinfo_lines++], DEBUG_MSG_LEN,
1687 lcd_puts(0, line++, pbuf); 1676 "IWmax: %d..%d mA",
1688 snprintf(pbuf, sizeof(pbuf), "R2W: *%d", card->r2w_factor); 1677 i_vmin[card_extract_bits(card->csd, 72, 3)],
1689 lcd_puts(0, line++, pbuf); 1678 i_vmax[card_extract_bits(card->csd, 75, 3)]);
1690 snprintf(pbuf, sizeof(pbuf), "IRmax: %d..%d mA",
1691 i_vmin[card_extract_bits(card->csd, 66, 3)],
1692 i_vmax[card_extract_bits(card->csd, 69, 3)]);
1693 lcd_puts(0, line++, pbuf);
1694 snprintf(pbuf, sizeof(pbuf), "IWmax: %d..%d mA",
1695 i_vmin[card_extract_bits(card->csd, 72, 3)],
1696 i_vmax[card_extract_bits(card->csd, 75, 3)]);
1697 lcd_puts(0, line++, pbuf);
1698 }
1699 } 1679 }
1700 else 1680 else
1701 lcd_puts(0, line++, "Not found!");
1702
1703 lcd_update();
1704
1705 switch (get_action(CONTEXT_SETTINGS,HZ/2))
1706 { 1681 {
1707 case ACTION_STD_CANCEL: 1682 snprintf(debug_list_messages[cardinfo_lines++], DEBUG_MSG_LEN,
1708 done = true; 1683 "Not Found!");
1709 break; 1684 }
1710 1685 if (lists)
1711 case ACTION_SETTINGS_DEC: 1686 {
1712 currval--; 1687 snprintf(listtitle, sizeof listtitle,
1713 if (currval < 0) 1688 "[MMC/microSD %d]", current_card);
1714 currval = 3; 1689 gui_synclist_set_title(lists, listtitle, NOICON);
1715 break; 1690 gui_synclist_select_item(lists, 0);
1716 1691 gui_synclist_set_nb_items(lists, cardinfo_lines);
1717 case ACTION_SETTINGS_INC: 1692 gui_synclist_draw(lists);
1718 currval++;
1719 if (currval > 3)
1720 currval = 0;
1721 break;
1722 } 1693 }
1723 } 1694 }
1724 action_signalscreenchange(); 1695 return btn;
1696}
1697static bool dbg_disk_info(void)
1698{
1699 current_card = 1; /* the callback changes this to 0 */
1700 cardinfo_callback(ACTION_STD_OK, 0);
1701 dbg_list("[MMC/microSD 0]", cardinfo_lines, 1,
1702 cardinfo_callback, dbg_listmessage_getname);
1725 return false; 1703 return false;
1726} 1704}
1727#else /* !defined(HAVE_MMC) && !defined(HAVE_HOTSWAP) */ 1705#else /* !defined(HAVE_MMC) && !defined(HAVE_HOTSWAP) */
1728static bool dbg_disk_info(void) 1706static int disklines = 0;
1707static int disk_callback(int btn, struct gui_synclist *lists)
1729{ 1708{
1730 char buf[128];
1731 bool done = false;
1732 int i; 1709 int i;
1733 int page = 0; 1710 char buf[128];
1734 const int max_page = 11;
1735 unsigned short* identify_info = ata_get_identify(); 1711 unsigned short* identify_info = ata_get_identify();
1736 bool timing_info_present = false; 1712 bool timing_info_present = false;
1737 char pio3[2], pio4[2]; 1713 (void)btn; (void)lists;
1738 1714 disklines = 0;
1739 lcd_setmargins(0, 0); 1715 for (i=0; i < 20; i++)
1740 1716 ((unsigned short*)buf)[i]=htobe16(identify_info[i+27]);
1741 while(!done) 1717 buf[40]=0;
1742 { 1718 /* kill trailing space */
1743 int y=0; 1719 for (i=39; i && buf[i]==' '; i--)
1744 int key; 1720 buf[i] = 0;
1745 lcd_clear_display(); 1721 snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN,
1746#ifdef HAVE_LCD_BITMAP 1722 "Model: %s", buf);
1747 lcd_puts(0, y++, "Disk info:"); 1723 for (i=0; i < 4; i++)
1748 y++; 1724 ((unsigned short*)buf)[i]=htobe16(identify_info[i+23]);
1749#endif 1725 buf[8]=0;
1750 1726 snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN,
1751 switch (page) { 1727 "Firmare: %s", buf);
1752 case 0: 1728 snprintf(buf, sizeof buf, "%ld MB",
1753 for (i=0; i < 20; i++) 1729 ((unsigned long)identify_info[61] << 16 |
1754 ((unsigned short*)buf)[i]=htobe16(identify_info[i+27]); 1730 (unsigned long)identify_info[60]) / 2048 );
1755 buf[40]=0; 1731 snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN,
1756 /* kill trailing space */ 1732 "Size: %s", buf);
1757 for (i=39; i && buf[i]==' '; i--) 1733 unsigned long free;
1758 buf[i] = 0; 1734 fat_size( IF_MV2(0,) NULL, &free );
1759 lcd_puts(0, y++, "Model"); 1735 snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN,
1760 lcd_puts_scroll(0, y++, buf); 1736 "Free: %ld MB", free / 1024);
1761 break; 1737 snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN,
1762 1738 "Spinup time: %d ms", ata_spinup_time * (1000/HZ));
1763 case 1: 1739 i = identify_info[83] & (1<<3);
1764 for (i=0; i < 4; i++) 1740 snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN,
1765 ((unsigned short*)buf)[i]=htobe16(identify_info[i+23]); 1741 "Power mgmt: %s", i ? "enabled" : "unsupported");
1766 buf[8]=0; 1742 i = identify_info[83] & (1<<9);
1767 lcd_puts(0, y++, "Firmware"); 1743 snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN,
1768 lcd_puts(0, y++, buf); 1744 "Noise mgmt: %s", i ? "enabled" : "unsupported");
1769 break; 1745 i = identify_info[82] & (1<<6);
1770 1746 snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN,
1771 case 2: 1747 "Read-ahead: %s", i ? "enabled" : "unsupported");
1772 snprintf(buf, sizeof buf, "%ld MB", 1748 timing_info_present = identify_info[53] & (1<<1);
1773 ((unsigned long)identify_info[61] << 16 | 1749 if(timing_info_present) {
1774 (unsigned long)identify_info[60]) / 2048 ); 1750 char pio3[2], pio4[2];pio3[1] = 0;
1775 lcd_puts(0, y++, "Size"); 1751 pio4[1] = 0;
1776 lcd_puts(0, y++, buf); 1752 pio3[0] = (identify_info[64] & (1<<0)) ? '3' : 0;
1777 break; 1753 pio4[0] = (identify_info[64] & (1<<1)) ? '4' : 0;
1778 1754 snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN,
1779 case 3: { 1755 "PIO modes: 0 1 2 %s %s", pio3, pio4);
1780 unsigned long free;
1781 fat_size( IF_MV2(0,) NULL, &free );
1782 snprintf(buf, sizeof buf, "%ld MB", free / 1024 );
1783 lcd_puts(0, y++, "Free");
1784 lcd_puts(0, y++, buf);
1785 break;
1786 }
1787
1788 case 4:
1789 snprintf(buf, sizeof buf, "%d ms", ata_spinup_time * (1000/HZ));
1790 lcd_puts(0, y++, "Spinup time");
1791 lcd_puts(0, y++, buf);
1792 break;
1793
1794 case 5:
1795 i = identify_info[83] & (1<<3);
1796 lcd_puts(0, y++, "Power mgmt:");
1797 lcd_puts(0, y++, i ? "enabled" : "unsupported");
1798 break;
1799
1800 case 6:
1801 i = identify_info[83] & (1<<9);
1802 lcd_puts(0, y++, "Noise mgmt:");
1803 lcd_puts(0, y++, i ? "enabled" : "unsupported");
1804 break;
1805
1806 case 7:
1807 i = identify_info[82] & (1<<6);
1808 lcd_puts(0, y++, "Read-ahead:");
1809 lcd_puts(0, y++, i ? "enabled" : "unsupported");
1810 break;
1811
1812 case 8:
1813 timing_info_present = identify_info[53] & (1<<1);
1814 if(timing_info_present) {
1815 pio3[1] = 0;
1816 pio4[1] = 0;
1817 lcd_puts(0, y++, "PIO modes:");
1818 pio3[0] = (identify_info[64] & (1<<0)) ? '3' : 0;
1819 pio4[0] = (identify_info[64] & (1<<1)) ? '4' : 0;
1820 snprintf(buf, 128, "0 1 2 %s %s", pio3, pio4);
1821 lcd_puts(0, y++, buf);
1822 } else {
1823 lcd_puts(0, y++, "No PIO mode info");
1824 }
1825 break;
1826
1827 case 9:
1828 timing_info_present = identify_info[53] & (1<<1);
1829 if(timing_info_present) {
1830 lcd_puts(0, y++, "Cycle times");
1831 snprintf(buf, 128, "%dns/%dns",
1832 identify_info[67],
1833 identify_info[68]);
1834 lcd_puts(0, y++, buf);
1835 } else {
1836 lcd_puts(0, y++, "No timing info");
1837 }
1838 break;
1839
1840 case 10:
1841 timing_info_present = identify_info[53] & (1<<1);
1842 if(timing_info_present) {
1843 i = identify_info[49] & (1<<11);
1844 snprintf(buf, 128, "IORDY support: %s", i ? "yes" : "no");
1845 lcd_puts(0, y++, buf);
1846 i = identify_info[49] & (1<<10);
1847 snprintf(buf, 128, "IORDY disable: %s", i ? "yes" : "no");
1848 lcd_puts(0, y++, buf);
1849 } else {
1850 lcd_puts(0, y++, "No timing info");
1851 }
1852 break;
1853
1854 case 11:
1855 lcd_puts(0, y++, "Cluster size");
1856 snprintf(buf, 128, "%d bytes", fat_get_cluster_size(IF_MV(0)));
1857 lcd_puts(0, y++, buf);
1858 break;
1859 }
1860 lcd_update();
1861
1862 /* Wait for a key to be pushed */
1863 key = get_action(CONTEXT_SETTINGS,HZ/5);
1864 switch(key) {
1865 case ACTION_STD_CANCEL:
1866 done = true;
1867 break;
1868
1869 case ACTION_SETTINGS_DEC:
1870 if (--page < 0)
1871 page = max_page;
1872 break;
1873
1874 case ACTION_SETTINGS_INC:
1875 if (++page > max_page)
1876 page = 0;
1877 break;
1878 }
1879 lcd_stop_scroll();
1880 } 1756 }
1881 action_signalscreenchange(); 1757 else {
1758 snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN,
1759 "No PIO mode info");
1760 }
1761 timing_info_present = identify_info[53] & (1<<1);
1762 if(timing_info_present) {
1763 snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN,
1764 "Cycle times %dns/%dns",
1765 identify_info[67],
1766 identify_info[68] );
1767 } else {
1768 snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN,
1769 "No timing info");
1770 }
1771 timing_info_present = identify_info[53] & (1<<1);
1772 if(timing_info_present) {
1773 i = identify_info[49] & (1<<11);
1774 snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN,
1775 "IORDY support: %s", i ? "yes" : "no");
1776 i = identify_info[49] & (1<<10);
1777 snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN,
1778 "IORDY disable: %s", i ? "yes" : "no");
1779 } else {
1780 snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN,
1781 "No timing info");
1782 }
1783 snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN,
1784 "Cluster size: %d bytes", fat_get_cluster_size(IF_MV(0)));
1785 return btn;
1786}
1787static bool dbg_disk_info(void)
1788{
1789 disk_callback(0,0);
1790 dbg_list("Disk Info",disklines, 1, disk_callback, dbg_listmessage_getname);
1882 return false; 1791 return false;
1883} 1792}
1884#endif /* !defined(HAVE_MMC) && !defined(HAVE_HOTSWAP) */ 1793#endif /* !defined(HAVE_MMC) && !defined(HAVE_HOTSWAP) */
@@ -2292,14 +2201,8 @@ static const struct the_menu_item menuitems[] = {
2292 { "View partitions", dbg_partitions }, 2201 { "View partitions", dbg_partitions },
2293#endif 2202#endif
2294#ifndef SIMULATOR 2203#ifndef SIMULATOR
2295#if defined(HAVE_MMC)
2296 { "View MMC info", dbg_card_info },
2297#elif defined(HAVE_HOTSWAP)
2298 { "View microSD info", dbg_card_info },
2299#else
2300 { "View disk info", dbg_disk_info }, 2204 { "View disk info", dbg_disk_info },
2301#endif 2205#endif
2302#endif
2303#ifdef HAVE_DIRCACHE 2206#ifdef HAVE_DIRCACHE
2304 { "View dircache info", dbg_dircache_info }, 2207 { "View dircache info", dbg_dircache_info },
2305#endif 2208#endif