Annotation of XNU/osfmk/ppc/mem.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
                      3:  *
                      4:  * @APPLE_LICENSE_HEADER_START@
                      5:  * 
                      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.
                     11:  * 
                     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
                     18:  * under the License.
                     19:  * 
                     20:  * @APPLE_LICENSE_HEADER_END@
                     21:  */
                     22: /*
                     23:  * @OSF_COPYRIGHT@
                     24:  */
                     25: 
                     26: /* A marvelous selection of support routines for virtual memory */
                     27: 
                     28: #include <cpus.h>
                     29: #include <debug.h>
                     30: #include <mach_kdb.h>
                     31: #include <mach_vm_debug.h>
                     32: 
                     33: #include <kern/cpu_number.h>
                     34: #include <kern/misc_protos.h>
                     35: #include <kern/assert.h>
                     36: #include <ppc/misc_protos.h>
                     37: #include <ppc/mem.h>
                     38: #include <ppc/pmap_internals.h>                /* For pmap_pteg_overflow */
                     39: 
                     40: /* These refer to physical addresses and are set and referenced elsewhere */
                     41: 
                     42: unsigned int hash_table_base;
                     43: unsigned int hash_table_size;
                     44: 
                     45: unsigned int hash_function_mask;
                     46: 
                     47: struct shadowBAT shadow_BAT;
                     48: 
                     49: /* gather statistics about hash table usage */
                     50: 
                     51: #if    DEBUG
                     52: #define MEM_STATS 1
                     53: #else
                     54: #define MEM_STATS 0
                     55: #endif /* DEBUG */
                     56: 
                     57: #if MEM_STATS
                     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 {
                     64:                int found_primary;
                     65:                int found_secondary;
                     66:                int alloc_primary;
                     67:                int alloc_secondary;
                     68:                int overflow;
                     69:                int not_found;
                     70:        } find_or_alloc_calls[2];
                     71:        
                     72: } hash_table_stats[NCPUS];
                     73: 
                     74: #define INC_STAT(LOC) \
                     75:        hash_table_stats[cpu_number()].find_pte_in_pteg_location[LOC]++
                     76: 
                     77: #else  /* MEM_STATS */
                     78: #define INC_STAT(LOC)
                     79: #endif /* MEM_STATS */
                     80: 
                     81: /* Set up the machine registers for the given hash table.
                     82:  * The table has already been zeroed.
                     83:  */
                     84: void hash_table_init(unsigned int base, unsigned int size)
                     85: {
                     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... */
                     89:        isync();
                     90: }
                     91: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.