xref: /titanic_52/usr/src/uts/i86pc/os/ppage.c (revision 0eb822a1c0c2bea495647510b75f77f0e57633eb)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 #include <sys/t_lock.h>
30 #include <sys/vmem.h>
31 #include <sys/mman.h>
32 #include <sys/vm.h>
33 #include <sys/cpuvar.h>
34 #include <sys/systm.h>
35 #include <vm/as.h>
36 #include <vm/hat.h>
37 #include <vm/page.h>
38 #include <vm/seg.h>
39 #include <vm/seg_kmem.h>
40 #include <sys/kmem.h>
41 #include <sys/cmn_err.h>
42 #include <sys/debug.h>
43 
44 /*
45  * ppcopy() and pagezero() have moved to i86/vm/vm_machdep.c
46  */
47 
48 /*
49  * Architecures with a vac use this routine to quickly make
50  * a vac-aligned mapping.  We don't have a vac, so we don't
51  * care about that - just make this simple.
52  */
53 /* ARGSUSED2 */
54 caddr_t
55 ppmapin(page_t *pp, uint_t vprot, caddr_t avoid)
56 {
57 	caddr_t va;
58 
59 	va = vmem_alloc(heap_arena, PAGESIZE, VM_SLEEP);
60 	hat_memload(kas.a_hat, va, pp, vprot | HAT_NOSYNC, HAT_LOAD_LOCK);
61 	return (va);
62 }
63 
64 void
65 ppmapout(caddr_t va)
66 {
67 	hat_unload(kas.a_hat, va, PAGESIZE, HAT_UNLOAD_UNLOCK);
68 	vmem_free(heap_arena, va, PAGESIZE);
69 }
70 
71 
72 /*
73  * Map the page pointed to by pp into the kernel virtual address space.
74  * This routine is used by the rootnexus.
75  */
76 void
77 i86_pp_map(page_t *pp, caddr_t kaddr)
78 {
79 	hat_devload(kas.a_hat, kaddr, MMU_PAGESIZE, page_pptonum(pp),
80 	    HAT_STORECACHING_OK | PROT_READ | PROT_WRITE | HAT_NOSYNC,
81 	    HAT_LOAD_LOCK);
82 }
83 
84 /*
85  * Map the page containing the virtual address into the kernel virtual address
86  * space.  This routine is used by the rootnexus.
87  */
88 void
89 i86_va_map(caddr_t vaddr, struct as *asp, caddr_t kaddr)
90 {
91 	pfn_t pfnum;
92 
93 	pfnum = hat_getpfnum(asp->a_hat, vaddr);
94 	hat_devload(kas.a_hat, kaddr, MMU_PAGESIZE, pfnum,
95 	    HAT_STORECACHING_OK | PROT_READ | PROT_WRITE | HAT_NOSYNC,
96 	    HAT_LOAD_LOCK);
97 }
98