]> git.saurik.com Git - apple/xnu.git/blob - osfmk/ppc/machine_routines.h
xnu-344.tar.gz
[apple/xnu.git] / osfmk / ppc / machine_routines.h
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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.
11 *
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
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22 /*
23 * @OSF_COPYRIGHT@
24 */
25
26 #ifndef _PPC_MACHINE_ROUTINES_H_
27 #define _PPC_MACHINE_ROUTINES_H_
28
29 #include <mach/mach_types.h>
30 #include <mach/boolean.h>
31 #include <kern/kern_types.h>
32 #include <pexpert/pexpert.h>
33
34 #include <sys/appleapiopts.h>
35
36 /* Get Interrupts Enabled */
37 boolean_t ml_get_interrupts_enabled(void);
38
39 /* Set Interrupts Enabled */
40 boolean_t ml_set_interrupts_enabled(boolean_t enable);
41
42 /* Check if running at interrupt context */
43 boolean_t ml_at_interrupt_context(void);
44
45 /* Generate a fake interrupt */
46 void ml_cause_interrupt(void);
47
48 /* Type for the IPI Hander */
49 typedef void (*ipi_handler_t)(void);
50
51 /* Type for the Time Base Enable function */
52 typedef void (*time_base_enable_t)(cpu_id_t cpu_id, boolean_t enable);
53
54 /* enables (or disables) the processor nap mode the function returns the previous value*/
55 boolean_t ml_enable_nap(
56 int target_cpu,
57 boolean_t nap_enabled);
58
59 /* Put the processor to sleep */
60 void ml_ppc_sleep(void);
61 void ml_get_timebase(unsigned long long *timstamp);
62 void ml_sense__nmi(void);
63
64 int ml_enable_cache_level(int cache_level, int enable);
65
66 void ml_static_mfree(
67 vm_offset_t,
68 vm_size_t);
69
70 /* Init Interrupts */
71 void ml_install_interrupt_handler(
72 void *nub,
73 int source,
74 void *target,
75 IOInterruptHandler handler,
76 void *refCon);
77
78 #ifdef __APPLE_API_UNSTABLE
79
80 vm_offset_t
81 ml_static_ptovirt(
82 vm_offset_t);
83
84 /* virtual to physical on wired pages */
85 vm_offset_t ml_vtophys(
86 vm_offset_t vaddr);
87
88 /* PCI config cycle probing */
89 boolean_t ml_probe_read(
90 vm_offset_t paddr,
91 unsigned int *val);
92
93 /* Read physical address byte */
94 unsigned int ml_phys_read_byte(
95 vm_offset_t paddr);
96
97 /* Read physical address */
98 unsigned int ml_phys_read(
99 vm_offset_t paddr);
100
101 /* Write physical address byte */
102 void ml_phys_write_byte(
103 vm_offset_t paddr, unsigned int data);
104
105 /* Write physical address */
106 void ml_phys_write(
107 vm_offset_t paddr, unsigned int data);
108
109 /* Struct for ml_processor_register */
110 struct ml_processor_info_t {
111 cpu_id_t cpu_id;
112 boolean_t boot_cpu;
113 vm_offset_t start_paddr;
114 boolean_t supports_nap;
115 unsigned long l2cr_value;
116 time_base_enable_t time_base_enable;
117 };
118
119 typedef struct ml_processor_info_t ml_processor_info_t;
120
121 /* Register a processor */
122 kern_return_t ml_processor_register(
123 ml_processor_info_t *processor_info,
124 processor_t *processor,
125 ipi_handler_t *ipi_handler);
126
127 #endif /* __APPLE_API_UNSTABLE */
128
129 #ifdef __APPLE_API_PRIVATE
130 #if defined(PEXPERT_KERNEL_PRIVATE) || defined(MACH_KERNEL_PRIVATE)
131 /* IO memory map services */
132
133 /* Map memory map IO space */
134 vm_offset_t ml_io_map(
135 vm_offset_t phys_addr,
136 vm_size_t size);
137
138 /* boot memory allocation */
139 vm_offset_t ml_static_malloc(
140 vm_size_t size);
141
142 #endif /* PEXPERT_KERNEL_PRIVATE || MACH_KERNEL_PRIVATE */
143
144 #ifdef MACH_KERNEL_PRIVATE
145 void ml_init_interrupt(void);
146
147 boolean_t fake_get_interrupts_enabled(void);
148
149 boolean_t fake_set_interrupts_enabled(
150 boolean_t enable);
151
152 /* check pending timers */
153 void machine_clock_assist(void);
154
155 void machine_idle(void);
156
157 void machine_signal_idle(
158 processor_t processor);
159
160 void cacheInit(void);
161
162 void cacheDisable(void);
163
164 void ml_thrm_init(void);
165 unsigned int ml_read_temp(void);
166
167 void ml_thrm_set(
168 unsigned int low,
169 unsigned int high);
170
171 unsigned int ml_throttle(
172 unsigned int);
173
174 #endif /* MACH_KERNEL_PRIVATE */
175
176 void ml_thread_policy(
177 thread_t thread,
178 unsigned policy_id,
179 unsigned policy_info);
180
181 #define MACHINE_GROUP 0x00000001
182 #define MACHINE_NETWORK_GROUP 0x10000000
183 #define MACHINE_NETWORK_WORKLOOP 0x00000001
184 #define MACHINE_NETWORK_NETISR 0x00000002
185
186 /* Struct for ml_ppc_get_cpu_info */
187 struct ml_ppc_cpu_info_t {
188 unsigned long vector_unit;
189 unsigned long cache_line_size;
190 unsigned long l1_icache_size;
191 unsigned long l1_dcache_size;
192 unsigned long l2_settings;
193 unsigned long l2_cache_size;
194 unsigned long l3_settings;
195 unsigned long l3_cache_size;
196 };
197
198 typedef struct ml_ppc_cpu_info_t ml_ppc_cpu_info_t;
199
200 /* Get processor info */
201 void ml_ppc_get_info(ml_ppc_cpu_info_t *cpu_info);
202
203 void ml_set_processor_speed(unsigned long speed);
204
205 #endif /* __APPLE_API_PRIVATE */
206
207 #endif /* _PPC_MACHINE_ROUTINES_H_ */