add dump eeprom option (-d) to ath_info to dump the entire contents

of the eeprom to the screen and to a file


git-svn-id: http://madwifi-project.org/svn/madwifi/trunk@2750 0192ed92-7a03-0410-a25b-9323aeb14dbd
This commit is contained in:
br1 2007-10-16 12:32:26 +00:00
parent 66c5993fc6
commit ab34867986

View File

@ -691,13 +691,14 @@ usage(const char *n)
{
int i;
fprintf(stderr, "%s [-w [-g N:M]] [-v] [-f] <base_address> "
fprintf(stderr, "%s [-w [-g N:M]] [-v] [-f] [-d] <base_address> "
"[<name1> <val1> [<name2> <val2> ...]]\n\n", n);
fprintf(stderr,
"-w write values into EEPROM\n"
"-g N:M set GPIO N to level M (only used with -w)\n"
"-v verbose output\n"
"-f force; suppress question before writing\n"
"-d dump eeprom (file 'ath-eeprom-dump.bin' and screen)\n"
"<base_address> device base address (see lspci output)\n\n");
fprintf(stderr,
@ -728,10 +729,13 @@ main(int argc, char *argv[])
u_int16_t eeprom_header, srev, phy_rev_5ghz, phy_rev_2ghz;
u_int16_t eeprom_version, mac_version, regdomain, has_crystal, ee_magic;
u_int8_t error, has_a, has_b, has_g, has_rfkill, eeprom_size;
int byte_size=0;
void *mem;
int fd;
int i, anr=1;
int do_write=0; /* default: read only */
int do_dump=0;
struct {
int valid;
int value;
@ -773,6 +777,10 @@ main(int argc, char *argv[])
verbose=1;
break;
case 'd':
do_dump=1;
break;
case 'h':
usage(argv[0]);
return 0;
@ -949,12 +957,18 @@ main(int argc, char *argv[])
printf("EEPROM Size: ");
if (eeprom_size == 0)
if (eeprom_size == 0) {
printf(" 4K\n");
else if (eeprom_size == 1)
byte_size = 4096;
}
else if (eeprom_size == 1) {
printf(" 8K\n");
else if (eeprom_size == 2)
byte_size = 8192;
}
else if (eeprom_size == 2) {
printf(" 16K\n");
byte_size = 16384;
}
else
printf(" ??\n");
@ -1000,6 +1014,26 @@ main(int argc, char *argv[])
AR5K_REG_READ(AR5K_GPIOCR), AR5K_REG_READ(AR5K_GPIODO),
AR5K_REG_READ(AR5K_GPIODI));
if (do_dump) {
printf("\nEEPROM dump (%d byte)\n", byte_size);
printf("==============================================");
u_int16_t data;
FILE* dumpfile = fopen("ath-eeprom-dump.bin", "w");
for (i=1; i<=(byte_size/2); i++) {
error = ath5k_hw_eeprom_read(mem, i, &data, mac_version);
if (error) {
printf("\nUnable to read at %04x !\n", i);
continue;
}
if (!((i-1)%8))
printf("\n%04x: ",i);
printf("%04x ", data);
fwrite(&data, 2, 1, dumpfile);
}
printf("\n==============================================\n");
fclose(dumpfile);
}
if (do_write) {
unsigned long int rcr=AR5K_REG_READ(AR5K_GPIOCR),
rdo=AR5K_REG_READ(AR5K_GPIODO);