1993-06-12 14:49:13 +00:00
|
|
|
.\" Copyright (c) 1991 The Regents of the University of California.
|
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\" 3. All advertising materials mentioning features or use of this software
|
|
|
|
.\" must display the following acknowledgement:
|
|
|
|
.\" This product includes software developed by the University of
|
|
|
|
.\" California, Berkeley and its contributors.
|
|
|
|
.\" 4. Neither the name of the University nor the names of its contributors
|
|
|
|
.\" may be used to endorse or promote products derived from this software
|
|
|
|
.\" without specific prior written permission.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
.\" SUCH DAMAGE.
|
|
|
|
.\"
|
|
|
|
.\" @(#)mem.4 5.3 (Berkeley) 5/2/91
|
1999-08-28 00:22:10 +00:00
|
|
|
.\" $FreeBSD$
|
1993-06-12 14:49:13 +00:00
|
|
|
.\"
|
|
|
|
.Dd May 2, 1991
|
1999-11-15 23:14:32 +00:00
|
|
|
.Dt MEM 4
|
1993-06-12 14:49:13 +00:00
|
|
|
.Os
|
|
|
|
.Sh NAME
|
|
|
|
.Nm mem ,
|
|
|
|
.Nm kmem
|
|
|
|
.Nd memory files
|
|
|
|
.Sh DESCRIPTION
|
|
|
|
The special file
|
|
|
|
.Nm /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
|
|
|
|
.Nm /dev/mem
|
|
|
|
are allowed.
|
|
|
|
.Pp
|
|
|
|
Kernel virtual memory is accessed through the interface
|
|
|
|
.Nm /dev/kmem
|
|
|
|
in the same manner as
|
|
|
|
.Nm /dev/mem .
|
|
|
|
Only kernel virtual addresses that are currently mapped to memory are allowed.
|
|
|
|
.Pp
|
|
|
|
On
|
|
|
|
.Tn ISA
|
|
|
|
the
|
|
|
|
.Tn I/O
|
|
|
|
memory space begins at physical address 0x000a0000
|
|
|
|
and runs to 0x00100000.
|
|
|
|
The
|
|
|
|
per-process data
|
|
|
|
size
|
|
|
|
for the current process
|
|
|
|
is
|
|
|
|
.Dv UPAGES
|
|
|
|
long, and ends at virtual
|
1994-08-23 09:34:10 +00:00
|
|
|
address 0xf0000000.
|
1999-04-07 04:03:51 +00:00
|
|
|
.Sh IOCTL INTERFACE
|
|
|
|
Several architectures allow attributes to be associated with ranges of physical
|
|
|
|
memory. These attributes can be manipulated via
|
|
|
|
.Fn ioctl
|
|
|
|
calls performed on
|
|
|
|
.Nm /dev/mem .
|
|
|
|
Declarations and data types are to be found in
|
2002-02-10 08:52:25 +00:00
|
|
|
.Pa <sys/memrange.h>
|
1999-04-07 04:03:51 +00:00
|
|
|
.Pp
|
|
|
|
The specific attributes, and number of programmable ranges may vary between
|
|
|
|
architectures. The full set of supported attributes is:
|
2001-02-01 16:38:02 +00:00
|
|
|
.Bl -tag -width indent
|
1999-04-07 04:03:51 +00:00
|
|
|
.It MDF_UNCACHEABLE
|
|
|
|
The region is not cached.
|
|
|
|
.It MDF_WRITECOMBINE
|
|
|
|
Writes to the region may be combined or performed out of order.
|
|
|
|
.It MDF_WRITETHROUGH
|
|
|
|
Writes to the region are committed synchronously.
|
|
|
|
.It MDF_WRITEBACK
|
|
|
|
Writes to the region are committed asynchronously.
|
|
|
|
.It MDF_WRITEPROTECT
|
|
|
|
The region cannot be written to.
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
Memory ranges are described by
|
|
|
|
.Fa struct mem_range_desc :
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
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];
|
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
In addition to the region attributes listed above, the following flags
|
|
|
|
may also be set in the
|
|
|
|
.Fa mr_flags
|
|
|
|
field:
|
2001-02-01 16:38:02 +00:00
|
|
|
.Bl -tag -width indent
|
1999-04-07 04:03:51 +00:00
|
|
|
.It MDF_FIXBASE
|
|
|
|
The region's base address cannot be changed.
|
|
|
|
.It MDF_FIXLEN
|
|
|
|
The region's length cannot be changed.
|
|
|
|
.It MDF_FIRMWARE
|
2002-01-21 12:09:13 +00:00
|
|
|
The region is believed to have been established by the system firmware.
|
1999-04-07 04:03:51 +00:00
|
|
|
.It MDF_ACTIVE
|
|
|
|
The region is currently active.
|
|
|
|
.It MDF_BOGUS
|
|
|
|
We believe the region to be invalid or otherwise erroneous.
|
|
|
|
.It MDF_FIXACTIVE
|
|
|
|
The region cannot be disabled.
|
|
|
|
.It MDF_BUSY
|
2001-07-14 19:41:16 +00:00
|
|
|
The region is currently owned by another process and may not be
|
1999-04-07 04:03:51 +00:00
|
|
|
altered.
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
Operations are performed using
|
|
|
|
.Fa struct mem_range_op :
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
struct mem_range_desc *mo_desc;
|
|
|
|
int mo_arg[2];
|
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fa MEMRANGE_GET
|
2000-03-01 14:50:24 +00:00
|
|
|
ioctl is used to retrieve current memory range attributes.
|
|
|
|
If
|
1999-04-07 04:03:51 +00:00
|
|
|
.Fa 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
|
|
|
|
.Fa mo_desc
|
|
|
|
will be filled with a corresponding number of descriptor structures,
|
|
|
|
or the maximum, whichever is less.
|
|
|
|
.Pp
|
2001-07-14 19:41:16 +00:00
|
|
|
The
|
1999-04-07 04:03:51 +00:00
|
|
|
.Fa 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.
|
|
|
|
.Pp
|
2001-07-14 19:41:16 +00:00
|
|
|
.Fa mo_arg[0]
|
1999-04-07 04:03:51 +00:00
|
|
|
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.
|
|
|
|
.Sh RETURN VALUES
|
2000-11-22 16:11:48 +00:00
|
|
|
.Bl -tag -width Er
|
|
|
|
.It Bq Er EOPNOTSUPP
|
1999-04-07 04:03:51 +00:00
|
|
|
Memory range operations are not supported on this architecture.
|
2000-11-22 16:11:48 +00:00
|
|
|
.It Bq Er ENXIO
|
1999-04-07 04:03:51 +00:00
|
|
|
No memory range descriptors are available (eg. firmware has not enabled
|
|
|
|
any).
|
2000-11-22 16:11:48 +00:00
|
|
|
.It Bq Er EINVAL
|
1999-04-07 04:03:51 +00:00
|
|
|
The memory range supplied as an argument is invalid or overlaps another
|
|
|
|
range in a fashion not supported by this architecture.
|
2000-11-22 16:11:48 +00:00
|
|
|
.It Bq Er EBUSY
|
1999-04-07 04:03:51 +00:00
|
|
|
An attempt to remove or update a range failed because the range is busy.
|
2000-11-22 16:11:48 +00:00
|
|
|
.It Bq Er ENOSPC
|
1999-04-07 04:03:51 +00:00
|
|
|
An attempt to create a new range failed due to a shortage of hardware
|
|
|
|
resources (eg. descriptor slots).
|
2000-11-22 16:11:48 +00:00
|
|
|
.It Bq Er ENOENT
|
1999-04-07 04:03:51 +00:00
|
|
|
An attempt to remove a range failed because no range matches the descriptor
|
2002-01-21 12:09:13 +00:00
|
|
|
base/length supplied.
|
2000-11-22 16:11:48 +00:00
|
|
|
.It Bq Er EPERM
|
1999-04-07 04:03:51 +00:00
|
|
|
An attempt to remove a range failed because the range is permanently
|
|
|
|
enabled.
|
|
|
|
.El
|
|
|
|
.Sh BUGS
|
|
|
|
Busy range attributes are not yet managed correctly.
|
1993-06-12 14:49:13 +00:00
|
|
|
.Sh FILES
|
2001-02-01 16:38:02 +00:00
|
|
|
.Bl -tag -width /dev/kmem -compact
|
1993-06-12 14:49:13 +00:00
|
|
|
.It Pa /dev/mem
|
|
|
|
.It Pa /dev/kmem
|
|
|
|
.El
|
1999-04-07 04:03:51 +00:00
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr memcontrol 8
|
1993-06-12 14:49:13 +00:00
|
|
|
.Sh HISTORY
|
|
|
|
The
|
2000-11-20 18:41:33 +00:00
|
|
|
.Nm ,
|
1993-06-12 14:49:13 +00:00
|
|
|
.Nm kmem
|
|
|
|
files appeared in
|
|
|
|
.At v6 .
|
1999-04-07 04:03:51 +00:00
|
|
|
The ioctl interface for memory range attributes was added in
|
|
|
|
.Fx 3.2 .
|