8devices / mmio Goto Github PK
View Code? Open in Web Editor NEWH/W register access using MMIO from userspace
H/W register access using MMIO from userspace
Hi,
I stumbled across your utility and it's great. I wanted to dump some gpio registers in binary so I hacked that into the utility. I'm not sure it's 100% correct, but it works for me. Here's the patch.
diff --git a/src/mmio.c b/src/mmio.c
index cd48237..c8bd7a5 100644
--- a/src/mmio.c
+++ b/src/mmio.c
@@ -38,6 +38,7 @@ static const char *usage =
" -a - 8bit hex + ascii output\n"
" -b - 8bit hex output\n"
" -h - 16bit hex output\n"
+" -n - 32bit binary output\n"
" -x - 32bit hex output\n"
" -k - use /dev/kmem instead of /dev/mem (default)\n"
"\n"
@@ -95,7 +96,7 @@ static void mmio_parse(struct mmio_options *mo, int argc, char *argv[])
for (;;) {
int ch;
ch = getopt(argc, argv, "abhxk");
ch = getopt(argc, argv, "abhnxk");
if (ch == -1)
break;
@@ -112,6 +113,10 @@ static void mmio_parse(struct mmio_options *mo, int argc, char *argv[])
mo->flags = HEXDUMP_16BIT;
break;
case 'n':
mo->flags = HEXDUMP_BIN;
break;
+static void hexdump_bin(const void *data, size_t length, size_t count)
+{
printf("%c", bit & 1 ? '1' : '0');
printf(" ");
static void hexdump_8bit(const void *data, size_t length, size_t count)
{
const unsigned char *ptr = data;
@@ -98,8 +118,12 @@ void __hexdump(unsigned long base, const void *data,
int nleft;
count = HEXDUMP_COUNT(flags);
count = 16; /\* default */
count = 4;
count = 16; /\* default */
@@ -111,7 +135,9 @@ void __hexdump(unsigned long base, const void *data,
hexdump_addr(base);
if (HEXDUMP_ISSET(flags, HEXDUMP_8BIT)) {
hexdump_bin(data, nleft, count);
Thanks,
Seth
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.