2 * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
5 * Copyright (C) 1990, NeXT, Inc.
7 * File: next/kern_machdep.c
10 * Machine-specific kernel routines.
13 #include <sys/types.h>
14 #include <mach/machine.h>
15 #include <kern/cpu_number.h>
16 #include <machine/exec.h>
17 #include <pexpert/arm64/board_config.h>
20 static cpu_subtype_t
cpu_subtype32(void);
21 #endif /* __arm64__ */
25 * When an arm64 CPU is executing an arm32 binary, we need to map from the
26 * host's 64-bit subtype to the appropriate 32-bit subtype.
31 switch (cpu_subtype()) {
32 case CPU_SUBTYPE_ARM64_V8
:
33 return CPU_SUBTYPE_ARM_V8
;
40 /**********************************************************************
41 * Routine: grade_binary()
43 * Function: Return a relative preference for exectypes and
44 * execsubtypes in fat executable files. The higher the
45 * grade, the higher the preference. A grade of 0 means
47 **********************************************************************/
49 grade_binary(cpu_type_t exectype
, cpu_subtype_t execsubtype
, bool allow_simulator_binary __unused
)
52 cpu_subtype_t hostsubtype
=
53 (exectype
& CPU_ARCH_ABI64
) ? cpu_subtype() : cpu_subtype32();
55 cpu_subtype_t hostsubtype
= cpu_subtype();
56 #endif /* __arm64__ */
61 switch (hostsubtype
) {
62 case CPU_SUBTYPE_ARM64_V8
:
63 switch (execsubtype
) {
64 case CPU_SUBTYPE_ARM64_V8
:
66 case CPU_SUBTYPE_ARM64_ALL
:
71 } /* switch (hostsubtype) */
76 switch (hostsubtype
) {
78 * For 32-bit ARMv8, try the ARMv8 slice before falling back to Swift.
80 case CPU_SUBTYPE_ARM_V8
:
81 switch (execsubtype
) {
82 case CPU_SUBTYPE_ARM_V8
:
88 * For Swift and later, we prefer to run a swift slice, but fall back
89 * to v7 as Cortex A9 errata should not apply
92 case CPU_SUBTYPE_ARM_V7S
:
93 switch (execsubtype
) {
94 case CPU_SUBTYPE_ARM_V7S
:
100 * For Cortex A7, accept v7k only due to differing ABI
102 case CPU_SUBTYPE_ARM_V7K
:
103 switch (execsubtype
) {
104 case CPU_SUBTYPE_ARM_V7K
:
110 * For Cortex A9, we prefer the A9 slice, but will run v7 albeit
111 * under the risk of hitting the NEON load/store errata
113 case CPU_SUBTYPE_ARM_V7F
:
114 switch (execsubtype
) {
115 case CPU_SUBTYPE_ARM_V7F
:
121 case CPU_SUBTYPE_ARM_V7
:
122 switch (execsubtype
) {
123 case CPU_SUBTYPE_ARM_V7
:
128 case CPU_SUBTYPE_ARM_V6
:
129 switch (execsubtype
) {
130 case CPU_SUBTYPE_ARM_V6
:
135 case CPU_SUBTYPE_ARM_V5TEJ
:
136 switch (execsubtype
) {
137 case CPU_SUBTYPE_ARM_V5TEJ
:
142 case CPU_SUBTYPE_ARM_V4T
:
143 switch (execsubtype
) {
144 case CPU_SUBTYPE_ARM_V4T
:
146 case CPU_SUBTYPE_ARM_ALL
:
151 case CPU_SUBTYPE_ARM_XSCALE
:
152 switch (execsubtype
) {
153 case CPU_SUBTYPE_ARM_XSCALE
:
155 case CPU_SUBTYPE_ARM_V5TEJ
:
157 case CPU_SUBTYPE_ARM_V4T
:
159 case CPU_SUBTYPE_ARM_ALL
:
164 #endif /* __arm64__ */
171 pie_required(cpu_type_t exectype
, cpu_subtype_t execsubtype
)
177 #endif /* __arm64__ */
180 switch (execsubtype
) {
181 case CPU_SUBTYPE_ARM_V7K
: