Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/m/mmap_device_memory.html on line 1

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/m/mmap_device_memory.html on line 1

Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/m/mmap_device_memory.html on line 8

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/m/mmap_device_memory.html on line 8

mmap_device_memory()

Map a device's physical memory into a process's address space

Synopsis:

#include <sys/mman.h>

void * mmap_device_memory( void * addr,
                           size_t len,
                           int prot,
                           int flags,
                           uint64_t physical );

Arguments:

addr
NULL, or a pointer to where you want to map the object in the calling process's address space.
len
The number of bytes you want to map into the caller's address space. It can't be 0.
prot
The access capabilities that you want to use for the memory region being mapped. You can use a combination of at least the following protection bits, as defined in <sys/mman.h>:
flags
Specifies further information about handling the mapped region. You can use the following flag:

This function already uses MAP_SHARED ORed with MAP_PHYS (see mmap() for a description of these flags).

physical
The physical address of the memory to map into the caller's address space.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The mmap_device_memory() function maps len bytes of a device's physical memory address into the caller's address space at the location returned by mmap_device_memory().

You should use this function instead of using mmap() with the MAP_PHYS flag.

Typically, you don't need to use addr; you can just pass NULL instead. If you set addr to a non-NULL value, whether the object is mapped depends on whether or not you set MAP_FIXED in flags:

MAP_FIXED is set
The object is mapped to the address in addr, or the function fails.
MAP_FIXED isn't set
The value of addr is taken as a hint as to where to map the object in the calling process's address space. The mapped area won't overlay any current mapped areas.

Returns:

The address of the mapped-in object, or MAP_FAILED if an error occurs (errno is set).

Errors:

EINVAL
Invalid flags type, or len is 0.
ENOMEM
The address range requested is outside of the allowed process address range, or there wasn't enough memory to satisfy the request.
ENXIO
The address from physical for len bytes is invalid for the requested object, or MAP_FIXED was specified and addr, len, and physical are invalid for the requested object.

Examples:

/* Map in the physical memory; 0xb8000 is text mode VGA video memory */
    
ptr = mmap_device_memory( 0, len, PROT_READ|PROT_WRITE|PROT_NOCACHE, 0, 0xb8000 );
if ( ptr == MAP_FAILED ) {
    perror( "mmap_device_memory for physical address 0xb8000 failed" );
    exit( EXIT_FAILURE );
}

Classification:

QNX Neutrino

Safety:
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

mmap(), mmap_device_io(), munmap_device_memory()


Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/m/mmap_device_memory.html on line 297

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/m/mmap_device_memory.html on line 297