X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=common%2Fcmd_mem.c;h=4262e26a61576c46f5f336044e5ce2fdaad307a9;hb=7f1d846e5c5754449c286587d099d85246062772;hp=d0fae6b24c23ca87bf6ef9187aaeabe5ff93fc7a;hpb=4bbd4537835f72b5c46ca6efb38143e431b3dbd5;p=u-boot diff --git a/common/cmd_mem.c b/common/cmd_mem.c index d0fae6b24c..4262e26a61 100644 --- a/common/cmd_mem.c +++ b/common/cmd_mem.c @@ -29,18 +29,19 @@ #include #include -#if (CONFIG_COMMANDS & CFG_CMD_MMC) +#if defined(CONFIG_CMD_MMC) #include #endif #ifdef CONFIG_HAS_DATAFLASH #include #endif -#if (CONFIG_COMMANDS & (CFG_CMD_MEMORY | \ - CFG_CMD_I2C | \ - CFG_CMD_ITEST | \ - CFG_CMD_PCI | \ - CMD_CMD_PORTIO ) ) +#if defined(CONFIG_CMD_MEMORY) \ + || defined(CONFIG_CMD_I2C) \ + || defined(CONFIG_CMD_ITEST) \ + || defined(CONFIG_CMD_PCI) \ + || defined(CONFIG_CMD_PORTIO) + int cmd_get_data_size(char* arg, int default_size) { /* Check for a size specification .b, .w or .l. @@ -64,7 +65,7 @@ int cmd_get_data_size(char* arg, int default_size) } #endif -#if (CONFIG_COMMANDS & CFG_CMD_MEMORY) +#if defined(CONFIG_CMD_MEMORY) #ifdef CMD_MEM_DEBUG #define PRINTF(fmt,args...) printf (fmt ,##args) @@ -92,8 +93,9 @@ static ulong base_address = 0; int do_mem_md ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { ulong addr, length; - ulong i, nbytes, linebytes; - u_char *cp; +#if defined(CONFIG_HAS_DATAFLASH) + ulong nbytes, linebytes; +#endif int size; int rc = 0; @@ -128,6 +130,7 @@ int do_mem_md ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) length = simple_strtoul(argv[2], NULL, 16); } +#if defined(CONFIG_HAS_DATAFLASH) /* Print the lines. * * We buffer all read data, so we can make sure data is read only @@ -136,64 +139,48 @@ int do_mem_md ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) nbytes = length * size; do { char linebuf[DISP_LINE_LEN]; - uint *uip = (uint *)linebuf; - ushort *usp = (ushort *)linebuf; - u_char *ucp = (u_char *)linebuf; -#ifdef CONFIG_HAS_DATAFLASH - int rc; -#endif - printf("%08lx:", addr); + void* p; linebytes = (nbytes>DISP_LINE_LEN)?DISP_LINE_LEN:nbytes; -#ifdef CONFIG_HAS_DATAFLASH - if ((rc = read_dataflash(addr, (linebytes/size)*size, linebuf)) == DATAFLASH_OK){ - /* if outside dataflash */ - /*if (rc != 1) { - dataflash_perror (rc); - return (1); - }*/ - for (i=0; i 0x7e)) - putc ('.'); - else - printf("%c", *cp); - cp++; - } - putc ('\n'); nbytes -= linebytes; + addr += linebytes; if (ctrlc()) { rc = 1; break; } } while (nbytes > 0); +#else + +# if defined(CONFIG_BLACKFIN) + /* See if we're trying to display L1 inst */ + if (addr_bfin_on_chip_mem(addr)) { + char linebuf[DISP_LINE_LEN]; + ulong linebytes, nbytes = length * size; + do { + linebytes = (nbytes > DISP_LINE_LEN) ? DISP_LINE_LEN : nbytes; + memcpy(linebuf, (void *)addr, linebytes); + print_buffer(addr, linebuf, size, linebytes/size, DISP_LINE_LEN/size); + + nbytes -= linebytes; + addr += linebytes; + if (ctrlc()) { + rc = 1; + break; + } + } while (nbytes > 0); + } else +# endif + + { + /* Print the lines. */ + print_buffer(addr, (void*)addr, size, length, DISP_LINE_LEN/size); + addr += size*length; + } +#endif dp_last_addr = addr; dp_last_length = length; @@ -344,6 +331,13 @@ int do_mem_cmp (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } #endif +#ifdef CONFIG_BLACKFIN + if (addr_bfin_on_chip_mem(addr1) || addr_bfin_on_chip_mem(addr2)) { + puts ("Comparison with L1 instruction memory not supported.\n\r"); + return 0; + } +#endif + ngood = 0; while (count-- > 0) { @@ -423,7 +417,7 @@ int do_mem_cp ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) /* check if we are copying to Flash */ if ( (addr2info(dest) != NULL) #ifdef CONFIG_HAS_DATAFLASH - && (!addr_dataflash(addr)) + && (!addr_dataflash(dest)) #endif ) { int rc; @@ -440,7 +434,7 @@ int do_mem_cp ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } #endif -#if (CONFIG_COMMANDS & CFG_CMD_MMC) +#if defined(CONFIG_CMD_MMC) if (mmc2info(dest)) { int rc; @@ -514,6 +508,14 @@ int do_mem_cp ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } #endif +#ifdef CONFIG_BLACKFIN + /* See if we're copying to/from L1 inst */ + if (addr_bfin_on_chip_mem(dest) || addr_bfin_on_chip_mem(addr)) { + memcpy((void *)dest, (void *)addr, count * size); + return 0; + } +#endif + while (count-- > 0) { if (size == 4) *((ulong *)dest) = *((ulong *)addr); @@ -695,9 +697,10 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) vu_long *addr, *start, *end; ulong val; ulong readback; + int rcode = 0; #if defined(CFG_ALT_MEMTEST) - vu_long addr_mask; + vu_long len; vu_long offset; vu_long test_offset; vu_long pattern; @@ -725,7 +728,6 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) #else ulong incr; ulong pattern; - int rcode = 0; #endif if (argc > 1) { @@ -834,26 +836,19 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) * all possible. * * Returns: 0 if the test succeeds, 1 if the test fails. - * - * ## NOTE ## Be sure to specify start and end - * addresses such that addr_mask has - * lots of bits set. For example an - * address range of 01000000 02000000 is - * bad while a range of 01000000 - * 01ffffff is perfect. */ - addr_mask = ((ulong)end - (ulong)start)/sizeof(vu_long); + len = ((ulong)end - (ulong)start)/sizeof(vu_long); pattern = (vu_long) 0xaaaaaaaa; anti_pattern = (vu_long) 0x55555555; - PRINTF("%s:%d: addr mask = 0x%.8lx\n", + PRINTF("%s:%d: length = 0x%.8lx\n", __FUNCTION__, __LINE__, - addr_mask); + len); /* * Write the default pattern at each of the * power-of-two offsets. */ - for (offset = 1; (offset & addr_mask) != 0; offset <<= 1) { + for (offset = 1; offset < len; offset <<= 1) { start[offset] = pattern; } @@ -863,7 +858,7 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) test_offset = 0; start[test_offset] = anti_pattern; - for (offset = 1; (offset & addr_mask) != 0; offset <<= 1) { + for (offset = 1; offset < len; offset <<= 1) { temp = start[offset]; if (temp != pattern) { printf ("\nFAILURE: Address bit stuck high @ 0x%.8lx:" @@ -877,10 +872,10 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) /* * Check for addr bits stuck low or shorted. */ - for (test_offset = 1; (test_offset & addr_mask) != 0; test_offset <<= 1) { + for (test_offset = 1; test_offset < len; test_offset <<= 1) { start[test_offset] = anti_pattern; - for (offset = 1; (offset & addr_mask) != 0; offset <<= 1) { + for (offset = 1; offset < len; offset <<= 1) { temp = start[offset]; if ((temp != pattern) && (offset != test_offset)) { printf ("\nFAILURE: Address bit stuck low or shorted @" @@ -990,8 +985,8 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } incr = -incr; } - return rcode; #endif + return rcode; } @@ -1042,6 +1037,13 @@ mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char *argv[]) } #endif +#ifdef CONFIG_BLACKFIN + if (addr_bfin_on_chip_mem(addr)) { + puts ("Can't modify L1 instruction in place. Use cp instead.\n\r"); + return 0; + } +#endif + /* Print the address, followed by value. Then accept input for * the next value. A non-converted value exits. */ @@ -1186,7 +1188,7 @@ int do_mem_crc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) #endif /* CONFIG_CRC32_VERIFY */ /**************************************************/ -#if (CONFIG_COMMANDS & CFG_CMD_MEMORY) +#if defined(CONFIG_CMD_MEMORY) U_BOOT_CMD( md, 3, 1, do_mem_md, "md - memory display\n", @@ -1289,4 +1291,4 @@ U_BOOT_CMD( #endif /* CONFIG_MX_CYCLIC */ #endif -#endif /* CFG_CMD_MEMORY */ +#endif