I have a board with an APM86290(ppc) SOC on it. This is my first foray into this type of development and I’m trying to work with the SPI controller which is mapped using a 36bit address(according to the datasheet). I want to read some of the registers using mmap() and /dev/mem. Is there normally a uniform way to address those high four bits? Or is this likely something specific to this processor/compiler? This is how I was attempting to do it now.
#define OFFSET 0xfa0000000
int main()
{
int i;
unsigned int * someRegister;
int fd = open("/dev/mem",O_RDWR|O_SYNC);
if(fd < 0)
{
printf("Can't open /dev/mem\n");
return 1;
}
someRegister = (unsigned int *) mmap(0, sizeof(int), PROT_READ|PROT_WRITE, MAP_SHARED, fd, OFFSET);
if(someRegister <= NULL)
{
printf("Can't mmap\n");
return 1;
}
else
{
printf("register=%x\n",OFFSET);
printf("contents=%x\n",*someRegister);
}
return 0;
}
The output of the above program returns these errors
Machine check in kernel mode.
Instruction Read PLB Error
PLB Master Port Request Error
PLB read error 0x11000000 at 0x00000000_00000000
I thought maybe it wasn’t using the 36bit addresses and truncating something, but When I do a cat /proc/iomem
effff8000-effffffff : ocm_mem
fa0000000-fa000001f : serial
Which show the 36 bit values I’m expecting.
It depends a lot on your setup. There’s a 64-bit version of mmap() that you could try: mmap64(). If that won’t work for you, you may need to map an upper and lower register for each 36-bit register.