Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ phys(3C) — Duplix 4.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

brk(2)

getpagesize(2)

mmap(2)

mem(4)

PHYS(3C)  —  Unix Programmer’s Manual

NAME

phys − allows a process to access physical addresses

SYNOPSIS

phys(physnum, addr, len, physaddr)
int physnum;
char ∗addr;
int len;
char ∗physaddr;

DESCRIPTION

Although phys has been updated by the mmap(2) system call (mmap actually maps the region), it is provided here for compatibility with previous systems. 

Phys maps a region of program virtual addresses to arbitrary physical memory.  Physnum specifies which of four address regions (0-3) to set up.  Up to four phys calls can be active at any one time.  Phys causes the address region (starting at addr and continuing for len bytes) to be mapped to physical memory at the absolute address physaddr. 

Addr and physaddr must be a multiple of the the page size; see getpagesize(2).  Unlike System III, this implementation permits addr to lie within the active data segment. 

If len is non-zero, it is rounded up to the next multiple of the page size.  If len is zero, any previous phys mapping for that physnum region is nullified; further references to that region refer to private memory initialized to zero. 

For example, the call
 

phys(2, 0x100000, 32768, 0)
 

allows a process to access physical locations 0 through 32767 by referencing virtual address 0x100000 through 0x100000 + 32767. 

The current implementation applies the mmap(2) system call to the mem(4) character special file as follows.  The file /dev/mem is opened for reading and writing on the first call to phys and remains open.  (The program must have read and write permission for /dev/mem.)  To remove any previous mapping for this physnum region, use munmap(2).  The virtual address region addr through addr + len − 1 is made part of the data segment with the brk(2) system call if necessary. 

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. 

ERRORS

Phys will fail when one of the following occurs:

[EPERM] The file /dev/mem cannot be opened for reading and writing. 

[EINVAL] One of addr, len, or physaddr is not a multiple of the page size. 

[EINVAL] Physaddr + len exceeds the size of addressable physical memory. 

SEE ALSO

brk(2), getpagesize(2), mmap(2), mem(4)

BUGS

This routine is Integrated Solutions machine-dependent. 

4th Berkeley Distribution  —  1 August 1985

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026