Message ID | 1319547581-30650-1-git-send-email-sjg@chromium.org |
---|---|
State | New, archived |
Headers | show |
On Tue, Oct 25, 2011 at 08:59, Simon Glass wrote: > --- a/common/cmd_mem.c > +++ b/common/cmd_mem.c > > + int bytes = size * length; unsigned long > + char *buf = map_physmem(addr, bytes, MAP_WRBACK); probably want void * > + /* TODO: create a utility function to map and print error */ > + if (!buf) { > + puts("Failed to map physical memory\n"); > + return 1; > + } unfortunately, this breaks some arches. address 0 is valid on some targets. maybe change the logic to: if (addr && !buf) the rest makes sense to me -mike
Hi Mike, On Tue, Oct 25, 2011 at 6:11 AM, Mike Frysinger <vapier@gentoo.org> wrote: > On Tue, Oct 25, 2011 at 08:59, Simon Glass wrote: >> --- a/common/cmd_mem.c >> +++ b/common/cmd_mem.c >> >> + int bytes = size * length; > > unsigned long > >> + char *buf = map_physmem(addr, bytes, MAP_WRBACK); > > probably want void * > >> + /* TODO: create a utility function to map and print error */ >> + if (!buf) { >> + puts("Failed to map physical memory\n"); >> + return 1; >> + } > > unfortunately, this breaks some arches. address 0 is valid on some > targets. maybe change the logic to: > if (addr && !buf) > I think I should just take this out, in the absence of anything that explains what the failure case for map_physmem() returns. I don't think it is permitted to fail at present. Will resend. Regards, Simon > the rest makes sense to me > -mike >
diff --git a/common/cmd_mem.c b/common/cmd_mem.c index 28476d7..cf59f6d 100644 --- a/common/cmd_mem.c +++ b/common/cmd_mem.c @@ -33,6 +33,7 @@ #include <dataflash.h> #endif #include <watchdog.h> +#include <asm/io.h> #ifdef CMD_MEM_DEBUG #define PRINTF(fmt,args...) printf (fmt ,##args) @@ -141,9 +142,19 @@ int do_mem_md ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) # endif { + int bytes = size * length; + char *buf = map_physmem(addr, bytes, MAP_WRBACK); + + /* TODO: create a utility function to map and print error */ + if (!buf) { + puts("Failed to map physical memory\n"); + return 1; + } + /* Print the lines. */ - print_buffer(addr, (void*)addr, size, length, DISP_LINE_LEN/size); - addr += size*length; + print_buffer(addr, buf, size, length, DISP_LINE_LEN / size); + addr += bytes; + unmap_physmem(buf, bytes); } #endif
Sandbox wants to support commands which use memory. The map_physmen() call provides this feature, so should be used more consistently in U-Boot. Note: We will need a utility function which includes the mapping and printing of an error to avoid code size increase. Signed-off-by: Simon Glass <sjg@chromium.org> --- common/cmd_mem.c | 15 +++++++++++++-- 1 files changed, 13 insertions(+), 2 deletions(-)