]>
Commit | Line | Data |
---|---|---|
5d5c5d0d A |
1 | /* |
2 | * Copyright (c) 2003-2004 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_OSREFERENCE_HEADER_START@ | |
5 | * | |
6 | * This file contains Original Code and/or Modifications of Original Code | |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. The rights granted to you under the | |
10 | * License may not be used to create, or enable the creation or | |
11 | * redistribution of, unlawful or unlicensed copies of an Apple operating | |
12 | * system, or to circumvent, violate, or enable the circumvention or | |
13 | * violation of, any terms of an Apple operating system software license | |
14 | * agreement. | |
15 | * | |
16 | * Please obtain a copy of the License at | |
17 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
18 | * file. | |
19 | * | |
20 | * The Original Code and all software distributed under the License are | |
21 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
22 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
23 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
24 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
25 | * Please see the License for the specific language governing rights and | |
26 | * limitations under the License. | |
27 | * | |
28 | * @APPLE_LICENSE_OSREFERENCE_HEADER_END@ | |
29 | */ | |
30 | #include <mach/mach_types.h> | |
31 | #include <mach/mach_host.h> | |
32 | ||
33 | #include <kern/host.h> | |
34 | #include <kern/processor.h> | |
35 | #include <kern/cpu_data.h> | |
36 | ||
37 | #include <machine/machine_routines.h> | |
38 | ||
39 | #include <chud/chud_xnu.h> | |
40 | ||
41 | #pragma mark **** cpu count **** | |
42 | ||
43 | __private_extern__ int | |
44 | chudxnu_avail_cpu_count(void) | |
45 | { | |
46 | host_basic_info_data_t hinfo; | |
47 | kern_return_t kr; | |
48 | mach_msg_type_number_t count = HOST_BASIC_INFO_COUNT; | |
49 | ||
50 | kr = host_info(host_self(), HOST_BASIC_INFO, (integer_t *)&hinfo, &count); | |
51 | if(kr == KERN_SUCCESS) { | |
52 | return hinfo.avail_cpus; | |
53 | } else { | |
54 | return 0; | |
55 | } | |
56 | } | |
57 | ||
58 | __private_extern__ int | |
59 | chudxnu_phys_cpu_count(void) | |
60 | { | |
61 | host_basic_info_data_t hinfo; | |
62 | kern_return_t kr; | |
63 | mach_msg_type_number_t count = HOST_BASIC_INFO_COUNT; | |
64 | ||
65 | kr = host_info(host_self(), HOST_BASIC_INFO, (integer_t *)&hinfo, &count); | |
66 | if(kr == KERN_SUCCESS) { | |
67 | return hinfo.max_cpus; | |
68 | } else { | |
69 | return 0; | |
70 | } | |
71 | } | |
72 | ||
73 | __private_extern__ | |
74 | int chudxnu_cpu_number(void) | |
75 | { | |
76 | return cpu_number(); | |
77 | } | |
78 | ||
79 | #pragma mark **** branch trace buffer **** | |
80 | ||
81 | extern int pc_trace_buf[1024]; | |
82 | ||
83 | __private_extern__ uint32_t * | |
84 | chudxnu_get_branch_trace_buffer(uint32_t *entries) | |
85 | { | |
86 | if(entries) { | |
87 | *entries = sizeof(pc_trace_buf)/sizeof(int); | |
88 | } | |
89 | return pc_trace_buf; | |
90 | } | |
91 | ||
92 | #pragma mark **** interrupts enable/disable **** | |
93 | ||
94 | __private_extern__ boolean_t | |
95 | chudxnu_get_interrupts_enabled(void) | |
96 | { | |
97 | return ml_get_interrupts_enabled(); | |
98 | } | |
99 | ||
100 | __private_extern__ boolean_t | |
101 | chudxnu_set_interrupts_enabled(boolean_t enable) | |
102 | { | |
103 | return ml_set_interrupts_enabled(enable); | |
104 | } | |
105 | ||
106 | __private_extern__ boolean_t | |
107 | chudxnu_at_interrupt_context(void) | |
108 | { | |
109 | return ml_at_interrupt_context(); | |
110 | } | |
111 | ||
112 | __private_extern__ void | |
113 | chudxnu_cause_interrupt(void) | |
114 | { | |
115 | ml_cause_interrupt(); | |
116 | } | |
117 | ||
118 | #pragma mark **** preemption enable/disable **** | |
119 | ||
120 | __private_extern__ void | |
121 | chudxnu_enable_preemption(void) | |
122 | { | |
123 | enable_preemption(); | |
124 | } | |
125 | ||
126 | __private_extern__ void | |
127 | chudxnu_disable_preemption(void) | |
128 | { | |
129 | disable_preemption(); | |
130 | } | |
131 | ||
132 | __private_extern__ int | |
133 | chudxnu_get_preemption_level(void) | |
134 | { | |
135 | return get_preemption_level(); | |
136 | } |