Commit f1cdde28338806ebb309576d9235b3701aa00548
Committed by
Stefan Roese
1 parent
f3c89d9228
Exists in
v2017.01-smarct4x
and in
37 other branches
common: Fix cmd_fpgad addressing
Addressing was completely broken for cmd_fpgad. Signed-off-by: Dirk Eibach <dirk.eibach@gdsys.cc> Signed-off-by: Stefan Roese <sr@denx.de>
Showing 1 changed file with 24 additions and 8 deletions Side-by-side Diff
common/cmd_fpgad.c
... | ... | @@ -31,7 +31,8 @@ |
31 | 31 | unsigned int fpga; |
32 | 32 | ulong addr, length; |
33 | 33 | int rc = 0; |
34 | - u16 linebuf[DISP_LINE_LEN/sizeof(u16)]; | |
34 | + u16 linebuf[DISP_LINE_LEN/sizeof(u16)]; | |
35 | + ulong nbytes; | |
35 | 36 | |
36 | 37 | /* |
37 | 38 | * We use the last specified parameters, unless new ones are |
... | ... | @@ -63,13 +64,28 @@ |
63 | 64 | length = simple_strtoul(argv[3], NULL, 16); |
64 | 65 | } |
65 | 66 | |
66 | - /* Print the lines. */ | |
67 | - for (k = 0; k < DISP_LINE_LEN / sizeof(u16); ++k) | |
68 | - fpga_get_reg(fpga, (u16 *)fpga_ptr[fpga] + k, k * sizeof(u16), | |
69 | - &linebuf[k]); | |
70 | - print_buffer(addr, (void *)linebuf, sizeof(u16), | |
71 | - length, DISP_LINE_LEN / sizeof(u16)); | |
72 | - addr += sizeof(u16)*length; | |
67 | + nbytes = length * sizeof(u16); | |
68 | + do { | |
69 | + ulong linebytes = (nbytes > DISP_LINE_LEN) ? | |
70 | + DISP_LINE_LEN : nbytes; | |
71 | + | |
72 | + for (k = 0; k < linebytes / sizeof(u16); ++k) | |
73 | + fpga_get_reg(fpga, | |
74 | + (u16 *)fpga_ptr[fpga] + addr | |
75 | + / sizeof(u16) + k, | |
76 | + addr + k * sizeof(u16), | |
77 | + &linebuf[k]); | |
78 | + print_buffer(addr, (void *)linebuf, sizeof(u16), | |
79 | + linebytes / sizeof(u16), | |
80 | + DISP_LINE_LEN / sizeof(u16)); | |
81 | + | |
82 | + nbytes -= linebytes; | |
83 | + addr += linebytes; | |
84 | + if (ctrlc()) { | |
85 | + rc = 1; | |
86 | + break; | |
87 | + } | |
88 | + } while (nbytes > 0); | |
73 | 89 | |
74 | 90 | dp_last_fpga = fpga; |
75 | 91 | dp_last_addr = addr; |