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@
25 * cpu specific routines
28 #include <kern/kalloc.h>
29 #include <kern/misc_protos.h>
30 #include <kern/machine.h>
31 #include <mach/processor_info.h>
33 #include <i386/machine_cpu.h>
34 #include <i386/machine_routines.h>
35 #include <i386/pmap.h>
36 #include <i386/misc_protos.h>
37 #include <i386/cpu_threads.h>
38 #include <i386/rtclock.h>
39 #include <vm/vm_kern.h>
42 struct processor processor_master
;
48 processor_info_t info
,
51 printf("cpu_control(%d,0x%x,%d) not implemented\n",
52 slot_num
, info
, count
);
53 return (KERN_FAILURE
);
59 __unused processor_flavor_t flavor
,
63 return (KERN_FAILURE
);
69 processor_flavor_t flavor
,
71 processor_info_t info
,
74 printf("cpu_info(%d,%d,0x%x,0x%x) not implemented\n",
75 flavor
, slot_num
, info
, count
);
76 return (KERN_FAILURE
);
82 cpu_data_t
*proc_info
= current_cpu_datap();
84 proc_info
->cpu_running
= FALSE
;
86 PE_cpu_machine_quiesce(proc_info
->cpu_id
);
94 cpu_data_t
*cdp
= current_cpu_datap();
96 /* be sure cpuid is initialized */
99 /* and allow it to be authoritative */
100 cdp
->cpu_type
= cpuid_cputype();
101 cdp
->cpu_subtype
= cpuid_cpusubtype();
103 cdp
->cpu_running
= TRUE
;
112 if (cpu
== cpu_number()) {
117 * Should call out through PE.
118 * But take the shortcut here.
120 ret
= intel_startCPU(cpu
);
135 cpu_data_t
*cdp
= current_cpu_datap();
137 PE_cpu_machine_init(cdp
->cpu_id
, !cdp
->cpu_boot_complete
);
138 cdp
->cpu_boot_complete
= TRUE
;
139 cdp
->cpu_running
= TRUE
;
141 if (cpu_datap(cpu
)->hibernate
)
143 cpu_datap(cpu
)->hibernate
= 0;
144 hibernate_machine_init();
151 cpu_processor_alloc(boolean_t is_boot_cpu
)
157 return &processor_master
;
159 ret
= kmem_alloc(kernel_map
, (vm_offset_t
*) &proc
, sizeof(*proc
));
160 if (ret
!= KERN_SUCCESS
)
163 bzero((void *) proc
, sizeof(*proc
));
168 cpu_processor_free(processor_t proc
)
170 if (proc
!= NULL
&& proc
!= &processor_master
)
171 kfree((void *) proc
, sizeof(*proc
));
175 current_processor(void)
177 return current_cpu_datap()->cpu_processor
;
184 return cpu_datap(cpu
)->cpu_processor
;
190 return (¤t_cpu_datap()->cpu_pending_ast
);
197 return (cpu_datap(slot_num
)->cpu_type
);
204 return (cpu_datap(slot_num
)->cpu_subtype
);
211 return (cpu_datap(slot_num
)->cpu_threadtype
);
217 return (current_cpu_datap()->cpu_type
);
223 return (current_cpu_datap()->cpu_subtype
);
229 return (current_cpu_datap()->cpu_threadtype
);