|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. ! 3: * ! 4: * @APPLE_LICENSE_HEADER_START@ ! 5: * ! 6: * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights ! 7: * Reserved. This file contains Original Code and/or Modifications of ! 8: * Original Code as defined in and that are subject to the Apple Public ! 9: * Source License Version 1.1 (the "License"). You may not use this file ! 10: * except in compliance with the License. Please obtain a copy of the ! 11: * License at http://www.apple.com/publicsource and read it before using ! 12: * this file. ! 13: * ! 14: * The Original Code and all software distributed under the License are ! 15: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER ! 16: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, ! 17: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, ! 18: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the ! 19: * License for the specific language governing rights and limitations ! 20: * under the License. ! 21: * ! 22: * @APPLE_LICENSE_HEADER_END@ ! 23: */ ! 24: ! 25: /* ! 26: * Copyright (C) 1990, NeXT, Inc. ! 27: * ! 28: * File: next/kern_machdep.c ! 29: * Author: John Seamons ! 30: * ! 31: * Machine-specific kernel routines. ! 32: * ! 33: * 8-Dec-91 Peter King (king) at NeXT ! 34: * Added grade_cpu_subtype(). ! 35: * FIXME: Do we want to merge this with check_cpu_subtype()? ! 36: * ! 37: * 5-Mar-90 John Seamons (jks) at NeXT ! 38: * Created. ! 39: */ ! 40: ! 41: #import <sys/types.h> ! 42: #import <mach/machine.h> ! 43: #import <bsd/i386/cpu.h> ! 44: ! 45: check_cpu_subtype (cpu_subtype) ! 46: cpu_subtype_t cpu_subtype; ! 47: { ! 48: struct machine_slot *ms = &machine_slot[cpu_number()]; ! 49: ! 50: switch (ms->cpu_subtype) { ! 51: case CPU_SUBTYPE_386: ! 52: if (cpu_subtype == CPU_SUBTYPE_386) ! 53: return (TRUE); ! 54: break; ! 55: ! 56: case CPU_SUBTYPE_486: ! 57: case CPU_SUBTYPE_486SX: ! 58: if ( cpu_subtype == CPU_SUBTYPE_486 || ! 59: cpu_subtype == CPU_SUBTYPE_486SX || ! 60: cpu_subtype == CPU_SUBTYPE_386 ) ! 61: return (TRUE); ! 62: break; ! 63: ! 64: case CPU_SUBTYPE_586: ! 65: if ( cpu_subtype == CPU_SUBTYPE_586 || ! 66: cpu_subtype == CPU_SUBTYPE_486 || ! 67: cpu_subtype == CPU_SUBTYPE_486SX || ! 68: cpu_subtype == CPU_SUBTYPE_386 ) ! 69: return (TRUE); ! 70: break; ! 71: ! 72: default: ! 73: if ( CPU_SUBTYPE_INTEL_MODEL(cpu_subtype) == ! 74: CPU_SUBTYPE_INTEL_MODEL_ALL) { ! 75: if ( CPU_SUBTYPE_INTEL_FAMILY(ms->cpu_subtype) >= ! 76: CPU_SUBTYPE_INTEL_FAMILY(cpu_subtype)) ! 77: return (TRUE); ! 78: } ! 79: else { ! 80: if ( ms->cpu_subtype == cpu_subtype) ! 81: return (TRUE); ! 82: } ! 83: break; ! 84: } ! 85: ! 86: return (FALSE); ! 87: } ! 88: ! 89: /********************************************************************** ! 90: * Routine: grade_cpu_subtype() ! 91: * ! 92: * Function: Return a relative preference for cpu_subtypes in fat ! 93: * executable files. The higher the grade, the higher the ! 94: * preference. A grade of 0 means not acceptable. ! 95: **********************************************************************/ ! 96: grade_cpu_subtype (cpu_subtype) ! 97: cpu_subtype_t cpu_subtype; ! 98: { ! 99: struct machine_slot *ms = &machine_slot[cpu_number()]; ! 100: ! 101: switch (ms->cpu_subtype) { ! 102: case CPU_SUBTYPE_386: ! 103: switch (cpu_subtype) { ! 104: case CPU_SUBTYPE_386: ! 105: return 1; ! 106: default: ! 107: return 0; ! 108: } ! 109: ! 110: case CPU_SUBTYPE_486: ! 111: switch (cpu_subtype) { ! 112: case CPU_SUBTYPE_386: ! 113: return 1; ! 114: ! 115: case CPU_SUBTYPE_486SX: ! 116: return 2; ! 117: ! 118: case CPU_SUBTYPE_486: ! 119: return 3; ! 120: ! 121: default: ! 122: return 0; ! 123: } ! 124: ! 125: case CPU_SUBTYPE_486SX: ! 126: switch (cpu_subtype) { ! 127: case CPU_SUBTYPE_386: ! 128: return 1; ! 129: ! 130: case CPU_SUBTYPE_486: ! 131: return 2; ! 132: ! 133: case CPU_SUBTYPE_486SX: ! 134: return 3; ! 135: ! 136: default: ! 137: return 0; ! 138: } ! 139: ! 140: case CPU_SUBTYPE_586: ! 141: switch (cpu_subtype) { ! 142: case CPU_SUBTYPE_386: ! 143: return 1; ! 144: ! 145: case CPU_SUBTYPE_486SX: ! 146: return 2; ! 147: ! 148: case CPU_SUBTYPE_486: ! 149: return 3; ! 150: ! 151: case CPU_SUBTYPE_586: ! 152: return 4; ! 153: ! 154: default: ! 155: return 0; ! 156: } ! 157: ! 158: default: ! 159: if ( CPU_SUBTYPE_INTEL_MODEL(cpu_subtype) == ! 160: CPU_SUBTYPE_INTEL_MODEL_ALL) { ! 161: if ( CPU_SUBTYPE_INTEL_FAMILY(ms->cpu_subtype) >= ! 162: CPU_SUBTYPE_INTEL_FAMILY(cpu_subtype)) ! 163: return CPU_SUBTYPE_INTEL_FAMILY_MAX - ! 164: CPU_SUBTYPE_INTEL_FAMILY(ms->cpu_subtype) - ! 165: CPU_SUBTYPE_INTEL_FAMILY(cpu_subtype); ! 166: } ! 167: else { ! 168: if ( ms->cpu_subtype == cpu_subtype) ! 169: return CPU_SUBTYPE_INTEL_FAMILY_MAX + 1; ! 170: } ! 171: return 0; ! 172: } ! 173: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.