Date:2012-12-05 17:25:25 (6 years 9 months ago)
Author:Werner Almesberger
Commit:4d096580369cf6d7dd678b2ebc21280dccad3efd
Message:tornado/fw/ben/ben.c: accept optional byte address argument

Files: tornado/fw/ben/ben.c (5 diffs)

Change Details

tornado/fw/ben/ben.c
5353}
5454
5555
56static void read_block(void)
56static void read_block(int addr)
5757{
5858    int i;
5959
60    if (!mmc_begin_read(0)) {
60    if (!mmc_begin_read(addr)) {
6161        fprintf(stderr, "mmc_begin_read failed\n");
6262        exit(1);
6363    }
...... 
6767}
6868
6969
70static void write_block(void)
70static void write_block(int addr)
7171{
7272    int i;
7373
74    if (!mmc_begin_write(0)) {
74    if (!mmc_begin_write(addr)) {
7575        fprintf(stderr, "mmc_begin_write failed\n");
7676        exit(1);
7777    }
...... 
8686
8787static void usage(const char *name)
8888{
89    fprintf(stderr, "usage: %s [-w]\n", name);
89    fprintf(stderr, "usage: %s [-w] [byte_addr]\n", name);
9090    exit(1);
9191}
9292
...... 
9494int main(int argc, char **argv)
9595{
9696    int do_read = 1;
97    int addr;
9798    int c;
99    char *end;
98100
99101    io_setup();
100102
...... 
111113        default:
112114            usage(*argv);
113115        }
114    if (optind != argc)
116
117    switch (argc-optind) {
118    case 0:
119        addr = 0;
120        break;
121    case 1:
122        addr = strtoul(argv[optind], &end, 0);
123        if (*end)
124            usage(*argv);
125        break;
126    default:
115127        usage(*argv);
128    }
116129
117130    if (do_read)
118        read_block();
131        read_block(addr);
119132    else
120        write_block();
133        write_block(addr);
121134
122135    return 0;
123136}

Archive Download the corresponding diff file

Branches:
master
tornado-v1



interactive