]> git.saurik.com Git - apple/xnu.git/blob - bsd/dev/i386/kern_machdep.c
xnu-792.2.4.tar.gz
[apple/xnu.git] / bsd / dev / i386 / kern_machdep.c
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, NeXT, Inc.
24 *
25 * File: next/kern_machdep.c
26 * Author: John Seamons
27 *
28 * Machine-specific kernel routines.
29 */
30
31 #include <sys/types.h>
32 #include <mach/machine.h>
33 #include <kern/cpu_number.h>
34
35 extern int grade_binary(cpu_type_t exectype, cpu_subtype_t execsubtype);
36
37 /**********************************************************************
38 * Routine: grade_binary()
39 *
40 * Function: Return a relative preference for exectypes and
41 * execsubtypes in fat executable files. The higher the
42 * grade, the higher the preference. A grade of 0 means
43 * not acceptable.
44 **********************************************************************/
45 int
46 grade_binary(__unused cpu_type_t exectype, cpu_subtype_t execsubtype)
47 {
48 int cpusubtype = cpu_subtype();
49
50 switch (cpusubtype) {
51 case CPU_SUBTYPE_386:
52 switch (execsubtype) {
53 case CPU_SUBTYPE_386:
54 return 1;
55 default:
56 return 0;
57 }
58
59 case CPU_SUBTYPE_486:
60 switch (execsubtype) {
61 case CPU_SUBTYPE_386:
62 return 1;
63
64 case CPU_SUBTYPE_486SX:
65 return 2;
66
67 case CPU_SUBTYPE_486:
68 return 3;
69
70 default:
71 return 0;
72 }
73
74 case CPU_SUBTYPE_486SX:
75 switch (execsubtype) {
76 case CPU_SUBTYPE_386:
77 return 1;
78
79 case CPU_SUBTYPE_486:
80 return 2;
81
82 case CPU_SUBTYPE_486SX:
83 return 3;
84
85 default:
86 return 0;
87 }
88
89 case CPU_SUBTYPE_586:
90 switch (execsubtype) {
91 case CPU_SUBTYPE_386:
92 return 1;
93
94 case CPU_SUBTYPE_486SX:
95 return 2;
96
97 case CPU_SUBTYPE_486:
98 return 3;
99
100 case CPU_SUBTYPE_586:
101 return 4;
102
103 default:
104 return 0;
105 }
106
107 default:
108 if ( CPU_SUBTYPE_INTEL_MODEL(execsubtype) ==
109 CPU_SUBTYPE_INTEL_MODEL_ALL) {
110 if ( CPU_SUBTYPE_INTEL_FAMILY(cpusubtype) >=
111 CPU_SUBTYPE_INTEL_FAMILY(execsubtype))
112 return CPU_SUBTYPE_INTEL_FAMILY_MAX -
113 CPU_SUBTYPE_INTEL_FAMILY(cpusubtype) -
114 CPU_SUBTYPE_INTEL_FAMILY(execsubtype);
115 }
116 else {
117 if ( cpusubtype == execsubtype)
118 return CPU_SUBTYPE_INTEL_FAMILY_MAX + 1;
119 }
120 return 0;
121 }
122 }
123
124 extern void md_prepare_for_shutdown(int, int, char *);
125
126 void
127 md_prepare_for_shutdown(
128 __unused int paniced,
129 __unused int howto,
130 __unused char * command)
131 {
132 }