Changeset 2750

Show
Ignore:
Timestamp:
10/16/07 14:32:26 (1 year ago)
Author:
br1
Message:

add dump eeprom option (-d) to ath_info to dump the entire contents
of the eeprom to the screen and to a file

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • madwifi/trunk/tools/ath_info.c

    r2707 r2750  
    692692        int i; 
    693693 
    694         fprintf(stderr, "%s [-w [-g N:M]] [-v] [-f] <base_address> " 
     694        fprintf(stderr, "%s [-w [-g N:M]] [-v] [-f] [-d] <base_address> " 
    695695                "[<name1> <val1> [<name2> <val2> ...]]\n\n", n); 
    696696        fprintf(stderr, 
     
    699699                "-v      verbose output\n" 
    700700                "-f      force; suppress question before writing\n" 
     701                "-d      dump eeprom (file 'ath-eeprom-dump.bin' and screen)\n" 
    701702                "<base_address>  device base address (see lspci output)\n\n"); 
    702703 
     
    729730        u_int16_t eeprom_version, mac_version, regdomain, has_crystal, ee_magic; 
    730731        u_int8_t error, has_a, has_b, has_g, has_rfkill, eeprom_size; 
     732        int byte_size=0; 
    731733        void *mem; 
    732734        int fd; 
    733735        int i, anr=1; 
    734736        int do_write=0; /* default: read only */ 
     737        int do_dump=0; 
     738 
    735739        struct { 
    736740                int valid; 
     
    774778                        break; 
    775779 
     780                case 'd': 
     781                        do_dump=1; 
     782                        break; 
     783 
    776784                case 'h': 
    777785                        usage(argv[0]); 
     
    950958        printf("EEPROM Size: "); 
    951959 
    952         if (eeprom_size == 0) 
     960        if (eeprom_size == 0) { 
    953961                printf("       4K\n"); 
    954         else if (eeprom_size == 1) 
     962                byte_size = 4096; 
     963        } 
     964        else if (eeprom_size == 1) { 
    955965                printf("       8K\n"); 
    956         else if (eeprom_size == 2) 
     966                byte_size = 8192; 
     967        } 
     968        else if (eeprom_size == 2) { 
    957969                printf("       16K\n"); 
     970                byte_size = 16384; 
     971        } 
    958972        else 
    959973                printf("       ??\n"); 
     
    10001014               AR5K_REG_READ(AR5K_GPIOCR), AR5K_REG_READ(AR5K_GPIODO), 
    10011015               AR5K_REG_READ(AR5K_GPIODI)); 
     1016 
     1017        if (do_dump) { 
     1018                printf("\nEEPROM dump (%d byte)\n", byte_size); 
     1019                printf("=============================================="); 
     1020                u_int16_t data; 
     1021                FILE* dumpfile = fopen("ath-eeprom-dump.bin", "w"); 
     1022                for (i=1; i<=(byte_size/2); i++) { 
     1023                        error = ath5k_hw_eeprom_read(mem, i, &data, mac_version); 
     1024                        if (error) { 
     1025                                printf("\nUnable to read at %04x !\n", i); 
     1026                                continue; 
     1027                        } 
     1028                        if (!((i-1)%8)) 
     1029                                printf("\n%04x:  ",i); 
     1030                        printf("%04x ", data); 
     1031                        fwrite(&data, 2, 1, dumpfile); 
     1032                } 
     1033                printf("\n==============================================\n"); 
     1034                fclose(dumpfile); 
     1035        } 
    10021036 
    10031037        if (do_write) {