QNX 6.x…
Can anyone provide sample C++ code to access an absolute memory address?
This won’t work because it yields the data at location 0x100 in the virtual
address space of the process, correct?
unsigned char *ptr = 0x100; // address 0x100
unsigned char chr;
chr = *ptr;
Thanks,
Bill
Cincinnati, OH USA
Dirk Gently wrote:
QNX 6.x…
Can anyone provide sample C++ code to access an absolute memory address?
This won’t work because it yields the data at location 0x100 in the virtual
address space of the process, correct?
unsigned char *ptr = 0x100; // address 0x100
unsigned char chr;
chr = *ptr;
Thanks,
Bill
Cincinnati, OH USA
You need to map that physical address+range into the address space. You
can do so via:
vaddr = mmap64(0, , PROT_READ|PROT_WRITE, MAP_PHYS|MAP_SHARED,
NOFD, );
Now the pointer ‘vaddr’ will allow you to access that physical location.
Check the docs on mmap() for more flags (like PROT_NOCACHE etc) and
information.
–
Cheers,
Adam
With a PC, I always felt limited by the software available.
On Unix, I am limited only by my knowledge.
–Peter J. Schoenster <pschon@baste.magibox.net>
Thanks!
“Adam Mallory” <amallory@qnx.com> wrote in message
news:cdr9jr$m23$1@inn.qnx.com…
Dirk Gently wrote:
QNX 6.x…
Can anyone provide sample C++ code to access an absolute memory address?
This won’t work because it yields the data at location 0x100 in the
virtual
address space of the process, correct?
unsigned char *ptr = 0x100; // address 0x100
unsigned char chr;
chr = *ptr;
Thanks,
Bill
Cincinnati, OH USA
You need to map that physical address+range into the address space. You
can do so via:
vaddr = mmap64(0, , PROT_READ|PROT_WRITE, MAP_PHYS|MAP_SHARED,
NOFD, );
Now the pointer ‘vaddr’ will allow you to access that physical location.
Check the docs on mmap() for more flags (like PROT_NOCACHE etc) and
information.
–
Cheers,
Adam
QNX Software Systems Ltd.
[ > amallory@qnx.com > ]
With a PC, I always felt limited by the software available.
On Unix, I am limited only by my knowledge.
–Peter J. Schoenster <> pschon@baste.magibox.net