]> git.saurik.com Git - apple/xnu.git/blob - osfmk/ppc/pmap.h
xnu-344.23.tar.gz
[apple/xnu.git] / osfmk / ppc / pmap.h
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22 /*
23 * @OSF_COPYRIGHT@
24 */
25 /*
26 * Copyright (c) 1990 The University of Utah and
27 * the Center for Software Science at the University of Utah (CSS).
28 * All rights reserved.
29 *
30 * Permission to use, copy, modify and distribute this software is hereby
31 * granted provided that (1) source code retains these copyright, permission,
32 * and disclaimer notices, and (2) redistributions including binaries
33 * reproduce the notices in supporting documentation, and (3) all advertising
34 * materials mentioning features or use of this software display the following
35 * acknowledgement: ``This product includes software developed by the Center
36 * for Software Science at the University of Utah.''
37 *
38 * THE UNIVERSITY OF UTAH AND CSS ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS
39 * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSS DISCLAIM ANY LIABILITY OF
40 * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
41 *
42 * CSS requests users of this software to return to css-dist@cs.utah.edu any
43 * improvements that they make and grant CSS redistribution rights.
44 *
45 * Utah $Hdr: pmap.h 1.13 91/09/25$
46 * Author: Mike Hibler, Bob Wheeler, University of Utah CSS, 9/90
47 */
48
49 #ifndef _PPC_PMAP_H_
50 #define _PPC_PMAP_H_
51
52 #include <mach/vm_types.h>
53 #include <mach/machine/vm_types.h>
54 #include <mach/vm_prot.h>
55 #include <mach/vm_statistics.h>
56 #include <kern/queue.h>
57 #include <vm/pmap.h>
58
59 struct pmap {
60 queue_head_t pmap_link; /* MUST BE FIRST */
61 unsigned int pmapvr; /* Virtual to real conversion mask */
62 space_t space; /* space for this pmap */
63 #define BMAPLOCK 0x00000001
64 struct blokmap *bmaps; /* Physical pointer to odd-size page maps */
65 int ref_count; /* reference count */
66 unsigned int vflags; /* Alternate map validity flags */
67 #define pmapBatVal 0xFF000000
68 #define pmapBatDVal 0xF0000000
69 #define pmapBatIVal 0x0F000000
70 #define pmapFlags 0x00FF0000
71 #define pmapSubord 0x00800000
72 #define pmapVMhost 0x00400000
73 #define pmapAltSeg 0x0000FFFF
74 unsigned int spaceNum; /* Space number */
75 /* PPC line boundary here - 020 */
76 unsigned int pmapSegs[16]; /* Contents of segment register if different than base space */
77 /* PPC line boundary here - 060 */
78 struct pmap *pmapPmaps[16]; /* Pointer to next lower level of pmaps */
79 /* PPC line boundary here - 0A0 */
80 /* Note: this must start on a word boundary */
81 unsigned short pmapUsage[128]; /* Count of pages mapped into 32mb (8192 page) slots */
82 #define pmapUsageShft 25
83 #define pmapUsageMask 0x0000007F
84 #define pmapUsageSize (32*1024*1024)
85
86 /* PPC line boundary here - 1A0 */
87 struct pmap_statistics stats; /* statistics */
88 decl_simple_lock_data(,lock) /* lock on map */
89
90 /* Need to pad out to a power of 2 - right now it is 512 bytes */
91 #define pmapSize 512
92 };
93
94 #define PMAP_NULL ((pmap_t) 0)
95
96 extern pmap_t kernel_pmap; /* The kernel's map */
97 extern pmap_t cursor_pmap; /* The pmap to start allocations with */
98
99 #define PMAP_SWITCH_USER(th, map, my_cpu) th->map = map;
100
101 #define PMAP_ACTIVATE(pmap, th, cpu)
102 #define PMAP_DEACTIVATE(pmap, th, cpu)
103 #define PMAP_CONTEXT(pmap,th)
104
105 #define pmap_kernel_va(VA) \
106 (((VA) >= VM_MIN_KERNEL_ADDRESS) && ((VA) <= VM_MAX_KERNEL_ADDRESS))
107
108 #define PPC_SID_KERNEL 0 /* Must change KERNEL_SEG_REG0_VALUE if !0 */
109 #define SID_MAX ((1<<20) - 1) /* Space ID=20 bits, segment_id=SID + 4 bits */
110
111 #define pmap_kernel() (kernel_pmap)
112 #define pmap_resident_count(pmap) ((pmap)->stats.resident_count)
113 #define pmap_remove_attributes(pmap,start,end)
114 #define pmap_copy(dpmap,spmap,da,len,sa)
115 #define pmap_update()
116
117 #define pmap_phys_address(x) ((x) << PPC_PGSHIFT)
118 #define pmap_phys_to_frame(x) ((x) >> PPC_PGSHIFT)
119
120 #define PMAP_DEFAULT_CACHE 0
121 #define PMAP_INHIBIT_CACHE 1
122 #define PMAP_GUARDED_CACHE 2
123 #define PMAP_ACTIVATE_CACHE 4
124 #define PMAP_NO_GUARD_CACHE 8
125
126 /* corresponds to cached, coherent, not writethru, not guarded */
127 #define VM_WIMG_DEFAULT VM_MEM_COHERENT
128 #define VM_WIMG_IO VM_MEM_COHERENT | \
129 VM_MEM_NOT_CACHEABLE | VM_MEM_GUARDED
130
131 /*
132 * prototypes.
133 */
134 extern void ppc_protection_init(void);
135 extern vm_offset_t phystokv(vm_offset_t pa); /* Get kernel virtual address from physical */
136 extern vm_offset_t kvtophys(vm_offset_t va); /* Get physical address from kernel virtual */
137 extern vm_offset_t pmap_map(vm_offset_t va,
138 vm_offset_t spa,
139 vm_offset_t epa,
140 vm_prot_t prot);
141 extern kern_return_t pmap_add_physical_memory(vm_offset_t spa,
142 vm_offset_t epa,
143 boolean_t available,
144 unsigned int attr);
145 extern vm_offset_t pmap_map_bd(vm_offset_t va,
146 vm_offset_t spa,
147 vm_offset_t epa,
148 vm_prot_t prot);
149 extern void pmap_bootstrap(unsigned int mem_size,
150 vm_offset_t *first_avail,
151 vm_offset_t *first_phys_avail, unsigned int kmapsize);
152 extern void pmap_block_map(vm_offset_t pa,
153 vm_size_t size,
154 vm_prot_t prot,
155 int entry,
156 int dtlb);
157 extern void pmap_switch(pmap_t);
158
159 extern vm_offset_t pmap_extract(pmap_t pmap,
160 vm_offset_t va);
161
162 extern void pmap_remove_all(vm_offset_t pa);
163
164 extern boolean_t pmap_verify_free(vm_offset_t pa);
165 extern void sync_cache(vm_offset_t pa, unsigned length);
166 extern void flush_dcache(vm_offset_t va, unsigned length, boolean_t phys);
167 extern void invalidate_dcache(vm_offset_t va, unsigned length, boolean_t phys);
168 extern void invalidate_icache(vm_offset_t va, unsigned length, boolean_t phys);
169 extern void pmap_sync_caches_phys(vm_offset_t pa);
170 extern void invalidate_cache_for_io(vm_offset_t va, unsigned length, boolean_t phys);
171 extern void pmap_map_block(pmap_t pmap, vm_offset_t va, vm_offset_t pa, vm_size_t size,
172 vm_prot_t prot, int attr, unsigned int flags); /* Map a block */
173 extern kern_return_t pmap_map_block_opt(vm_map_t map, vm_offset_t *va,
174 vm_offset_t pa, vm_size_t size, vm_prot_t prot, int attr); /* Map a block allocating an optimal virtual address */
175 extern kern_return_t vm_map_block(vm_map_t map, vm_offset_t *va, vm_offset_t *bnd, vm_offset_t pa,
176 vm_size_t size, vm_prot_t prot);
177
178 extern kern_return_t pmap_nest(pmap_t grand, pmap_t subord, vm_offset_t vaddr, vm_size_t size);
179
180 extern void pmap_ver(pmap_t pmap, vm_offset_t sva, vm_offset_t eva);
181
182 #endif /* _PPC_PMAP_H_ */
183