]> git.saurik.com Git - apple/xnu.git/blob - osfmk/ppc/mem.c
8f9bb7c729f4f394aa7eda53aaf036b9d3c19374
[apple/xnu.git] / osfmk / ppc / mem.c
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 /* A marvelous selection of support routines for virtual memory */
30
31 #include <cpus.h>
32 #include <debug.h>
33 #include <mach_kdb.h>
34 #include <mach_vm_debug.h>
35
36 #include <kern/cpu_number.h>
37 #include <kern/misc_protos.h>
38 #include <kern/assert.h>
39 #include <ppc/misc_protos.h>
40 #include <ppc/mem.h>
41 #include <ppc/pmap_internals.h> /* For pmap_pteg_overflow */
42
43 /* These refer to physical addresses and are set and referenced elsewhere */
44
45 unsigned int hash_table_base;
46 unsigned int hash_table_size;
47
48 unsigned int hash_function_mask;
49
50 struct shadowBAT shadow_BAT;
51
52 /* gather statistics about hash table usage */
53
54 #if DEBUG
55 #define MEM_STATS 1
56 #else
57 #define MEM_STATS 0
58 #endif /* DEBUG */
59
60 #if MEM_STATS
61 /* hash table usage information */
62 struct hash_table_stats {
63 int find_pte_in_pteg_calls;
64 int find_pte_in_pteg_not_found;
65 int find_pte_in_pteg_location[8];
66 struct find_or_alloc_calls {
67 int found_primary;
68 int found_secondary;
69 int alloc_primary;
70 int alloc_secondary;
71 int overflow;
72 int not_found;
73 } find_or_alloc_calls[2];
74
75 } hash_table_stats[NCPUS];
76
77 #define INC_STAT(LOC) \
78 hash_table_stats[cpu_number()].find_pte_in_pteg_location[LOC]++
79
80 #else /* MEM_STATS */
81 #define INC_STAT(LOC)
82 #endif /* MEM_STATS */
83
84 /* Set up the machine registers for the given hash table.
85 * The table has already been zeroed.
86 */
87 void hash_table_init(unsigned int base, unsigned int size)
88 {
89 sync(); /* SYNC: it's not just the law, it's a good idea... */
90 mtsdr1(hash_table_base | ((size-1)>>16)); /* Slam the SDR1 with the has table address */
91 sync(); /* SYNC: it's not just the law, it's a good idea... */
92 isync();
93 }
94