]> git.saurik.com Git - apple/xnu.git/blob - osfmk/ppc/pmap_internals.h
c7ff3bb196ae0f51d40fd0fdb66224518423f685
[apple/xnu.git] / osfmk / ppc / pmap_internals.h
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25 /*
26 * @OSF_COPYRIGHT@
27 */
28
29 /* Things that don't need to be exported from pmap. Putting
30 * them here and not in pmap.h avoids major recompiles when
31 * modifying something either here or in proc_reg.h
32 */
33
34 #ifndef _PMAP_INTERNALS_H_
35 #define _PMAP_INTERNALS_H_
36
37 /*
38 * Definition of the flags in the low 5 bits of the phys_link field of the phys_entry
39 */
40
41 #define PHYS_LOCK 0x00000001
42 #define PHYS_FLAGS 0x0000001F
43
44 #ifndef ASSEMBLER
45
46 #include <cpus.h>
47 #include <mach_ldebug.h>
48 #include <debug.h>
49
50 #include <mach/vm_types.h>
51 #include <mach/machine/vm_types.h>
52 #include <mach/vm_prot.h>
53 #include <mach/vm_statistics.h>
54 #include <kern/assert.h>
55 #include <kern/cpu_number.h>
56 #include <kern/lock.h>
57 #include <kern/queue.h>
58 #include <ppc/proc_reg.h>
59
60
61 /* Page table entries are stored in groups (PTEGS) in a hash table */
62
63 #if __PPC__
64 #if _BIG_ENDIAN == 0
65 error - bitfield structures are not checked for bit ordering in words
66 #endif /* _BIG_ENDIAN */
67 #endif /* __PPC__ */
68
69 /*
70 * Don't change these structures unless you change the assembly code
71 */
72
73 struct phys_entry {
74 struct mapping *phys_link; /* MUST BE FIRST - chain of mappings and flags in the low 5 bits, see above */
75 unsigned int pte1; /* referenced/changed/wimg - info update atomically */
76 };
77
78
79 #define PHYS_NULL ((struct phys_entry *)0)
80
81 /* Memory may be non-contiguous. This data structure contains info
82 * for mapping this non-contiguous space into the contiguous
83 * physical->virtual mapping tables. An array of this type is
84 * provided to the pmap system at bootstrap by ppc_vm_init.
85 *
86 * NB : regions must be in order in this structure.
87 */
88
89 typedef struct mem_region {
90 vm_offset_t start; /* Address of base of region */
91 struct phys_entry *phys_table; /* base of region's table */
92 unsigned int end; /* End address+1 */
93 } mem_region_t;
94
95 /* PMAP_MEM_REGION_MAX has a PowerMac dependancy - at least the value of
96 * kMaxRAMBanks in ppc/POWERMAC/nkinfo.h
97 */
98 #define PMAP_MEM_REGION_MAX 26
99
100 extern mem_region_t pmap_mem_regions[PMAP_MEM_REGION_MAX];
101 extern int pmap_mem_regions_count;
102
103 /* keep track of free regions of physical memory so that we can offer
104 * them up via pmap_next_page later on
105 */
106
107 #define FREE_REGION_MAX 8
108 extern mem_region_t free_regions[FREE_REGION_MAX];
109 extern int free_regions_count;
110
111 /* Prototypes */
112
113 struct phys_entry *pmap_find_physentry(vm_offset_t pa);
114
115
116 #if DEBUG
117 extern int pmdebug;
118 #define PDB_LOCK 0x100
119 #define LOCKPRINTF(args) if (pmdebug & PDB_LOCK) printf args; else
120 #else /* DEBUG */
121 #define LOCKPRINTF(args)
122 #endif /* DEBUG */
123
124 extern vm_offset_t hash_table_base;
125 extern unsigned int hash_table_size;
126
127 #endif
128 #endif /* _PMAP_INTERNALS_H_ */