Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Device register mapping in ARM: (3 Items)
   
Device register mapping in ARM  
we are using AT91SAM9263 on QNX 6.4.1. As per QNX documentation 'mmap_device_io()' should be called only with io 
privileges. i.e)calling thread should have called ThreadCtl() with the _NTO_TCTL_IO before using mmap_device_io().
I got following code to toggle gpio port. I am able to run this code successful without io privilege.

fyi, I am running this code as 'root'.

#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <sys/mman.h>
#include <arm/at91sam9263.h>
#include <sys/types.h>
#include <hw/inout.h>

int main(int argc, char *argv[]) {
	volatile uintptr_t	gpio_hw_vbase = (uintptr_t)MAP_FAILED;
	gpio_hw_vbase = mmap_device_io((size_t)(5u * (uint_t)AT91SAM9263_PIO_SIZE), (uint64_t)AT91SAM9263_PIOA_BASE);
	if(gpio_hw_vbase == MAP_FAILED)
	{
		printf("map failed, no io privilege");
	}
	else
	{
		printf("map success, io privilege granted");
		out32( (uintptr_t)(gpio_hw_vbase + ((uintptr_t)2*(uintptr_t)AT91SAM9263_PIO_SIZE) + AT91SAM9263_PIO_SODR), 
(uint32_t)0x00001000u );
		getchar();
		out32( (uintptr_t)(gpio_hw_vbase + ((uintptr_t)2*(uintptr_t)AT91SAM9263_PIO_SIZE) + AT91SAM9263_PIO_CODR), 
(uint32_t)0x00001000u );
	}
	return EXIT_SUCCESS;
}
Re: Device register mapping in ARM  
I'd also like to know the answer to this question.

i.e mmap_device_io appears to allow I/O access without I/O priveleges even though the documentation indicates ThreadCtl(
...) is required.

Is this an aspect of ARM memory mapped I/O and therefore only root permissions are required in order to do the mapping 
in the first place, or is this an oversight in the documentation that should indicate this isn't strictly necessary for 
ARM processors but should be coded thus for portability?
Re: Device register mapping in ARM  
Memory mapped I/O doesn't require privileged mode, so _NTO_TCTL_IO is
essentially only required to manipulate the CPSR I bit to disable
interrupts.

	Sunil.

On 12-04-20 5:56 AM, Richard Jones wrote:
> I'd also like to know the answer to this question.
>
> i.e mmap_device_io appears to allow I/O access without I/O priveleges even though the documentation indicates 
ThreadCtl(...) is required.
>
> Is this an aspect of ARM memory mapped I/O and therefore only root permissions are required in order to do the mapping
 in the first place, or is this an oversight in the documentation that should indicate this isn't strictly necessary for
 ARM processors but should be coded thus for portability?
>
>
>
> _______________________________________________
>
> OSTech
> http://community.qnx.com/sf/go/post92662
>