]> git.saurik.com Git - apple/xnu.git/blame - osfmk/ppc/machine_routines.h
xnu-517.3.7.tar.gz
[apple/xnu.git] / osfmk / ppc / machine_routines.h
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
43866e37 6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
1c79356b 7 *
43866e37
A
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
1c79356b
A
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
43866e37
A
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
1c79356b
A
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25/*
26 * @OSF_COPYRIGHT@
27 */
28
29#ifndef _PPC_MACHINE_ROUTINES_H_
30#define _PPC_MACHINE_ROUTINES_H_
31
32#include <mach/mach_types.h>
33#include <mach/boolean.h>
34#include <kern/kern_types.h>
55e303ae 35#include <kern/sched_prim.h>
1c79356b
A
36#include <pexpert/pexpert.h>
37
9bccf70c 38#include <sys/appleapiopts.h>
1c79356b 39
9bccf70c
A
40/* Get Interrupts Enabled */
41boolean_t ml_get_interrupts_enabled(void);
1c79356b 42
9bccf70c
A
43/* Set Interrupts Enabled */
44boolean_t ml_set_interrupts_enabled(boolean_t enable);
1c79356b 45
9bccf70c
A
46/* Check if running at interrupt context */
47boolean_t ml_at_interrupt_context(void);
1c79356b 48
9bccf70c
A
49/* Generate a fake interrupt */
50void ml_cause_interrupt(void);
51
52/* Type for the IPI Hander */
53typedef void (*ipi_handler_t)(void);
54
55/* Type for the Time Base Enable function */
56typedef void (*time_base_enable_t)(cpu_id_t cpu_id, boolean_t enable);
57
58/* enables (or disables) the processor nap mode the function returns the previous value*/
59boolean_t ml_enable_nap(
60 int target_cpu,
61 boolean_t nap_enabled);
62
63/* Put the processor to sleep */
64void ml_ppc_sleep(void);
65void ml_get_timebase(unsigned long long *timstamp);
66void ml_sense__nmi(void);
67
68int ml_enable_cache_level(int cache_level, int enable);
1c79356b
A
69
70void ml_static_mfree(
71 vm_offset_t,
72 vm_size_t);
73
1c79356b
A
74/* Init Interrupts */
75void ml_install_interrupt_handler(
76 void *nub,
77 int source,
78 void *target,
79 IOInterruptHandler handler,
80 void *refCon);
81
9bccf70c 82#ifdef __APPLE_API_UNSTABLE
1c79356b 83
9bccf70c
A
84vm_offset_t
85ml_static_ptovirt(
86 vm_offset_t);
1c79356b 87
9bccf70c
A
88/* virtual to physical on wired pages */
89vm_offset_t ml_vtophys(
90 vm_offset_t vaddr);
1c79356b
A
91
92/* PCI config cycle probing */
93boolean_t ml_probe_read(
94 vm_offset_t paddr,
95 unsigned int *val);
55e303ae
A
96boolean_t ml_probe_read_64(
97 addr64_t paddr,
98 unsigned int *val);
1c79356b
A
99
100/* Read physical address byte */
101unsigned int ml_phys_read_byte(
102 vm_offset_t paddr);
55e303ae
A
103unsigned int ml_phys_read_byte_64(
104 addr64_t paddr);
105
106/* Read physical address half word */
107unsigned int ml_phys_read_half(
108 vm_offset_t paddr);
109unsigned int ml_phys_read_half_64(
110 addr64_t paddr);
1c79356b 111
55e303ae 112/* Read physical address word*/
1c79356b
A
113unsigned int ml_phys_read(
114 vm_offset_t paddr);
55e303ae
A
115unsigned int ml_phys_read_64(
116 addr64_t paddr);
117unsigned int ml_phys_read_word(
118 vm_offset_t paddr);
119unsigned int ml_phys_read_word_64(
120 addr64_t paddr);
121
122/* Read physical address double word */
123unsigned long long ml_phys_read_double(
124 vm_offset_t paddr);
125unsigned long long ml_phys_read_double_64(
126 addr64_t paddr);
1c79356b
A
127
128/* Write physical address byte */
129void ml_phys_write_byte(
130 vm_offset_t paddr, unsigned int data);
55e303ae
A
131void ml_phys_write_byte_64(
132 addr64_t paddr, unsigned int data);
1c79356b 133
55e303ae
A
134/* Write physical address half word */
135void ml_phys_write_half(
136 vm_offset_t paddr, unsigned int data);
137void ml_phys_write_half_64(
138 addr64_t paddr, unsigned int data);
139
140/* Write physical address word */
1c79356b
A
141void ml_phys_write(
142 vm_offset_t paddr, unsigned int data);
55e303ae
A
143void ml_phys_write_64(
144 addr64_t paddr, unsigned int data);
145void ml_phys_write_word(
146 vm_offset_t paddr, unsigned int data);
147void ml_phys_write_word_64(
148 addr64_t paddr, unsigned int data);
149
150/* Write physical address double word */
151void ml_phys_write_double(
152 vm_offset_t paddr, unsigned long long data);
153void ml_phys_write_double_64(
154 addr64_t paddr, unsigned long long data);
1c79356b 155
1c79356b 156/* Struct for ml_processor_register */
55e303ae 157struct ml_processor_info {
1c79356b
A
158 cpu_id_t cpu_id;
159 boolean_t boot_cpu;
160 vm_offset_t start_paddr;
161 boolean_t supports_nap;
162 unsigned long l2cr_value;
163 time_base_enable_t time_base_enable;
164};
165
55e303ae 166typedef struct ml_processor_info ml_processor_info_t;
1c79356b
A
167
168/* Register a processor */
169kern_return_t ml_processor_register(
170 ml_processor_info_t *processor_info,
171 processor_t *processor,
172 ipi_handler_t *ipi_handler);
173
55e303ae
A
174/* Zero bytes starting at a physical address */
175void bzero_phys(
176 addr64_t phys_address,
177 uint32_t length);
178
9bccf70c 179#endif /* __APPLE_API_UNSTABLE */
1c79356b 180
9bccf70c
A
181#ifdef __APPLE_API_PRIVATE
182#if defined(PEXPERT_KERNEL_PRIVATE) || defined(MACH_KERNEL_PRIVATE)
183/* IO memory map services */
1c79356b 184
9bccf70c
A
185/* Map memory map IO space */
186vm_offset_t ml_io_map(
187 vm_offset_t phys_addr,
188 vm_size_t size);
1c79356b 189
9bccf70c
A
190/* boot memory allocation */
191vm_offset_t ml_static_malloc(
192 vm_size_t size);
1c79356b 193
9bccf70c 194#endif /* PEXPERT_KERNEL_PRIVATE || MACH_KERNEL_PRIVATE */
1c79356b
A
195
196#ifdef MACH_KERNEL_PRIVATE
9bccf70c
A
197void ml_init_interrupt(void);
198
199boolean_t fake_get_interrupts_enabled(void);
200
201boolean_t fake_set_interrupts_enabled(
202 boolean_t enable);
203
9bccf70c
A
204void machine_idle(void);
205
206void machine_signal_idle(
207 processor_t processor);
208
1c79356b
A
209void cacheInit(void);
210
211void cacheDisable(void);
212
213void ml_thrm_init(void);
214unsigned int ml_read_temp(void);
215
216void ml_thrm_set(
217 unsigned int low,
218 unsigned int high);
219
220unsigned int ml_throttle(
221 unsigned int);
1c79356b 222
ab86ba33
A
223void ml_init_lock_timeout(void);
224
9bccf70c
A
225#endif /* MACH_KERNEL_PRIVATE */
226
227void ml_thread_policy(
228 thread_t thread,
229 unsigned policy_id,
230 unsigned policy_info);
231
232#define MACHINE_GROUP 0x00000001
233#define MACHINE_NETWORK_GROUP 0x10000000
234#define MACHINE_NETWORK_WORKLOOP 0x00000001
235#define MACHINE_NETWORK_NETISR 0x00000002
236
43866e37
A
237/* Initialize the maximum number of CPUs */
238void ml_init_max_cpus(
239 unsigned long max_cpus);
240
241/* Return the maximum number of CPUs set by ml_init_max_cpus() */
242int ml_get_max_cpus(
243 void);
244
245/* Return the current number of CPUs */
246int ml_get_current_cpus(
247 void);
248
249/* Struct for ml_cpu_get_info */
250struct ml_cpu_info {
9bccf70c
A
251 unsigned long vector_unit;
252 unsigned long cache_line_size;
253 unsigned long l1_icache_size;
254 unsigned long l1_dcache_size;
255 unsigned long l2_settings;
256 unsigned long l2_cache_size;
257 unsigned long l3_settings;
258 unsigned long l3_cache_size;
259};
260
43866e37 261typedef struct ml_cpu_info ml_cpu_info_t;
9bccf70c
A
262
263/* Get processor info */
43866e37 264void ml_cpu_get_info(ml_cpu_info_t *cpu_info);
1c79356b 265
d52fe63f 266void ml_set_processor_speed(unsigned long speed);
d12e1678 267void ml_set_processor_voltage(unsigned long voltage);
d52fe63f 268
9bccf70c
A
269#endif /* __APPLE_API_PRIVATE */
270
1c79356b 271#endif /* _PPC_MACHINE_ROUTINES_H_ */