Merge branch 'mem' of git://git.denx.de/u-boot-x86
This commit is contained in:
commit
1c9f47ab2a
9
README
9
README
@ -3811,6 +3811,15 @@ Low Level (hardware related) configuration options:
|
|||||||
that is executed before the actual U-Boot. E.g. when
|
that is executed before the actual U-Boot. E.g. when
|
||||||
compiling a NAND SPL.
|
compiling a NAND SPL.
|
||||||
|
|
||||||
|
- CONFIG_ARCH_MAP_SYSMEM
|
||||||
|
Generally U-Boot (and in particular the md command) uses
|
||||||
|
effective address. It is therefore not necessary to regard
|
||||||
|
U-Boot address as virtual addresses that need to be translated
|
||||||
|
to physical addresses. However, sandbox requires this, since
|
||||||
|
it maintains its own little RAM buffer which contains all
|
||||||
|
addressable memory. This option causes some memory accesses
|
||||||
|
to be mapped through map_sysmem() / unmap_sysmem().
|
||||||
|
|
||||||
- CONFIG_USE_ARCH_MEMCPY
|
- CONFIG_USE_ARCH_MEMCPY
|
||||||
CONFIG_USE_ARCH_MEMSET
|
CONFIG_USE_ARCH_MEMSET
|
||||||
If these options are used a optimized version of memcpy/memset will
|
If these options are used a optimized version of memcpy/memset will
|
||||||
|
@ -18,4 +18,5 @@
|
|||||||
# MA 02111-1307 USA
|
# MA 02111-1307 USA
|
||||||
|
|
||||||
PLATFORM_CPPFLAGS += -DCONFIG_SANDBOX -D__SANDBOX__ -U_FORTIFY_SOURCE
|
PLATFORM_CPPFLAGS += -DCONFIG_SANDBOX -D__SANDBOX__ -U_FORTIFY_SOURCE
|
||||||
|
PLATFORM_CPPFLAGS += -DCONFIG_ARCH_MAP_SYSMEM
|
||||||
PLATFORM_LIBS += -lrt
|
PLATFORM_LIBS += -lrt
|
||||||
|
@ -44,6 +44,14 @@ ssize_t os_read(int fd, void *buf, size_t count)
|
|||||||
return read(fd, buf, count);
|
return read(fd, buf, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ssize_t os_read_no_block(int fd, void *buf, size_t count)
|
||||||
|
{
|
||||||
|
const int flags = fcntl(fd, F_GETFL, 0);
|
||||||
|
|
||||||
|
fcntl(fd, F_SETFL, flags | O_NONBLOCK);
|
||||||
|
return os_read(fd, buf, count);
|
||||||
|
}
|
||||||
|
|
||||||
ssize_t os_write(int fd, const void *buf, size_t count)
|
ssize_t os_write(int fd, const void *buf, size_t count)
|
||||||
{
|
{
|
||||||
return write(fd, buf, count);
|
return write(fd, buf, count);
|
||||||
|
@ -122,4 +122,7 @@ int main(int argc, char *argv[])
|
|||||||
* never return.
|
* never return.
|
||||||
*/
|
*/
|
||||||
board_init_f(0);
|
board_init_f(0);
|
||||||
|
|
||||||
|
/* NOTREACHED - board_init_f() does not return */
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -39,3 +39,13 @@ static inline void unmap_physmem(void *vaddr, unsigned long flags)
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* For sandbox, we want addresses to point into our RAM buffer */
|
||||||
|
static inline void *map_sysmem(phys_addr_t paddr, unsigned long len)
|
||||||
|
{
|
||||||
|
return map_physmem(paddr, len, MAP_WRBACK);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void unmap_sysmem(const void *vaddr)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
@ -452,9 +452,7 @@ static int bootm_start_standalone(ulong iflag, int argc, char * const argv[])
|
|||||||
|
|
||||||
/* Don't start if "autostart" is set to "no" */
|
/* Don't start if "autostart" is set to "no" */
|
||||||
if (((s = getenv("autostart")) != NULL) && (strcmp(s, "no") == 0)) {
|
if (((s = getenv("autostart")) != NULL) && (strcmp(s, "no") == 0)) {
|
||||||
char buf[32];
|
setenv_hex("filesize", images.os.image_len);
|
||||||
sprintf(buf, "%lX", images.os.image_len);
|
|
||||||
setenv("filesize", buf);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
appl = (int (*)(int, char * const []))(ulong)ntohl(images.ep);
|
appl = (int (*)(int, char * const []))(ulong)ntohl(images.ep);
|
||||||
@ -529,17 +527,14 @@ static int do_bootm_subcommand(cmd_tbl_t *cmdtp, int flag, int argc,
|
|||||||
case BOOTM_STATE_RAMDISK:
|
case BOOTM_STATE_RAMDISK:
|
||||||
{
|
{
|
||||||
ulong rd_len = images.rd_end - images.rd_start;
|
ulong rd_len = images.rd_end - images.rd_start;
|
||||||
char str[17];
|
|
||||||
|
|
||||||
ret = boot_ramdisk_high(&images.lmb, images.rd_start,
|
ret = boot_ramdisk_high(&images.lmb, images.rd_start,
|
||||||
rd_len, &images.initrd_start, &images.initrd_end);
|
rd_len, &images.initrd_start, &images.initrd_end);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
sprintf(str, "%lx", images.initrd_start);
|
setenv_hex("initrd_start", images.initrd_start);
|
||||||
setenv("initrd_start", str);
|
setenv_hex("initrd_end", images.initrd_end);
|
||||||
sprintf(str, "%lx", images.initrd_end);
|
|
||||||
setenv("initrd_end", str);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
@ -65,7 +65,6 @@ int do_cbfs_fsload(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
|
|||||||
const struct cbfs_cachenode *file;
|
const struct cbfs_cachenode *file;
|
||||||
unsigned long offset;
|
unsigned long offset;
|
||||||
unsigned long count;
|
unsigned long count;
|
||||||
char buf[12];
|
|
||||||
long size;
|
long size;
|
||||||
|
|
||||||
if (argc < 3) {
|
if (argc < 3) {
|
||||||
@ -95,8 +94,7 @@ int do_cbfs_fsload(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
|
|||||||
|
|
||||||
printf("\n%ld bytes read\n", size);
|
printf("\n%ld bytes read\n", size);
|
||||||
|
|
||||||
sprintf(buf, "%lX", size);
|
setenv_hex("filesize", size);
|
||||||
setenv("filesize", buf);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -146,11 +146,9 @@ int do_cramfs_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
|||||||
size = cramfs_load ((char *) offset, &part, filename);
|
size = cramfs_load ((char *) offset, &part, filename);
|
||||||
|
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
char buf[10];
|
|
||||||
printf("### CRAMFS load complete: %d bytes loaded to 0x%lx\n",
|
printf("### CRAMFS load complete: %d bytes loaded to 0x%lx\n",
|
||||||
size, offset);
|
size, offset);
|
||||||
sprintf(buf, "%x", size);
|
setenv_hex("filesize", size);
|
||||||
setenv("filesize", buf);
|
|
||||||
} else {
|
} else {
|
||||||
printf("### CRAMFS LOAD ERROR<%x> for %s!\n", size, filename);
|
printf("### CRAMFS LOAD ERROR<%x> for %s!\n", size, filename);
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,6 @@ int do_fdosboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
|||||||
char *name;
|
char *name;
|
||||||
char *ep;
|
char *ep;
|
||||||
int size;
|
int size;
|
||||||
char buf [12];
|
|
||||||
int drive = CONFIG_SYS_FDC_DRIVE_NUMBER;
|
int drive = CONFIG_SYS_FDC_DRIVE_NUMBER;
|
||||||
|
|
||||||
/* pre-set load_addr */
|
/* pre-set load_addr */
|
||||||
@ -91,8 +90,7 @@ int do_fdosboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
|||||||
}
|
}
|
||||||
flush_cache (load_addr, size);
|
flush_cache (load_addr, size);
|
||||||
|
|
||||||
sprintf(buf, "%x", size);
|
setenv_hex("filesize", size);
|
||||||
setenv("filesize", buf);
|
|
||||||
|
|
||||||
printf("Floppy DOS load complete: %d bytes loaded to 0x%lx\n",
|
printf("Floppy DOS load complete: %d bytes loaded to 0x%lx\n",
|
||||||
size, load_addr);
|
size, load_addr);
|
||||||
|
@ -55,12 +55,8 @@ struct fdt_header *working_fdt;
|
|||||||
|
|
||||||
void set_working_fdt_addr(void *addr)
|
void set_working_fdt_addr(void *addr)
|
||||||
{
|
{
|
||||||
char buf[17];
|
|
||||||
|
|
||||||
working_fdt = addr;
|
working_fdt = addr;
|
||||||
|
setenv_addr("fdtaddr", addr);
|
||||||
sprintf(buf, "%lx", (unsigned long)addr);
|
|
||||||
setenv("fdtaddr", buf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -347,10 +343,7 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
|||||||
}
|
}
|
||||||
if (subcmd[0] == 's') {
|
if (subcmd[0] == 's') {
|
||||||
/* get the num nodes at this level */
|
/* get the num nodes at this level */
|
||||||
char buf[11];
|
setenv_ulong(var, curIndex + 1);
|
||||||
|
|
||||||
sprintf(buf, "%d", curIndex + 1);
|
|
||||||
setenv(var, buf);
|
|
||||||
} else {
|
} else {
|
||||||
/* node index not found */
|
/* node index not found */
|
||||||
printf("libfdt node not found\n");
|
printf("libfdt node not found\n");
|
||||||
|
@ -26,22 +26,30 @@
|
|||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <command.h>
|
#include <command.h>
|
||||||
#include <hash.h>
|
#include <hash.h>
|
||||||
|
#include <linux/ctype.h>
|
||||||
|
|
||||||
static int do_hash(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
static int do_hash(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
||||||
{
|
{
|
||||||
|
char *s;
|
||||||
#ifdef CONFIG_HASH_VERIFY
|
#ifdef CONFIG_HASH_VERIFY
|
||||||
int verify = 0;
|
int flags = HASH_FLAG_ENV;
|
||||||
|
|
||||||
|
if (argc < 4)
|
||||||
|
return CMD_RET_USAGE;
|
||||||
if (!strcmp(argv[1], "-v")) {
|
if (!strcmp(argv[1], "-v")) {
|
||||||
verify = 1;
|
flags |= HASH_FLAG_VERIFY;
|
||||||
argc--;
|
argc--;
|
||||||
argv++;
|
argv++;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
const int flags = HASH_FLAG_ENV;
|
||||||
#endif
|
#endif
|
||||||
/* Move forward to 'algorithm' parameter */
|
/* Move forward to 'algorithm' parameter */
|
||||||
argc--;
|
argc--;
|
||||||
argv++;
|
argv++;
|
||||||
return hash_command(*argv, verify, cmdtp, flag, argc - 1, argv + 1);
|
for (s = *argv; *s; s++)
|
||||||
|
*s = tolower(*s);
|
||||||
|
return hash_command(*argv, flags, cmdtp, flag, argc - 1, argv + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_HASH_VERIFY
|
#ifdef CONFIG_HASH_VERIFY
|
||||||
|
@ -525,11 +525,9 @@ int do_jffs2_fsload(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
char buf[10];
|
|
||||||
printf("### %s load complete: %d bytes loaded to 0x%lx\n",
|
printf("### %s load complete: %d bytes loaded to 0x%lx\n",
|
||||||
fsname, size, offset);
|
fsname, size, offset);
|
||||||
sprintf(buf, "%x", size);
|
setenv_hex("filesize", size);
|
||||||
setenv("filesize", buf);
|
|
||||||
} else {
|
} else {
|
||||||
printf("### %s LOAD ERROR<%x> for %s!\n", fsname, size, filename);
|
printf("### %s LOAD ERROR<%x> for %s!\n", fsname, size, filename);
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,6 @@ static ulong load_serial(long offset)
|
|||||||
int type; /* return code for record type */
|
int type; /* return code for record type */
|
||||||
ulong addr; /* load address from S-Record */
|
ulong addr; /* load address from S-Record */
|
||||||
ulong size; /* number of bytes transferred */
|
ulong size; /* number of bytes transferred */
|
||||||
char buf[32];
|
|
||||||
ulong store_addr;
|
ulong store_addr;
|
||||||
ulong start_addr = ~0;
|
ulong start_addr = ~0;
|
||||||
ulong end_addr = 0;
|
ulong end_addr = 0;
|
||||||
@ -198,8 +197,7 @@ static ulong load_serial(long offset)
|
|||||||
start_addr, end_addr, size, size
|
start_addr, end_addr, size, size
|
||||||
);
|
);
|
||||||
flush_cache(start_addr, size);
|
flush_cache(start_addr, size);
|
||||||
sprintf(buf, "%lX", size);
|
setenv_hex("filesize", size);
|
||||||
setenv("filesize", buf);
|
|
||||||
return (addr);
|
return (addr);
|
||||||
case SREC_START:
|
case SREC_START:
|
||||||
break;
|
break;
|
||||||
@ -519,7 +517,6 @@ static int do_load_serial_bin(cmd_tbl_t *cmdtp, int flag, int argc,
|
|||||||
static ulong load_serial_bin(ulong offset)
|
static ulong load_serial_bin(ulong offset)
|
||||||
{
|
{
|
||||||
int size, i;
|
int size, i;
|
||||||
char buf[32];
|
|
||||||
|
|
||||||
set_kerm_bin_mode((ulong *) offset);
|
set_kerm_bin_mode((ulong *) offset);
|
||||||
size = k_recv();
|
size = k_recv();
|
||||||
@ -539,8 +536,7 @@ static ulong load_serial_bin(ulong offset)
|
|||||||
flush_cache(offset, size);
|
flush_cache(offset, size);
|
||||||
|
|
||||||
printf("## Total Size = 0x%08x = %d Bytes\n", size, size);
|
printf("## Total Size = 0x%08x = %d Bytes\n", size, size);
|
||||||
sprintf(buf, "%X", size);
|
setenv_hex("filesize", size);
|
||||||
setenv("filesize", buf);
|
|
||||||
|
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
@ -965,7 +961,6 @@ static int getcxmodem(void) {
|
|||||||
static ulong load_serial_ymodem(ulong offset)
|
static ulong load_serial_ymodem(ulong offset)
|
||||||
{
|
{
|
||||||
int size;
|
int size;
|
||||||
char buf[32];
|
|
||||||
int err;
|
int err;
|
||||||
int res;
|
int res;
|
||||||
connection_info_t info;
|
connection_info_t info;
|
||||||
@ -1012,8 +1007,7 @@ static ulong load_serial_ymodem(ulong offset)
|
|||||||
flush_cache(offset, size);
|
flush_cache(offset, size);
|
||||||
|
|
||||||
printf("## Total Size = 0x%08x = %d Bytes\n", size, size);
|
printf("## Total Size = 0x%08x = %d Bytes\n", size, size);
|
||||||
sprintf(buf, "%X", size);
|
setenv_hex("filesize", size);
|
||||||
setenv("filesize", buf);
|
|
||||||
|
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
533
common/cmd_mem.c
533
common/cmd_mem.c
@ -32,11 +32,17 @@
|
|||||||
#ifdef CONFIG_HAS_DATAFLASH
|
#ifdef CONFIG_HAS_DATAFLASH
|
||||||
#include <dataflash.h>
|
#include <dataflash.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <hash.h>
|
||||||
#include <watchdog.h>
|
#include <watchdog.h>
|
||||||
|
#include <asm/io.h>
|
||||||
#include <linux/compiler.h>
|
#include <linux/compiler.h>
|
||||||
|
|
||||||
DECLARE_GLOBAL_DATA_PTR;
|
DECLARE_GLOBAL_DATA_PTR;
|
||||||
|
|
||||||
|
#ifndef CONFIG_SYS_MEMTEST_SCRATCH
|
||||||
|
#define CONFIG_SYS_MEMTEST_SCRATCH 0
|
||||||
|
#endif
|
||||||
|
|
||||||
static int mod_mem(cmd_tbl_t *, int, int, int, char * const []);
|
static int mod_mem(cmd_tbl_t *, int, int, int, char * const []);
|
||||||
|
|
||||||
/* Display values from last command.
|
/* Display values from last command.
|
||||||
@ -138,9 +144,13 @@ static int do_mem_md(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
|||||||
# endif
|
# endif
|
||||||
|
|
||||||
{
|
{
|
||||||
|
ulong bytes = size * length;
|
||||||
|
const void *buf = map_sysmem(addr, bytes);
|
||||||
|
|
||||||
/* Print the lines. */
|
/* Print the lines. */
|
||||||
print_buffer(addr, (void*)addr, size, length, DISP_LINE_LEN/size);
|
print_buffer(addr, buf, size, length, DISP_LINE_LEN / size);
|
||||||
addr += size*length;
|
addr += bytes;
|
||||||
|
unmap_sysmem(buf);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -163,6 +173,8 @@ static int do_mem_mw(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
|||||||
{
|
{
|
||||||
ulong addr, writeval, count;
|
ulong addr, writeval, count;
|
||||||
int size;
|
int size;
|
||||||
|
void *buf;
|
||||||
|
ulong bytes;
|
||||||
|
|
||||||
if ((argc < 3) || (argc > 4))
|
if ((argc < 3) || (argc > 4))
|
||||||
return CMD_RET_USAGE;
|
return CMD_RET_USAGE;
|
||||||
@ -188,15 +200,18 @@ static int do_mem_mw(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
|||||||
count = 1;
|
count = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bytes = size * count;
|
||||||
|
buf = map_sysmem(addr, bytes);
|
||||||
while (count-- > 0) {
|
while (count-- > 0) {
|
||||||
if (size == 4)
|
if (size == 4)
|
||||||
*((ulong *)addr) = (ulong )writeval;
|
*((ulong *)buf) = (ulong)writeval;
|
||||||
else if (size == 2)
|
else if (size == 2)
|
||||||
*((ushort *)addr) = (ushort)writeval;
|
*((ushort *)buf) = (ushort)writeval;
|
||||||
else
|
else
|
||||||
*((u_char *)addr) = (u_char)writeval;
|
*((u_char *)buf) = (u_char)writeval;
|
||||||
addr += size;
|
buf += size;
|
||||||
}
|
}
|
||||||
|
unmap_sysmem(buf);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,10 +273,11 @@ int do_mem_mwc ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
|||||||
|
|
||||||
static int do_mem_cmp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
static int do_mem_cmp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
||||||
{
|
{
|
||||||
ulong addr1, addr2, count, ngood;
|
ulong addr1, addr2, count, ngood, bytes;
|
||||||
int size;
|
int size;
|
||||||
int rcode = 0;
|
int rcode = 0;
|
||||||
const char *type;
|
const char *type;
|
||||||
|
const void *buf1, *buf2, *base;
|
||||||
|
|
||||||
if (argc != 4)
|
if (argc != 4)
|
||||||
return CMD_RET_USAGE;
|
return CMD_RET_USAGE;
|
||||||
@ -294,33 +310,40 @@ static int do_mem_cmp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
bytes = size * count;
|
||||||
|
base = buf1 = map_sysmem(addr1, bytes);
|
||||||
|
buf2 = map_sysmem(addr2, bytes);
|
||||||
for (ngood = 0; ngood < count; ++ngood) {
|
for (ngood = 0; ngood < count; ++ngood) {
|
||||||
ulong word1, word2;
|
ulong word1, word2;
|
||||||
if (size == 4) {
|
if (size == 4) {
|
||||||
word1 = *(ulong *)addr1;
|
word1 = *(ulong *)buf1;
|
||||||
word2 = *(ulong *)addr2;
|
word2 = *(ulong *)buf2;
|
||||||
} else if (size == 2) {
|
} else if (size == 2) {
|
||||||
word1 = *(ushort *)addr1;
|
word1 = *(ushort *)buf1;
|
||||||
word2 = *(ushort *)addr2;
|
word2 = *(ushort *)buf2;
|
||||||
} else {
|
} else {
|
||||||
word1 = *(u_char *)addr1;
|
word1 = *(u_char *)buf1;
|
||||||
word2 = *(u_char *)addr2;
|
word2 = *(u_char *)buf2;
|
||||||
}
|
}
|
||||||
if (word1 != word2) {
|
if (word1 != word2) {
|
||||||
|
ulong offset = buf1 - base;
|
||||||
|
|
||||||
printf("%s at 0x%08lx (%#0*lx) != %s at 0x%08lx (%#0*lx)\n",
|
printf("%s at 0x%08lx (%#0*lx) != %s at 0x%08lx (%#0*lx)\n",
|
||||||
type, addr1, size, word1,
|
type, (ulong)(addr1 + offset), size, word1,
|
||||||
type, addr2, size, word2);
|
type, (ulong)(addr2 + offset), size, word2);
|
||||||
rcode = 1;
|
rcode = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
addr1 += size;
|
buf1 += size;
|
||||||
addr2 += size;
|
buf2 += size;
|
||||||
|
|
||||||
/* reset watchdog from time to time */
|
/* reset watchdog from time to time */
|
||||||
if ((ngood % (64 << 10)) == 0)
|
if ((ngood % (64 << 10)) == 0)
|
||||||
WATCHDOG_RESET();
|
WATCHDOG_RESET();
|
||||||
}
|
}
|
||||||
|
unmap_sysmem(buf1);
|
||||||
|
unmap_sysmem(buf2);
|
||||||
|
|
||||||
printf("Total of %ld %s(s) were the same\n", ngood, type);
|
printf("Total of %ld %s(s) were the same\n", ngood, type);
|
||||||
return rcode;
|
return rcode;
|
||||||
@ -328,8 +351,10 @@ static int do_mem_cmp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
|||||||
|
|
||||||
static int do_mem_cp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
static int do_mem_cp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
||||||
{
|
{
|
||||||
ulong addr, dest, count;
|
ulong addr, dest, count, bytes;
|
||||||
int size;
|
int size;
|
||||||
|
const void *src;
|
||||||
|
void *buf;
|
||||||
|
|
||||||
if (argc != 4)
|
if (argc != 4)
|
||||||
return CMD_RET_USAGE;
|
return CMD_RET_USAGE;
|
||||||
@ -419,15 +444,18 @@ static int do_mem_cp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
bytes = size * count;
|
||||||
|
buf = map_sysmem(addr, bytes);
|
||||||
|
src = map_sysmem(addr, bytes);
|
||||||
while (count-- > 0) {
|
while (count-- > 0) {
|
||||||
if (size == 4)
|
if (size == 4)
|
||||||
*((ulong *)dest) = *((ulong *)addr);
|
*((ulong *)buf) = *((ulong *)src);
|
||||||
else if (size == 2)
|
else if (size == 2)
|
||||||
*((ushort *)dest) = *((ushort *)addr);
|
*((ushort *)buf) = *((ushort *)src);
|
||||||
else
|
else
|
||||||
*((u_char *)dest) = *((u_char *)addr);
|
*((u_char *)buf) = *((u_char *)src);
|
||||||
addr += size;
|
src += size;
|
||||||
dest += size;
|
buf += size;
|
||||||
|
|
||||||
/* reset watchdog from time to time */
|
/* reset watchdog from time to time */
|
||||||
if ((count % (64 << 10)) == 0)
|
if ((count % (64 << 10)) == 0)
|
||||||
@ -453,11 +481,12 @@ static int do_mem_base(cmd_tbl_t *cmdtp, int flag, int argc,
|
|||||||
static int do_mem_loop(cmd_tbl_t *cmdtp, int flag, int argc,
|
static int do_mem_loop(cmd_tbl_t *cmdtp, int flag, int argc,
|
||||||
char * const argv[])
|
char * const argv[])
|
||||||
{
|
{
|
||||||
ulong addr, length, i;
|
ulong addr, length, i, bytes;
|
||||||
int size;
|
int size;
|
||||||
volatile uint *longp;
|
volatile uint *longp;
|
||||||
volatile ushort *shortp;
|
volatile ushort *shortp;
|
||||||
volatile u_char *cp;
|
volatile u_char *cp;
|
||||||
|
const void *buf;
|
||||||
|
|
||||||
if (argc < 3)
|
if (argc < 3)
|
||||||
return CMD_RET_USAGE;
|
return CMD_RET_USAGE;
|
||||||
@ -477,28 +506,31 @@ static int do_mem_loop(cmd_tbl_t *cmdtp, int flag, int argc,
|
|||||||
*/
|
*/
|
||||||
length = simple_strtoul(argv[2], NULL, 16);
|
length = simple_strtoul(argv[2], NULL, 16);
|
||||||
|
|
||||||
|
bytes = size * length;
|
||||||
|
buf = map_sysmem(addr, bytes);
|
||||||
|
|
||||||
/* We want to optimize the loops to run as fast as possible.
|
/* We want to optimize the loops to run as fast as possible.
|
||||||
* If we have only one object, just run infinite loops.
|
* If we have only one object, just run infinite loops.
|
||||||
*/
|
*/
|
||||||
if (length == 1) {
|
if (length == 1) {
|
||||||
if (size == 4) {
|
if (size == 4) {
|
||||||
longp = (uint *)addr;
|
longp = (uint *)buf;
|
||||||
for (;;)
|
for (;;)
|
||||||
i = *longp;
|
i = *longp;
|
||||||
}
|
}
|
||||||
if (size == 2) {
|
if (size == 2) {
|
||||||
shortp = (ushort *)addr;
|
shortp = (ushort *)buf;
|
||||||
for (;;)
|
for (;;)
|
||||||
i = *shortp;
|
i = *shortp;
|
||||||
}
|
}
|
||||||
cp = (u_char *)addr;
|
cp = (u_char *)buf;
|
||||||
for (;;)
|
for (;;)
|
||||||
i = *cp;
|
i = *cp;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size == 4) {
|
if (size == 4) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
longp = (uint *)addr;
|
longp = (uint *)buf;
|
||||||
i = length;
|
i = length;
|
||||||
while (i-- > 0)
|
while (i-- > 0)
|
||||||
*longp++;
|
*longp++;
|
||||||
@ -506,28 +538,30 @@ static int do_mem_loop(cmd_tbl_t *cmdtp, int flag, int argc,
|
|||||||
}
|
}
|
||||||
if (size == 2) {
|
if (size == 2) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
shortp = (ushort *)addr;
|
shortp = (ushort *)buf;
|
||||||
i = length;
|
i = length;
|
||||||
while (i-- > 0)
|
while (i-- > 0)
|
||||||
*shortp++;
|
*shortp++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (;;) {
|
for (;;) {
|
||||||
cp = (u_char *)addr;
|
cp = (u_char *)buf;
|
||||||
i = length;
|
i = length;
|
||||||
while (i-- > 0)
|
while (i-- > 0)
|
||||||
*cp++;
|
*cp++;
|
||||||
}
|
}
|
||||||
|
unmap_sysmem(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_LOOPW
|
#ifdef CONFIG_LOOPW
|
||||||
int do_mem_loopw (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
int do_mem_loopw (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
||||||
{
|
{
|
||||||
ulong addr, length, i, data;
|
ulong addr, length, i, data, bytes;
|
||||||
int size;
|
int size;
|
||||||
volatile uint *longp;
|
volatile uint *longp;
|
||||||
volatile ushort *shortp;
|
volatile ushort *shortp;
|
||||||
volatile u_char *cp;
|
volatile u_char *cp;
|
||||||
|
void *buf;
|
||||||
|
|
||||||
if (argc < 4)
|
if (argc < 4)
|
||||||
return CMD_RET_USAGE;
|
return CMD_RET_USAGE;
|
||||||
@ -550,28 +584,31 @@ int do_mem_loopw (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
|||||||
/* data to write */
|
/* data to write */
|
||||||
data = simple_strtoul(argv[3], NULL, 16);
|
data = simple_strtoul(argv[3], NULL, 16);
|
||||||
|
|
||||||
|
bytes = size * length;
|
||||||
|
buf = map_sysmem(addr, bytes);
|
||||||
|
|
||||||
/* We want to optimize the loops to run as fast as possible.
|
/* We want to optimize the loops to run as fast as possible.
|
||||||
* If we have only one object, just run infinite loops.
|
* If we have only one object, just run infinite loops.
|
||||||
*/
|
*/
|
||||||
if (length == 1) {
|
if (length == 1) {
|
||||||
if (size == 4) {
|
if (size == 4) {
|
||||||
longp = (uint *)addr;
|
longp = (uint *)buf;
|
||||||
for (;;)
|
for (;;)
|
||||||
*longp = data;
|
*longp = data;
|
||||||
}
|
}
|
||||||
if (size == 2) {
|
if (size == 2) {
|
||||||
shortp = (ushort *)addr;
|
shortp = (ushort *)buf;
|
||||||
for (;;)
|
for (;;)
|
||||||
*shortp = data;
|
*shortp = data;
|
||||||
}
|
}
|
||||||
cp = (u_char *)addr;
|
cp = (u_char *)buf;
|
||||||
for (;;)
|
for (;;)
|
||||||
*cp = data;
|
*cp = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size == 4) {
|
if (size == 4) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
longp = (uint *)addr;
|
longp = (uint *)buf;
|
||||||
i = length;
|
i = length;
|
||||||
while (i-- > 0)
|
while (i-- > 0)
|
||||||
*longp++ = data;
|
*longp++ = data;
|
||||||
@ -579,14 +616,14 @@ int do_mem_loopw (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
|||||||
}
|
}
|
||||||
if (size == 2) {
|
if (size == 2) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
shortp = (ushort *)addr;
|
shortp = (ushort *)buf;
|
||||||
i = length;
|
i = length;
|
||||||
while (i-- > 0)
|
while (i-- > 0)
|
||||||
*shortp++ = data;
|
*shortp++ = data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (;;) {
|
for (;;) {
|
||||||
cp = (u_char *)addr;
|
cp = (u_char *)buf;
|
||||||
i = length;
|
i = length;
|
||||||
while (i-- > 0)
|
while (i-- > 0)
|
||||||
*cp++ = data;
|
*cp++ = data;
|
||||||
@ -594,36 +631,19 @@ int do_mem_loopw (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
|||||||
}
|
}
|
||||||
#endif /* CONFIG_LOOPW */
|
#endif /* CONFIG_LOOPW */
|
||||||
|
|
||||||
/*
|
static ulong mem_test_alt(vu_long *buf, ulong start_addr, ulong end_addr,
|
||||||
* Perform a memory test. A more complete alternative test can be
|
vu_long *dummy)
|
||||||
* configured using CONFIG_SYS_ALT_MEMTEST. The complete test loops until
|
|
||||||
* interrupted by ctrl-c or by a failure of one of the sub-tests.
|
|
||||||
*/
|
|
||||||
static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc,
|
|
||||||
char * const argv[])
|
|
||||||
{
|
{
|
||||||
vu_long *addr, *start, *end;
|
vu_long *addr;
|
||||||
ulong val;
|
|
||||||
ulong readback;
|
|
||||||
ulong errs = 0;
|
ulong errs = 0;
|
||||||
int iterations = 1;
|
ulong val, readback;
|
||||||
int iteration_limit;
|
int j;
|
||||||
|
|
||||||
#if defined(CONFIG_SYS_ALT_MEMTEST)
|
|
||||||
vu_long len;
|
|
||||||
vu_long offset;
|
vu_long offset;
|
||||||
vu_long test_offset;
|
vu_long test_offset;
|
||||||
vu_long pattern;
|
vu_long pattern;
|
||||||
vu_long temp;
|
vu_long temp;
|
||||||
vu_long anti_pattern;
|
vu_long anti_pattern;
|
||||||
vu_long num_words;
|
vu_long num_words;
|
||||||
#if defined(CONFIG_SYS_MEMTEST_SCRATCH)
|
|
||||||
vu_long *dummy = (vu_long*)CONFIG_SYS_MEMTEST_SCRATCH;
|
|
||||||
#else
|
|
||||||
vu_long *dummy = NULL; /* yes, this is address 0x0, not NULL */
|
|
||||||
#endif
|
|
||||||
int j;
|
|
||||||
|
|
||||||
static const ulong bitpattern[] = {
|
static const ulong bitpattern[] = {
|
||||||
0x00000001, /* single bit */
|
0x00000001, /* single bit */
|
||||||
0x00000003, /* two adjacent bits */
|
0x00000003, /* two adjacent bits */
|
||||||
@ -634,52 +654,8 @@ static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc,
|
|||||||
0x00000055, /* four non-adjacent bits */
|
0x00000055, /* four non-adjacent bits */
|
||||||
0xaaaaaaaa, /* alternating 1/0 */
|
0xaaaaaaaa, /* alternating 1/0 */
|
||||||
};
|
};
|
||||||
#else
|
|
||||||
ulong incr;
|
|
||||||
ulong pattern;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (argc > 1)
|
num_words = (end_addr - start_addr) / sizeof(vu_long);
|
||||||
start = (ulong *)simple_strtoul(argv[1], NULL, 16);
|
|
||||||
else
|
|
||||||
start = (ulong *)CONFIG_SYS_MEMTEST_START;
|
|
||||||
|
|
||||||
if (argc > 2)
|
|
||||||
end = (ulong *)simple_strtoul(argv[2], NULL, 16);
|
|
||||||
else
|
|
||||||
end = (ulong *)(CONFIG_SYS_MEMTEST_END);
|
|
||||||
|
|
||||||
if (argc > 3)
|
|
||||||
pattern = (ulong)simple_strtoul(argv[3], NULL, 16);
|
|
||||||
else
|
|
||||||
pattern = 0;
|
|
||||||
|
|
||||||
if (argc > 4)
|
|
||||||
iteration_limit = (ulong)simple_strtoul(argv[4], NULL, 16);
|
|
||||||
else
|
|
||||||
iteration_limit = 0;
|
|
||||||
|
|
||||||
#if defined(CONFIG_SYS_ALT_MEMTEST)
|
|
||||||
printf ("Testing %08x ... %08x:\n", (uint)start, (uint)end);
|
|
||||||
debug("%s:%d: start 0x%p end 0x%p\n",
|
|
||||||
__FUNCTION__, __LINE__, start, end);
|
|
||||||
|
|
||||||
for (;;) {
|
|
||||||
if (ctrlc()) {
|
|
||||||
putc ('\n');
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (iteration_limit && iterations > iteration_limit) {
|
|
||||||
printf("Tested %d iteration(s) with %lu errors.\n",
|
|
||||||
iterations-1, errs);
|
|
||||||
return errs != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Iteration: %6d\r", iterations);
|
|
||||||
debug("\n");
|
|
||||||
iterations++;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Data line test: write a pattern to the first
|
* Data line test: write a pattern to the first
|
||||||
@ -698,22 +674,20 @@ static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc,
|
|||||||
* '0's and '0' bits through a field of '1's (i.e.
|
* '0's and '0' bits through a field of '1's (i.e.
|
||||||
* pattern and ~pattern).
|
* pattern and ~pattern).
|
||||||
*/
|
*/
|
||||||
addr = start;
|
addr = buf;
|
||||||
for (j = 0; j < sizeof(bitpattern) / sizeof(bitpattern[0]); j++) {
|
for (j = 0; j < sizeof(bitpattern) / sizeof(bitpattern[0]); j++) {
|
||||||
val = bitpattern[j];
|
val = bitpattern[j];
|
||||||
for (; val != 0; val <<= 1) {
|
for (; val != 0; val <<= 1) {
|
||||||
*addr = val;
|
*addr = val;
|
||||||
*dummy = ~val; /* clear the test data off of the bus */
|
*dummy = ~val; /* clear the test data off the bus */
|
||||||
readback = *addr;
|
readback = *addr;
|
||||||
if (readback != val) {
|
if (readback != val) {
|
||||||
printf("FAILURE (data line): "
|
printf("FAILURE (data line): "
|
||||||
"expected %08lx, actual %08lx\n",
|
"expected %08lx, actual %08lx\n",
|
||||||
val, readback);
|
val, readback);
|
||||||
errs++;
|
errs++;
|
||||||
if (ctrlc()) {
|
if (ctrlc())
|
||||||
putc ('\n');
|
return -1;
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
*addr = ~val;
|
*addr = ~val;
|
||||||
*dummy = val;
|
*dummy = val;
|
||||||
@ -723,10 +697,8 @@ static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc,
|
|||||||
"Is %08lx, should be %08lx\n",
|
"Is %08lx, should be %08lx\n",
|
||||||
readback, ~val);
|
readback, ~val);
|
||||||
errs++;
|
errs++;
|
||||||
if (ctrlc()) {
|
if (ctrlc())
|
||||||
putc ('\n');
|
return -1;
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -743,7 +715,7 @@ static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc,
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Address line test
|
* Address line test
|
||||||
*
|
|
||||||
* Description: Test the address bus wiring in a
|
* Description: Test the address bus wiring in a
|
||||||
* memory region by performing a walking
|
* memory region by performing a walking
|
||||||
* 1's test on the relevant bits of the
|
* 1's test on the relevant bits of the
|
||||||
@ -753,7 +725,7 @@ static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc,
|
|||||||
* stuck-low, and shorted pins. The base
|
* stuck-low, and shorted pins. The base
|
||||||
* address and size of the region are
|
* address and size of the region are
|
||||||
* selected by the caller.
|
* selected by the caller.
|
||||||
*
|
|
||||||
* Notes: For best results, the selected base
|
* Notes: For best results, the selected base
|
||||||
* address should have enough LSB 0's to
|
* address should have enough LSB 0's to
|
||||||
* guarantee single address bit changes.
|
* guarantee single address bit changes.
|
||||||
@ -765,63 +737,56 @@ static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc,
|
|||||||
*
|
*
|
||||||
* Returns: 0 if the test succeeds, 1 if the test fails.
|
* Returns: 0 if the test succeeds, 1 if the test fails.
|
||||||
*/
|
*/
|
||||||
len = ((ulong)end - (ulong)start)/sizeof(vu_long);
|
|
||||||
pattern = (vu_long) 0xaaaaaaaa;
|
pattern = (vu_long) 0xaaaaaaaa;
|
||||||
anti_pattern = (vu_long) 0x55555555;
|
anti_pattern = (vu_long) 0x55555555;
|
||||||
|
|
||||||
debug("%s:%d: length = 0x%.8lx\n",
|
debug("%s:%d: length = 0x%.8lx\n", __func__, __LINE__, num_words);
|
||||||
__FUNCTION__, __LINE__,
|
|
||||||
len);
|
|
||||||
/*
|
/*
|
||||||
* Write the default pattern at each of the
|
* Write the default pattern at each of the
|
||||||
* power-of-two offsets.
|
* power-of-two offsets.
|
||||||
*/
|
*/
|
||||||
for (offset = 1; offset < len; offset <<= 1) {
|
for (offset = 1; offset < num_words; offset <<= 1)
|
||||||
start[offset] = pattern;
|
addr[offset] = pattern;
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check for address bits stuck high.
|
* Check for address bits stuck high.
|
||||||
*/
|
*/
|
||||||
test_offset = 0;
|
test_offset = 0;
|
||||||
start[test_offset] = anti_pattern;
|
addr[test_offset] = anti_pattern;
|
||||||
|
|
||||||
for (offset = 1; offset < len; offset <<= 1) {
|
for (offset = 1; offset < num_words; offset <<= 1) {
|
||||||
temp = start[offset];
|
temp = addr[offset];
|
||||||
if (temp != pattern) {
|
if (temp != pattern) {
|
||||||
printf("\nFAILURE: Address bit stuck high @ 0x%.8lx:"
|
printf("\nFAILURE: Address bit stuck high @ 0x%.8lx:"
|
||||||
" expected 0x%.8lx, actual 0x%.8lx\n",
|
" expected 0x%.8lx, actual 0x%.8lx\n",
|
||||||
(ulong)&start[offset], pattern, temp);
|
start_addr + offset, pattern, temp);
|
||||||
errs++;
|
errs++;
|
||||||
if (ctrlc()) {
|
if (ctrlc())
|
||||||
putc ('\n');
|
return -1;
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
addr[test_offset] = pattern;
|
||||||
start[test_offset] = pattern;
|
|
||||||
WATCHDOG_RESET();
|
WATCHDOG_RESET();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check for addr bits stuck low or shorted.
|
* Check for addr bits stuck low or shorted.
|
||||||
*/
|
*/
|
||||||
for (test_offset = 1; test_offset < len; test_offset <<= 1) {
|
for (test_offset = 1; test_offset < num_words; test_offset <<= 1) {
|
||||||
start[test_offset] = anti_pattern;
|
addr[test_offset] = anti_pattern;
|
||||||
|
|
||||||
for (offset = 1; offset < len; offset <<= 1) {
|
for (offset = 1; offset < num_words; offset <<= 1) {
|
||||||
temp = start[offset];
|
temp = addr[offset];
|
||||||
if ((temp != pattern) && (offset != test_offset)) {
|
if ((temp != pattern) && (offset != test_offset)) {
|
||||||
printf ("\nFAILURE: Address bit stuck low or shorted @"
|
printf("\nFAILURE: Address bit stuck low or"
|
||||||
" 0x%.8lx: expected 0x%.8lx, actual 0x%.8lx\n",
|
" shorted @ 0x%.8lx: expected 0x%.8lx,"
|
||||||
(ulong)&start[offset], pattern, temp);
|
" actual 0x%.8lx\n",
|
||||||
|
start_addr + offset, pattern, temp);
|
||||||
errs++;
|
errs++;
|
||||||
if (ctrlc()) {
|
if (ctrlc())
|
||||||
putc ('\n');
|
return -1;
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
addr[test_offset] = pattern;
|
||||||
start[test_offset] = pattern;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -836,14 +801,14 @@ static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc,
|
|||||||
*
|
*
|
||||||
* Returns: 0 if the test succeeds, 1 if the test fails.
|
* Returns: 0 if the test succeeds, 1 if the test fails.
|
||||||
*/
|
*/
|
||||||
num_words = ((ulong)end - (ulong)start)/sizeof(vu_long) + 1;
|
num_words++;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fill memory with a known pattern.
|
* Fill memory with a known pattern.
|
||||||
*/
|
*/
|
||||||
for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
|
for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
|
||||||
WATCHDOG_RESET();
|
WATCHDOG_RESET();
|
||||||
start[offset] = pattern;
|
addr[offset] = pattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -851,20 +816,18 @@ static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc,
|
|||||||
*/
|
*/
|
||||||
for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
|
for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
|
||||||
WATCHDOG_RESET();
|
WATCHDOG_RESET();
|
||||||
temp = start[offset];
|
temp = addr[offset];
|
||||||
if (temp != pattern) {
|
if (temp != pattern) {
|
||||||
printf("\nFAILURE (read/write) @ 0x%.8lx:"
|
printf("\nFAILURE (read/write) @ 0x%.8lx:"
|
||||||
" expected 0x%.8lx, actual 0x%.8lx)\n",
|
" expected 0x%.8lx, actual 0x%.8lx)\n",
|
||||||
(ulong)&start[offset], pattern, temp);
|
start_addr + offset, pattern, temp);
|
||||||
errs++;
|
errs++;
|
||||||
if (ctrlc()) {
|
if (ctrlc())
|
||||||
putc ('\n');
|
return -1;
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
anti_pattern = ~pattern;
|
anti_pattern = ~pattern;
|
||||||
start[offset] = anti_pattern;
|
addr[offset] = anti_pattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -873,42 +836,53 @@ static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc,
|
|||||||
for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
|
for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
|
||||||
WATCHDOG_RESET();
|
WATCHDOG_RESET();
|
||||||
anti_pattern = ~pattern;
|
anti_pattern = ~pattern;
|
||||||
temp = start[offset];
|
temp = addr[offset];
|
||||||
if (temp != anti_pattern) {
|
if (temp != anti_pattern) {
|
||||||
printf("\nFAILURE (read/write): @ 0x%.8lx:"
|
printf("\nFAILURE (read/write): @ 0x%.8lx:"
|
||||||
" expected 0x%.8lx, actual 0x%.8lx)\n",
|
" expected 0x%.8lx, actual 0x%.8lx)\n",
|
||||||
(ulong)&start[offset], anti_pattern, temp);
|
start_addr + offset, anti_pattern, temp);
|
||||||
errs++;
|
errs++;
|
||||||
if (ctrlc()) {
|
if (ctrlc())
|
||||||
putc ('\n');
|
return -1;
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
start[offset] = 0;
|
|
||||||
}
|
}
|
||||||
|
addr[offset] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else /* The original, quickie test */
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ulong mem_test_quick(vu_long *buf, ulong start_addr, ulong end_addr,
|
||||||
|
vu_long pattern, int iteration)
|
||||||
|
{
|
||||||
|
vu_long *end;
|
||||||
|
vu_long *addr;
|
||||||
|
ulong errs = 0;
|
||||||
|
ulong incr, length;
|
||||||
|
ulong val, readback;
|
||||||
|
|
||||||
|
/* Alternate the pattern */
|
||||||
incr = 1;
|
incr = 1;
|
||||||
for (;;) {
|
if (iteration & 1) {
|
||||||
if (ctrlc()) {
|
incr = -incr;
|
||||||
putc ('\n');
|
/*
|
||||||
return 1;
|
* Flip the pattern each time to make lots of zeros and
|
||||||
|
* then, the next time, lots of ones. We decrement
|
||||||
|
* the "negative" patterns and increment the "positive"
|
||||||
|
* patterns to preserve this feature.
|
||||||
|
*/
|
||||||
|
if (pattern & 0x80000000)
|
||||||
|
pattern = -pattern; /* complement & increment */
|
||||||
|
else
|
||||||
|
pattern = ~pattern;
|
||||||
}
|
}
|
||||||
|
length = (end_addr - start_addr) / sizeof(ulong);
|
||||||
if (iteration_limit && iterations > iteration_limit) {
|
end = buf + length;
|
||||||
printf("Tested %d iteration(s) with %lu errors.\n",
|
|
||||||
iterations-1, errs);
|
|
||||||
return errs != 0;
|
|
||||||
}
|
|
||||||
++iterations;
|
|
||||||
|
|
||||||
printf("\rPattern %08lX Writing..."
|
printf("\rPattern %08lX Writing..."
|
||||||
"%12s"
|
"%12s"
|
||||||
"\b\b\b\b\b\b\b\b\b\b",
|
"\b\b\b\b\b\b\b\b\b\b",
|
||||||
pattern, "");
|
pattern, "");
|
||||||
|
|
||||||
for (addr=start,val=pattern; addr<end; addr++) {
|
for (addr = buf, val = pattern; addr < end; addr++) {
|
||||||
WATCHDOG_RESET();
|
WATCHDOG_RESET();
|
||||||
*addr = val;
|
*addr = val;
|
||||||
val += incr;
|
val += incr;
|
||||||
@ -916,38 +890,117 @@ static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc,
|
|||||||
|
|
||||||
puts("Reading...");
|
puts("Reading...");
|
||||||
|
|
||||||
for (addr=start,val=pattern; addr<end; addr++) {
|
for (addr = buf, val = pattern; addr < end; addr++) {
|
||||||
WATCHDOG_RESET();
|
WATCHDOG_RESET();
|
||||||
readback = *addr;
|
readback = *addr;
|
||||||
if (readback != val) {
|
if (readback != val) {
|
||||||
|
ulong offset = addr - buf;
|
||||||
|
|
||||||
printf("\nMem error @ 0x%08X: "
|
printf("\nMem error @ 0x%08X: "
|
||||||
"found %08lX, expected %08lX\n",
|
"found %08lX, expected %08lX\n",
|
||||||
(uint)(uintptr_t)addr, readback, val);
|
(uint)(uintptr_t)(start_addr + offset),
|
||||||
|
readback, val);
|
||||||
errs++;
|
errs++;
|
||||||
if (ctrlc()) {
|
if (ctrlc())
|
||||||
putc ('\n');
|
return -1;
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
val += incr;
|
val += incr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Flip the pattern each time to make lots of zeros and
|
* Perform a memory test. A more complete alternative test can be
|
||||||
* then, the next time, lots of ones. We decrement
|
* configured using CONFIG_SYS_ALT_MEMTEST. The complete test loops until
|
||||||
* the "negative" patterns and increment the "positive"
|
* interrupted by ctrl-c or by a failure of one of the sub-tests.
|
||||||
* patterns to preserve this feature.
|
|
||||||
*/
|
*/
|
||||||
if(pattern & 0x80000000) {
|
static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc,
|
||||||
pattern = -pattern; /* complement & increment */
|
char * const argv[])
|
||||||
}
|
{
|
||||||
else {
|
ulong start, end;
|
||||||
pattern = ~pattern;
|
vu_long *buf, *dummy;
|
||||||
}
|
int iteration_limit;
|
||||||
incr = -incr;
|
int ret;
|
||||||
}
|
ulong errs = 0; /* number of errors, or -1 if interrupted */
|
||||||
|
ulong pattern;
|
||||||
|
int iteration;
|
||||||
|
#if defined(CONFIG_SYS_ALT_MEMTEST)
|
||||||
|
const int alt_test = 1;
|
||||||
|
#else
|
||||||
|
const int alt_test = 0;
|
||||||
#endif
|
#endif
|
||||||
return 0; /* not reached */
|
|
||||||
|
if (argc > 1)
|
||||||
|
start = simple_strtoul(argv[1], NULL, 16);
|
||||||
|
else
|
||||||
|
start = CONFIG_SYS_MEMTEST_START;
|
||||||
|
|
||||||
|
if (argc > 2)
|
||||||
|
end = simple_strtoul(argv[2], NULL, 16);
|
||||||
|
else
|
||||||
|
end = CONFIG_SYS_MEMTEST_END;
|
||||||
|
|
||||||
|
if (argc > 3)
|
||||||
|
pattern = (ulong)simple_strtoul(argv[3], NULL, 16);
|
||||||
|
else
|
||||||
|
pattern = 0;
|
||||||
|
|
||||||
|
if (argc > 4)
|
||||||
|
iteration_limit = (ulong)simple_strtoul(argv[4], NULL, 16);
|
||||||
|
else
|
||||||
|
iteration_limit = 0;
|
||||||
|
|
||||||
|
printf("Testing %08x ... %08x:\n", (uint)start, (uint)end);
|
||||||
|
debug("%s:%d: start %#08lx end %#08lx\n", __func__, __LINE__,
|
||||||
|
start, end);
|
||||||
|
|
||||||
|
buf = map_sysmem(start, end - start);
|
||||||
|
dummy = map_sysmem(CONFIG_SYS_MEMTEST_SCRATCH, sizeof(vu_long));
|
||||||
|
for (iteration = 0;
|
||||||
|
!iteration_limit || iteration < iteration_limit;
|
||||||
|
iteration++) {
|
||||||
|
if (ctrlc()) {
|
||||||
|
errs = -1UL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Iteration: %6d\r", iteration + 1);
|
||||||
|
debug("\n");
|
||||||
|
if (alt_test) {
|
||||||
|
errs = mem_test_alt(buf, start, end, dummy);
|
||||||
|
} else {
|
||||||
|
errs = mem_test_quick(buf, start, end, pattern,
|
||||||
|
iteration);
|
||||||
|
}
|
||||||
|
if (errs == -1UL)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Work-around for eldk-4.2 which gives this warning if we try to
|
||||||
|
* case in the unmap_sysmem() call:
|
||||||
|
* warning: initialization discards qualifiers from pointer target type
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
void *vbuf = (void *)buf;
|
||||||
|
void *vdummy = (void *)dummy;
|
||||||
|
|
||||||
|
unmap_sysmem(vbuf);
|
||||||
|
unmap_sysmem(vdummy);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (errs == -1UL) {
|
||||||
|
/* Memory test was aborted - write a newline to finish off */
|
||||||
|
putc('\n');
|
||||||
|
ret = 1;
|
||||||
|
} else {
|
||||||
|
printf("Tested %d iteration(s) with %lu errors.\n",
|
||||||
|
iteration, errs);
|
||||||
|
ret = errs != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret; /* not reached */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -962,6 +1015,7 @@ mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[])
|
|||||||
{
|
{
|
||||||
ulong addr, i;
|
ulong addr, i;
|
||||||
int nbytes, size;
|
int nbytes, size;
|
||||||
|
void *ptr = NULL;
|
||||||
|
|
||||||
if (argc != 2)
|
if (argc != 2)
|
||||||
return CMD_RET_USAGE;
|
return CMD_RET_USAGE;
|
||||||
@ -1006,13 +1060,14 @@ mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[])
|
|||||||
* the next value. A non-converted value exits.
|
* the next value. A non-converted value exits.
|
||||||
*/
|
*/
|
||||||
do {
|
do {
|
||||||
|
ptr = map_sysmem(addr, size);
|
||||||
printf("%08lx:", addr);
|
printf("%08lx:", addr);
|
||||||
if (size == 4)
|
if (size == 4)
|
||||||
printf(" %08x", *((uint *)addr));
|
printf(" %08x", *((uint *)ptr));
|
||||||
else if (size == 2)
|
else if (size == 2)
|
||||||
printf(" %04x", *((ushort *)addr));
|
printf(" %04x", *((ushort *)ptr));
|
||||||
else
|
else
|
||||||
printf(" %02x", *((u_char *)addr));
|
printf(" %02x", *((u_char *)ptr));
|
||||||
|
|
||||||
nbytes = readline (" ? ");
|
nbytes = readline (" ? ");
|
||||||
if (nbytes == 0 || (nbytes == 1 && console_buffer[0] == '-')) {
|
if (nbytes == 0 || (nbytes == 1 && console_buffer[0] == '-')) {
|
||||||
@ -1042,16 +1097,18 @@ mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[])
|
|||||||
reset_cmd_timeout();
|
reset_cmd_timeout();
|
||||||
#endif
|
#endif
|
||||||
if (size == 4)
|
if (size == 4)
|
||||||
*((uint *)addr) = i;
|
*((uint *)ptr) = i;
|
||||||
else if (size == 2)
|
else if (size == 2)
|
||||||
*((ushort *)addr) = i;
|
*((ushort *)ptr) = i;
|
||||||
else
|
else
|
||||||
*((u_char *)addr) = i;
|
*((u_char *)ptr) = i;
|
||||||
if (incrflag)
|
if (incrflag)
|
||||||
addr += size;
|
addr += size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (nbytes);
|
} while (nbytes);
|
||||||
|
if (ptr)
|
||||||
|
unmap_sysmem(ptr);
|
||||||
|
|
||||||
mm_last_addr = addr;
|
mm_last_addr = addr;
|
||||||
mm_last_size = size;
|
mm_last_size = size;
|
||||||
@ -1060,89 +1117,27 @@ mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[])
|
|||||||
|
|
||||||
#ifdef CONFIG_CMD_CRC32
|
#ifdef CONFIG_CMD_CRC32
|
||||||
|
|
||||||
#ifndef CONFIG_CRC32_VERIFY
|
|
||||||
|
|
||||||
static int do_mem_crc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
static int do_mem_crc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
||||||
{
|
{
|
||||||
ulong addr, length;
|
int flags = 0;
|
||||||
ulong crc;
|
int ac;
|
||||||
ulong *ptr;
|
char * const *av;
|
||||||
|
|
||||||
if (argc < 3)
|
if (argc < 3)
|
||||||
return CMD_RET_USAGE;
|
return CMD_RET_USAGE;
|
||||||
|
|
||||||
addr = simple_strtoul (argv[1], NULL, 16);
|
|
||||||
addr += base_address;
|
|
||||||
|
|
||||||
length = simple_strtoul (argv[2], NULL, 16);
|
|
||||||
|
|
||||||
crc = crc32_wd (0, (const uchar *) addr, length, CHUNKSZ_CRC32);
|
|
||||||
|
|
||||||
printf ("CRC32 for %08lx ... %08lx ==> %08lx\n",
|
|
||||||
addr, addr + length - 1, crc);
|
|
||||||
|
|
||||||
if (argc > 3) {
|
|
||||||
ptr = (ulong *) simple_strtoul (argv[3], NULL, 16);
|
|
||||||
*ptr = crc;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else /* CONFIG_CRC32_VERIFY */
|
|
||||||
|
|
||||||
int do_mem_crc (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
|
||||||
{
|
|
||||||
ulong addr, length;
|
|
||||||
ulong crc;
|
|
||||||
ulong *ptr;
|
|
||||||
ulong vcrc;
|
|
||||||
int verify;
|
|
||||||
int ac;
|
|
||||||
char * const *av;
|
|
||||||
|
|
||||||
if (argc < 3) {
|
|
||||||
usage:
|
|
||||||
return CMD_RET_USAGE;
|
|
||||||
}
|
|
||||||
|
|
||||||
av = argv + 1;
|
av = argv + 1;
|
||||||
ac = argc - 1;
|
ac = argc - 1;
|
||||||
|
#ifdef CONFIG_HASH_VERIFY
|
||||||
if (strcmp(*av, "-v") == 0) {
|
if (strcmp(*av, "-v") == 0) {
|
||||||
verify = 1;
|
flags |= HASH_FLAG_VERIFY;
|
||||||
av++;
|
av++;
|
||||||
ac--;
|
ac--;
|
||||||
if (ac < 3)
|
|
||||||
goto usage;
|
|
||||||
} else
|
|
||||||
verify = 0;
|
|
||||||
|
|
||||||
addr = simple_strtoul(*av++, NULL, 16);
|
|
||||||
addr += base_address;
|
|
||||||
length = simple_strtoul(*av++, NULL, 16);
|
|
||||||
|
|
||||||
crc = crc32_wd (0, (const uchar *) addr, length, CHUNKSZ_CRC32);
|
|
||||||
|
|
||||||
if (!verify) {
|
|
||||||
printf ("CRC32 for %08lx ... %08lx ==> %08lx\n",
|
|
||||||
addr, addr + length - 1, crc);
|
|
||||||
if (ac > 2) {
|
|
||||||
ptr = (ulong *) simple_strtoul (*av++, NULL, 16);
|
|
||||||
*ptr = crc;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
vcrc = simple_strtoul(*av++, NULL, 16);
|
|
||||||
if (vcrc != crc) {
|
|
||||||
printf ("CRC32 for %08lx ... %08lx ==> %08lx != %08lx ** ERROR **\n",
|
|
||||||
addr, addr + length - 1, crc, vcrc);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return hash_command("crc32", flags, cmdtp, flag, ac, av);
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_CRC32_VERIFY */
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -230,7 +230,6 @@ static void memsize_format(char *buf, u32 size)
|
|||||||
*/
|
*/
|
||||||
static void index_partitions(void)
|
static void index_partitions(void)
|
||||||
{
|
{
|
||||||
char buf[16];
|
|
||||||
u16 mtddevnum;
|
u16 mtddevnum;
|
||||||
struct part_info *part;
|
struct part_info *part;
|
||||||
struct list_head *dentry;
|
struct list_head *dentry;
|
||||||
@ -244,8 +243,7 @@ static void index_partitions(void)
|
|||||||
dev = list_entry(dentry, struct mtd_device, link);
|
dev = list_entry(dentry, struct mtd_device, link);
|
||||||
if (dev == current_mtd_dev) {
|
if (dev == current_mtd_dev) {
|
||||||
mtddevnum += current_mtd_partnum;
|
mtddevnum += current_mtd_partnum;
|
||||||
sprintf(buf, "%d", mtddevnum);
|
setenv_ulong("mtddevnum", mtddevnum);
|
||||||
setenv("mtddevnum", buf);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
mtddevnum += dev->num_parts;
|
mtddevnum += dev->num_parts;
|
||||||
|
@ -373,7 +373,6 @@ static void nand_print_and_set_info(int idx)
|
|||||||
{
|
{
|
||||||
nand_info_t *nand = &nand_info[idx];
|
nand_info_t *nand = &nand_info[idx];
|
||||||
struct nand_chip *chip = nand->priv;
|
struct nand_chip *chip = nand->priv;
|
||||||
char buf[32];
|
|
||||||
|
|
||||||
printf("Device %d: ", idx);
|
printf("Device %d: ", idx);
|
||||||
if (chip->numchips > 1)
|
if (chip->numchips > 1)
|
||||||
@ -385,14 +384,9 @@ static void nand_print_and_set_info(int idx)
|
|||||||
printf(" Erase size %8d b\n", nand->erasesize);
|
printf(" Erase size %8d b\n", nand->erasesize);
|
||||||
|
|
||||||
/* Set geometry info */
|
/* Set geometry info */
|
||||||
sprintf(buf, "%x", nand->writesize);
|
setenv_hex("nand_writesize", nand->writesize);
|
||||||
setenv("nand_writesize", buf);
|
setenv_hex("nand_oobsize", nand->oobsize);
|
||||||
|
setenv_hex("nand_erasesize", nand->erasesize);
|
||||||
sprintf(buf, "%x", nand->oobsize);
|
|
||||||
setenv("nand_oobsize", buf);
|
|
||||||
|
|
||||||
sprintf(buf, "%x", nand->erasesize);
|
|
||||||
setenv("nand_erasesize", buf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int raw_access(nand_info_t *nand, ulong addr, loff_t off, ulong count,
|
static int raw_access(nand_info_t *nand, ulong addr, loff_t off, ulong count,
|
||||||
|
@ -295,17 +295,17 @@ int setenv_ulong(const char *varname, ulong value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set an environment variable to an address in hex
|
* Set an environment variable to an value in hex
|
||||||
*
|
*
|
||||||
* @param varname Environmet variable to set
|
* @param varname Environmet variable to set
|
||||||
* @param addr Value to set it to
|
* @param value Value to set it to
|
||||||
* @return 0 if ok, 1 on error
|
* @return 0 if ok, 1 on error
|
||||||
*/
|
*/
|
||||||
int setenv_addr(const char *varname, const void *addr)
|
int setenv_hex(const char *varname, ulong value)
|
||||||
{
|
{
|
||||||
char str[17];
|
char str[17];
|
||||||
|
|
||||||
sprintf(str, "%lx", (uintptr_t)addr);
|
sprintf(str, "%lx", value);
|
||||||
return setenv(varname, str);
|
return setenv(varname, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -891,8 +891,7 @@ NXTARG: ;
|
|||||||
envp->flags = ACTIVE_FLAG;
|
envp->flags = ACTIVE_FLAG;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
sprintf(buf, "%zX", (size_t)(len + offsetof(env_t, data)));
|
setenv_hex("filesize", len + offsetof(env_t, data));
|
||||||
setenv("filesize", buf);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -100,7 +100,6 @@ int do_reiserload (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
|||||||
ulong addr = 0, filelen;
|
ulong addr = 0, filelen;
|
||||||
disk_partition_t info;
|
disk_partition_t info;
|
||||||
block_dev_desc_t *dev_desc = NULL;
|
block_dev_desc_t *dev_desc = NULL;
|
||||||
char buf [12];
|
|
||||||
unsigned long count;
|
unsigned long count;
|
||||||
char *addr_str;
|
char *addr_str;
|
||||||
|
|
||||||
@ -175,8 +174,7 @@ int do_reiserload (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
|||||||
load_addr = addr;
|
load_addr = addr;
|
||||||
|
|
||||||
printf ("\n%ld bytes read\n", filelen);
|
printf ("\n%ld bytes read\n", filelen);
|
||||||
sprintf(buf, "%lX", filelen);
|
setenv_hex("filesize", filelen);
|
||||||
setenv("filesize", buf);
|
|
||||||
|
|
||||||
return filelen;
|
return filelen;
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ static ulong get_arg(char *s, int w)
|
|||||||
static int do_setexpr(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
static int do_setexpr(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
||||||
{
|
{
|
||||||
ulong a, b;
|
ulong a, b;
|
||||||
char buf[16];
|
ulong value;
|
||||||
int w;
|
int w;
|
||||||
|
|
||||||
/* Validate arguments */
|
/* Validate arguments */
|
||||||
@ -67,8 +67,7 @@ static int do_setexpr(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
|||||||
a = get_arg(argv[2], w);
|
a = get_arg(argv[2], w);
|
||||||
|
|
||||||
if (argc == 3) {
|
if (argc == 3) {
|
||||||
sprintf(buf, "%lx", a);
|
setenv_hex(argv[1], a);
|
||||||
setenv(argv[1], buf);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -76,20 +75,36 @@ static int do_setexpr(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
|||||||
b = get_arg(argv[4], w);
|
b = get_arg(argv[4], w);
|
||||||
|
|
||||||
switch (argv[3][0]) {
|
switch (argv[3][0]) {
|
||||||
case '|': sprintf(buf, "%lx", (a | b)); break;
|
case '|':
|
||||||
case '&': sprintf(buf, "%lx", (a & b)); break;
|
value = a | b;
|
||||||
case '+': sprintf(buf, "%lx", (a + b)); break;
|
break;
|
||||||
case '^': sprintf(buf, "%lx", (a ^ b)); break;
|
case '&':
|
||||||
case '-': sprintf(buf, "%lx", (a - b)); break;
|
value = a & b;
|
||||||
case '*': sprintf(buf, "%lx", (a * b)); break;
|
break;
|
||||||
case '/': sprintf(buf, "%lx", (a / b)); break;
|
case '+':
|
||||||
case '%': sprintf(buf, "%lx", (a % b)); break;
|
value = a + b;
|
||||||
|
break;
|
||||||
|
case '^':
|
||||||
|
value = a ^ b;
|
||||||
|
break;
|
||||||
|
case '-':
|
||||||
|
value = a - b;
|
||||||
|
break;
|
||||||
|
case '*':
|
||||||
|
value = a * b;
|
||||||
|
break;
|
||||||
|
case '/':
|
||||||
|
value = a / b;
|
||||||
|
break;
|
||||||
|
case '%':
|
||||||
|
value = a % b;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
printf("invalid op\n");
|
printf("invalid op\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
setenv(argv[1], buf);
|
setenv_hex(argv[1], value);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
int do_sha1sum(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
int do_sha1sum(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
||||||
{
|
{
|
||||||
int verify = 0;
|
int flags = HASH_FLAG_ENV;
|
||||||
int ac;
|
int ac;
|
||||||
char * const *av;
|
char * const *av;
|
||||||
|
|
||||||
@ -42,13 +42,13 @@ int do_sha1sum(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
|||||||
ac = argc - 1;
|
ac = argc - 1;
|
||||||
#ifdef CONFIG_SHA1SUM_VERIFY
|
#ifdef CONFIG_SHA1SUM_VERIFY
|
||||||
if (strcmp(*av, "-v") == 0) {
|
if (strcmp(*av, "-v") == 0) {
|
||||||
verify = 1;
|
flags |= HASH_FLAG_VERIFY;
|
||||||
av++;
|
av++;
|
||||||
ac--;
|
ac--;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return hash_command("sha1", verify, cmdtp, flag, ac, av);
|
return hash_command("sha1", flags, cmdtp, flag, ac, av);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_SHA1SUM_VERIFY
|
#ifdef CONFIG_SHA1SUM_VERIFY
|
||||||
|
@ -28,7 +28,6 @@ static int do_unzip(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
|||||||
{
|
{
|
||||||
unsigned long src, dst;
|
unsigned long src, dst;
|
||||||
unsigned long src_len = ~0UL, dst_len = ~0UL;
|
unsigned long src_len = ~0UL, dst_len = ~0UL;
|
||||||
char buf[32];
|
|
||||||
|
|
||||||
switch (argc) {
|
switch (argc) {
|
||||||
case 4:
|
case 4:
|
||||||
@ -46,8 +45,7 @@ static int do_unzip(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
|||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
printf("Uncompressed size: %ld = 0x%lX\n", src_len, src_len);
|
printf("Uncompressed size: %ld = 0x%lX\n", src_len, src_len);
|
||||||
sprintf(buf, "%lX", src_len);
|
setenv_hex("filesize", src_len);
|
||||||
setenv("filesize", buf);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,6 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
|
|||||||
ulong data, len, count;
|
ulong data, len, count;
|
||||||
int verify;
|
int verify;
|
||||||
int part = 0;
|
int part = 0;
|
||||||
char pbuf[10];
|
|
||||||
image_header_t *hdr;
|
image_header_t *hdr;
|
||||||
#if defined(CONFIG_FIT)
|
#if defined(CONFIG_FIT)
|
||||||
const char *uname = NULL;
|
const char *uname = NULL;
|
||||||
@ -256,10 +255,8 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
|
|||||||
puts("OK\n");
|
puts("OK\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(pbuf, "%8lx", data);
|
setenv_hex("fileaddr", data);
|
||||||
setenv("fileaddr", pbuf);
|
setenv_hex("filesize", len);
|
||||||
sprintf(pbuf, "%8lx", len);
|
|
||||||
setenv("filesize", pbuf);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -129,8 +129,7 @@ static int do_zfs_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]
|
|||||||
load_addr = addr;
|
load_addr = addr;
|
||||||
|
|
||||||
printf("%llu bytes read\n", zfile.size);
|
printf("%llu bytes read\n", zfile.size);
|
||||||
sprintf(buf, "%llX", zfile.size);
|
setenv_hex("filesize", zfile.size);
|
||||||
setenv("filesize", buf);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,6 @@ static int do_zip(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
|||||||
{
|
{
|
||||||
unsigned long src, dst;
|
unsigned long src, dst;
|
||||||
unsigned long src_len, dst_len = ~0UL;
|
unsigned long src_len, dst_len = ~0UL;
|
||||||
char buf[32];
|
|
||||||
|
|
||||||
switch (argc) {
|
switch (argc) {
|
||||||
case 5:
|
case 5:
|
||||||
@ -47,8 +46,7 @@ static int do_zip(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
|||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
printf("Compressed size: %ld = 0x%lX\n", dst_len, dst_len);
|
printf("Compressed size: %ld = 0x%lX\n", dst_len, dst_len);
|
||||||
sprintf(buf, "%lX", dst_len);
|
setenv_hex("filesize", dst_len);
|
||||||
setenv("filesize", buf);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
148
common/hash.c
148
common/hash.c
@ -28,49 +28,87 @@
|
|||||||
#include <hash.h>
|
#include <hash.h>
|
||||||
#include <sha1.h>
|
#include <sha1.h>
|
||||||
#include <sha256.h>
|
#include <sha256.h>
|
||||||
|
#include <asm/io.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These are the hash algorithms we support. Chips which support accelerated
|
* These are the hash algorithms we support. Chips which support accelerated
|
||||||
* crypto could perhaps add named version of these algorithms here.
|
* crypto could perhaps add named version of these algorithms here. Note that
|
||||||
|
* algorithm names must be in lower case.
|
||||||
*/
|
*/
|
||||||
static struct hash_algo hash_algo[] = {
|
static struct hash_algo hash_algo[] = {
|
||||||
#ifdef CONFIG_SHA1
|
/*
|
||||||
|
* This is CONFIG_CMD_SHA1SUM instead of CONFIG_SHA1 since otherwise
|
||||||
|
* it bloats the code for boards which use SHA1 but not the 'hash'
|
||||||
|
* or 'sha1sum' commands.
|
||||||
|
*/
|
||||||
|
#ifdef CONFIG_CMD_SHA1SUM
|
||||||
{
|
{
|
||||||
"SHA1",
|
"sha1",
|
||||||
SHA1_SUM_LEN,
|
SHA1_SUM_LEN,
|
||||||
sha1_csum_wd,
|
sha1_csum_wd,
|
||||||
CHUNKSZ_SHA1,
|
CHUNKSZ_SHA1,
|
||||||
},
|
},
|
||||||
|
#define MULTI_HASH
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_SHA256
|
#ifdef CONFIG_SHA256
|
||||||
{
|
{
|
||||||
"SHA256",
|
"sha256",
|
||||||
SHA256_SUM_LEN,
|
SHA256_SUM_LEN,
|
||||||
sha256_csum_wd,
|
sha256_csum_wd,
|
||||||
CHUNKSZ_SHA256,
|
CHUNKSZ_SHA256,
|
||||||
},
|
},
|
||||||
|
#define MULTI_HASH
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
|
"crc32",
|
||||||
|
4,
|
||||||
|
crc32_wd_buf,
|
||||||
|
CHUNKSZ_CRC32,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if defined(CONFIG_HASH_VERIFY) || defined(CONFIG_CMD_HASH)
|
||||||
|
#define MULTI_HASH
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Try to minimize code size for boards that don't want much hashing */
|
||||||
|
#ifdef MULTI_HASH
|
||||||
|
#define multi_hash() 1
|
||||||
|
#else
|
||||||
|
#define multi_hash() 0
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* store_result: Store the resulting sum to an address or variable
|
* store_result: Store the resulting sum to an address or variable
|
||||||
*
|
*
|
||||||
* @algo: Hash algorithm being used
|
* @algo: Hash algorithm being used
|
||||||
* @sum: Hash digest (algo->digest_size bytes)
|
* @sum: Hash digest (algo->digest_size bytes)
|
||||||
* @dest: Destination, interpreted as a hex address if it starts
|
* @dest: Destination, interpreted as a hex address if it starts
|
||||||
* with * or otherwise as an environment variable.
|
* with * (or allow_env_vars is 0) or otherwise as an
|
||||||
|
* environment variable.
|
||||||
|
* @allow_env_vars: non-zero to permit storing the result to an
|
||||||
|
* variable environment
|
||||||
*/
|
*/
|
||||||
static void store_result(struct hash_algo *algo, const u8 *sum,
|
static void store_result(struct hash_algo *algo, const u8 *sum,
|
||||||
const char *dest)
|
const char *dest, int allow_env_vars)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
int env_var = 0;
|
||||||
|
|
||||||
if (*dest == '*') {
|
/*
|
||||||
u8 *ptr;
|
* If environment variables are allowed, then we assume that 'dest'
|
||||||
|
* is an environment variable, unless it starts with *, in which
|
||||||
|
* case we assume it is an address. If not allowed, it is always an
|
||||||
|
* address. This is to support the crc32 command.
|
||||||
|
*/
|
||||||
|
if (allow_env_vars) {
|
||||||
|
if (*dest == '*')
|
||||||
|
dest++;
|
||||||
|
else
|
||||||
|
env_var = 1;
|
||||||
|
}
|
||||||
|
|
||||||
ptr = (u8 *)simple_strtoul(dest + 1, NULL, 16);
|
if (env_var) {
|
||||||
memcpy(ptr, sum, algo->digest_size);
|
|
||||||
} else {
|
|
||||||
char str_output[HASH_MAX_DIGEST_SIZE * 2 + 1];
|
char str_output[HASH_MAX_DIGEST_SIZE * 2 + 1];
|
||||||
char *str_ptr = str_output;
|
char *str_ptr = str_output;
|
||||||
|
|
||||||
@ -80,6 +118,14 @@ static void store_result(struct hash_algo *algo, const u8 *sum,
|
|||||||
}
|
}
|
||||||
str_ptr = '\0';
|
str_ptr = '\0';
|
||||||
setenv(dest, str_output);
|
setenv(dest, str_output);
|
||||||
|
} else {
|
||||||
|
ulong addr;
|
||||||
|
void *buf;
|
||||||
|
|
||||||
|
addr = simple_strtoul(dest, NULL, 16);
|
||||||
|
buf = map_sysmem(addr, algo->digest_size);
|
||||||
|
memcpy(buf, sum, algo->digest_size);
|
||||||
|
unmap_sysmem(buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,15 +140,31 @@ static void store_result(struct hash_algo *algo, const u8 *sum,
|
|||||||
* Otherwise we assume it is an environment variable, and
|
* Otherwise we assume it is an environment variable, and
|
||||||
* look up its value (it must contain a hex digest).
|
* look up its value (it must contain a hex digest).
|
||||||
* @vsum: Returns binary digest value (algo->digest_size bytes)
|
* @vsum: Returns binary digest value (algo->digest_size bytes)
|
||||||
|
* @allow_env_vars: non-zero to permit storing the result to an environment
|
||||||
|
* variable. If 0 then verify_str is assumed to be an
|
||||||
|
* address, and the * prefix is not expected.
|
||||||
* @return 0 if ok, non-zero on error
|
* @return 0 if ok, non-zero on error
|
||||||
*/
|
*/
|
||||||
static int parse_verify_sum(struct hash_algo *algo, char *verify_str, u8 *vsum)
|
static int parse_verify_sum(struct hash_algo *algo, char *verify_str, u8 *vsum,
|
||||||
|
int allow_env_vars)
|
||||||
{
|
{
|
||||||
if (*verify_str == '*') {
|
int env_var = 0;
|
||||||
u8 *ptr;
|
|
||||||
|
|
||||||
ptr = (u8 *)simple_strtoul(verify_str + 1, NULL, 16);
|
/* See comment above in store_result() */
|
||||||
memcpy(vsum, ptr, algo->digest_size);
|
if (allow_env_vars) {
|
||||||
|
if (*verify_str == '*')
|
||||||
|
verify_str++;
|
||||||
|
else
|
||||||
|
env_var = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (env_var) {
|
||||||
|
ulong addr;
|
||||||
|
void *buf;
|
||||||
|
|
||||||
|
addr = simple_strtoul(verify_str, NULL, 16);
|
||||||
|
buf = map_sysmem(addr, algo->digest_size);
|
||||||
|
memcpy(vsum, buf, algo->digest_size);
|
||||||
} else {
|
} else {
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
char *vsum_str;
|
char *vsum_str;
|
||||||
@ -141,7 +203,7 @@ static struct hash_algo *find_hash_algo(const char *name)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(hash_algo); i++) {
|
for (i = 0; i < ARRAY_SIZE(hash_algo); i++) {
|
||||||
if (!strcasecmp(name, hash_algo[i].name))
|
if (!strcmp(name, hash_algo[i].name))
|
||||||
return &hash_algo[i];
|
return &hash_algo[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,24 +220,28 @@ static void show_hash(struct hash_algo *algo, ulong addr, ulong len,
|
|||||||
printf("%02x", output[i]);
|
printf("%02x", output[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
int hash_command(const char *algo_name, int verify, cmd_tbl_t *cmdtp, int flag,
|
int hash_command(const char *algo_name, int flags, cmd_tbl_t *cmdtp, int flag,
|
||||||
int argc, char * const argv[])
|
int argc, char * const argv[])
|
||||||
{
|
{
|
||||||
struct hash_algo *algo;
|
|
||||||
ulong addr, len;
|
ulong addr, len;
|
||||||
u8 output[HASH_MAX_DIGEST_SIZE];
|
|
||||||
u8 vsum[HASH_MAX_DIGEST_SIZE];
|
|
||||||
|
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
return CMD_RET_USAGE;
|
return CMD_RET_USAGE;
|
||||||
|
|
||||||
|
addr = simple_strtoul(*argv++, NULL, 16);
|
||||||
|
len = simple_strtoul(*argv++, NULL, 16);
|
||||||
|
|
||||||
|
if (multi_hash()) {
|
||||||
|
struct hash_algo *algo;
|
||||||
|
u8 output[HASH_MAX_DIGEST_SIZE];
|
||||||
|
u8 vsum[HASH_MAX_DIGEST_SIZE];
|
||||||
|
void *buf;
|
||||||
|
|
||||||
algo = find_hash_algo(algo_name);
|
algo = find_hash_algo(algo_name);
|
||||||
if (!algo) {
|
if (!algo) {
|
||||||
printf("Unknown hash algorithm '%s'\n", algo_name);
|
printf("Unknown hash algorithm '%s'\n", algo_name);
|
||||||
return CMD_RET_USAGE;
|
return CMD_RET_USAGE;
|
||||||
}
|
}
|
||||||
addr = simple_strtoul(*argv++, NULL, 16);
|
|
||||||
len = simple_strtoul(*argv++, NULL, 16);
|
|
||||||
argc -= 2;
|
argc -= 2;
|
||||||
|
|
||||||
if (algo->digest_size > HASH_MAX_DIGEST_SIZE) {
|
if (algo->digest_size > HASH_MAX_DIGEST_SIZE) {
|
||||||
@ -183,20 +249,22 @@ int hash_command(const char *algo_name, int verify, cmd_tbl_t *cmdtp, int flag,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
algo->hash_func_ws((const unsigned char *)addr, len, output,
|
buf = map_sysmem(addr, len);
|
||||||
algo->chunk_size);
|
algo->hash_func_ws(buf, len, output, algo->chunk_size);
|
||||||
|
unmap_sysmem(buf);
|
||||||
|
|
||||||
/* Try to avoid code bloat when verify is not needed */
|
/* Try to avoid code bloat when verify is not needed */
|
||||||
#ifdef CONFIG_HASH_VERIFY
|
#ifdef CONFIG_HASH_VERIFY
|
||||||
if (verify) {
|
if (flags & HASH_FLAG_VERIFY) {
|
||||||
#else
|
#else
|
||||||
if (0) {
|
if (0) {
|
||||||
#endif
|
#endif
|
||||||
if (!argc)
|
if (!argc)
|
||||||
return CMD_RET_USAGE;
|
return CMD_RET_USAGE;
|
||||||
if (parse_verify_sum(algo, *argv, vsum)) {
|
if (parse_verify_sum(algo, *argv, vsum,
|
||||||
printf("ERROR: %s does not contain a valid %s sum\n",
|
flags & HASH_FLAG_ENV)) {
|
||||||
*argv, algo->name);
|
printf("ERROR: %s does not contain a valid "
|
||||||
|
"%s sum\n", *argv, algo->name);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (memcmp(output, vsum, algo->digest_size) != 0) {
|
if (memcmp(output, vsum, algo->digest_size) != 0) {
|
||||||
@ -213,8 +281,26 @@ int hash_command(const char *algo_name, int verify, cmd_tbl_t *cmdtp, int flag,
|
|||||||
show_hash(algo, addr, len, output);
|
show_hash(algo, addr, len, output);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
if (argc)
|
if (argc) {
|
||||||
store_result(algo, output, *argv);
|
store_result(algo, output, *argv,
|
||||||
|
flags & HASH_FLAG_ENV);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Horrible code size hack for boards that just want crc32 */
|
||||||
|
} else {
|
||||||
|
ulong crc;
|
||||||
|
ulong *ptr;
|
||||||
|
|
||||||
|
crc = crc32_wd(0, (const uchar *)addr, len, CHUNKSZ_CRC32);
|
||||||
|
|
||||||
|
printf("CRC32 for %08lx ... %08lx ==> %08lx\n",
|
||||||
|
addr, addr + len - 1, crc);
|
||||||
|
|
||||||
|
if (argc > 3) {
|
||||||
|
ptr = (ulong *)simple_strtoul(argv[3], NULL, 16);
|
||||||
|
*ptr = crc;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -74,6 +74,8 @@ static const image_header_t *image_get_ramdisk(ulong rd_addr, uint8_t arch,
|
|||||||
#include <image.h>
|
#include <image.h>
|
||||||
#endif /* !USE_HOSTCC*/
|
#endif /* !USE_HOSTCC*/
|
||||||
|
|
||||||
|
#include <u-boot/crc.h>
|
||||||
|
|
||||||
static const table_entry_t uimage_arch[] = {
|
static const table_entry_t uimage_arch[] = {
|
||||||
{ IH_ARCH_INVALID, NULL, "Invalid ARCH", },
|
{ IH_ARCH_INVALID, NULL, "Invalid ARCH", },
|
||||||
{ IH_ARCH_ALPHA, "alpha", "Alpha", },
|
{ IH_ARCH_ALPHA, "alpha", "Alpha", },
|
||||||
@ -160,8 +162,6 @@ static const table_entry_t uimage_comp[] = {
|
|||||||
{ -1, "", "", },
|
{ -1, "", "", },
|
||||||
};
|
};
|
||||||
|
|
||||||
uint32_t crc32(uint32_t, const unsigned char *, uint);
|
|
||||||
uint32_t crc32_wd(uint32_t, const unsigned char *, uint, uint);
|
|
||||||
#if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) || defined(USE_HOSTCC)
|
#if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) || defined(USE_HOSTCC)
|
||||||
static void genimg_print_time(time_t timestamp);
|
static void genimg_print_time(time_t timestamp);
|
||||||
#endif
|
#endif
|
||||||
|
@ -362,7 +362,6 @@ static void fm_init_qmi(struct fm_qmi_common *qmi)
|
|||||||
int fm_init_common(int index, struct ccsr_fman *reg)
|
int fm_init_common(int index, struct ccsr_fman *reg)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
char env_addr[32];
|
|
||||||
#if defined(CONFIG_SYS_QE_FMAN_FW_IN_NOR)
|
#if defined(CONFIG_SYS_QE_FMAN_FW_IN_NOR)
|
||||||
void *addr = (void *)CONFIG_SYS_QE_FMAN_FW_ADDR;
|
void *addr = (void *)CONFIG_SYS_QE_FMAN_FW_ADDR;
|
||||||
#elif defined(CONFIG_SYS_QE_FMAN_FW_IN_NAND)
|
#elif defined(CONFIG_SYS_QE_FMAN_FW_IN_NAND)
|
||||||
@ -416,8 +415,7 @@ int fm_init_common(int index, struct ccsr_fman *reg)
|
|||||||
rc = fman_upload_firmware(index, ®->fm_imem, addr);
|
rc = fman_upload_firmware(index, ®->fm_imem, addr);
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
sprintf(env_addr, "0x%lx", (long unsigned int)addr);
|
setenv_addr("fman_ucode", addr);
|
||||||
setenv("fman_ucode", env_addr);
|
|
||||||
|
|
||||||
fm_init_muram(index, ®->muram);
|
fm_init_muram(index, ®->muram);
|
||||||
fm_init_qmi(®->fm_qmi_common);
|
fm_init_qmi(®->fm_qmi_common);
|
||||||
|
@ -30,6 +30,19 @@
|
|||||||
#include <serial.h>
|
#include <serial.h>
|
||||||
#include <linux/compiler.h>
|
#include <linux/compiler.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* serial_buf: A buffer that holds keyboard characters for the
|
||||||
|
* Sandbox U-boot.
|
||||||
|
*
|
||||||
|
* invariants:
|
||||||
|
* serial_buf_write == serial_buf_read -> empty buffer
|
||||||
|
* (serial_buf_write + 1) % 16 == serial_buf_read -> full buffer
|
||||||
|
*/
|
||||||
|
static char serial_buf[16];
|
||||||
|
static unsigned int serial_buf_write;
|
||||||
|
static unsigned int serial_buf_read;
|
||||||
|
|
||||||
static int sandbox_serial_init(void)
|
static int sandbox_serial_init(void)
|
||||||
{
|
{
|
||||||
os_tty_raw(0);
|
os_tty_raw(0);
|
||||||
@ -50,18 +63,37 @@ static void sandbox_serial_puts(const char *str)
|
|||||||
os_write(1, str, strlen(str));
|
os_write(1, str, strlen(str));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sandbox_serial_getc(void)
|
static unsigned int increment_buffer_index(unsigned int index)
|
||||||
{
|
{
|
||||||
char buf;
|
return (index + 1) % ARRAY_SIZE(serial_buf);
|
||||||
ssize_t count;
|
|
||||||
|
|
||||||
count = os_read(0, &buf, 1);
|
|
||||||
return count == 1 ? buf : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sandbox_serial_tstc(void)
|
static int sandbox_serial_tstc(void)
|
||||||
{
|
{
|
||||||
return 0;
|
const unsigned int next_index =
|
||||||
|
increment_buffer_index(serial_buf_write);
|
||||||
|
ssize_t count;
|
||||||
|
|
||||||
|
os_usleep(100);
|
||||||
|
if (next_index == serial_buf_read)
|
||||||
|
return 1; /* buffer full */
|
||||||
|
|
||||||
|
count = os_read_no_block(0, &serial_buf[serial_buf_write], 1);
|
||||||
|
if (count == 1)
|
||||||
|
serial_buf_write = next_index;
|
||||||
|
return serial_buf_write != serial_buf_read;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int sandbox_serial_getc(void)
|
||||||
|
{
|
||||||
|
int result;
|
||||||
|
|
||||||
|
while (!sandbox_serial_tstc())
|
||||||
|
; /* buffer empty */
|
||||||
|
|
||||||
|
result = serial_buf[serial_buf_read];
|
||||||
|
serial_buf_read = increment_buffer_index(serial_buf_read);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct serial_device sandbox_serial_drv = {
|
static struct serial_device sandbox_serial_drv = {
|
||||||
|
4
fs/fs.c
4
fs/fs.c
@ -256,7 +256,6 @@ int do_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
|
|||||||
unsigned long bytes;
|
unsigned long bytes;
|
||||||
unsigned long pos;
|
unsigned long pos;
|
||||||
int len_read;
|
int len_read;
|
||||||
char buf[12];
|
|
||||||
unsigned long time;
|
unsigned long time;
|
||||||
|
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
@ -308,8 +307,7 @@ int do_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
|
|||||||
}
|
}
|
||||||
puts("\n");
|
puts("\n");
|
||||||
|
|
||||||
sprintf(buf, "0x%x", len_read);
|
setenv_hex("filesize", len_read);
|
||||||
setenv("filesize", buf);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -687,7 +687,6 @@ int ubifs_load(char *filename, u32 addr, u32 size)
|
|||||||
int i;
|
int i;
|
||||||
int count;
|
int count;
|
||||||
int last_block_size = 0;
|
int last_block_size = 0;
|
||||||
char buf [10];
|
|
||||||
|
|
||||||
c->ubi = ubi_open_volume(c->vi.ubi_num, c->vi.vol_id, UBI_READONLY);
|
c->ubi = ubi_open_volume(c->vi.ubi_num, c->vi.vol_id, UBI_READONLY);
|
||||||
/* ubifs_findfile will resolve symlinks, so we know that we get
|
/* ubifs_findfile will resolve symlinks, so we know that we get
|
||||||
@ -740,8 +739,7 @@ int ubifs_load(char *filename, u32 addr, u32 size)
|
|||||||
if (err)
|
if (err)
|
||||||
printf("Error reading file '%s'\n", filename);
|
printf("Error reading file '%s'\n", filename);
|
||||||
else {
|
else {
|
||||||
sprintf(buf, "%X", size);
|
setenv_hex("filesize", size);
|
||||||
setenv("filesize", buf);
|
|
||||||
printf("Done\n");
|
printf("Done\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,7 +270,8 @@ int cpu_init(void);
|
|||||||
phys_size_t initdram (int);
|
phys_size_t initdram (int);
|
||||||
int display_options (void);
|
int display_options (void);
|
||||||
void print_size(unsigned long long, const char *);
|
void print_size(unsigned long long, const char *);
|
||||||
int print_buffer (ulong addr, void* data, uint width, uint count, uint linelen);
|
int print_buffer(ulong addr, const void *data, uint width, uint count,
|
||||||
|
uint linelen);
|
||||||
|
|
||||||
/* common/main.c */
|
/* common/main.c */
|
||||||
void main_loop (void);
|
void main_loop (void);
|
||||||
@ -357,7 +358,19 @@ int getenv_yesno(const char *var);
|
|||||||
int saveenv (void);
|
int saveenv (void);
|
||||||
int setenv (const char *, const char *);
|
int setenv (const char *, const char *);
|
||||||
int setenv_ulong(const char *varname, ulong value);
|
int setenv_ulong(const char *varname, ulong value);
|
||||||
int setenv_addr(const char *varname, const void *addr);
|
int setenv_hex(const char *varname, ulong value);
|
||||||
|
/**
|
||||||
|
* setenv_addr - Set an environment variable to an address in hex
|
||||||
|
*
|
||||||
|
* @varname: Environmet variable to set
|
||||||
|
* @addr: Value to set it to
|
||||||
|
* @return 0 if ok, 1 on error
|
||||||
|
*/
|
||||||
|
static inline int setenv_addr(const char *varname, const void *addr)
|
||||||
|
{
|
||||||
|
return setenv_hex(varname, (ulong)addr);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_ARM
|
#ifdef CONFIG_ARM
|
||||||
# include <asm/mach-types.h>
|
# include <asm/mach-types.h>
|
||||||
# include <asm/setup.h>
|
# include <asm/setup.h>
|
||||||
@ -869,6 +882,18 @@ int cpu_disable(int nr);
|
|||||||
int cpu_release(int nr, int argc, char * const argv[]);
|
int cpu_release(int nr, int argc, char * const argv[]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Define a null map_sysmem() if the architecture doesn't use it */
|
||||||
|
# ifndef CONFIG_ARCH_MAP_SYSMEM
|
||||||
|
static inline void *map_sysmem(phys_addr_t paddr, unsigned long len)
|
||||||
|
{
|
||||||
|
return (void *)(uintptr_t)paddr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void unmap_sysmem(const void *vaddr)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
#endif /* __ASSEMBLY__ */
|
#endif /* __ASSEMBLY__ */
|
||||||
|
|
||||||
#ifdef CONFIG_PPC
|
#ifdef CONFIG_PPC
|
||||||
|
@ -63,8 +63,8 @@
|
|||||||
#define CONFIG_SYS_HZ 1000
|
#define CONFIG_SYS_HZ 1000
|
||||||
|
|
||||||
/* Memory things - we don't really want a memory test */
|
/* Memory things - we don't really want a memory test */
|
||||||
#define CONFIG_SYS_LOAD_ADDR 0x10000000
|
#define CONFIG_SYS_LOAD_ADDR 0x00000000
|
||||||
#define CONFIG_SYS_MEMTEST_START 0x10000000
|
#define CONFIG_SYS_MEMTEST_START 0x00100000
|
||||||
#define CONFIG_SYS_MEMTEST_END (CONFIG_SYS_MEMTEST_START + 0x1000)
|
#define CONFIG_SYS_MEMTEST_END (CONFIG_SYS_MEMTEST_START + 0x1000)
|
||||||
#define CONFIG_PHYS_64BIT
|
#define CONFIG_PHYS_64BIT
|
||||||
|
|
||||||
@ -85,6 +85,11 @@
|
|||||||
#undef CONFIG_CMD_NET
|
#undef CONFIG_CMD_NET
|
||||||
#undef CONFIG_CMD_NFS
|
#undef CONFIG_CMD_NFS
|
||||||
|
|
||||||
|
#define CONFIG_CMD_HASH
|
||||||
|
#define CONFIG_HASH_VERIFY
|
||||||
|
#define CONFIG_SHA1
|
||||||
|
#define CONFIG_SHA256
|
||||||
|
|
||||||
#define CONFIG_BOOTARGS ""
|
#define CONFIG_BOOTARGS ""
|
||||||
|
|
||||||
#define CONFIG_EXTRA_ENV_SETTINGS "stdin=serial\0" \
|
#define CONFIG_EXTRA_ENV_SETTINGS "stdin=serial\0" \
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#ifndef _HASH_H
|
#ifndef _HASH_H
|
||||||
#define _HASH_H
|
#define _HASH_H
|
||||||
|
|
||||||
#ifdef CONFIG_SHA1SUM_VERIFY
|
#if defined(CONFIG_SHA1SUM_VERIFY) || defined(CONFIG_CRC32_VERIFY)
|
||||||
#define CONFIG_HASH_VERIFY
|
#define CONFIG_HASH_VERIFY
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -51,19 +51,24 @@ struct hash_algo {
|
|||||||
*/
|
*/
|
||||||
#define HASH_MAX_DIGEST_SIZE 32
|
#define HASH_MAX_DIGEST_SIZE 32
|
||||||
|
|
||||||
|
enum {
|
||||||
|
HASH_FLAG_VERIFY = 1 << 0, /* Enable verify mode */
|
||||||
|
HASH_FLAG_ENV = 1 << 1, /* Allow env vars */
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* hash_command: Process a hash command for a particular algorithm
|
* hash_command: Process a hash command for a particular algorithm
|
||||||
*
|
*
|
||||||
* This common function is used to implement specific hash commands.
|
* This common function is used to implement specific hash commands.
|
||||||
*
|
*
|
||||||
* @algo_name: Hash algorithm being used
|
* @algo_name: Hash algorithm being used (lower case!)
|
||||||
* @verify: Non-zero to enable verify mode
|
* @flags: Flags value (HASH_FLAG_...)
|
||||||
* @cmdtp: Pointer to command table entry
|
* @cmdtp: Pointer to command table entry
|
||||||
* @flag: Some flags normally 0 (see CMD_FLAG_.. above)
|
* @flag: Some flags normally 0 (see CMD_FLAG_.. above)
|
||||||
* @argc: Number of arguments (arg 0 must be the command text)
|
* @argc: Number of arguments (arg 0 must be the command text)
|
||||||
* @argv: Arguments
|
* @argv: Arguments
|
||||||
*/
|
*/
|
||||||
int hash_command(const char *algo_name, int verify, cmd_tbl_t *cmdtp, int flag,
|
int hash_command(const char *algo_name, int flags, cmd_tbl_t *cmdtp, int flag,
|
||||||
int argc, char * const argv[]);
|
int argc, char * const argv[]);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
10
include/os.h
10
include/os.h
@ -39,6 +39,16 @@ struct sandbox_state;
|
|||||||
*/
|
*/
|
||||||
ssize_t os_read(int fd, void *buf, size_t count);
|
ssize_t os_read(int fd, void *buf, size_t count);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Access to the OS read() system call with non-blocking access
|
||||||
|
*
|
||||||
|
* \param fd File descriptor as returned by os_open()
|
||||||
|
* \param buf Buffer to place data
|
||||||
|
* \param count Number of bytes to read
|
||||||
|
* \return number of bytes read, or -1 on error
|
||||||
|
*/
|
||||||
|
ssize_t os_read_no_block(int fd, void *buf, size_t count);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Access to the OS write() system call
|
* Access to the OS write() system call
|
||||||
*
|
*
|
||||||
|
@ -30,4 +30,15 @@ uint32_t crc32 (uint32_t, const unsigned char *, uint);
|
|||||||
uint32_t crc32_wd (uint32_t, const unsigned char *, uint, uint);
|
uint32_t crc32_wd (uint32_t, const unsigned char *, uint, uint);
|
||||||
uint32_t crc32_no_comp (uint32_t, const unsigned char *, uint);
|
uint32_t crc32_no_comp (uint32_t, const unsigned char *, uint);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* crc32_wd_buf - Perform CRC32 on a buffer and return result in buffer
|
||||||
|
*
|
||||||
|
* @input: Input buffer
|
||||||
|
* @ilen: Input buffer length
|
||||||
|
* @output: Place to put checksum result (4 bytes)
|
||||||
|
* @chunk_sz: Trigger watchdog after processing this many bytes
|
||||||
|
*/
|
||||||
|
void crc32_wd_buf(const unsigned char *input, uint ilen,
|
||||||
|
unsigned char *output, uint chunk_sz);
|
||||||
|
|
||||||
#endif /* _UBOOT_CRC_H */
|
#endif /* _UBOOT_CRC_H */
|
||||||
|
@ -249,3 +249,12 @@ uint32_t ZEXPORT crc32_wd (uint32_t crc,
|
|||||||
|
|
||||||
return crc;
|
return crc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void crc32_wd_buf(const unsigned char *input, unsigned int ilen,
|
||||||
|
unsigned char *output, unsigned int chunk_sz)
|
||||||
|
{
|
||||||
|
uint32_t crc;
|
||||||
|
|
||||||
|
crc = crc32_wd(0, input, ilen, chunk_sz);
|
||||||
|
memcpy(output, &crc, sizeof(crc));
|
||||||
|
}
|
||||||
|
@ -98,7 +98,8 @@ void print_size(unsigned long long size, const char *s)
|
|||||||
*/
|
*/
|
||||||
#define MAX_LINE_LENGTH_BYTES (64)
|
#define MAX_LINE_LENGTH_BYTES (64)
|
||||||
#define DEFAULT_LINE_LENGTH_BYTES (16)
|
#define DEFAULT_LINE_LENGTH_BYTES (16)
|
||||||
int print_buffer (ulong addr, void* data, uint width, uint count, uint linelen)
|
int print_buffer(ulong addr, const void *data, uint width, uint count,
|
||||||
|
uint linelen)
|
||||||
{
|
{
|
||||||
/* linebuf as a union causes proper alignment */
|
/* linebuf as a union causes proper alignment */
|
||||||
union linebuf {
|
union linebuf {
|
||||||
|
@ -528,15 +528,11 @@ restart:
|
|||||||
case NETLOOP_SUCCESS:
|
case NETLOOP_SUCCESS:
|
||||||
net_cleanup_loop();
|
net_cleanup_loop();
|
||||||
if (NetBootFileXferSize > 0) {
|
if (NetBootFileXferSize > 0) {
|
||||||
char buf[20];
|
|
||||||
printf("Bytes transferred = %ld (%lx hex)\n",
|
printf("Bytes transferred = %ld (%lx hex)\n",
|
||||||
NetBootFileXferSize,
|
NetBootFileXferSize,
|
||||||
NetBootFileXferSize);
|
NetBootFileXferSize);
|
||||||
sprintf(buf, "%lX", NetBootFileXferSize);
|
setenv_hex("filesize", NetBootFileXferSize);
|
||||||
setenv("filesize", buf);
|
setenv_hex("fileaddr", load_addr);
|
||||||
|
|
||||||
sprintf(buf, "%lX", (unsigned long)load_addr);
|
|
||||||
setenv("fileaddr", buf);
|
|
||||||
}
|
}
|
||||||
if (protocol != NETCONS)
|
if (protocol != NETCONS)
|
||||||
eth_halt();
|
eth_halt();
|
||||||
|
Loading…
Reference in New Issue
Block a user