2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
23 * Copyright (C) 1990, 1993 NeXT, Inc.
24 * Copyright (C) 1997 Apple Computer, Inc.
26 * File: next/kern_machdep.c
27 * Author: John Seamons
29 * Machine-specific kernel routines.
32 #include <sys/types.h>
33 #include <sys/param.h>
34 #include <mach/machine.h>
35 #include <mach/boolean.h>
36 #include <mach/vm_param.h>
37 #include <kern/cpu_number.h>
38 #include <machine/exec.h>
41 * Routine: grade_binary()
44 * Return a relative preference for exectypes and execsubtypes in fat
45 * executable files. The higher the grade, the higher the preference.
46 * A grade of 0 means not acceptable.
48 * Note: We really don't care about the real cpu_type() here,
49 * because machines can only have one type.
52 grade_binary(cpu_type_t exectype
, cpu_subtype_t execsubtype
)
54 int cpusubtype
= cpu_subtype();
57 * This code should match cpusubtype_findbestarch() in best_arch.c
58 * in the cctools project. As of 2/16/98 this is what has been
59 * agreed upon for the PowerPC subtypes. If an exact match is not
60 * found the subtype will be picked from the following order:
61 * 970(but only on 970), 7450, 7400, 750, ALL
62 * Note the 601 is NOT in the list above. It is only picked via
63 * an exact match. For details see Radar 2213821.
67 case CPU_SUBTYPE_POWERPC_970
:
69 case CPU_TYPE_POWERPC64
: /* CPU_IS64BIT | CPU_POWERPC */
72 * Prefer 64 bit architecture specific binaries; note
73 * that this value does not mean the same thing here
76 case CPU_SUBTYPE_POWERPC_970
:
78 /* Prefer generic binaries */
79 case CPU_SUBTYPE_POWERPC_ALL
:
86 case CPU_TYPE_POWERPC
:
89 * Prefer 32 bit binaries with 64 bit leaf functions;
90 * this is actually bogus use of the subtype to encode
93 case CPU_SUBTYPE_POWERPC_970
:
95 case CPU_SUBTYPE_POWERPC_7450
:
97 case CPU_SUBTYPE_POWERPC_7400
:
99 case CPU_SUBTYPE_POWERPC_750
:
101 case CPU_SUBTYPE_POWERPC_ALL
:
113 case CPU_SUBTYPE_POWERPC_7450
:
115 case CPU_TYPE_POWERPC64
: /* CPU_IS64BIT | CPU_POWERPC */
118 case CPU_TYPE_POWERPC
:
119 switch(execsubtype
) {
120 case CPU_SUBTYPE_POWERPC_7450
:
122 case CPU_SUBTYPE_POWERPC_7400
:
124 case CPU_SUBTYPE_POWERPC_750
:
126 case CPU_SUBTYPE_POWERPC_ALL
:
138 case CPU_SUBTYPE_POWERPC_7400
:
140 case CPU_TYPE_POWERPC64
: /* CPU_IS64BIT | CPU_POWERPC */
143 case CPU_TYPE_POWERPC
:
144 switch(execsubtype
) {
145 case CPU_SUBTYPE_POWERPC_7400
:
147 case CPU_SUBTYPE_POWERPC_7450
:
149 case CPU_SUBTYPE_POWERPC_750
:
151 case CPU_SUBTYPE_POWERPC_ALL
:
163 case CPU_SUBTYPE_POWERPC_750
:
165 case CPU_TYPE_POWERPC64
: /* CPU_IS64BIT | CPU_POWERPC */
168 case CPU_TYPE_POWERPC
:
169 switch(execsubtype
) {
170 case CPU_SUBTYPE_POWERPC_750
:
172 #ifndef ADDRESS_RADAR_2678019
174 * Currently implemented because dropping this would
175 * turn the executable subtype into a "has Altivec"
176 * flag, which we do not want to permit. It could
177 * also break working third party applications
178 * already in use in the field.
180 case CPU_SUBTYPE_POWERPC_7400
:
182 case CPU_SUBTYPE_POWERPC_7450
:
184 #endif /* ADDRESS_RADAR_2678019 */
185 case CPU_SUBTYPE_POWERPC_ALL
:
199 case CPU_TYPE_POWERPC64
: /* CPU_IS64BIT | CPU_POWERPC */
202 case CPU_TYPE_POWERPC
:
203 /* Special case for PPC601 */
204 if (cpusubtype
== execsubtype
)
207 * If we get here it is because it is a cpusubtype we
208 * don't support or a new cpusubtype that was added
209 * since this code was written. Both will be
210 * considered unacceptable.
232 base
= trunc_page_64(start
);
236 if(kvtophys((vm_offset_t
)base
) == NULL
)
245 md_prepare_for_shutdown(int paniced
, int howto
, char * command
);
247 extern void IOSystemShutdownNotification(void);
250 md_prepare_for_shutdown(__unused
int paniced
, __unused
int howto
,
251 __unused
char * command
)
255 * Temporary hack to notify the power management root domain
256 * that the system will shut down.
258 IOSystemShutdownNotification();