2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 * Copyright (C) 1990, 1993 NeXT, Inc.
30 * Copyright (C) 1997 Apple Computer, Inc.
32 * File: next/kern_machdep.c
33 * Author: John Seamons
35 * Machine-specific kernel routines.
38 #include <sys/types.h>
39 #include <sys/param.h>
40 #include <mach/machine.h>
41 #include <mach/boolean.h>
42 #include <mach/vm_param.h>
43 #include <kern/cpu_number.h>
44 #include <machine/exec.h>
47 * Routine: grade_binary()
50 * Return a relative preference for exectypes and execsubtypes in fat
51 * executable files. The higher the grade, the higher the preference.
52 * A grade of 0 means not acceptable.
54 * Note: We really don't care about the real cpu_type() here,
55 * because machines can only have one type.
58 grade_binary(cpu_type_t exectype
, cpu_subtype_t execsubtype
)
60 int cpusubtype
= cpu_subtype();
63 * This code should match cpusubtype_findbestarch() in best_arch.c
64 * in the cctools project. As of 2/16/98 this is what has been
65 * agreed upon for the PowerPC subtypes. If an exact match is not
66 * found the subtype will be picked from the following order:
67 * 970(but only on 970), 7450, 7400, 750, ALL
68 * Note the 601 is NOT in the list above. It is only picked via
69 * an exact match. For details see Radar 2213821.
73 case CPU_SUBTYPE_POWERPC_970
:
75 case CPU_TYPE_POWERPC64
: /* CPU_IS64BIT | CPU_POWERPC */
78 * Prefer 64 bit architecture specific binaries; note
79 * that this value does not mean the same thing here
82 case CPU_SUBTYPE_POWERPC_970
:
84 /* Prefer generic binaries */
85 case CPU_SUBTYPE_POWERPC_ALL
:
92 case CPU_TYPE_POWERPC
:
95 * Prefer 32 bit binaries with 64 bit leaf functions;
96 * this is actually bogus use of the subtype to encode
99 case CPU_SUBTYPE_POWERPC_970
:
101 case CPU_SUBTYPE_POWERPC_7450
:
103 case CPU_SUBTYPE_POWERPC_7400
:
105 case CPU_SUBTYPE_POWERPC_750
:
107 case CPU_SUBTYPE_POWERPC_ALL
:
119 case CPU_SUBTYPE_POWERPC_7450
:
121 case CPU_TYPE_POWERPC64
: /* CPU_IS64BIT | CPU_POWERPC */
124 case CPU_TYPE_POWERPC
:
125 switch(execsubtype
) {
126 case CPU_SUBTYPE_POWERPC_7450
:
128 case CPU_SUBTYPE_POWERPC_7400
:
130 case CPU_SUBTYPE_POWERPC_750
:
132 case CPU_SUBTYPE_POWERPC_ALL
:
144 case CPU_SUBTYPE_POWERPC_7400
:
146 case CPU_TYPE_POWERPC64
: /* CPU_IS64BIT | CPU_POWERPC */
149 case CPU_TYPE_POWERPC
:
150 switch(execsubtype
) {
151 case CPU_SUBTYPE_POWERPC_7400
:
153 case CPU_SUBTYPE_POWERPC_7450
:
155 case CPU_SUBTYPE_POWERPC_750
:
157 case CPU_SUBTYPE_POWERPC_ALL
:
169 case CPU_SUBTYPE_POWERPC_750
:
171 case CPU_TYPE_POWERPC64
: /* CPU_IS64BIT | CPU_POWERPC */
174 case CPU_TYPE_POWERPC
:
175 switch(execsubtype
) {
176 case CPU_SUBTYPE_POWERPC_750
:
178 #ifndef ADDRESS_RADAR_2678019
180 * Currently implemented because dropping this would
181 * turn the executable subtype into a "has Altivec"
182 * flag, which we do not want to permit. It could
183 * also break working third party applications
184 * already in use in the field.
186 case CPU_SUBTYPE_POWERPC_7400
:
188 case CPU_SUBTYPE_POWERPC_7450
:
190 #endif /* ADDRESS_RADAR_2678019 */
191 case CPU_SUBTYPE_POWERPC_ALL
:
205 case CPU_TYPE_POWERPC64
: /* CPU_IS64BIT | CPU_POWERPC */
208 case CPU_TYPE_POWERPC
:
209 /* Special case for PPC601 */
210 if (cpusubtype
== execsubtype
)
213 * If we get here it is because it is a cpusubtype we
214 * don't support or a new cpusubtype that was added
215 * since this code was written. Both will be
216 * considered unacceptable.
238 base
= trunc_page_64(start
);
242 if(kvtophys((vm_offset_t
)base
) == NULL
)
251 md_prepare_for_shutdown(int paniced
, int howto
, char * command
);
253 extern void IOSystemShutdownNotification(void);
256 md_prepare_for_shutdown(__unused
int paniced
, __unused
int howto
,
257 __unused
char * command
)
261 * Temporary hack to notify the power management root domain
262 * that the system will shut down.
264 IOSystemShutdownNotification();