Hello,
I'm trying to read and write some cpu registers directly from a user
program (not programming a kernel module), and after following some info
found, I'm able to read some portions, but not others. In the attached code
you can see it trying to access to the "Hibernate Scratch Pattern Register"
and when I execute the program the only reply I got is:
Before
Bus error
I'm forgetting to add some kind of offset in the address?
--
Felix
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/stat.h>
main()
{
int devmem;
off_t PageOffset, PageAddress;
unsigned long *hw_addr = (unsigned long *) 0x10003034;
unsigned long read_data;
devmem = open("/dev/mem", O_RDWR | O_SYNC);
PageOffset = (off_t) hw_addr % getpagesize();
PageAddress = (off_t) (hw_addr - PageOffset);
hw_addr = (unsigned long *) mmap(0, 4, PROT_READ, MAP_SHARED, devmem, PageAddress);
printf("Before\n");
read_data = *(hw_addr);
printf("Read from hardware %x\n",read_data);
}
_______________________________________________
Qi Hardware Discussion List
Mail to list (members only): [email protected]
Subscribe or Unsubscribe:
http://lists.en.qi-hardware.com/mailman/listinfo/discussion