next up previous contents
Next: munlock: unlock a region Up: MOSS system calls Previous: mlockall: lock all memory

mmap: map a file's contents into memory

SYNOPSIS

void *mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset);

DESCRIPTION

This system call implements the POSIX.1b mmap function, which maps a file into the program's address space.

Currently, MOSS only supports this function on the ``magic'' file `/dev/mem'; it will fail if used on any other file. You can mmap /dev/mem in order to gain direct access to physical memory, which is not normally available to the program running under MOSS.

Note that the munmap function is not currently supported. (Actually, it is available, but it simply returns success without doing anything.)

PARAMETERS

addr
The desired address at which to map the file. Currently MOSS always ignores this paramter.
len
Size in bytes of the file region to map.
prot
Permissions to apply to the mapped memory. Currently MOSS simply ignores this parameter and always provides full permissions.
flags
Flags describing how to map the file. Currently MOSS simply ignores this parameter and behaves as if MAP_SHARED was specified.
fd
The file descriptor of the file to map. Currently this must be a file descriptor opened on the special file /dev/mem.
offset
Starting offset in the file to map. For /dev/mem, this is the physical address to map from.

RETURN VALUE

Returns the start address of the mapped region if successful, or (void*)-1 on error, in which case errno indicates the error.



Bryan Ford