1
0
Fork 0
forked from len0rd/rockbox

convert the disk info debug screen to a list.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13863 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jonathan Gordon 2007-07-12 09:58:54 +00:00
parent 00251d1643
commit d7dd23939a

View file

@ -89,7 +89,7 @@
#include "hwcompat.h" #include "hwcompat.h"
#if defined(HAVE_DIRCACHE) || defined(HAVE_TAGCACHE) || CONFIG_TUNER #if defined(HAVE_DIRCACHE) || defined(HAVE_TAGCACHE) || CONFIG_TUNER
#define MAX_DEBUG_MESSAGES 8 #define MAX_DEBUG_MESSAGES 16
#define DEBUG_MSG_LEN 32 #define DEBUG_MSG_LEN 32
char debug_list_messages[MAX_DEBUG_MESSAGES][DEBUG_MSG_LEN]; char debug_list_messages[MAX_DEBUG_MESSAGES][DEBUG_MSG_LEN];
static char* dbg_listmessage_getname(int item, void * data, char *buffer) static char* dbg_listmessage_getname(int item, void * data, char *buffer)
@ -1607,278 +1607,187 @@ static bool view_battery(void)
#ifndef SIMULATOR #ifndef SIMULATOR
#if defined(HAVE_MMC) || defined(HAVE_HOTSWAP) #if defined(HAVE_MMC) || defined(HAVE_HOTSWAP)
static bool dbg_card_info(void) static int cardinfo_lines = 0,
current_card = 1; /* the first call changes this card to 0 */
static int cardinfo_callback(int btn, struct gui_synclist *lists)
{ {
bool done = false;
int currval = 0;
int line;
tCardInfo *card; tCardInfo *card;
unsigned char pbuf[32], pbuf2[32];
unsigned char card_name[7]; unsigned char card_name[7];
unsigned char pbuf[32];
static char listtitle[16];
static const unsigned char i_vmin[] = { 0, 1, 5, 10, 25, 35, 60, 100 }; static const unsigned char i_vmin[] = { 0, 1, 5, 10, 25, 35, 60, 100 };
static const unsigned char i_vmax[] = { 1, 5, 10, 25, 35, 45, 80, 200 }; static const unsigned char i_vmax[] = { 1, 5, 10, 25, 35, 45, 80, 200 };
static const unsigned char *kbit_units[] = { "kBit/s", "MBit/s", "GBit/s" }; static const unsigned char *kbit_units[] = { "kBit/s", "MBit/s", "GBit/s" };
static const unsigned char *nsec_units[] = { "ns", "µs", "ms" }; static const unsigned char *nsec_units[] = { "ns", "µs", "ms" };
static const char *spec_vers[] = { "1.0-1.2", "1.4", "2.0-2.2", static const char *spec_vers[] = { "1.0-1.2", "1.4", "2.0-2.2",
"3.1-3.31", "4.0" }; "3.1-3.31", "4.0" };
if ((btn == ACTION_STD_OK) || (btn == SYS_FS_CHANGED))/* change cards */
card_name[6] = '\0';
lcd_setmargins(0, 0);
lcd_setfont(FONT_SYSFIXED);
while (!done)
{ {
card = card_get_info(currval / 2); if (btn == ACTION_STD_OK)
current_card ^= 0x1;
line = 0; cardinfo_lines = 0;
lcd_clear_display(); card = card_get_info(current_card);
snprintf(pbuf, sizeof(pbuf), "[MMC%d p%d]", currval / 2,
(currval % 2) + 1);
lcd_puts(0, line++, pbuf);
if (card->initialized) if (card->initialized)
{ {
if (!(currval % 2)) /* General info */ card_name[6] = '\0';
{ strncpy(card_name, ((unsigned char*)card->cid) + 3, 6);
int temp; snprintf(debug_list_messages[cardinfo_lines++], DEBUG_MSG_LEN,
"%s Rev %d.%d", card_name,
strncpy(card_name, ((unsigned char*)card->cid) + 3, 6); (int) card_extract_bits(card->cid, 72, 4),
snprintf(pbuf, sizeof(pbuf), "%s Rev %d.%d", card_name, (int) card_extract_bits(card->cid, 76, 4));
(int) card_extract_bits(card->cid, 72, 4), snprintf(debug_list_messages[cardinfo_lines++], DEBUG_MSG_LEN,
(int) card_extract_bits(card->cid, 76, 4)); "Prod: %d/%d",
lcd_puts(0, line++, pbuf); (int) card_extract_bits(card->cid, 112, 4),
snprintf(pbuf, sizeof(pbuf), "Prod: %d/%d", (int) card_extract_bits(card->cid, 116, 4) + 1997);
(int) card_extract_bits(card->cid, 112, 4), snprintf(debug_list_messages[cardinfo_lines++], DEBUG_MSG_LEN,
(int) card_extract_bits(card->cid, 116, 4) + 1997); "Ser#: 0x%08lx",
lcd_puts(0, line++, pbuf); card_extract_bits(card->cid, 80, 32));
snprintf(pbuf, sizeof(pbuf), "Ser#: 0x%08lx", snprintf(debug_list_messages[cardinfo_lines++], DEBUG_MSG_LEN,
card_extract_bits(card->cid, 80, 32)); "M=%02x, O=%04x",
lcd_puts(0, line++, pbuf); (int) card_extract_bits(card->cid, 0, 8),
snprintf(pbuf, sizeof(pbuf), "M=%02x, O=%04x", (int) card_extract_bits(card->cid, 8, 16));
(int) card_extract_bits(card->cid, 0, 8), int temp = card_extract_bits(card->csd, 2, 4);
(int) card_extract_bits(card->cid, 8, 16)); snprintf(debug_list_messages[cardinfo_lines++], DEBUG_MSG_LEN,
lcd_puts(0, line++, pbuf); "MMC v%s", temp < 5 ?
temp = card_extract_bits(card->csd, 2, 4); spec_vers[temp] : "?.?");
snprintf(pbuf, sizeof(pbuf), "MMC v%s", temp < 5 ? snprintf(debug_list_messages[cardinfo_lines++], DEBUG_MSG_LEN,
spec_vers[temp] : "?.?"); "Blocks: 0x%06lx", card->numblocks);
lcd_puts(0, line++, pbuf); snprintf(debug_list_messages[cardinfo_lines++], DEBUG_MSG_LEN,
snprintf(pbuf, sizeof(pbuf), "Blocks: 0x%06lx", card->numblocks); "Blksz.: %d P:%c%c", card->blocksize,
lcd_puts(0, line++, pbuf); card_extract_bits(card->csd, 48, 1) ? 'R' : '-',
snprintf(pbuf, sizeof(pbuf), "Blksz.: %d P:%c%c", card->blocksize, card_extract_bits(card->csd, 106, 1) ? 'W' : '-');
card_extract_bits(card->csd, 48, 1) ? 'R' : '-', output_dyn_value(pbuf, sizeof pbuf, card->speed / 1000,
card_extract_bits(card->csd, 106, 1) ? 'W' : '-'); kbit_units, false);
lcd_puts(0, line++, pbuf); snprintf(debug_list_messages[cardinfo_lines++], DEBUG_MSG_LEN,
} "Speed: %s", pbuf);
else /* Technical details */ output_dyn_value(pbuf, sizeof pbuf, card->tsac,
{ nsec_units, false);
output_dyn_value(pbuf2, sizeof pbuf2, card->speed / 1000, snprintf(debug_list_messages[cardinfo_lines++], DEBUG_MSG_LEN,
kbit_units, false); "Tsac: %s", pbuf);
snprintf(pbuf, sizeof pbuf, "Speed: %s", pbuf2); snprintf(debug_list_messages[cardinfo_lines++], DEBUG_MSG_LEN,
lcd_puts(0, line++, pbuf); "Nsac: %d clk", card->nsac);
snprintf(debug_list_messages[cardinfo_lines++], DEBUG_MSG_LEN,
output_dyn_value(pbuf2, sizeof pbuf2, card->tsac, "R2W: *%d", card->r2w_factor);
nsec_units, false); snprintf(debug_list_messages[cardinfo_lines++], DEBUG_MSG_LEN,
snprintf(pbuf, sizeof pbuf, "Tsac: %s", pbuf2); "IRmax: %d..%d mA",
lcd_puts(0, line++, pbuf); i_vmin[card_extract_bits(card->csd, 66, 3)],
i_vmax[card_extract_bits(card->csd, 69, 3)]);
snprintf(pbuf, sizeof(pbuf), "Nsac: %d clk", card->nsac); snprintf(debug_list_messages[cardinfo_lines++], DEBUG_MSG_LEN,
lcd_puts(0, line++, pbuf); "IWmax: %d..%d mA",
snprintf(pbuf, sizeof(pbuf), "R2W: *%d", card->r2w_factor); i_vmin[card_extract_bits(card->csd, 72, 3)],
lcd_puts(0, line++, pbuf); i_vmax[card_extract_bits(card->csd, 75, 3)]);
snprintf(pbuf, sizeof(pbuf), "IRmax: %d..%d mA",
i_vmin[card_extract_bits(card->csd, 66, 3)],
i_vmax[card_extract_bits(card->csd, 69, 3)]);
lcd_puts(0, line++, pbuf);
snprintf(pbuf, sizeof(pbuf), "IWmax: %d..%d mA",
i_vmin[card_extract_bits(card->csd, 72, 3)],
i_vmax[card_extract_bits(card->csd, 75, 3)]);
lcd_puts(0, line++, pbuf);
}
} }
else else
lcd_puts(0, line++, "Not found!");
lcd_update();
switch (get_action(CONTEXT_SETTINGS,HZ/2))
{ {
case ACTION_STD_CANCEL: snprintf(debug_list_messages[cardinfo_lines++], DEBUG_MSG_LEN,
done = true; "Not Found!");
break; }
if (lists)
case ACTION_SETTINGS_DEC: {
currval--; snprintf(listtitle, sizeof listtitle,
if (currval < 0) "[MMC/microSD %d]", current_card);
currval = 3; gui_synclist_set_title(lists, listtitle, NOICON);
break; gui_synclist_select_item(lists, 0);
gui_synclist_set_nb_items(lists, cardinfo_lines);
case ACTION_SETTINGS_INC: gui_synclist_draw(lists);
currval++;
if (currval > 3)
currval = 0;
break;
} }
} }
action_signalscreenchange(); return btn;
}
static bool dbg_disk_info(void)
{
current_card = 1; /* the callback changes this to 0 */
cardinfo_callback(ACTION_STD_OK, 0);
dbg_list("[MMC/microSD 0]", cardinfo_lines, 1,
cardinfo_callback, dbg_listmessage_getname);
return false; return false;
} }
#else /* !defined(HAVE_MMC) && !defined(HAVE_HOTSWAP) */ #else /* !defined(HAVE_MMC) && !defined(HAVE_HOTSWAP) */
static bool dbg_disk_info(void) static int disklines = 0;
static int disk_callback(int btn, struct gui_synclist *lists)
{ {
char buf[128];
bool done = false;
int i; int i;
int page = 0; char buf[128];
const int max_page = 11;
unsigned short* identify_info = ata_get_identify(); unsigned short* identify_info = ata_get_identify();
bool timing_info_present = false; bool timing_info_present = false;
char pio3[2], pio4[2]; (void)btn; (void)lists;
disklines = 0;
lcd_setmargins(0, 0); for (i=0; i < 20; i++)
((unsigned short*)buf)[i]=htobe16(identify_info[i+27]);
while(!done) buf[40]=0;
{ /* kill trailing space */
int y=0; for (i=39; i && buf[i]==' '; i--)
int key; buf[i] = 0;
lcd_clear_display(); snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN,
#ifdef HAVE_LCD_BITMAP "Model: %s", buf);
lcd_puts(0, y++, "Disk info:"); for (i=0; i < 4; i++)
y++; ((unsigned short*)buf)[i]=htobe16(identify_info[i+23]);
#endif buf[8]=0;
snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN,
switch (page) { "Firmare: %s", buf);
case 0: snprintf(buf, sizeof buf, "%ld MB",
for (i=0; i < 20; i++) ((unsigned long)identify_info[61] << 16 |
((unsigned short*)buf)[i]=htobe16(identify_info[i+27]); (unsigned long)identify_info[60]) / 2048 );
buf[40]=0; snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN,
/* kill trailing space */ "Size: %s", buf);
for (i=39; i && buf[i]==' '; i--) unsigned long free;
buf[i] = 0; fat_size( IF_MV2(0,) NULL, &free );
lcd_puts(0, y++, "Model"); snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN,
lcd_puts_scroll(0, y++, buf); "Free: %ld MB", free / 1024);
break; snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN,
"Spinup time: %d ms", ata_spinup_time * (1000/HZ));
case 1: i = identify_info[83] & (1<<3);
for (i=0; i < 4; i++) snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN,
((unsigned short*)buf)[i]=htobe16(identify_info[i+23]); "Power mgmt: %s", i ? "enabled" : "unsupported");
buf[8]=0; i = identify_info[83] & (1<<9);
lcd_puts(0, y++, "Firmware"); snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN,
lcd_puts(0, y++, buf); "Noise mgmt: %s", i ? "enabled" : "unsupported");
break; i = identify_info[82] & (1<<6);
snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN,
case 2: "Read-ahead: %s", i ? "enabled" : "unsupported");
snprintf(buf, sizeof buf, "%ld MB", timing_info_present = identify_info[53] & (1<<1);
((unsigned long)identify_info[61] << 16 | if(timing_info_present) {
(unsigned long)identify_info[60]) / 2048 ); char pio3[2], pio4[2];pio3[1] = 0;
lcd_puts(0, y++, "Size"); pio4[1] = 0;
lcd_puts(0, y++, buf); pio3[0] = (identify_info[64] & (1<<0)) ? '3' : 0;
break; pio4[0] = (identify_info[64] & (1<<1)) ? '4' : 0;
snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN,
case 3: { "PIO modes: 0 1 2 %s %s", pio3, pio4);
unsigned long free;
fat_size( IF_MV2(0,) NULL, &free );
snprintf(buf, sizeof buf, "%ld MB", free / 1024 );
lcd_puts(0, y++, "Free");
lcd_puts(0, y++, buf);
break;
}
case 4:
snprintf(buf, sizeof buf, "%d ms", ata_spinup_time * (1000/HZ));
lcd_puts(0, y++, "Spinup time");
lcd_puts(0, y++, buf);
break;
case 5:
i = identify_info[83] & (1<<3);
lcd_puts(0, y++, "Power mgmt:");
lcd_puts(0, y++, i ? "enabled" : "unsupported");
break;
case 6:
i = identify_info[83] & (1<<9);
lcd_puts(0, y++, "Noise mgmt:");
lcd_puts(0, y++, i ? "enabled" : "unsupported");
break;
case 7:
i = identify_info[82] & (1<<6);
lcd_puts(0, y++, "Read-ahead:");
lcd_puts(0, y++, i ? "enabled" : "unsupported");
break;
case 8:
timing_info_present = identify_info[53] & (1<<1);
if(timing_info_present) {
pio3[1] = 0;
pio4[1] = 0;
lcd_puts(0, y++, "PIO modes:");
pio3[0] = (identify_info[64] & (1<<0)) ? '3' : 0;
pio4[0] = (identify_info[64] & (1<<1)) ? '4' : 0;
snprintf(buf, 128, "0 1 2 %s %s", pio3, pio4);
lcd_puts(0, y++, buf);
} else {
lcd_puts(0, y++, "No PIO mode info");
}
break;
case 9:
timing_info_present = identify_info[53] & (1<<1);
if(timing_info_present) {
lcd_puts(0, y++, "Cycle times");
snprintf(buf, 128, "%dns/%dns",
identify_info[67],
identify_info[68]);
lcd_puts(0, y++, buf);
} else {
lcd_puts(0, y++, "No timing info");
}
break;
case 10:
timing_info_present = identify_info[53] & (1<<1);
if(timing_info_present) {
i = identify_info[49] & (1<<11);
snprintf(buf, 128, "IORDY support: %s", i ? "yes" : "no");
lcd_puts(0, y++, buf);
i = identify_info[49] & (1<<10);
snprintf(buf, 128, "IORDY disable: %s", i ? "yes" : "no");
lcd_puts(0, y++, buf);
} else {
lcd_puts(0, y++, "No timing info");
}
break;
case 11:
lcd_puts(0, y++, "Cluster size");
snprintf(buf, 128, "%d bytes", fat_get_cluster_size(IF_MV(0)));
lcd_puts(0, y++, buf);
break;
}
lcd_update();
/* Wait for a key to be pushed */
key = get_action(CONTEXT_SETTINGS,HZ/5);
switch(key) {
case ACTION_STD_CANCEL:
done = true;
break;
case ACTION_SETTINGS_DEC:
if (--page < 0)
page = max_page;
break;
case ACTION_SETTINGS_INC:
if (++page > max_page)
page = 0;
break;
}
lcd_stop_scroll();
} }
action_signalscreenchange(); else {
snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN,
"No PIO mode info");
}
timing_info_present = identify_info[53] & (1<<1);
if(timing_info_present) {
snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN,
"Cycle times %dns/%dns",
identify_info[67],
identify_info[68] );
} else {
snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN,
"No timing info");
}
timing_info_present = identify_info[53] & (1<<1);
if(timing_info_present) {
i = identify_info[49] & (1<<11);
snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN,
"IORDY support: %s", i ? "yes" : "no");
i = identify_info[49] & (1<<10);
snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN,
"IORDY disable: %s", i ? "yes" : "no");
} else {
snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN,
"No timing info");
}
snprintf(debug_list_messages[disklines++], DEBUG_MSG_LEN,
"Cluster size: %d bytes", fat_get_cluster_size(IF_MV(0)));
return btn;
}
static bool dbg_disk_info(void)
{
disk_callback(0,0);
dbg_list("Disk Info",disklines, 1, disk_callback, dbg_listmessage_getname);
return false; return false;
} }
#endif /* !defined(HAVE_MMC) && !defined(HAVE_HOTSWAP) */ #endif /* !defined(HAVE_MMC) && !defined(HAVE_HOTSWAP) */
@ -2292,14 +2201,8 @@ static const struct the_menu_item menuitems[] = {
{ "View partitions", dbg_partitions }, { "View partitions", dbg_partitions },
#endif #endif
#ifndef SIMULATOR #ifndef SIMULATOR
#if defined(HAVE_MMC)
{ "View MMC info", dbg_card_info },
#elif defined(HAVE_HOTSWAP)
{ "View microSD info", dbg_card_info },
#else
{ "View disk info", dbg_disk_info }, { "View disk info", dbg_disk_info },
#endif #endif
#endif
#ifdef HAVE_DIRCACHE #ifdef HAVE_DIRCACHE
{ "View dircache info", dbg_dircache_info }, { "View dircache info", dbg_dircache_info },
#endif #endif