]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
de355530 A |
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. | |
1c79356b | 11 | * |
de355530 A |
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 | |
1c79356b A |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
de355530 A |
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. | |
1c79356b A |
19 | * |
20 | * @APPLE_LICENSE_HEADER_END@ | |
21 | */ | |
22 | /* | |
23 | * Copyright (C) 1990, 1993 NeXT, Inc. | |
24 | * Copyright (C) 1997 Apple Computer, Inc. | |
25 | * | |
26 | * File: next/kern_machdep.c | |
27 | * Author: John Seamons | |
28 | * | |
29 | * Machine-specific kernel routines. | |
30 | * | |
31 | * HISTORY | |
32 | * 8-Dec-91 Peter King (king) at NeXT | |
33 | * Added grade_cpu_subtype(). | |
34 | * FIXME: Do we want to merge this with check_cpu_subtype()? | |
35 | * | |
36 | * 5-Mar-90 John Seamons (jks) at NeXT | |
37 | * Created. | |
38 | */ | |
39 | ||
40 | #include <sys/types.h> | |
41 | #include <sys/param.h> | |
42 | #include <mach/machine.h> | |
43 | #include <mach/boolean.h> | |
44 | #include <mach/vm_param.h> | |
45 | #include <kern/cpu_number.h> | |
46 | ||
47 | int | |
48 | check_cpu_subtype(cpu_subtype_t cpu_subtype) | |
49 | { | |
50 | struct machine_slot *ms = &machine_slot[cpu_number()]; | |
51 | ||
52 | if (cpu_subtype == ms->cpu_subtype) | |
53 | return (TRUE); | |
54 | ||
de355530 A |
55 | if (cpu_subtype == CPU_SUBTYPE_POWERPC_601) |
56 | return (FALSE); | |
57 | ||
1c79356b A |
58 | switch (cpu_subtype) { |
59 | case CPU_SUBTYPE_POWERPC_7450: | |
60 | case CPU_SUBTYPE_POWERPC_7400: | |
61 | case CPU_SUBTYPE_POWERPC_750: | |
de355530 A |
62 | case CPU_SUBTYPE_POWERPC_604e: |
63 | case CPU_SUBTYPE_POWERPC_604: | |
64 | case CPU_SUBTYPE_POWERPC_603ev: | |
65 | case CPU_SUBTYPE_POWERPC_603e: | |
66 | case CPU_SUBTYPE_POWERPC_603: | |
1c79356b A |
67 | case CPU_SUBTYPE_POWERPC_ALL: |
68 | return (TRUE); | |
69 | } | |
70 | ||
71 | return (FALSE); | |
72 | } | |
73 | ||
74 | /* | |
75 | * Routine: grade_cpu_subtype() | |
76 | * | |
77 | * Function: | |
78 | * Return a relative preference for cpu_subtypes in fat executable files. | |
79 | * The higher the grade, the higher the preference. | |
80 | * A grade of 0 means not acceptable. | |
81 | */ | |
82 | ||
83 | int | |
84 | grade_cpu_subtype(cpu_subtype_t cpu_subtype) | |
85 | { | |
86 | struct machine_slot *ms = &machine_slot[cpu_number()]; | |
87 | ||
88 | /* | |
89 | * This code should match cpusubtype_findbestarch() in best_arch.c in the | |
90 | * cctools project. As of 2/16/98 this is what has been agreed upon for | |
91 | * the PowerPC subtypes. If an exact match is not found the subtype will | |
92 | * be picked from the following order: | |
de355530 | 93 | * 7400, 750, 604e, 604, 603ev, 603e, 603, ALL |
1c79356b A |
94 | * Note the 601 is NOT in the list above. It is only picked via an exact |
95 | * match. For details see Radar 2213821. | |
96 | * | |
97 | * To implement this function to follow what was agreed upon above, we use | |
de355530 A |
98 | * the fact there are currently 10 different subtypes. Exact matches return |
99 | * the value 10, the value 0 is returned for 601 that is not an exact match, | |
100 | * and the values 9 thru 1 are returned for the subtypes listed in the order | |
101 | * above. | |
1c79356b A |
102 | */ |
103 | if (ms->cpu_subtype == cpu_subtype) | |
de355530 A |
104 | return 10; |
105 | if (cpu_subtype == CPU_SUBTYPE_POWERPC_601) | |
106 | return 0; | |
1c79356b | 107 | switch (cpu_subtype) { |
d7e50217 | 108 | case CPU_SUBTYPE_POWERPC_7450: |
de355530 | 109 | return 9; |
d7e50217 | 110 | case CPU_SUBTYPE_POWERPC_7400: |
de355530 | 111 | return 8; |
d7e50217 | 112 | case CPU_SUBTYPE_POWERPC_750: |
de355530 A |
113 | return 7; |
114 | case CPU_SUBTYPE_POWERPC_604e: | |
115 | return 6; | |
116 | case CPU_SUBTYPE_POWERPC_604: | |
117 | return 5; | |
118 | case CPU_SUBTYPE_POWERPC_603ev: | |
119 | return 4; | |
120 | case CPU_SUBTYPE_POWERPC_603e: | |
121 | return 3; | |
122 | case CPU_SUBTYPE_POWERPC_603: | |
1c79356b A |
123 | return 2; |
124 | case CPU_SUBTYPE_POWERPC_ALL: | |
125 | return 1; | |
126 | } | |
127 | /* | |
de355530 A |
128 | * If we get here it is because it is a cpusubtype we don't support (602 and |
129 | * 620) or new cpusubtype that was added since this code was written. Both | |
1c79356b A |
130 | * will be considered unacceptable. |
131 | */ | |
132 | return 0; | |
133 | } | |
134 | ||
135 | boolean_t | |
136 | kernacc( | |
137 | off_t start, | |
138 | size_t len | |
139 | ) | |
140 | { | |
141 | off_t base; | |
142 | off_t end; | |
143 | ||
de355530 | 144 | base = trunc_page(start); |
1c79356b A |
145 | end = start + len; |
146 | ||
147 | while (base < end) { | |
148 | if(kvtophys((vm_offset_t)base) == NULL) | |
149 | return(FALSE); | |
150 | base += page_size; | |
151 | } | |
152 | ||
153 | return (TRUE); | |
154 | } |