*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->FreeBSD man pages -> mem (4)              



NAME    [Toc]    [Back]

     mem, kmem -- memory files

DESCRIPTION    [Toc]    [Back]

     The special file /dev/mem is an interface to the physical memory of the
     computer.	Byte offsets in this file are interpreted as physical memory
     addresses.  Reading and writing this file is equivalent to reading and
     writing memory itself.  Only offsets within the bounds of /dev/mem are

     Kernel virtual memory is accessed through the interface /dev/kmem in the
     same manner as /dev/mem.  Only kernel virtual addresses that are currently
 mapped to memory are allowed.

     On ISA the I/O memory space begins at physical address 0x000a0000 and
     runs to 0x00100000.  The per-process data size for the current process is
     UPAGES long, and ends at virtual address 0xf0000000.

IOCTL INTERFACE    [Toc]    [Back]

     Several architectures allow attributes to be associated with ranges of
     physical memory.  These attributes can be manipulated via ioctl() calls
     performed on /dev/mem.  Declarations and data types are to be found in

     The specific attributes, and number of programmable ranges may vary
     between architectures.  The full set of supported attributes is:

	     The region is not cached.

	     Writes to the region may be combined or performed out of order.

	     Writes to the region are committed synchronously.

	     Writes to the region are committed asynchronously.

	     The region cannot be written to.

     Memory ranges are described by struct mem_range_desc:

	   u_int64_t	   mr_base;	   /* physical base address */
	   u_int64_t	   mr_len;	   /* physical length of region */
	   int		   mr_flags;	   /* attributes of region */
	   char 	   mr_owner[8];

     In addition to the region attributes listed above, the following flags
     may also be set in the mr_flags field:

	     The region's base address cannot be changed.

	     The region's length cannot be changed.

	     The region is believed to have been established by the system

	     The region is currently active.

	     We believe the region to be invalid or otherwise erroneous.

	     The region cannot be disabled.

	     The region is currently owned by another process and may not be

     Operations are performed using struct mem_range_op:

	   struct mem_range_desc   *mo_desc;
	   int			   mo_arg[2];

     The MEMRANGE_GET ioctl is used to retrieve current memory range
     attributes.  If mo_arg[0] is set to 0, it will be updated with the total
     number of memory range descriptors.  If greater than 0, the array at
     mo_desc will be filled with a corresponding number of descriptor structures,
 or the maximum, whichever is less.

     The MEMRANGE_SET ioctl is used to add, alter and remove memory range
     attributes.  A range with the MDF_FIXACTIVE flag may not be removed; a
     range with the MDF_BUSY flag may not be removed or updated.

     mo_arg[0] should be set to MEMRANGE_SET_UPDATE to update an existing or
     establish a new range, or to MEMRANGE_SET_REMOVE to remove a range.

RETURN VALUES    [Toc]    [Back]

     [EOPNOTSUPP]	Memory range operations are not supported on this

     [ENXIO]		No memory range descriptors are available (eg.
			firmware has not enabled any).

     [EINVAL]		The memory range supplied as an argument is invalid or
			overlaps another range in a fashion not supported by
			this architecture.

     [EBUSY]		An attempt to remove or update a range failed because
			the range is busy.

     [ENOSPC]		An attempt to create a new range failed due to a
			shortage of hardware resources (eg. descriptor slots).

     [ENOENT]		An attempt to remove a range failed because no range
			matches the descriptor base/length supplied.

     [EPERM]		An attempt to remove a range failed because the range
			is permanently enabled.

BUGS    [Toc]    [Back]

     Busy range attributes are not yet managed correctly.

FILES    [Toc]    [Back]


SEE ALSO    [Toc]    [Back]


HISTORY    [Toc]    [Back]

     The mem and kmem files appeared in Version 6 AT&T UNIX.  The ioctl interface
 for memory range attributes was added in FreeBSD 3.2.

FreeBSD 5.2.1			  May 2, 1991			 FreeBSD 5.2.1
[ Back ]
 Similar pages
Name OS Title
mmap FreeBSD allocate memory, or map files or devices into memory
kmem OpenBSD memory files and memory controller
mem OpenBSD memory files and memory controller
mmap NetBSD map files or devices into memory
mmap OpenBSD map files or devices into memory
mmap Linux map or unmap files or devices into memory
TIFFmemory IRIX memory management-related functions for use with TIFF files
pax HP-UX Extracts, writes, and lists archive files; copies files and directory hierarchies
dcl2inc Linux postprocess ftnchek .dcl files to create separate INCLUDE files
znew OpenBSD convert compressed files to gzipped files
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service