[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Possible Silicon Graphics port
Rob (or William):
Here is a man page decribing the memory-mapping call available in Irix
(SGI's Unix). Can we tell from this whether the port would be
straightforward? If not, maybe we need to get a manual from Witkin or to
ask SGI directly.
-- Scott
---------------------------------------------------------------------------
NAME
mmap - map pages of memory
SYNOPSIS
#include <sys/types.h>
#include <sys/mman.h>
void *mmap(void *addr, int len, int prot, int flags, int fd, off_t off);
void *paddr;
DESCRIPTION
mmap establishes a mapping between the process's address space at an
address paddr for len bytes to the object represented by fd at off for
len bytes. The value of paddr is an implementation-dependent function of
the parameter addr and values of flags, further described below. A
successful mmap call returns paddr as its result.
The parameter prot determines whether read, execute, write, or some
combination of accesses are permitted to the pages being mapped. The
following protection options are defined in <sys/mman.h>:
PROT_READ Page can be read.
PROT_WRITE Page can be written.
PROT_EXECUTE Page can be executed.
The parameter flags provides other information about the handling of the
mapped pages. The following options are defined in <sys/mman.h>:
MAP_SHARED All write references will change the object.
MAP_PRIVATE Write references will not change the object. The
initial write reference will cause a private copy of the
page of the file object to be created.
MAP_AUTOGROW If MAP_AUTOGROW is specified, the mapped object will be
implicitly grown when referenced by a store operation
(write) if the store is beyond the current end of the
object (or if the store in within the last page of the
object's mapping and the object is mapped beyond its
end). The object will be grown and zero-filled to the
next page boundary [see getpagesize(2)] beyond the
reference, or to the end of the mapping, whichever is
less.
MAP_AUTOGROW requires that the object is mapped with
PROT_WRITE permission. Read references to mapped pages
following the end of a object will result in the
delivery of a SIGSEGV signal, as will various filesystem
conditions on stores. Whenever a SIGSEGV signal is
delivered, the second argument to the signal handler
contains a value that indicates the reason for the
delivery of the signal; these values are defined in
/usr/include/sys/errno.h.
MAP_LOCAL If the process does an sproc(2) each process will
receive a private copy of the object's mapping. All
subsequent write reference of objects mapped MAP_PRIVATE
will cause private copies of the object to be created.
In addition, the share group processes will be able to
independently unmap the object from their address
spaces.
MAP_FIXED MAP_FIXED informs the system that the value of paddr
must be addr, exactly. The mapping thus established by
mmap replaces any previous mappings for the process's
pages in the range (addr, addr + len). The use of
MAP_FIXED is discouraged, as it may prevent an
implementation from making the most effective use of
system resources.
When MAP_FIXED is not set, the system uses addr as a
hint in an implementation-defined manner to arrive at
paddr. The paddr so chosen will be an area of the
address space which the system deems suitable for a
mapping of len bytes to the specified object. When the
system selects a value for paddr, it will never place a
mapping at address 0, nor will it replace any extant
mapping.
The parameter fd is the file descriptor returned from a creat, open or
dup system call.
The parameter off is constrained to be aligned and sized according to the
value returned by getpagesize(2). When MAP_FIXED is specified, the
parameter addr must also meet these constraints. The system performs
mapping operations over whole pages. Thus, while the parameter len need
not meet a size or alignment constraint, the system will include in any
mapping operation any partial page specified by the range (paddr, paddr +
len).
It should be noted that the system will always zero-fill any partial
pages at the end of an object. Further, the system will never write out
any modified portions of the last page of an object which are beyond the
end of the mapping. Any reference to pages outside of a mapping will
result in the delivery of a SIGSEGV signal.
mmap will fail if:
[EBADF] Fd is not open.
[EACCES] Fd is not open for read and PROT_READ or PROT_EXECUTE were
specified, or fd is not open for write and PROT_WRITE was
specified for a MAP_SHARED type mapping.
[ENXIO] Addresses in the range (off, off + len) are invalid for fd
and MAP_AUTOGROW was not specified.
[EINVAL] The arguments addr (if MAP_FIXED was specified) and off
are not multiples of the page size as returned by
getpagesize(2).
[EINVAL] Invalid MAP_TYPE field in flags (neither MAP_PRIVATE nor
MAP_SHARED).
[ENODEV] Fd refers to an object for which mmap is meaningless, such
as a terminal.
[ENOMEM] MAP_FIXED was specified, and the range (addr, addr + len)
exceeds that allowed for the address space of a process;
or the process would exceed its maximum allowable virtual
size {PROCSIZE_MAX}; or MAP_FIXED was not specified and no
suitably large virtual address space is available.
SEE ALSO
madvise(2), munmap(2), msync(2), sigaction(2), signal(2), sigset(2),
sproc(2), sigvec(3B).
DIAGNOSTICS
A successful mmap returns the address at which the mapping was placed
(paddr). A failing mmap returns -1 and sets errno to indicate the error.