2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
26 /* A marvelous selection of support routines for virtual memory */
31 #include <mach_vm_debug.h>
33 #include <kern/cpu_number.h>
34 #include <kern/misc_protos.h>
35 #include <kern/assert.h>
36 #include <ppc/misc_protos.h>
38 #include <ppc/pmap_internals.h> /* For pmap_pteg_overflow */
40 /* These refer to physical addresses and are set and referenced elsewhere */
42 unsigned int hash_table_base
;
43 unsigned int hash_table_size
;
45 unsigned int hash_function_mask
;
47 struct shadowBAT shadow_BAT
;
49 /* gather statistics about hash table usage */
58 /* hash table usage information */
59 struct hash_table_stats
{
60 int find_pte_in_pteg_calls
;
61 int find_pte_in_pteg_not_found
;
62 int find_pte_in_pteg_location
[8];
63 struct find_or_alloc_calls
{
70 } find_or_alloc_calls
[2];
72 } hash_table_stats
[NCPUS
];
74 #define INC_STAT(LOC) \
75 hash_table_stats[cpu_number()].find_pte_in_pteg_location[LOC]++
79 #endif /* MEM_STATS */
81 /* Set up the machine registers for the given hash table.
82 * The table has already been zeroed.
84 void hash_table_init(unsigned int base
, unsigned int size
)
86 sync(); /* SYNC: it's not just the law, it's a good idea... */
87 mtsdr1(hash_table_base
| ((size
-1)>>16)); /* Slam the SDR1 with the has table address */
88 sync(); /* SYNC: it's not just the law, it's a good idea... */