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>
39 int grade_binary(cpu_type_t exectype
, cpu_subtype_t execsubtype
);
42 * Routine: grade_binary()
45 * Return a relative preference for exectypes and execsubtypes in fat
46 * executable files. The higher the grade, the higher the preference.
47 * A grade of 0 means not acceptable.
49 * Note: We really don't care about the real cpu_type() here,
50 * because machines can only have one type.
53 grade_binary(cpu_type_t exectype
, cpu_subtype_t execsubtype
)
55 int cpusubtype
= cpu_subtype();
58 * This code should match cpusubtype_findbestarch() in best_arch.c
59 * in the cctools project. As of 2/16/98 this is what has been
60 * agreed upon for the PowerPC subtypes. If an exact match is not
61 * found the subtype will be picked from the following order:
62 * 970(but only on 970), 7450, 7400, 750, ALL
63 * Note the 601 is NOT in the list above. It is only picked via
64 * an exact match. For details see Radar 2213821.
68 case CPU_SUBTYPE_POWERPC_970
:
70 case CPU_TYPE_POWERPC64
: /* CPU_IS64BIT | CPU_POWERPC */
73 * Prefer 64 bit architecture specific binaries; note
74 * that this value does not mean the same thing here
77 case CPU_SUBTYPE_POWERPC_970
:
79 /* Prefer generic binaries */
80 case CPU_SUBTYPE_POWERPC_ALL
:
87 case CPU_TYPE_POWERPC
:
90 * Prefer 32 bit binaries with 64 bit leaf functions;
91 * this is actually bogus use of the subtype to encode
94 case CPU_SUBTYPE_POWERPC_970
:
96 case CPU_SUBTYPE_POWERPC_7450
:
98 case CPU_SUBTYPE_POWERPC_7400
:
100 case CPU_SUBTYPE_POWERPC_750
:
102 case CPU_SUBTYPE_POWERPC_ALL
:
114 case CPU_SUBTYPE_POWERPC_7450
:
116 case CPU_TYPE_POWERPC64
: /* CPU_IS64BIT | CPU_POWERPC */
119 case CPU_TYPE_POWERPC
:
120 switch(execsubtype
) {
121 case CPU_SUBTYPE_POWERPC_7450
:
123 case CPU_SUBTYPE_POWERPC_7400
:
125 case CPU_SUBTYPE_POWERPC_750
:
127 case CPU_SUBTYPE_POWERPC_ALL
:
139 case CPU_SUBTYPE_POWERPC_7400
:
141 case CPU_TYPE_POWERPC64
: /* CPU_IS64BIT | CPU_POWERPC */
144 case CPU_TYPE_POWERPC
:
145 switch(execsubtype
) {
146 case CPU_SUBTYPE_POWERPC_7400
:
148 case CPU_SUBTYPE_POWERPC_7450
:
150 case CPU_SUBTYPE_POWERPC_750
:
152 case CPU_SUBTYPE_POWERPC_ALL
:
164 case CPU_SUBTYPE_POWERPC_750
:
166 case CPU_TYPE_POWERPC64
: /* CPU_IS64BIT | CPU_POWERPC */
169 case CPU_TYPE_POWERPC
:
170 switch(execsubtype
) {
171 case CPU_SUBTYPE_POWERPC_750
:
173 #ifndef ADDRESS_RADAR_2678019
175 * Currently implemented because dropping this would
176 * turn the executable subtype into a "has Altivec"
177 * flag, which we do not want to permit. It could
178 * also break working third party applications
179 * already in use in the field.
181 case CPU_SUBTYPE_POWERPC_7400
:
183 case CPU_SUBTYPE_POWERPC_7450
:
185 #endif /* ADDRESS_RADAR_2678019 */
186 case CPU_SUBTYPE_POWERPC_ALL
:
200 case CPU_TYPE_POWERPC64
: /* CPU_IS64BIT | CPU_POWERPC */
203 case CPU_TYPE_POWERPC
:
204 /* Special case for PPC601 */
205 if (cpusubtype
== execsubtype
)
208 * If we get here it is because it is a cpusubtype we
209 * don't support or a new cpusubtype that was added
210 * since this code was written. Both will be
211 * considered unacceptable.
233 base
= trunc_page_64(start
);
237 if(kvtophys((vm_offset_t
)base
) == NULL
)
246 md_prepare_for_shutdown(int paniced
, int howto
, char * command
);
248 extern void IOSystemShutdownNotification(void);
251 md_prepare_for_shutdown(__unused
int paniced
, __unused
int howto
,
252 __unused
char * command
)
256 * Temporary hack to notify the power management root domain
257 * that the system will shut down.
259 IOSystemShutdownNotification();