]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/man/man4/mem.4
sys/{x86,amd64}: remove one of doubled ;s
[FreeBSD/FreeBSD.git] / share / man / man4 / mem.4
1 .\" Copyright (c) 1991 The Regents of the University of California.
2 .\" All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. Neither the name of the University nor the names of its contributors
13 .\"    may be used to endorse or promote products derived from this software
14 .\"    without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 .\" SUCH DAMAGE.
27 .\"
28 .\"     @(#)mem.4       5.3 (Berkeley) 5/2/91
29 .\" $FreeBSD$
30 .\"
31 .Dd October 3, 2004
32 .Dt MEM 4
33 .Os
34 .Sh NAME
35 .Nm mem ,
36 .Nm kmem
37 .Nd memory files
38 .Sh SYNOPSIS
39 .Cd "device mem"
40 .Sh DESCRIPTION
41 The special file
42 .Pa /dev/mem
43 is an interface to the physical memory of the computer.
44 Byte offsets in this file are interpreted as physical memory addresses.
45 Reading and writing this file is equivalent to reading and writing
46 memory itself.
47 Only offsets within the bounds of
48 .Pa /dev/mem
49 are allowed.
50 .Pp
51 Kernel virtual memory is accessed through the interface
52 .Pa /dev/kmem
53 in the same manner as
54 .Pa /dev/mem .
55 Only kernel virtual addresses that are currently mapped to memory are allowed.
56 .Pp
57 On
58 .Tn ISA
59 the
60 .Tn I/O
61 memory space begins at physical address 0x000a0000
62 and runs to 0x00100000.
63 The
64 per-process data
65 size
66 for the current process
67 is
68 .Dv UPAGES
69 long, and ends at virtual
70 address 0xf0000000.
71 .Sh IOCTL INTERFACE
72 Several architectures allow attributes to be associated with ranges of physical
73 memory.
74 These attributes can be manipulated via
75 .Fn ioctl
76 calls performed on
77 .Pa /dev/mem .
78 Declarations and data types are to be found in
79 .In sys/memrange.h .
80 .Pp
81 The specific attributes, and number of programmable ranges may vary between
82 architectures.
83 The full set of supported attributes is:
84 .Bl -tag -width indent
85 .It Dv MDF_UNCACHEABLE
86 The region is not cached.
87 .It Dv MDF_WRITECOMBINE
88 Writes to the region may be combined or performed out of order.
89 .It Dv MDF_WRITETHROUGH
90 Writes to the region are committed synchronously.
91 .It Dv MDF_WRITEBACK
92 Writes to the region are committed asynchronously.
93 .It Dv MDF_WRITEPROTECT
94 The region cannot be written to.
95 .El
96 .Pp
97 Memory ranges are described by
98 .Vt struct mem_range_desc :
99 .Bd -literal -offset indent
100 uint64_t        mr_base;        /\(** physical base address \(**/
101 uint64_t        mr_len;         /\(** physical length of region \(**/
102 int             mr_flags;       /\(** attributes of region \(**/
103 char            mr_owner[8];
104 .Ed
105 .Pp
106 In addition to the region attributes listed above, the following flags
107 may also be set in the
108 .Fa mr_flags
109 field:
110 .Bl -tag -width indent
111 .It MDF_FIXBASE
112 The region's base address cannot be changed.
113 .It MDF_FIXLEN
114 The region's length cannot be changed.
115 .It MDF_FIRMWARE
116 The region is believed to have been established by the system firmware.
117 .It MDF_ACTIVE
118 The region is currently active.
119 .It MDF_BOGUS
120 We believe the region to be invalid or otherwise erroneous.
121 .It MDF_FIXACTIVE
122 The region cannot be disabled.
123 .It MDF_BUSY
124 The region is currently owned by another process and may not be
125 altered.
126 .El
127 .Pp
128 Operations are performed using
129 .Fa struct mem_range_op :
130 .Bd -literal -offset indent
131 struct mem_range_desc   *mo_desc;
132 int                     mo_arg[2];
133 .Ed
134 .Pp
135 The
136 .Dv MEMRANGE_GET
137 ioctl is used to retrieve current memory range attributes.
138 If
139 .Va mo_arg[0]
140 is set to 0, it will be updated with the total number of memory range
141 descriptors.
142 If greater than 0, the array at
143 .Va mo_desc
144 will be filled with a corresponding number of descriptor structures,
145 or the maximum, whichever is less.
146 .Pp
147 The
148 .Dv MEMRANGE_SET
149 ioctl is used to add, alter and remove memory range attributes.
150 A range
151 with the
152 .Dv MDF_FIXACTIVE
153 flag may not be removed; a range with the
154 .Dv MDF_BUSY
155 flag may not be removed or updated.
156 .Pp
157 .Va mo_arg[0]
158 should be set to
159 .Dv MEMRANGE_SET_UPDATE
160 to update an existing or establish a new range, or to
161 .Dv MEMRANGE_SET_REMOVE
162 to remove a range.
163 .Sh RETURN VALUES
164 .Bl -tag -width Er
165 .It Bq Er EOPNOTSUPP
166 Memory range operations are not supported on this architecture.
167 .It Bq Er ENXIO
168 No memory range descriptors are available (e.g.\& firmware has not enabled
169 any).
170 .It Bq Er EINVAL
171 The memory range supplied as an argument is invalid or overlaps another
172 range in a fashion not supported by this architecture.
173 .It Bq Er EBUSY
174 An attempt to remove or update a range failed because the range is busy.
175 .It Bq Er ENOSPC
176 An attempt to create a new range failed due to a shortage of hardware
177 resources (e.g.\& descriptor slots).
178 .It Bq Er ENOENT
179 An attempt to remove a range failed because no range matches the descriptor
180 base/length supplied.
181 .It Bq Er EPERM
182 An attempt to remove a range failed because the range is permanently
183 enabled.
184 .El
185 .Sh FILES
186 .Bl -tag -width /dev/kmem -compact
187 .It Pa /dev/mem
188 .It Pa /dev/kmem
189 .El
190 .Sh SEE ALSO
191 .Xr kvm 3 ,
192 .Xr memcontrol 8
193 .Sh HISTORY
194 The
195 .Nm mem
196 and
197 .Nm kmem
198 files appeared in
199 .At v6 .
200 The ioctl interface for memory range attributes was added in
201 .Fx 3.2 .
202 .Sh BUGS
203 Busy range attributes are not yet managed correctly.
204 .Pp
205 This device is required for all users of
206 .Xr kvm 3
207 to operate.