]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
e5568f75 A |
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. | |
1c79356b | 11 | * |
e5568f75 A |
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 | |
1c79356b A |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
e5568f75 A |
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. | |
1c79356b A |
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 | ||
55e303ae A |
59 | #define maxPPage32 0x000FFFFF /* Maximum page number in 32-bit machines */ |
60 | ||
61 | typedef uint32_t shexlock; | |
62 | ||
63 | #pragma pack(4) /* Make sure the structure stays as we defined it */ | |
64 | ||
65 | struct sgc { | |
66 | uint64_t sgcESID; /* ESID portion of segment cache */ | |
67 | #define sgcESmsk 0xFFFFFFFFF0000000ULL /* ESID portion of segment register cache */ | |
68 | uint64_t sgcVSID; /* VSID portion of segment cache */ | |
69 | #define sgcVSmsk 0xFFFFFFFFFFFFF000ULL /* VSID mask */ | |
70 | #define sgcVSKeys 0x0000000000000C00ULL /* Protection keys */ | |
71 | #define sgcVSKeyUsr 53 /* User protection key */ | |
72 | #define sgcVSNoEx 0x0000000000000200ULL /* No execute */ | |
73 | }; | |
74 | #pragma pack() | |
75 | ||
76 | typedef struct sgc sgc; | |
77 | ||
78 | #pragma pack(4) /* Make sure the structure stays as we defined it */ | |
1c79356b | 79 | struct pmap { |
55e303ae A |
80 | queue_head_t pmap_link; /* MUST BE FIRST */ |
81 | addr64_t pmapvr; /* Virtual to real conversion mask */ | |
82 | shexlock pmapSXlk; /* Shared/Exclusive lock for mapping changes */ | |
83 | unsigned int space; /* space for this pmap */ | |
84 | #define invalSpace 0x00000001 /* Predefined always invalid space */ | |
85 | int ref_count; /* reference count */ | |
86 | unsigned int pmapFlags; /* Flags */ | |
87 | #define pmapKeys 0x00000007 /* Keys and no execute bit to use with this pmap */ | |
88 | #define pmapKeyDef 0x00000006 /* Default keys - Sup = 1, user = 1, no ex = 0 */ | |
89 | #define pmapVMhost 0x00000010 /* pmap with Virtual Machines attached to it */ | |
90 | unsigned int spaceNum; /* Space number */ | |
91 | unsigned int pmapCCtl; /* Cache control */ | |
92 | #define pmapCCtlVal 0xFFFF0000 /* Valid entries */ | |
93 | #define pmapCCtlLck 0x00008000 /* Lock bit */ | |
94 | #define pmapCCtlLckb 16 /* Lock bit */ | |
95 | #define pmapCCtlGen 0x00007FFF /* Generation number */ | |
96 | ||
97 | #define pmapSegCacheCnt 16 /* Maximum number of cache entries */ | |
98 | #define pmapSegCacheUse 16 /* Number of cache entries to use */ | |
99 | ||
100 | struct pmap *freepmap; /* Free pmaps */ | |
101 | ||
102 | unsigned int pmapRsv1[3]; | |
103 | /* 0x038 */ | |
104 | uint64_t pmapSCSubTag; /* Segment cache sub-tags. This is a 16 entry 4 bit array */ | |
105 | /* 0x040 */ | |
106 | sgc pmapSegCache[pmapSegCacheCnt]; /* SLD values cached for quick load */ | |
107 | ||
108 | /* 0x140 */ | |
109 | /* if fanout is 4, then shift is 1, if fanout is 8 shift is 2, etc */ | |
110 | #define kSkipListFanoutShift 1 | |
111 | /* with n lists, we can handle (fanout**n) pages optimally */ | |
112 | #define kSkipListMaxLists 12 | |
113 | unsigned char pmapCurLists; /* 0x140 - max #lists any mapping in this pmap currently has */ | |
114 | unsigned char pmapRsv2[3]; | |
115 | uint32_t pmapRandNum; /* 0x144 - used by mapSetLists() as a random number generator */ | |
116 | addr64_t pmapSkipLists[kSkipListMaxLists]; /* 0x148 - the list headers */ | |
117 | /* following statistics conditionally gathered */ | |
118 | uint64_t pmapSearchVisits; /* 0x1A8 - nodes visited searching pmaps */ | |
119 | uint32_t pmapSearchCnt; /* 0x1B0 - number of calls to mapSearch or mapSearchFull */ | |
120 | ||
121 | unsigned int pmapRsv3[3]; | |
122 | ||
123 | /* 0x1C0 */ | |
124 | ||
125 | struct pmap_statistics stats; /* statistics */ | |
126 | decl_simple_lock_data(,lock) /* lock on map */ | |
1c79356b A |
127 | |
128 | /* Need to pad out to a power of 2 - right now it is 512 bytes */ | |
129 | #define pmapSize 512 | |
130 | }; | |
55e303ae A |
131 | #pragma pack() |
132 | ||
133 | #pragma pack(4) | |
134 | struct pmapTransTab { | |
135 | addr64_t pmapPAddr; /* Physcial address of pmap */ | |
136 | unsigned int pmapVAddr; /* Virtual address of pmap */ | |
137 | }; | |
138 | #pragma pack() /* Make sure the structure stays as we defined it */ | |
139 | ||
140 | typedef struct pmapTransTab pmapTransTab; | |
1c79356b A |
141 | |
142 | #define PMAP_NULL ((pmap_t) 0) | |
143 | ||
144 | extern pmap_t kernel_pmap; /* The kernel's map */ | |
145 | extern pmap_t cursor_pmap; /* The pmap to start allocations with */ | |
55e303ae A |
146 | extern pmap_t sharedPmap; |
147 | extern unsigned int sharedPage; | |
148 | extern int ppc_max_adrsp; /* Maximum number of concurrent address spaces allowed. */ | |
149 | extern addr64_t vm_max_address; /* Maximum effective address supported */ | |
150 | extern addr64_t vm_max_physical; /* Maximum physical address supported */ | |
151 | extern pmapTransTab *pmapTrans; /* Space to pmap translate table */ | |
1c79356b A |
152 | #define PMAP_SWITCH_USER(th, map, my_cpu) th->map = map; |
153 | ||
154 | #define PMAP_ACTIVATE(pmap, th, cpu) | |
155 | #define PMAP_DEACTIVATE(pmap, th, cpu) | |
156 | #define PMAP_CONTEXT(pmap,th) | |
157 | ||
158 | #define pmap_kernel_va(VA) \ | |
55e303ae | 159 | (((VA) >= VM_MIN_KERNEL_ADDRESS) && ((VA) <= vm_last_addr)) |
1c79356b A |
160 | |
161 | #define PPC_SID_KERNEL 0 /* Must change KERNEL_SEG_REG0_VALUE if !0 */ | |
55e303ae A |
162 | |
163 | #define maxAdrSp 16384 | |
164 | #define maxAdrSpb 14 | |
165 | #define copyIOaddr 0x00000000E0000000ULL | |
1c79356b A |
166 | |
167 | #define pmap_kernel() (kernel_pmap) | |
168 | #define pmap_resident_count(pmap) ((pmap)->stats.resident_count) | |
169 | #define pmap_remove_attributes(pmap,start,end) | |
170 | #define pmap_copy(dpmap,spmap,da,len,sa) | |
171 | #define pmap_update() | |
172 | ||
9bccf70c A |
173 | #define PMAP_DEFAULT_CACHE 0 |
174 | #define PMAP_INHIBIT_CACHE 1 | |
175 | #define PMAP_GUARDED_CACHE 2 | |
176 | #define PMAP_ACTIVATE_CACHE 4 | |
177 | #define PMAP_NO_GUARD_CACHE 8 | |
178 | ||
179 | /* corresponds to cached, coherent, not writethru, not guarded */ | |
55e303ae A |
180 | #define VM_WIMG_DEFAULT (VM_MEM_COHERENT) |
181 | #define VM_WIMG_COPYBACK (VM_MEM_COHERENT) | |
182 | #define VM_WIMG_IO (VM_MEM_COHERENT | \ | |
183 | VM_MEM_NOT_CACHEABLE | VM_MEM_GUARDED) | |
184 | #define VM_WIMG_WTHRU (VM_MEM_WRITE_THROUGH | VM_MEM_COHERENT | VM_MEM_GUARDED) | |
185 | /* write combining mode, aka store gather */ | |
186 | #define VM_WIMG_WCOMB (VM_MEM_NOT_CACHEABLE | VM_MEM_COHERENT) | |
9bccf70c | 187 | |
1c79356b A |
188 | /* |
189 | * prototypes. | |
190 | */ | |
1c79356b A |
191 | extern vm_offset_t phystokv(vm_offset_t pa); /* Get kernel virtual address from physical */ |
192 | extern vm_offset_t kvtophys(vm_offset_t va); /* Get physical address from kernel virtual */ | |
193 | extern vm_offset_t pmap_map(vm_offset_t va, | |
194 | vm_offset_t spa, | |
195 | vm_offset_t epa, | |
196 | vm_prot_t prot); | |
197 | extern kern_return_t pmap_add_physical_memory(vm_offset_t spa, | |
198 | vm_offset_t epa, | |
199 | boolean_t available, | |
200 | unsigned int attr); | |
55e303ae | 201 | extern void pmap_bootstrap(uint64_t msize, |
1c79356b | 202 | vm_offset_t *first_avail, |
55e303ae | 203 | unsigned int kmapsize); |
1c79356b A |
204 | extern void pmap_switch(pmap_t); |
205 | ||
206 | extern vm_offset_t pmap_extract(pmap_t pmap, | |
207 | vm_offset_t va); | |
208 | ||
209 | extern void pmap_remove_all(vm_offset_t pa); | |
210 | ||
55e303ae | 211 | extern boolean_t pmap_verify_free(ppnum_t pa); |
1c79356b | 212 | extern void sync_cache(vm_offset_t pa, unsigned length); |
55e303ae A |
213 | extern void sync_cache64(addr64_t pa, unsigned length); |
214 | extern void sync_ppage(ppnum_t pa); | |
215 | extern void sync_cache_virtual(vm_offset_t va, unsigned length); | |
1c79356b | 216 | extern void flush_dcache(vm_offset_t va, unsigned length, boolean_t phys); |
55e303ae | 217 | extern void flush_dcache64(addr64_t va, unsigned length, boolean_t phys); |
1c79356b | 218 | extern void invalidate_dcache(vm_offset_t va, unsigned length, boolean_t phys); |
55e303ae | 219 | extern void invalidate_dcache64(addr64_t va, unsigned length, boolean_t phys); |
1c79356b | 220 | extern void invalidate_icache(vm_offset_t va, unsigned length, boolean_t phys); |
55e303ae A |
221 | extern void invalidate_icache64(addr64_t va, unsigned length, boolean_t phys); |
222 | extern void pmap_sync_caches_phys(ppnum_t pa); | |
223 | extern void pmap_map_block(pmap_t pmap, addr64_t va, ppnum_t pa, vm_size_t size, vm_prot_t prot, int attr, unsigned int flags); | |
224 | extern int pmap_map_block_rc(pmap_t pmap, addr64_t va, ppnum_t pa, vm_size_t size, vm_prot_t prot, int attr, unsigned int flags); | |
225 | ||
226 | extern kern_return_t pmap_nest(pmap_t grand, pmap_t subord, addr64_t vstart, addr64_t nstart, uint64_t size); | |
227 | extern ppnum_t pmap_find_phys(pmap_t pmap, addr64_t va); | |
228 | extern addr64_t MapUserAddressSpace(vm_map_t map, addr64_t va, unsigned int size); | |
229 | extern void ReleaseUserAddressSpace(addr64_t kva); | |
230 | extern kern_return_t pmap_attribute_cache_sync(ppnum_t pp, vm_size_t size, | |
231 | vm_machine_attribute_t attribute, | |
232 | vm_machine_attribute_val_t* value); | |
233 | extern int pmap_canExecute(ppnum_t pa); | |
1c79356b A |
234 | |
235 | #endif /* _PPC_PMAP_H_ */ | |
236 |