]> git.saurik.com Git - apple/xnu.git/blame - osfmk/ppc/machine_routines.h
xnu-344.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 *
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
9bccf70c 34#include <sys/appleapiopts.h>
1c79356b 35
9bccf70c
A
36/* Get Interrupts Enabled */
37boolean_t ml_get_interrupts_enabled(void);
1c79356b 38
9bccf70c
A
39/* Set Interrupts Enabled */
40boolean_t ml_set_interrupts_enabled(boolean_t enable);
1c79356b 41
9bccf70c
A
42/* Check if running at interrupt context */
43boolean_t ml_at_interrupt_context(void);
1c79356b 44
9bccf70c
A
45/* Generate a fake interrupt */
46void ml_cause_interrupt(void);
47
48/* Type for the IPI Hander */
49typedef void (*ipi_handler_t)(void);
50
51/* Type for the Time Base Enable function */
52typedef 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*/
55boolean_t ml_enable_nap(
56 int target_cpu,
57 boolean_t nap_enabled);
58
59/* Put the processor to sleep */
60void ml_ppc_sleep(void);
61void ml_get_timebase(unsigned long long *timstamp);
62void ml_sense__nmi(void);
63
64int ml_enable_cache_level(int cache_level, int enable);
1c79356b
A
65
66void ml_static_mfree(
67 vm_offset_t,
68 vm_size_t);
69
1c79356b
A
70/* Init Interrupts */
71void ml_install_interrupt_handler(
72 void *nub,
73 int source,
74 void *target,
75 IOInterruptHandler handler,
76 void *refCon);
77
9bccf70c 78#ifdef __APPLE_API_UNSTABLE
1c79356b 79
9bccf70c
A
80vm_offset_t
81ml_static_ptovirt(
82 vm_offset_t);
1c79356b 83
9bccf70c
A
84/* virtual to physical on wired pages */
85vm_offset_t ml_vtophys(
86 vm_offset_t vaddr);
1c79356b
A
87
88/* PCI config cycle probing */
89boolean_t ml_probe_read(
90 vm_offset_t paddr,
91 unsigned int *val);
92
93/* Read physical address byte */
94unsigned int ml_phys_read_byte(
95 vm_offset_t paddr);
96
97/* Read physical address */
98unsigned int ml_phys_read(
99 vm_offset_t paddr);
100
101/* Write physical address byte */
102void ml_phys_write_byte(
103 vm_offset_t paddr, unsigned int data);
104
105/* Write physical address */
106void ml_phys_write(
107 vm_offset_t paddr, unsigned int data);
108
1c79356b
A
109/* Struct for ml_processor_register */
110struct 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
119typedef struct ml_processor_info_t ml_processor_info_t;
120
121/* Register a processor */
122kern_return_t ml_processor_register(
123 ml_processor_info_t *processor_info,
124 processor_t *processor,
125 ipi_handler_t *ipi_handler);
126
9bccf70c 127#endif /* __APPLE_API_UNSTABLE */
1c79356b 128
9bccf70c
A
129#ifdef __APPLE_API_PRIVATE
130#if defined(PEXPERT_KERNEL_PRIVATE) || defined(MACH_KERNEL_PRIVATE)
131/* IO memory map services */
1c79356b 132
9bccf70c
A
133/* Map memory map IO space */
134vm_offset_t ml_io_map(
135 vm_offset_t phys_addr,
136 vm_size_t size);
1c79356b 137
9bccf70c
A
138/* boot memory allocation */
139vm_offset_t ml_static_malloc(
140 vm_size_t size);
1c79356b 141
9bccf70c 142#endif /* PEXPERT_KERNEL_PRIVATE || MACH_KERNEL_PRIVATE */
1c79356b
A
143
144#ifdef MACH_KERNEL_PRIVATE
9bccf70c
A
145void ml_init_interrupt(void);
146
147boolean_t fake_get_interrupts_enabled(void);
148
149boolean_t fake_set_interrupts_enabled(
150 boolean_t enable);
151
152/* check pending timers */
153void machine_clock_assist(void);
154
155void machine_idle(void);
156
157void machine_signal_idle(
158 processor_t processor);
159
1c79356b
A
160void cacheInit(void);
161
162void cacheDisable(void);
163
164void ml_thrm_init(void);
165unsigned int ml_read_temp(void);
166
167void ml_thrm_set(
168 unsigned int low,
169 unsigned int high);
170
171unsigned int ml_throttle(
172 unsigned int);
1c79356b 173
9bccf70c
A
174#endif /* MACH_KERNEL_PRIVATE */
175
176void 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 */
187struct 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
198typedef struct ml_ppc_cpu_info_t ml_ppc_cpu_info_t;
199
200/* Get processor info */
201void ml_ppc_get_info(ml_ppc_cpu_info_t *cpu_info);
1c79356b 202
d52fe63f
A
203void ml_set_processor_speed(unsigned long speed);
204
9bccf70c
A
205#endif /* __APPLE_API_PRIVATE */
206
1c79356b 207#endif /* _PPC_MACHINE_ROUTINES_H_ */