kaiwan / device-memory-readwrite Goto Github PK
View Code? Open in Web Editor NEWRead / Write pretty much _any_ memory location (RAM or H/W IO Memory) on a device
Read / Write pretty much _any_ memory location (RAM or H/W IO Memory) on a device
Test case:
On a QEMU-emulated (Versatile Express CA-9) platform (in fact, I use my other opensource project - SEALS - to do so):
ARM # insmod ./rwmem.ko
rwmem: registered with major number 252
rwmem: cdev rwmem.0 added
rwmem: Device node /dev/rwmem.0 created.
rwmem: IO base address NOT specified (or len invalid) as module param; not performing ioremap...
ARM # ls /dev/rwmem*
ls: /dev/rwmem*: No such file or directory
ARM #
I had to manually create the device node:
ARM # mknod /dev/rwmem.0 c 252 0
ARM # ls -l /dev/rwmem.0
crw-r--r-- 1 0 0 252, 0 Oct 7 04:01 /dev/rwmem.0
ARM #
Then everything works just fine. For eg.:
ARM # ./rdmem 80000000 32
PID 620. [Enter] to cont...
PRINT_CTX:: in function rwmem_ioctl on cpu # 0
in process context: rdmem:620
+0 +4 +8 +c 0 4 8 c
+0000 00 00 a1 ff 00 00 00 0e 57 f6 34 7b 54 9b ed 86 ........W.4{T...
+0010 54 9b ed 6e 00 00 00 00 00 01 00 00 00 00 00 00 T..n............
+0020 00 00 00 00 00 00 00 01 62 2f 2e 2e 62 2f 6e 69 ........b/..b/ni
+0030 62 79 73 75 00 00 78 6f 00 00 00 00 00 00 00 00 bysu..xo........
ARM #
But how come the device node is not created (works on x86)?
TODO - have it work for Port IO as well...
Request a general code review. Thanks!
Original issue reported on code.google.com by [email protected]
on 25 Jul 2011 at 7:56
First: I use the tool to access the PINMUX control registers on a TI AM335x ARM Cortex-A8. These are protected, so that you need the Kernel Mode for writes.
I define an iobase with
insmod devmem_rw.ko iobase_start=0x44E10000 iobase_len=0x100
./wrmem -o 860 27 (e.g.) didn't work (... user mode)
At line 98 I added the first "if", like it is used in RDMEM:
if (st_wrm.flag != USE_IOBASE) {
if (is_user_address(st_wrm.addr)) {
if (uaddr_valid(st_wrm.addr) == -1) {
fprintf(stderr,
"%s: the (usermode virtual) address passed (%p) seems to be invalid. Aborting...\n",
argv[0], (void *)st_wrm.addr);
close(fd);
exit(1);
}
}
}
I didn't analyse the code in depth, as this worked right away. So I don't know if this is a good solution.
Applicable to ver 0.1.2 :
What steps will reproduce the problem?
1. 'make' on the device driver
What is the expected output? What do you see instead?
$ make
...
rwmem.c:271: warning: initialization from incompatible pointer type
...
$
Original issue reported on code.google.com by [email protected]
on 24 Sep 2012 at 6:26
on x86_64 Ubuntu 22.04 VM @ addr
ffffffffc0000000
Need to check...
File open on /sys/kernel/debug/devmem_rw/get_page_offset fails, even as root!
Error : "rdmem: open dbgfs_file: Operation not permitted"
errno=EPERM.
Weird:
Fails: on x86_64 native Ubuntu 18.10, fails on Fedora 29 guest.
(I tried disabling any active LSMs - AppArmor, SELinux. No luck).
Works: on x86_64 18.04 LTS guest VM, on ARMv7 Raspberry Pi
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.