1 .\" $NetBSD: pmap.9,v 1.40 2009/11/07 07:37:46 cegger Exp $
3 .\" Copyright (c) 2000, 2001, 2002 The NetBSD Foundation, Inc.
4 .\" All rights reserved.
6 .\" This code is derived from software contributed to The NetBSD Foundation
7 .\" by Jason R. Thorpe.
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\" notice, this list of conditions and the following disclaimer in the
16 .\" documentation and/or other materials provided with the distribution.
18 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 .\" POSSIBILITY OF SUCH DAMAGE.
35 .Nd machine-dependent portion of the virtual memory system
40 .Fn "pmap_init" "void"
42 .Fn "pmap_virtual_space" "vaddr_t *vstartp" "vaddr_t *vendp"
44 .Fn "pmap_steal_memory" "vsize_t size" "vaddr_t *vstartp" "vaddr_t *vendp"
46 .Fn "pmap_kernel" "void"
48 .Fn "pmap_create" "void"
50 .Fn "pmap_destroy" "pmap_t pmap"
52 .Fn "pmap_reference" "pmap_t pmap"
54 .Fn "pmap_fork" "pmap_t src_map" "pmap_t dst_map"
56 .Fn "pmap_resident_count" "pmap_t pmap"
58 .Fn "pmap_wired_count" "pmap_t pmap"
60 .Fn "pmap_growkernel" "vaddr_t maxkvaddr"
62 .Fn "pmap_enter" "pmap_t pmap" "vaddr_t va" "paddr_t pa" "vm_prot_t prot" \
65 .Fn "pmap_remove" "pmap_t pmap" "vaddr_t sva" "vaddr_t eva"
67 .Fn "pmap_remove_all" "pmap_t pmap"
69 .Fn "pmap_protect" "pmap_t pmap" "vaddr_t sva" "vaddr_t eva" "vm_prot_t prot"
71 .Fn "pmap_unwire" "pmap_t pmap" "vaddr_t va"
73 .Fn "pmap_extract" "pmap_t pmap" "vaddr_t va" "paddr_t *pap"
75 .Fn "pmap_kenter_pa" "vaddr_t va" "paddr_t pa" "vm_prot_t prot" "u_int flags"
77 .Fn "pmap_kremove" "vaddr_t va" "vsize_t size"
79 .Fn "pmap_copy" "pmap_t dst_map" "pmap_t src_map" "vaddr_t dst_addr" \
80 "vsize_t len" "vaddr_t src_addr"
82 .Fn "pmap_update" "pmap_t pmap"
84 .Fn "pmap_activate" "struct lwp *l"
86 .Fn "pmap_deactivate" "struct lwp *l"
88 .Fn "pmap_zero_page" "paddr_t pa"
90 .Fn "pmap_copy_page" "paddr_t src" "paddr_t dst"
92 .Fn "pmap_page_protect" "struct vm_page *pg" "vm_prot_t prot"
94 .Fn "pmap_clear_modify" "struct vm_page *pg"
96 .Fn "pmap_clear_reference" "struct vm_page *pg"
98 .Fn "pmap_is_modified" "struct vm_page *pg"
100 .Fn "pmap_is_referenced" "struct vm_page *pg"
102 .Fn "pmap_phys_address" "paddr_t cookie"
104 .Fn "PMAP_MAP_POOLPAGE" "paddr_t pa"
106 .Fn "PMAP_UNMAP_POOLPAGE" "vaddr_t va"
108 .Fn "PMAP_PREFER" "vaddr_t hint" "vaddr_t *vap" "vsize_t sz" "int td"
112 module is the machine-dependent portion of the
114 virtual memory system
118 module is to manage physical address maps, to program the
119 memory management hardware on the system, and perform any
120 cache operations necessary to ensure correct operation of
121 the virtual memory system.
124 module is also responsible for maintaining certain information
128 In order to cope with hardware architectures that make the
129 invalidation of virtual address mappings expensive (e.g.,
130 TLB invalidations, TLB shootdown operations for multiple
133 module is allowed to delay mapping invalidation or protection
134 operations until such time as they are actually necessary.
135 The functions that are allowed to delay such actions are
142 Callers of these functions must use the
144 function to notify the
146 module that the mappings need to be made correct.
149 module is provided with information as to which processors are
150 using a given physical map, the
152 module may use whatever optimizations it has available to reduce
153 the expense of virtual-to-physical mapping synchronization.
154 .Ss HEADER FILES AND DATA STRUCTURES
155 Machine-dependent code must provide the header file
156 .Aq Pa machine/pmap.h .
157 This file contains the definition of the
160 .Bd -literal -offset indent
162 /* Contents defined by pmap implementation. */
164 typedef struct pmap *pmap_t;
167 This header file may also define other data structures that the
171 Note that all prototypes for
173 interface functions are provided by the header file
174 .Aq Pa uvm/uvm_pmap.h .
175 It is possible to override this behavior by defining the
176 C pre-processor macro
177 .Dv PMAP_EXCLUDE_DECLS .
178 This may be used to add a layer of indirection to
180 API calls, for handling different MMU types in a single
184 .Dv PMAP_EXCLUDE_DECLS
186 .Aq Pa machine/pmap.h
188 provide function prototypes in a block like so:
189 .Bd -literal -offset indent
190 #ifdef _KERNEL /* not exposed to user namespace */
191 __BEGIN_DECLS /* make safe for C++ */
192 /* Prototypes go here. */
198 .Aq Pa uvm/uvm_pmap.h
199 defines a structure for tracking
201 statistics (see below).
202 This structure is defined as:
203 .Bd -literal -offset indent
204 struct pmap_statistics {
205 long resident_count; /* number of mapped pages */
206 long wired_count; /* number of wired pages */
212 module is based on the premise that all information contained
213 in the physical maps it manages is redundant.
214 That is, physical map information may be
218 module in the event that it is necessary to do so; it can be rebuilt
221 by taking a page fault.
222 There is one exception to this rule: so-called
224 mappings may not be forgotten.
225 Wired mappings are those for which either no high-level information
226 exists with which to rebuild the mapping, or mappings which are needed
227 by critical sections of code where taking a page fault is unacceptable.
228 Information about which mappings are wired is provided to the
230 module when a mapping is established.
231 .Ss MODIFIED/REFERENCED INFORMATION
234 module is required to keep track of whether or not a page managed
235 by the virtual memory system has been referenced or modified.
236 This information is used by
238 to determine what happens to the page when scanned by the
241 Many CPUs provide hardware support for tracking
242 modified/referenced information.
243 However, many CPUs, particularly modern RISC CPUs, do not.
244 On CPUs which lack hardware support for modified/referenced tracking, the
246 module must emulate it in software.
247 There are several strategies for doing this, and the best strategy
252 attribute is used by the pagedaemon to determine if a page is
254 Active pages are not candidates for re-use in the page replacement algorithm.
255 Accurate referenced information is not required for correct operation; if
256 supplying referenced information for a page is not feasible, then the
258 implementation should always consider the
265 attribute is used by the pagedaemon to determine if a page needs
266 to be cleaned (written to backing store; swap space, a regular file, etc.).
267 Accurate modified information
271 module for correct operation of the virtual memory system.
273 Note that modified/referenced information is only tracked for
274 pages managed by the virtual memory system (i.e., pages for
275 which a vm_page structure exists).
278 mappings of those pages have modified/referenced tracking.
279 Mappings entered with the
286 mappings of a page to be created, using the
291 mappings should be limited to code which may execute in interrupt context
292 (for example, the kernel memory allocator), or to enter mappings for
293 physical addresses which are not managed by the virtual memory system.
295 mappings may only be entered into the kernel's virtual address space.
296 This constraint is placed on the callers of the
300 functions so that the
302 implementation need not block interrupts when manipulating data
303 structures or holding locks.
305 Also note that the modified/referenced information must be tracked
306 on a per-page basis; they are not attributes of a mapping, but attributes
308 Therefore, even after all mappings for a given page have
309 been removed, the modified/referenced information for that page
312 The only time the modified/referenced attributes may
313 be cleared is when the virtual memory system explicitly calls the
314 .Fn pmap_clear_modify
316 .Fn pmap_clear_reference
318 These functions must also change any internal state necessary to detect
319 the page being modified or referenced again after the modified or
320 referenced state is cleared.
324 implementations could get away without this because UVM (and Mach VM
325 before that) always called
326 .Fn pmap_page_protect
327 before clearing the modified or referenced state, but UVM has been changed
328 to not do this anymore, so all
330 implementations must now handle this.)
334 is required to keep statistics as to the number of
336 pages and the number of
342 page is one for which a mapping exists.
343 This statistic is used to compute the resident size of a process and
344 enforce resource limits.
345 Only pages (whether managed by the virtual memory system or not)
346 which are mapped into a physical map should be counted in the resident
351 page is one for which a wired mapping exists.
352 This statistic is used to enforce resource limits.
354 Note that it is recommended (though not required) that the
356 implementation use the
358 structure in the tracking of
360 statistics by placing it inside the
362 structure and adjusting the counts when mappings are established, changed,
364 This avoids potentially expensive data structure traversals when the
365 statistics are queried.
366 .Ss REQUIRED FUNCTIONS
367 This section describes functions that a
369 module must provide to the virtual memory system.
370 .Bl -tag -width indent -offset indent
371 .It void Fn "pmap_init" "void"
372 This function initializes the
377 to initialize any data structures that the module needs to
378 manage physical maps.
379 .It pmap_t Fn "pmap_kernel" "void"
380 A machine independent macro which expands to
381 .Va kernel_pmap_ptr .
382 This variable must be exported by the platform's pmap module and it
383 must point to the kernel pmap.
384 .It void Fn "pmap_virtual_space" "vaddr_t *vstartp" "vaddr_t *vendp"
386 .Fn pmap_virtual_space
387 function is called to determine the initial kernel virtual address
388 space beginning and end.
389 These values are used to create the kernel's virtual memory map.
390 The function must set
392 to the first kernel virtual address that will be managed by
396 to the last kernel virtual address that will be managed by
405 should be set to the maximum kernel virtual address allowed by the
412 be set to the maximum kernel virtual address that can be mapped with
413 the resources currently allocated to map the kernel virtual address
415 .It pmap_t Fn "pmap_create" "void"
416 Create a physical map and return it to the caller.
417 The reference count on the new map is 1.
418 .It void Fn "pmap_destroy" "pmap_t pmap"
419 Drop the reference count on the specified physical map.
420 If the reference count drops to 0, all resources associated with the
421 physical map are released and the physical map destroyed.
422 In the case of a drop-to-0, no mappings will exist in the map.
425 implementation may assert this.
426 .It void Fn "pmap_reference" "pmap_t pmap"
427 Increment the reference count on the specified physical map.
428 .It long Fn "pmap_resident_count" "pmap_t pmap"
434 Note that this function may be provided as a C pre-processor macro.
435 .It long Fn "pmap_wired_count" "pmap_t pmap"
441 Note that this function may be provided as a C pre-processor macro.
442 .It int Fn "pmap_enter" "pmap_t pmap" "vaddr_t va" "paddr_t pa" \
443 "vm_prot_t prot" "u_int flags"
444 Create a mapping in physical map
446 for the physical address
448 at the virtual address
450 with protection specified by bits in
452 .Bl -tag -width "VM_PROT_EXECUTE " -offset indent
454 The mapping must allow reading.
456 The mapping must allow writing.
458 The page mapped contains instructions that will be executed by the
464 argument contains protection bits (the same bits as used in the
466 argument) indicating the type of access that caused the mapping to
468 This information may be used to seed modified/referenced
469 information for the page being mapped, possibly avoiding redundant faults
470 on platforms that track modified/referenced information in software.
471 Other information provided by
473 .Bl -tag -width "PMAP_CANFAIL " -offset indent
475 The mapping being created is a wired mapping.
484 call is unable to create the mapping, perhaps due to insufficient
489 The mapping being created is not cached.
490 Write accesses have a write-through policy.
493 The access type provided in the
495 argument will never exceed the protection specified by
499 implementation may assert this.
500 Note that on systems that do not provide hardware support for
501 tracking modified/referenced information, modified/referenced
502 information for the page
504 be seeded with the access type provided in
509 This is to prevent a fault for the purpose of tracking
510 modified/referenced information from occurring while the system is in
511 a critical section where a fault would be unacceptable.
515 is sometimes called to enter a mapping at a virtual address
516 for which a mapping already exists.
517 In this situation, the implementation must take whatever action is
518 necessary to invalidate the previous mapping before entering the new one.
522 is sometimes called to change the protection for a pre-existing
523 mapping, or to change the
525 attribute for a pre-existing mapping.
529 function returns 0 on success or an error code indicating the mode
531 .It void Fn "pmap_remove" "pmap_t pmap" "vaddr_t sva" "vaddr_t eva"
532 Remove mappings from the virtual address range
536 from the specified physical map.
537 .It void Fn "pmap_remove_all" "pmap_t pmap"
538 This function is a hint to the
540 implementation that all entries in
542 will be removed before any more entries are entered.
543 Following this call, there will be
545 calls resulting in every mapping being removed, followed by either
551 interfaces which take
553 as an argument will be called during this process.
554 Other interfaces which might need to access
557 .Fn pmap_page_protect )
558 are permitted during this process.
562 implementation is free to either remove all the
564 mappings immediately in
565 .Fn pmap_remove_all ,
566 or to use the knowledge of the upcoming
568 calls to optimize the removals (or to just ignore this call).
570 .It void Fn "pmap_protect" "pmap_t pmap" "vaddr_t sva" "vaddr_t eva" \
572 Set the protection of the mappings in the virtual address range
576 in the specified physical map.
577 .It void Fn "pmap_unwire" "pmap_t pmap" "vaddr_t va"
580 attribute on the mapping for virtual address
582 .It bool Fn "pmap_extract" "pmap_t pmap" "vaddr_t va" "paddr_t *pap"
583 This function extracts a mapping from the specified physical map.
584 It serves two purposes: to determine if a mapping exists for the specified
585 virtual address, and to determine what physical address is mapped at the
586 specified virtual address.
589 should return the physical address for any kernel-accessible address,
590 including KSEG-style direct-mapped kernel addresses.
599 Otherwise, it returns
601 and places the physical address mapped at
607 argument is non-NULL.
608 .It void Fn "pmap_kenter_pa" "vaddr_t va" "paddr_t pa" "vm_prot_t prot" \
612 mapping for physical address
616 with protection specified by bits in
618 .Bl -tag -width "VM_PROT_EXECUTE " -offset indent
620 The mapping must allow reading.
622 The mapping must allow writing.
624 The page mapped contains instructions that will be executed by the
628 Information provided by
630 .Bl -tag -width "PMAP_NOCACHE " -offset indent
632 The mapping being created is
635 Write accesses have a write-through policy.
638 Mappings of this type are always
640 and are unaffected by routines that alter the protection of pages
642 .Fn pmap_page_protect ) .
643 Such mappings are also not included in the gathering of modified/referenced
644 information about a page.
645 Mappings entered with
647 by machine-independent code
649 have execute permission, as the
650 data structures required to track execute permission of a page may not
653 Machine-independent code is not allowed to enter a mapping with
655 at a virtual address for which a valid mapping already exists.
656 Mappings created with
658 may be removed only with a call to
663 must be safe for use in interrupt context.
665 blocks interrupts that might cause
668 .It void Fn "pmap_kremove" "vaddr_t va" "vsize_t size"
669 Remove all mappings starting at virtual address
673 bytes from the kernel physical map.
674 All mappings that are removed must be the
678 The implementation may assert this.
679 .It void Fn "pmap_copy" "pmap_t dst_map" "pmap_t src_map" "vaddr_t dst_addr" \
680 "vsize_t len" "vaddr_t src_addr"
681 This function copies the mappings starting at
692 Note that while this function is required to be provided by a
694 implementation, it is not actually required to do anything.
696 is merely advisory (it is used in the
700 the child's address space).
701 .It void Fn "pmap_update" "pmap_t pmap"
702 This function is used to inform the
704 module that all physical mappings, for the specified pmap, must now be
706 That is, all delayed virtual-to-physical mappings updates (such as TLB
707 invalidation or address space identifier updates) must be completed.
708 This routine must be used after calls to
715 in order to ensure correct operation of the virtual memory system.
719 implementation does not delay virtual-to-physical mapping updates,
722 In this case, the call may be deleted using a C pre-processor macro in
723 .Aq Pa machine/pmap.h .
724 .It void Fn "pmap_activate" "struct lwp *l"
725 Activate the physical map used by the process behind lwp
727 This is called by the virtual memory system when the
728 virtual memory context for a process is changed, and is also
729 often used by machine-dependent context switch code to program
730 the memory management hardware with the process's page table
734 may not always be called when
738 must be able to handle this scenario.
739 .It void Fn "pmap_deactivate" "struct lwp *l"
740 Deactivate the physical map used by the process behind lwp
742 It is generally used in conjunction with
747 may not always be called when
750 .It void Fn "pmap_zero_page" "paddr_t pa"
751 Zero the PAGE_SIZE sized region starting at physical address
755 implementation must take whatever steps are necessary to map the
756 page to a kernel-accessible address and zero the page.
757 It is suggested that implementations use an optimized zeroing algorithm,
758 as the performance of this function directly impacts page fault performance.
759 The implementation may assume that the region is
760 PAGE_SIZE aligned and exactly PAGE_SIZE bytes in length.
762 Note that the cache configuration of the platform should also be
763 considered in the implementation of
765 For example, on systems with a physically-addressed cache, the cache
766 load caused by zeroing the page will not be wasted, as the zeroing is
767 usually done on-demand.
768 However, on systems with a virtually-addressed cached, the cache load
769 caused by zeroing the page
771 be wasted, as the page will be mapped at a virtual address which is
772 different from that used to zero the page.
773 In the virtually-addressed cache case, care should also be taken to
774 avoid cache alias problems.
775 .It void Fn "pmap_copy_page" "paddr_t src" "paddr_t dst"
776 Copy the PAGE_SIZE sized region starting at physical address
778 to the same sized region starting at physical address
782 implementation must take whatever steps are necessary to map the
783 source and destination pages to a kernel-accessible address and
785 It is suggested that implementations use an optimized copy algorithm,
786 as the performance of this function directly impacts page fault performance.
787 The implementation may assume that both regions are PAGE_SIZE aligned
788 and exactly PAGE_SIZE bytes in length.
790 The same cache considerations that apply to
794 .It void Fn "pmap_page_protect" "struct vm_page *pg" "vm_prot_t prot"
795 Lower the permissions for all mappings of the page
799 This function is used by the virtual memory system to implement
800 copy-on-write (called with VM_PROT_READ set in
802 and to revoke all mappings when cleaning a page (called with
805 Access permissions must never be added to a page as a result of
807 .It bool Fn "pmap_clear_modify" "struct vm_page *pg"
810 attribute on the page
814 .Fn pmap_clear_modify
819 indicating whether or not the
821 attribute was set on the page before it was cleared.
823 Note that this function may be provided as a C pre-processor macro.
824 .It bool Fn "pmap_clear_reference" "struct vm_page *pg"
827 attribute on the page
831 .Fn pmap_clear_reference
836 indicating whether or not the
838 attribute was set on the page before it was cleared.
840 Note that this function may be provided as a C pre-processor macro.
841 .It bool Fn "pmap_is_modified" "struct vm_page *pg"
842 Test whether or not the
844 attribute is set on page
847 Note that this function may be provided as a C pre-processor macro.
848 .It bool Fn "pmap_is_referenced" "struct vm_page *pg"
849 Test whether or not the
851 attribute is set on page
854 Note that this function may be provided as a C pre-processor macro.
855 .It paddr_t Fn "pmap_phys_address" "paddr_t cookie"
856 Convert a cookie returned by a device
858 function into a physical address.
859 This function is provided to accommodate systems which have physical
860 address spaces larger than can be directly addressed by the platform's
863 The existence of this function is highly dubious, and it is
864 expected that this function will be removed from the
866 API in a future release of
869 Note that this function may be provided as a C pre-processor macro.
871 .Ss OPTIONAL FUNCTIONS
872 This section describes several optional functions in the
875 .Bl -tag -width indent -offset indent
876 .It vaddr_t Fn "pmap_steal_memory" "vsize_t size" "vaddr_t *vstartp" \
878 This function is a bootstrap memory allocator, which may be provided
879 as an alternative to the bootstrap memory allocator used within
882 It is particularly useful on systems which provide for example a direct-mapped
884 This function works by stealing pages from the (to be) managed memory
885 pool, which has already been provided to
887 in the vm_physmem[] array.
888 The pages are then mapped, or otherwise made accessible to the kernel,
889 in a machine-dependent way.
890 The memory must be zeroed by
891 .Fn pmap_steal_memory .
892 Note that memory allocated with
893 .Fn pmap_steal_memory
894 will never be freed, and mappings made by
895 .Fn pmap_steal_memory
900 .Fn pmap_steal_memory
901 should not be used as a general-purpose early-startup memory
903 It is intended to be used only by the
904 .Fn uvm_pageboot_alloc
905 routine and its supporting routines.
906 If you need to allocate memory before the virtual memory system is
908 .Fn uvm_pageboot_alloc .
911 for more information.
914 .Fn pmap_steal_memory
915 function returns the kernel-accessible address of the allocated memory.
916 If no memory can be allocated, or if allocated memory cannot be mapped,
917 the function must panic.
920 .Fn pmap_steal_memory
921 function uses address space from the range provided to
924 .Fn pmap_virtual_space
926 .Fn pmap_steal_memory
934 .Fn pmap_steal_memory
935 function is enabled by defining the C pre-processor macro
936 .Dv PMAP_STEAL_MEMORY
938 .Aq Pa machine/pmap.h .
939 .It vaddr_t Fn "pmap_growkernel" "vaddr_t maxkvaddr"
940 Management of the kernel virtual address space is complicated by the
941 fact that it is not always safe to wait for resources with which to
942 map a kernel virtual address.
943 However, it is not always desirable to pre-allocate all resources
944 necessary to map the entire kernel virtual address space.
948 interface is designed to help alleviate this problem.
949 The virtual memory startup code may choose to allocate an initial set
950 of mapping resources (e.g., page tables) and set an internal variable
951 indicating how much kernel virtual address space can be mapped using
952 those initial resources.
953 Then, when the virtual memory system wishes to map something
954 at an address beyond that initial limit, it calls
956 to pre-allocate more sources with which to create the mapping.
957 Note that once additional kernel virtual address space mapping resources
958 have been allocated, they should not be freed; it is likely they will
963 function returns the new maximum kernel virtual address that can be mapped
964 with the resources it has available.
965 If new resources cannot be allocated,
971 function is enabled by defining the C pre-processor macro
974 .Aq Pa machine/pmap.h .
975 .It void Fn "pmap_fork" "pmap_t src_map" "pmap_t dst_map"
978 implementations may need to keep track of other information not
979 directly related to the virtual address space.
980 For example, on the i386 port, the Local Descriptor Table state of a
981 process is associated with the pmap (this is due to the fact that
982 applications manipulate the Local Descriptor Table directly expect it
983 to be logically associated with the virtual memory state of the process).
987 function is provided as a way to associate information from
1000 function is enabled by defining the C pre-processor macro
1003 .Aq Pa machine/pmap.h .
1004 .It vaddr_t Fn "PMAP_MAP_POOLPAGE" "paddr_t pa"
1005 This function is used by the
1007 memory pool manager.
1008 Pools allocate backing pages one at a time.
1009 This is provided as a means to use hardware features such as a
1010 direct-mapped memory segment to map the pages used by the
1013 This can lead to better performance by e.g. reducing TLB contention.
1015 .Fn PMAP_MAP_POOLPAGE
1016 returns the kernel-accessible address of the page being mapped.
1017 It must always succeed.
1020 .Fn PMAP_MAP_POOLPAGE
1021 is enabled by defining it as a C pre-processor macro in
1022 .Aq Pa machine/pmap.h .
1024 .Fn PMAP_MAP_POOLPAGE
1026 .Fn PMAP_UNMAP_POOLPAGE
1027 must also be defined.
1029 The following is an example of how to define
1030 .Fn PMAP_MAP_POOLPAGE :
1031 .Bd -literal -offset indent
1032 #define PMAP_MAP_POOLPAGE(pa) MIPS_PHYS_TO_KSEG0((pa))
1035 This takes the physical address of a page and returns the KSEG0
1036 address of that page on a MIPS processor.
1037 .It paddr_t Fn "PMAP_UNMAP_POOLPAGE" "vaddr_t va"
1038 This function is the inverse of
1039 .Fn PMAP_MAP_POOLPAGE .
1041 .Fn PMAP_UNMAP_POOLPAGE
1042 returns the physical address of the page corresponding to the
1043 provided kernel-accessible address.
1046 .Fn PMAP_UNMAP_POOLPAGE
1047 is enabled by defining it as a C pre-processor macro in
1048 .Aq Pa machine/pmap.h .
1050 .Fn PMAP_UNMAP_POOLPAGE
1052 .Fn PMAP_MAP_POOLPAGE
1053 must also be defined.
1055 The following is an example of how to define
1056 .Fn PMAP_UNMAP_POOLPAGE :
1057 .Bd -literal -offset indent
1058 #define PMAP_UNMAP_POOLPAGE(pa) MIPS_KSEG0_TO_PHYS((va))
1061 This takes the KSEG0 address of a previously-mapped pool page
1062 and returns the physical address of that page on a MIPS processor.
1063 .It void Fn "PMAP_PREFER" "vaddr_t hint" "vaddr_t *vap" "vsize_t sz" "int td"
1064 This function is used by
1066 to adjust a virtual address being allocated in order to avoid
1067 cache alias problems.
1068 If necessary, the virtual address pointed by
1072 is an object offset which will be mapped into the resulting virtual address, and
1074 is size of the object.
1076 indicates if the machine dependent pmap uses the topdown VM.
1080 is enabled by defining it as a C pre-processor macro in
1081 .Aq Pa machine/pmap.h .
1083 .It void Fn "pmap_procwr" "struct proc *p" "vaddr_t va" "vsize_t size"
1084 Synchronize CPU instruction caches of the specified range.
1085 The address space is designated by
1087 This function is typically used to flush instruction caches
1088 after code modification.
1092 is enabled by defining a C pre-processor macro
1093 .Dv PMAP_NEED_PROCWR
1095 .Aq Pa machine/pmap.h .
1102 module was originally part of the design of the virtual memory system
1103 in the Mach Operating System.
1104 The goal was to provide a clean separation between the machine-independent
1105 and the machine-dependent portions of the virtual memory system, in
1106 stark contrast to the original
1108 virtual memory system, which was specific to the VAX.
1114 the Mach virtual memory system, including the
1125 version of the Mach virtual memory system.
1129 release with the new
1131 virtual memory system, which included several changes to the
1134 Since the introduction of
1138 API has evolved further.
1140 The original Mach VAX
1142 module was written by
1143 .An Avadis Tevanian, Jr.
1145 .An Michael Wayne Young .
1148 did the integration of the Mach virtual memory system into
1152 module for the Motorola 68020+68851/68030/68040.
1160 and has been modified by
1162 .An Charles M. Hannum ,
1164 .An Wolfgang Solfrank ,
1165 .An Bill Sommerfeld ,
1167 .An Jason R. Thorpe .
1169 The author of this document is
1171 .Aq thorpej@NetBSD.org .
1173 The use and definition of
1177 needs to be reexamined.
1181 needs to be reexamined.
1182 Empirical evidence suggests that performance of the system suffers when
1184 actually performs its defined function.
1185 This is largely due to the fact that the copy of the virtual-to-physical
1186 mappings is wasted if the process calls
1190 For this reason, it is recommended that
1192 implementations leave the body of the
1194 function empty for now.