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