Why I can not access to phyzsical address from application ?

I have SBC based on ARM920T CPU, i use 6.2.1 QNX

I try use this code for access to internal build-in registers:

#include <errno.h>
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <sys/iofunc.h>
#include <sys/dispatch.h>
#include <sys/mman.h>
#include <hw/inout.h>
#include <semaphore.h>
#include <sys/stat.h>
#include <signal.h>
#include <fcntl.h>
#include <process.h>
#include <termios.h>
#include <unistd.h>
#include <string.h>

uintptr_t iobase;

int main(int argc, char *argv[]) {

printf("Begin \r\n");

/* initialize resource manager attributes */

if (ThreadCtl( _NTO_TCTL_IO, NULL )<0)
{
        fprintf(stderr, "IO privity Error \r\n");
        return EXIT_FAILURE;

} // Take acces to IO ports



iobase=mmap_device_io(4, 0xFFFFF000);


if (iobase<0) {
    fprintf(stderr, "error to map device \r\n");
    fprintf(stderr, "%s: %d  \r\n", __FILE__, __LINE__);
    return EXIT_FAILURE;
}


fprintf(stderr, "Try IN32(%x) \r\n",iobase);

    in32(iobase);

    fprintf(stderr, "Done \r\n");

munmap_device_io(iobase,4);

return EXIT_SUCCESS;

}

BUT I every times receive Memory Fault !
look like this:

Try IN32(1800000)

Process 462872 (check_io) terminated SIGSEGV code=1 fltno=11 ip=001007fc ref=01800000
Memory fault

I think address 0xFFFFF000 is bad for QNX, m.b. this address space are reserved or used by kernel ? or in 6.2.1 we have bag’s in MMU control with ARM CPU.? in mmap_device_io()

Anybody can try access this address on your ARM SBC?
This address space are closed from application, BUT from kernel (interrupt callouts) I can access to this address.

Please Help.
Best Regards!
MT.

Few people around here use ARM. Since IO on ARM are, I think, actually addresses, what about trying to use mmap_device_mem instead.

That could give some clue as to what is going on, though from the code I’m guessing it should work.

In x86 you can mmap_device_memory any address whether it physicaly exists or not and it will not SISEGV in either case. On Arm it could be different, if memory isn’t mapped/known of by the kernel it may SIGSEGV (although I would have expect mmap to fail in the first place)


if (iobase==MAP_DEVICE_FAILED) {

Indeed that’s better, but iobase is equal to 0x1800000 which I don’t think is equal to MAP_DEVICE_FAILED ;-)

Thank You for Answers!
I try use
iobase=mmap_device_memory(0,4,PROT_EXEC|PROT_NOCACHE|PROT_READ|PROT_WRITE,0,0xFFFFF000);
but again receive Memory Fault :frowning:
All address space from 0xFFFFF000 to 0xFFFFFFFF are closed for access from application, but from kernel callouts
I can access to this space. I use it space on timer, interrupts callouts.
I use AT91RM9200 CPU, in address space 0xFFFFF000-0xFFFFFFFF placed some internal registers for manage of
build in CPU perephiral units. I need read or write to them in device drivers but I can not :frowning:.
I want try find in main memory Translation Table virtual address to physical and look on it, and understand how manage
access for this address space.
May be I can access to this address by another way? Any body know how?

Regards!
MT.

You need to talk with the suppliers and/or post in nntp://inn.qnx.com/qnx.bsp

Looks like it’s a bug in 621’s memory manager code - have you tried 6.3.0?

Hellow Again!
Yes this is bug in 6.2.1 !!! under 6.3 it is working propertly !! I am happy! :slight_smile:)
Now I move my project’s unter 6.3.
Thank You ALL for Support!
MT!