diff --git a/commands/md.c b/commands/md.c index 07a03d5..c88259a 100644 --- a/commands/md.c +++ b/commands/md.c @@ -49,7 +49,7 @@ if (argc < 2) return COMMAND_ERROR_USAGE; - if (mem_parse_options(argc, argv, "bwls:x", &mode, &filename, NULL, + if (mem_parse_options(argc, argv, "bwlqs:x", &mode, &filename, NULL, &swab) < 0) return 1; @@ -105,6 +105,7 @@ BAREBOX_CMD_HELP_OPT ("-b", "byte access") BAREBOX_CMD_HELP_OPT ("-w", "word access (16 bit)") BAREBOX_CMD_HELP_OPT ("-l", "long access (32 bit)") +BAREBOX_CMD_HELP_OPT ("-q", "quad access (64 bit)") BAREBOX_CMD_HELP_OPT ("-s FILE", "display file (default /dev/mem)") BAREBOX_CMD_HELP_OPT ("-x", "swap bytes at output") BAREBOX_CMD_HELP_TEXT("") diff --git a/commands/mem.c b/commands/mem.c index 568050d..23c703f 100644 --- a/commands/mem.c +++ b/commands/mem.c @@ -84,6 +84,9 @@ case 'l': *mode = O_RWSIZE_4; break; + case 'q': + *mode = O_RWSIZE_8; + break; case 's': *sourcefile = optarg; break; diff --git a/commands/memcmp.c b/commands/memcmp.c index d048150..e079d5f 100644 --- a/commands/memcmp.c +++ b/commands/memcmp.c @@ -49,7 +49,7 @@ int offset = 0; struct stat statbuf; - if (mem_parse_options(argc, argv, "bwls:d:", &mode, &sourcefile, + if (mem_parse_options(argc, argv, "bwlqs:d:", &mode, &sourcefile, &destfile, NULL) < 0) return 1; @@ -138,6 +138,7 @@ BAREBOX_CMD_HELP_OPT ("-b", "byte access") BAREBOX_CMD_HELP_OPT ("-w", "word access (16 bit)") BAREBOX_CMD_HELP_OPT ("-l", "long access (32 bit)") +BAREBOX_CMD_HELP_OPT ("-q", "quad access (64 bit)") BAREBOX_CMD_HELP_OPT ("-s FILE", "source file (default /dev/mem)") BAREBOX_CMD_HELP_OPT ("-d FILE", "destination file (default /dev/mem)") BAREBOX_CMD_HELP_END diff --git a/commands/memcpy.c b/commands/memcpy.c index 78716b1..9c8b645 100644 --- a/commands/memcpy.c +++ b/commands/memcpy.c @@ -47,7 +47,7 @@ struct stat statbuf; int ret = 0; - if (mem_parse_options(argc, argv, "bwls:d:", &mode, &sourcefile, + if (mem_parse_options(argc, argv, "bwlqs:d:", &mode, &sourcefile, &destfile, NULL) < 0) return 1; @@ -135,6 +135,7 @@ BAREBOX_CMD_HELP_OPT ("-b", "byte access") BAREBOX_CMD_HELP_OPT ("-w", "word access (16 bit)") BAREBOX_CMD_HELP_OPT ("-l", "long access (32 bit)") +BAREBOX_CMD_HELP_OPT ("-q", "quad access (64 bit)") BAREBOX_CMD_HELP_OPT ("-s FILE", "source file (default /dev/mem)") BAREBOX_CMD_HELP_OPT ("-d FILE", "write file (default /dev/mem)") BAREBOX_CMD_HELP_END diff --git a/commands/memset.c b/commands/memset.c index bb5f46d..fc5b659 100644 --- a/commands/memset.c +++ b/commands/memset.c @@ -44,7 +44,7 @@ int ret = 1; char *file = "/dev/mem"; - if (mem_parse_options(argc, argv, "bwld:", &mode, NULL, &file, + if (mem_parse_options(argc, argv, "bwlqd:", &mode, NULL, &file, NULL) < 0) return 1; @@ -92,6 +92,7 @@ BAREBOX_CMD_HELP_OPT ("-b", "byte access") BAREBOX_CMD_HELP_OPT ("-w", "word access (16 bit)") BAREBOX_CMD_HELP_OPT ("-l", "long access (32 bit)") +BAREBOX_CMD_HELP_OPT ("-q", "quad access (64 bit)") BAREBOX_CMD_HELP_OPT ("-d FILE", "write file (default /dev/mem)") BAREBOX_CMD_HELP_END diff --git a/commands/mm.c b/commands/mm.c index ff2e746..7c890a6 100644 --- a/commands/mm.c +++ b/commands/mm.c @@ -38,9 +38,10 @@ u8 val8; u16 val16; u32 val32; - u32 value, mask; + u64 val64; + u64 value, mask; - if (mem_parse_options(argc, argv, "bwld:", &mode, NULL, &filename, + if (mem_parse_options(argc, argv, "bwlqd:", &mode, NULL, &filename, &swab) < 0) return 1; @@ -48,8 +49,8 @@ return COMMAND_ERROR_USAGE; adr = strtoull_suffix(argv[optind++], NULL, 0); - value = simple_strtoul(argv[optind++], NULL, 0); - mask = simple_strtoul(argv[optind++], NULL, 0); + value = simple_strtoull(argv[optind++], NULL, 0); + mask = simple_strtoull(argv[optind++], NULL, 0); fd = open_and_lseek(filename, mode | O_RDWR, adr); if (fd < 0) @@ -86,6 +87,16 @@ if (ret < 0) goto out_write; break; + case O_RWSIZE_8: + if (ret < 0) + goto out_read; + ret = pread(fd, &val64, 8, adr); + val64 &= ~mask; + val64 |= (value & mask); + ret = pwrite(fd, &val64, 8, adr); + if (ret < 0) + goto out_write; + break; } close(fd); @@ -110,6 +121,7 @@ BAREBOX_CMD_HELP_OPT ("-b", "byte access") BAREBOX_CMD_HELP_OPT ("-w", "word access (16 bit)") BAREBOX_CMD_HELP_OPT ("-l", "long access (32 bit)") +BAREBOX_CMD_HELP_OPT ("-q", "quad access (64 bit)") BAREBOX_CMD_HELP_OPT ("-d FILE", "write file (default /dev/mem)") BAREBOX_CMD_HELP_END diff --git a/commands/mw.c b/commands/mw.c index f0384f6..8ca3c61 100644 --- a/commands/mw.c +++ b/commands/mw.c @@ -42,7 +42,7 @@ loff_t adr; int swab = 0; - if (mem_parse_options(argc, argv, "bwld:x", &mode, NULL, &filename, + if (mem_parse_options(argc, argv, "bwlqd:x", &mode, NULL, &filename, &swab) < 0) return 1; @@ -59,6 +59,7 @@ u8 val8; u16 val16; u32 val32; + u64 val64; switch (mode) { case O_RWSIZE_1: val8 = simple_strtoul(argv[optind], NULL, 0); @@ -76,6 +77,12 @@ val32 = __swab32(val32); ret = write(fd, &val32, 4); break; + case O_RWSIZE_8: + val64 = simple_strtoull(argv[optind], NULL, 0); + if (swab) + val64 = __swab64(val64); + ret = write(fd, &val64, 8); + break; } if (ret < 0) { perror("write"); @@ -97,6 +104,7 @@ BAREBOX_CMD_HELP_OPT ("-b", "byte access") BAREBOX_CMD_HELP_OPT ("-w", "word access (16 bit)") BAREBOX_CMD_HELP_OPT ("-l", "long access (32 bit)") +BAREBOX_CMD_HELP_OPT ("-q", "quad access (64 bit)") BAREBOX_CMD_HELP_OPT ("-d FILE", "write file (default /dev/mem)") BAREBOX_CMD_HELP_END diff --git a/common/memory_display.c b/common/memory_display.c index 7b1d35e..ea91985 100644 --- a/common/memory_display.c +++ b/common/memory_display.c @@ -6,8 +6,8 @@ int memory_display(const void *addr, loff_t offs, unsigned nbytes, int size, int swab) { - ulong linebytes, i; - u_char *cp; + unsigned long linebytes, i; + unsigned char *cp; /* Print the lines. * @@ -15,20 +15,34 @@ * once, and all accesses are with the specified bus width. */ do { - char linebuf[DISP_LINE_LEN]; - uint32_t *uip = (uint *)linebuf; - uint16_t *usp = (ushort *)linebuf; - uint8_t *ucp = (u_char *)linebuf; + unsigned char linebuf[DISP_LINE_LEN]; + uint64_t *ullp = (uint64_t *)linebuf; + uint32_t *uip = (uint32_t *)linebuf; + uint16_t *usp = (uint16_t *)linebuf; + uint8_t *ucp = (uint8_t *)linebuf; unsigned count = 52; printf("%08llx:", offs); linebytes = (nbytes > DISP_LINE_LEN) ? DISP_LINE_LEN : nbytes; for (i = 0; i < linebytes; i += size) { - if (size == 4) { - u32 res; + if (size == 8) { + uint64_t res; data_abort_mask(); - res = *((uint *)addr); + res = *((uint64_t *)addr); + if (swab) + res = __swab64(res); + if (data_abort_unmask()) { + res = 0xffffffffffffffffULL; + count -= printf(" xxxxxxxxxxxxxxxx"); + } else { + count -= printf(" %016llx", res); + } + *ullp++ = res; + } else if (size == 4) { + uint32_t res; + data_abort_mask(); + res = *((uint32_t *)addr); if (swab) res = __swab32(res); if (data_abort_unmask()) { @@ -39,9 +53,9 @@ } *uip++ = res; } else if (size == 2) { - u16 res; + uint16_t res; data_abort_mask(); - res = *((ushort *)addr); + res = *((uint16_t *)addr); if (swab) res = __swab16(res); if (data_abort_unmask()) { @@ -52,9 +66,9 @@ } *usp++ = res; } else { - u8 res; + uint8_t res; data_abort_mask(); - res = *((u_char *)addr); + res = *((uint8_t *)addr); if (data_abort_unmask()) { res = 0xff; count -= printf(" xx"); @@ -70,7 +84,7 @@ while (count--) putchar(' '); - cp = (uint8_t *)linebuf; + cp = linebuf; for (i = 0; i < linebytes; i++) { if ((*cp < 0x20) || (*cp > 0x7e)) putchar('.'); diff --git a/fs/fs.c b/fs/fs.c index 779f264..9a79a03 100644 --- a/fs/fs.c +++ b/fs/fs.c @@ -1590,6 +1590,9 @@ case 4: *((ulong *)dst) = *((ulong *)src); break; + case 8: + *((u64 *)dst) = *((u64 *)src); + break; } dst += rwsize; src += rwsize; diff --git a/include/fcntl.h b/include/fcntl.h index aed741e..501b415 100644 --- a/include/fcntl.h +++ b/include/fcntl.h @@ -17,11 +17,12 @@ #define O_NOFOLLOW 00400000 /* don't follow links */ /* barebox additional flags */ -#define O_RWSIZE_MASK 00000070 +#define O_RWSIZE_MASK 00000170 #define O_RWSIZE_SHIFT 3 #define O_RWSIZE_1 00000010 #define O_RWSIZE_2 00000020 #define O_RWSIZE_4 00000040 +#define O_RWSIZE_8 00000100 #define F_DUPFD 0 /* dup */ #define F_GETFD 1 /* get close_on_exec */