MMAP(2) COMMAND REFERENCE MMAP(2) NAME mmap - map pages of memory SYNOPSIS #include <sys/types.h> #include <sys/mman.h> mmap(pid, fromaddr, toaddr, len, prot, share) int pid; caddrt fromaddr, toaddr; uint len, prot, share; DESCRIPTION The mapping routine mmap allows a process to access areas of other processes through its own address space. It causes the calling process' pages starting at toaddr and continuing for len bytes to map onto the process with id pid, starting at the object's pages fromaddr. If pid is M_SELF, an area of the process is mapped to itself. If pid is M_PHYS, an area of the process is mapped to physical memory (in which case share is ignored). If pid is M_ZFILL, an area of the process is made "zero-fill-on- demand" (in which case fromaddr and share are ignored). mmap has been enhanced for UTek 4301, 432X and 433X workstations with the ability to read and write into VME address space. share and prot are ignored. The user address range can cross a 16Mbyte boundary, but the VME memory range cannot. Following is a list of the pids: M_VMEEXT A32 extended M_VMESTD A24 standard M_VMESHORT A16 short M_VME an alias for M_VMEEXT If the parameter share is true, both mappings will share the same memory. Otherwise, a private copy of the area is made, and changes through one mapping are not visible through the other. PRIVATE make a private copy for the new mapping SHARED share the area between the mappings The parameter prot specifies the accessibility of the pages through the new mapping. Read and write access may be given on the basis of processes of the same user, same process group, same group, and world. A process may also protect its pages against itself. The protection for a page is specified by or'ing together the following values: Printed 4/12/89 1
MMAP(2) COMMAND REFERENCE MMAP(2) M_R_SELF read, process M_W_SELF write, process M_R_USER read, user M_W_USER write, user M_R_PGROUP read, process group M_W_PGROUP write, process group M_R_GROUP read, group M_W_GROUP write, group M_R_WORLD read, world M_W_WORLD write, world Note that the protection is associated with the mapping, and not with the actual memory. If the process must change the protection of a mapping, it may map the area to itself, with the new protection. Doing this with share cleared will disassociate the area with all other mappings. The terms "zero-fill-on-demand" and "provide-on-demand" used above refer to the handling of pages in mappings which have no initial contents. UTek does not allocate physical memory or swap space to such a page until the first reference (demand) for that page. If M_ZFILL is selected, the page is filled with zeros before the first reference is satisfied. This provides a standard initial value for data regions, which is expected by some software. The toaddr, fromaddr and len parameters must be multiples of the system cluster size (found using the getpagesize(2) call). DIAGNOSTICS Mmap will fail when one of the following occurs: [EINVAL] An address is not on a cluster boundary or len is not positive. [EMCOLLIDE] Portions of the new area are already mapped. [EMRANGE] An area is outside the possible user's address space or includes part of the uarea. [EACCES] The required permissions (for reading and/or writing) are denied for the named file or area of a process. [ESRCH] No process can be found corresponding to the specified pid. [EPERM] The area of the object to be mapped is protected against the desired operation. Printed 4/12/89 2
MMAP(2) COMMAND REFERENCE MMAP(2) RETURN VALUE Upon successful completion, a value of 0 is returned. Otherwise, a value of -1 is returned and errno is set to indicate the error. SEE ALSO getpagesize(2), mremap(2), and munmap(2). Printed 4/12/89 3
%%index%% na:240,78; sy:318,1581; de:1899,2226;4437,1389; di:5826,889; rv:7027,280; se:7307,223; %%index%%000000000120