2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
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
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.
23 * @APPLE_LICENSE_HEADER_END@
29 /* A marvelous selection of support routines for virtual memory */
34 #include <mach_vm_debug.h>
36 #include <kern/cpu_number.h>
37 #include <kern/misc_protos.h>
38 #include <kern/assert.h>
39 #include <ppc/misc_protos.h>
41 #include <ppc/pmap_internals.h> /* For pmap_pteg_overflow */
43 /* These refer to physical addresses and are set and referenced elsewhere */
45 unsigned int hash_table_base
;
46 unsigned int hash_table_size
;
48 unsigned int hash_function_mask
;
50 struct shadowBAT shadow_BAT
;
52 /* gather statistics about hash table usage */
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
{
73 } find_or_alloc_calls
[2];
75 } hash_table_stats
[NCPUS
];
77 #define INC_STAT(LOC) \
78 hash_table_stats[cpu_number()].find_pte_in_pteg_location[LOC]++
82 #endif /* MEM_STATS */
84 /* Set up the machine registers for the given hash table.
85 * The table has already been zeroed.
87 void hash_table_init(unsigned int base
, unsigned int size
)
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... */