1 .\" Copyright (c) 1991 The Regents of the University of California.
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
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.
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
28 .\" @(#)mem.4 5.3 (Berkeley) 5/2/91
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
47 Only offsets within the bounds of
51 Kernel virtual memory is accessed through the interface
55 Only kernel virtual addresses that are currently mapped to memory are allowed.
57 On ISA the I/O memory space begins at physical address 0x000a0000
58 and runs to 0x00100000.
62 for the current process
65 long, and ends at virtual
68 .Ss Address Properties
71 ioctl can be used to look up the physical address and NUMA domain of a given
72 virtual address in the calling process' address space.
73 The request is described by
76 uint64_t me_vaddr; /* input */
77 uint64_t me_paddr; /* output */
78 int me_domain; /* output */
79 int me_state; /* output */
83 The ioctl returns an error if the address is not valid.
84 The information returned by
86 may be out of date by the time that the ioctl call returns.
87 Specifically, concurrent system calls, page faults, or system page reclamation
88 activity may have unmapped the virtual page or replaced the backing physical
89 page before the ioctl call returns.
90 Wired pages, e.g., those locked by
92 will not be reclaimed by the system.
96 field provides information about the state of the virtual page:
97 .Bl -tag -width indent
98 .It Dv ME_STATE_INVALID
99 The virtual address is invalid.
100 .It Dv ME_STATE_VALID
101 The virtual address is valid but is not mapped at the time of the ioctl call.
102 .It Dv ME_STATE_MAPPED
103 The virtual address corresponds to a physical page mapping, and the
111 Several architectures allow attributes to be associated with ranges of physical
113 These attributes can be manipulated via
117 Declarations and data types are to be found in
120 The specific attributes, and number of programmable ranges may vary between
122 The full set of supported attributes is:
123 .Bl -tag -width indent
124 .It Dv MDF_UNCACHEABLE
125 The region is not cached.
126 .It Dv MDF_WRITECOMBINE
127 Writes to the region may be combined or performed out of order.
128 .It Dv MDF_WRITETHROUGH
129 Writes to the region are committed synchronously.
131 Writes to the region are committed asynchronously.
132 .It Dv MDF_WRITEPROTECT
133 The region cannot be written to.
136 Memory ranges are described by
138 struct mem_range_desc {
139 uint64_t mr_base; /* physical base address */
140 uint64_t mr_len; /* physical length of region */
141 int mr_flags; /* attributes of region */
146 In addition to the region attributes listed above, the following flags
147 may also be set in the
150 .Bl -tag -width indent
152 The region's base address cannot be changed.
154 The region's length cannot be changed.
156 The region is believed to have been established by the system firmware.
158 The region is currently active.
160 We believe the region to be invalid or otherwise erroneous.
162 The region cannot be disabled.
164 The region is currently owned by another process and may not be
168 Operations are performed using
170 struct mem_range_op {
171 struct mem_range_desc *mo_desc;
178 ioctl is used to retrieve current memory range attributes.
181 is set to 0, it will be updated with the total number of memory range
183 If greater than 0, the array at
185 will be filled with a corresponding number of descriptor structures,
186 or the maximum, whichever is less.
190 ioctl is used to add, alter and remove memory range attributes.
194 flag may not be removed; a range with the
196 flag may not be removed or updated.
200 .Dv MEMRANGE_SET_UPDATE
201 to update an existing or establish a new range, or to
202 .Dv MEMRANGE_SET_REMOVE
206 .Ss MEM_EXTRACT_PADDR
208 .Dv MEM_EXTRACT_PADDR
209 ioctl always returns a value of zero.
210 .Ss MEMRANGE_GET/MEMRANGE_SET
213 Memory range operations are not supported on this architecture.
215 No memory range descriptors are available (e.g., firmware has not enabled
218 The memory range supplied as an argument is invalid or overlaps another
219 range in a fashion not supported by this architecture.
221 An attempt to remove or update a range failed because the range is busy.
223 An attempt to create a new range failed due to a shortage of hardware
224 resources (e.g., descriptor slots).
226 An attempt to remove a range failed because no range matches the descriptor
227 base/length supplied.
229 An attempt to remove a range failed because the range is permanently
233 .Bl -tag -width /dev/kmem -compact
247 The ioctl interface for memory range attributes was added in
250 Busy range attributes are not yet managed correctly.
252 This device is required for all users of