xref: /illumos-gate/usr/src/uts/i86pc/os/ppage.c (revision 9164a50bf932130cbb5097a16f6986873ce0e6e5)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #include <sys/t_lock.h>
28 #include <sys/vmem.h>
29 #include <sys/mman.h>
30 #include <sys/vm.h>
31 #include <sys/cpuvar.h>
32 #include <sys/systm.h>
33 #include <vm/as.h>
34 #include <vm/hat.h>
35 #include <vm/page.h>
36 #include <vm/seg.h>
37 #include <vm/seg_kmem.h>
38 #include <sys/kmem.h>
39 #include <sys/cmn_err.h>
40 #include <sys/debug.h>
41 
42 /*
43  * ppcopy() and pagezero() have moved to i86/vm/vm_machdep.c
44  */
45 
46 /*
47  * Architecures with a vac use this routine to quickly make
48  * a vac-aligned mapping.  We don't have a vac, so we don't
49  * care about that - just make this simple.
50  */
51 /* ARGSUSED2 */
52 caddr_t
53 ppmapin(page_t *pp, uint_t vprot, caddr_t avoid)
54 {
55 	caddr_t va;
56 
57 	va = vmem_alloc(heap_arena, PAGESIZE, VM_SLEEP);
58 	hat_memload(kas.a_hat, va, pp, vprot | HAT_NOSYNC, HAT_LOAD_LOCK);
59 	return (va);
60 }
61 
62 void
63 ppmapout(caddr_t va)
64 {
65 	hat_unload(kas.a_hat, va, PAGESIZE, HAT_UNLOAD_UNLOCK);
66 	vmem_free(heap_arena, va, PAGESIZE);
67 }
68 
69 
70 /*
71  * Map the page pointed to by pp into the kernel virtual address space.
72  * This routine is used by the rootnexus.
73  */
74 void
75 i86_pp_map(page_t *pp, caddr_t kaddr)
76 {
77 	hat_devload(kas.a_hat, kaddr, MMU_PAGESIZE, page_pptonum(pp),
78 	    HAT_STORECACHING_OK | PROT_READ | PROT_WRITE | HAT_NOSYNC,
79 	    HAT_LOAD_LOCK);
80 }
81 
82 /*
83  * Map the page containing the virtual address into the kernel virtual address
84  * space.  This routine is used by the rootnexus.
85  */
86 void
87 i86_va_map(caddr_t vaddr, struct as *asp, caddr_t kaddr)
88 {
89 	pfn_t pfnum;
90 
91 	pfnum = hat_getpfnum(asp->a_hat, vaddr);
92 	hat_devload(kas.a_hat, kaddr, MMU_PAGESIZE, pfnum,
93 	    HAT_STORECACHING_OK | PROT_READ | PROT_WRITE | HAT_NOSYNC,
94 	    HAT_LOAD_LOCK);
95 }
96