/* Check our hardware type table for this type. */ struct hwtype *get_hwntype(int type) { struct hwtype **hwp; if (!sVhwinit) hwinit(); hwp = hwtypes; while (*hwp != NULL) { if ((*hwp)->type == type) return (*hwp); hwp++; } return (NULL); }
/* Check our hardware type table for this type. */ struct hwtype *get_hwtype(const char *name) { struct hwtype **hwp; if (!sVhwinit) hwinit(); hwp = hwtypes; while (*hwp != NULL) { if (!strcmp((*hwp)->name, name)) return (*hwp); hwp++; } return (NULL); }
/* type: 0=all, 1=ARPable */ void print_hwlist(int type) { int count = 0; char * txt; struct hwtype **hwp; if (!sVhwinit) hwinit(); hwp = hwtypes; while (*hwp != NULL) { if (((type == 1) && ((*hwp)->alen == 0)) || ((*hwp)->type == -1)) { hwp++; continue; } if ((count % 3) == 0) fprintf(stderr,count?"\n ":" "); txt = (*hwp)->name; if (!txt) txt = ".."; fprintf(stderr,"%s (%s) ",txt,(*hwp)->title); count++; hwp++; } fprintf(stderr,"\n"); }
int main(int argc, char *argv[]) #endif { u8 sta = 0, cmd; int i; #ifndef __AVR__ if (argc > 3 || argc < 2) { printf("Usage: (sudo) testfat rawdevice e.g. fat32 /dev/sdb \r\n"); return 1; } // fcntl(0, F_SETFL, fcntl(0, F_GETFL) | O_NONBLOCK); if (initsec(argv[1])) return -1; #endif hwinit(); printf("\nFAT32 Test\n"); i = sdhcinit(); printf("init %d\n", i); if (!i) { printf( "%lu sects\n", sdnumsectors ); i = mount(0); printf("Mount: %d\n", i); if (!i) seekfile(0, 0); #if 1 // show what is read else for (i = 0; i < 1; i++) { readsec(i); dumpsect(); } #endif } if (i) printf("Not Ready\n"); for (;;) { cmd = tzgetchar(); if (cmd >= 'a') cmd -= 32; switch (cmd) { #ifdef __AVR__ case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': // while (!tzkbhit()) { ADMUX = 0xe0 + cmd - '0'; ADCSRA = 0xc7; while (ADCSRA & 0x40); printf("%c %04x\n", cmd, ADC); // } break; #endif case 3: case 26: case 'Q': exit(0); case 'Y': { u16 u; u = getdirent((u8 *) ""); printf("%u entries in dir\n", u); } break; case 'I': sta = sdhcinit(); printf("init %d\n", sta); if (sta) continue; printf( "%lu sects\n", sdnumsectors ); sta = cardinfo(0); printf("inf %d\n", sta); if (sta) continue; for (sta = 0; sta < 18; sta++) printf("%02X", filesectbuf[sta]); printf(" "); for (sta = 0; sta < 18; sta++) printf("%c", dochar(filesectbuf[sta])); printf("\n"); sta = cardinfo(1); printf("inf %d\n", sta); if (sta) continue; for (sta = 0; sta < 18; sta++) printf("%02X", filesectbuf[sta]); printf(" "); for (sta = 0; sta < 18; sta++) printf("%c", dochar(filesectbuf[sta])); printf("\n"); break; case 'M': i = mount(0); if (!i) printf("Mounted\n"); else printf("Error\n"); break; case 'O': printf("Open:\n"); i = getfname(); if (i < 0) { printf("bad fname\n"); break; } i = getdirent(filename); if (i == 2) printf("Entered Dir\n"); else if (!i) printf("Opened\n"); else printf("Not Found\n"); break; case 'C': printf("Create:\n"); i = getfname(); if (i < 0) { printf("bad fname\n"); break; } if (i == 1) { printf("Directory:\n"); i = getfname(); if (i) { printf("bad fname\n"); break; } i = 0x10; // directory attribute } i = newdirent(filename, i); if (!i) printf("Created\n"); else if (i == 2) printf("Exists\n"); else printf("Error\n"); break; case 'N': i = newdirent(NULL, 0); if (!i) printf("Created Ser Log\n"); else printf("Error\n"); break; case 'L': resettodir(); seekfile(0, 0); for (i = 0; i < 16; i++) { if (!filesectbuf[i << 5]) break; if (0xe5 == filesectbuf[i << 5]) { printf("(del)\n"); continue; } if (0xf == filesectbuf[(i << 5) + 11]) { printf("(lfn)\n"); continue; } printf("%8.8s.%3.3s %c\n", &filesectbuf[i << 5], &filesectbuf[(i << 5) + 8], filesectbuf[(i << 5) + 11] & 0x10 ? '/' : ' '); if (i == 15) { i = readnextsect(); if (i != 512) break; i = -1; } } break; case 'W': printf("Write: ^c|^z to exit\n"); for (;;) { char cx; cx = tzgetchar(); if (cx == 3 || cx == 26) break; writebyte(cx); printf("%c", cx); } printf("\nWritten "); flushbuf(); printf("Flushed "); syncdirent(0); printf("DSynced\n"); break; case 'F': flushbuf(); printf("Flushed\n"); break; case 'E': syncdirent(0); printf("dirsynced\n"); break; case 'P': syncdirent(1); printf("size pushed\n"); break; case 'Z': zaphint(); printf("hint zapped\n"); break; case 'T': truncatefile(); printf("Trunc-ed\n"); break; case 'D': i = deletefile(); if (i == 1) printf("no rmdir\n"); else if (!i) printf("Deleted\n"); else printf("Error\n"); break; // will go away when seek is filled in case 'A': seekfile(0, 2); printf("At EOF\n"); break; case 'S': { u32 x = 0; u8 y = 1; seekfile(x, y); printf("Rewound\n"); } break; case 'R': case 'V': case 'X': sta = 0; while (!tzkbhit()) { i = readbyte(); if (i < 0) { printf("\n=EOF=\n"); break; } switch (cmd) { case 'R': printf("%c", i); break; case 'V': printf("%c", dochar(i)); break; case 'X': if (!(sta++ & 15)) printf("\n"); printf("%02X", i); break; } } break; case 'U': resetrootdir(); seekfile(0, 0); // for list printf("At rootdir\n"); break; case 'G': resettodir(); seekfile(0, 0); // for list printf("At curdir\n"); break; default: // help message { char *c = mainmenu; while (pgm_read_byte(c)) putchar(pgm_read_byte(c++)); } break; } } }