Changeset 362 for trunk/flashrom.c


Ignore:
Timestamp:
Dec 6, 2008 2:37:09 AM (4 years ago)
Author:
stuge
Message:

Original v2 revision: 3803

flashrom: Display test status in -L chip listing

Looks like this:

Supported flash chips: Tested OK operations: Known BAD operations:

AMD Am29F002(N)BB
AMD Am29F002(N)BT PROBE READ ERASE WRITE
AMD Am29F016D
AMD Am29F040B PROBE READ ERASE WRITE
AMD Am29LV040B
Atmel AT45CS1282 READ

Signed-off-by: Peter Stuge <peter@…>
Acked-by: Uwe Hermann <uwe@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/flashrom.c

    r360 r362  
    206206} 
    207207 
     208#define MAX(a, b) ((a) > (b) ? (a) : (b)) 
     209#define POS_PRINT(x) do { pos += strlen(x); printf(x); } while (0) 
     210 
    208211void print_supported_chips(void) 
    209212{ 
    210         int i; 
    211  
    212         printf("Supported ROM chips:\n\n"); 
    213  
    214         for (i = 0; flashchips[i].name != NULL; i++) 
    215                 printf("%s %s\n", flashchips[i].vendor, flashchips[i].name); 
     213        int okcol = 0, pos = 0; 
     214        struct flashchip *f; 
     215 
     216        for (f = flashchips; f->name != NULL; f++) { 
     217                if (GENERIC_DEVICE_ID == f->model_id) 
     218                        continue; 
     219                okcol = MAX(okcol, strlen(f->vendor) + 1 + strlen(f->name)); 
     220        } 
     221        okcol = (okcol + 7) & ~7; 
     222 
     223        POS_PRINT("Supported flash chips:"); 
     224        while (pos < okcol) { 
     225                printf("\t"); 
     226                pos += 8 - (pos % 8); 
     227        } 
     228        printf("Tested OK operations:\tKnown BAD operations:\n\n"); 
     229 
     230        for (f = flashchips; f->name != NULL; f++) { 
     231                printf("%s %s", f->vendor, f->name); 
     232                pos = strlen(f->vendor) + 1 + strlen(f->name); 
     233                while (pos < okcol) { 
     234                        printf("\t"); 
     235                        pos += 8 - (pos % 8); 
     236                } 
     237                if ((f->tested & TEST_OK_MASK)) { 
     238                        if ((f->tested & TEST_OK_PROBE)) 
     239                                POS_PRINT("PROBE "); 
     240                        if ((f->tested & TEST_OK_READ)) 
     241                                POS_PRINT("READ "); 
     242                        if ((f->tested & TEST_OK_ERASE)) 
     243                                POS_PRINT("ERASE "); 
     244                        if ((f->tested & TEST_OK_WRITE)) 
     245                                POS_PRINT("WRITE"); 
     246                } 
     247                while (pos < okcol + 24) { 
     248                        printf("\t"); 
     249                        pos += 8 - (pos % 8); 
     250                } 
     251                if ((f->tested & TEST_BAD_MASK)) { 
     252                        if ((f->tested & TEST_BAD_PROBE)) 
     253                                printf("PROBE "); 
     254                        if ((f->tested & TEST_BAD_READ)) 
     255                                printf("READ "); 
     256                        if ((f->tested & TEST_BAD_ERASE)) 
     257                                printf("ERASE "); 
     258                        if ((f->tested & TEST_BAD_WRITE)) 
     259                                printf("WRITE"); 
     260                } 
     261                printf("\n"); 
     262        } 
    216263} 
    217264 
Note: See TracChangeset for help on using the changeset viewer.