Annotation of XNU/bsd/dev/ppc/kern_machdep.c, revision 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:  *     Copyright (C) 1990, 1993  NeXT, Inc.
        !            24:  *     Copyright (C) 1997  Apple Computer, Inc.
        !            25:  *
        !            26:  *     File:   next/kern_machdep.c
        !            27:  *     Author: John Seamons
        !            28:  *
        !            29:  *     Machine-specific kernel routines.
        !            30:  *
        !            31:  * HISTORY
        !            32:  *  8-Dec-91  Peter King (king) at NeXT
        !            33:  *     Added grade_cpu_subtype().
        !            34:  *     FIXME: Do we want to merge this with check_cpu_subtype()?
        !            35:  *
        !            36:  *  5-Mar-90  John Seamons (jks) at NeXT
        !            37:  *     Created.
        !            38:  */
        !            39: 
        !            40: #include       <sys/types.h>
        !            41: #include       <sys/param.h>
        !            42: #include       <mach/machine.h>
        !            43: #include       <mach/boolean.h>
        !            44: #include       <mach/vm_param.h>
        !            45: #include       <kern/cpu_number.h>
        !            46: 
        !            47: int
        !            48: check_cpu_subtype(cpu_subtype_t cpu_subtype)
        !            49: {
        !            50:        struct machine_slot *ms = &machine_slot[cpu_number()];
        !            51: 
        !            52:        if (cpu_subtype == ms->cpu_subtype)
        !            53:                return (TRUE);
        !            54: 
        !            55:        if (cpu_subtype == CPU_SUBTYPE_POWERPC_601)
        !            56:                return (FALSE);
        !            57: 
        !            58:        switch (cpu_subtype) {
        !            59:                case CPU_SUBTYPE_POWERPC_Max:
        !            60:                case CPU_SUBTYPE_POWERPC_750:
        !            61:                case CPU_SUBTYPE_POWERPC_604e:
        !            62:                case CPU_SUBTYPE_POWERPC_604:
        !            63:                case CPU_SUBTYPE_POWERPC_603ev:
        !            64:                case CPU_SUBTYPE_POWERPC_603e:
        !            65:                case CPU_SUBTYPE_POWERPC_603:
        !            66:                case CPU_SUBTYPE_POWERPC_ALL:
        !            67:                        return (TRUE);
        !            68:        }
        !            69: 
        !            70:        return (FALSE);
        !            71: }
        !            72: 
        !            73: /*
        !            74:  * Routine: grade_cpu_subtype()
        !            75:  *
        !            76:  * Function:
        !            77:  *     Return a relative preference for cpu_subtypes in fat executable files.
        !            78:  *     The higher the grade, the higher the preference.
        !            79:  *     A grade of 0 means not acceptable.
        !            80:  */
        !            81: 
        !            82: int
        !            83: grade_cpu_subtype(cpu_subtype_t cpu_subtype)
        !            84: {
        !            85:        struct machine_slot *ms = &machine_slot[cpu_number()];
        !            86: 
        !            87:        /*
        !            88:         * This code should match cpusubtype_findbestarch() in best_arch.c in the
        !            89:         * cctools project.  As of 2/16/98 this is what has been agreed upon for
        !            90:         * the PowerPC subtypes.  If an exact match is not found the subtype will
        !            91:         * be picked from the following order:
        !            92:         *              Max, 750, 604e, 604, 603ev, 603e, 603, ALL
        !            93:         * Note the 601 is NOT in the list above.  It is only picked via an exact
        !            94:         * match. For details see Radar 2213821.
        !            95:         *
        !            96:         * To implement this function to follow what was agreed upon above, we use
        !            97:         * the fact there are currently 9 different subtypes.  Exact matches return
        !            98:         * the value 9, the value 0 is returned for 601 that is not an exact match,
        !            99:         * and the values 8 thru 1 are returned for the subtypes listed in the order
        !           100:         * above.
        !           101:         */
        !           102:        if (ms->cpu_subtype == cpu_subtype)
        !           103:                return 9;
        !           104:        if (cpu_subtype == CPU_SUBTYPE_POWERPC_601)
        !           105:                return 0;
        !           106:        switch (cpu_subtype) {
        !           107:                case CPU_SUBTYPE_POWERPC_Max:
        !           108:                        return 8;
        !           109:                case CPU_SUBTYPE_POWERPC_750:
        !           110:                        return 7;
        !           111:                case CPU_SUBTYPE_POWERPC_604e:
        !           112:                        return 6;
        !           113:                case CPU_SUBTYPE_POWERPC_604:
        !           114:                        return 5;
        !           115:                case CPU_SUBTYPE_POWERPC_603ev:
        !           116:                        return 4;
        !           117:                case CPU_SUBTYPE_POWERPC_603e:
        !           118:                        return 3;
        !           119:                case CPU_SUBTYPE_POWERPC_603:
        !           120:                        return 2;
        !           121:                case CPU_SUBTYPE_POWERPC_ALL:
        !           122:                        return 1;
        !           123:        }
        !           124:        /*
        !           125:         * If we get here it is because it is a cpusubtype we don't support (602 and
        !           126:         * 620) or new cpusubtype that was added since this code was written.  Both
        !           127:         * will be considered unacceptable.
        !           128:         */
        !           129:        return 0;
        !           130: }
        !           131: 
        !           132: boolean_t
        !           133: kernacc(
        !           134:     off_t      start,
        !           135:     size_t     len
        !           136: )
        !           137: {
        !           138:        off_t base;
        !           139:        off_t end;
        !           140:     
        !           141:        base = trunc_page(start);
        !           142:        end = start + len;
        !           143:        
        !           144:        while (base < end) {
        !           145:                if(kvtophys((vm_offset_t)base) == NULL)
        !           146:                        return(FALSE);
        !           147:                base += page_size;
        !           148:        }   
        !           149: 
        !           150:        return (TRUE);
        !           151: }

unix.superglobalmegacorp.com

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