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@
26 #ifndef _PPC_MACHINE_ROUTINES_H_
27 #define _PPC_MACHINE_ROUTINES_H_
29 #include <mach/mach_types.h>
30 #include <mach/boolean.h>
31 #include <kern/kern_types.h>
32 #include <kern/sched_prim.h>
33 #include <pexpert/pexpert.h>
35 #include <sys/appleapiopts.h>
37 /* Get Interrupts Enabled */
38 boolean_t
ml_get_interrupts_enabled(void);
40 /* Set Interrupts Enabled */
41 boolean_t
ml_set_interrupts_enabled(boolean_t enable
);
43 /* Check if running at interrupt context */
44 boolean_t
ml_at_interrupt_context(void);
46 /* Generate a fake interrupt */
47 void ml_cause_interrupt(void);
49 /* Type for the IPI Hander */
50 typedef void (*ipi_handler_t
)(void);
52 /* Type for the Time Base Enable function */
53 typedef void (*time_base_enable_t
)(cpu_id_t cpu_id
, boolean_t enable
);
55 /* enables (or disables) the processor nap mode the function returns the previous value*/
56 boolean_t
ml_enable_nap(
58 boolean_t nap_enabled
);
60 /* Put the processor to sleep */
61 void ml_ppc_sleep(void);
62 void ml_get_timebase(unsigned long long *timstamp
);
63 void ml_sense__nmi(void);
65 int ml_enable_cache_level(int cache_level
, int enable
);
72 void ml_install_interrupt_handler(
76 IOInterruptHandler handler
,
79 #ifdef __APPLE_API_UNSTABLE
85 /* virtual to physical on wired pages */
86 vm_offset_t
ml_vtophys(
89 /* PCI config cycle probing */
90 boolean_t
ml_probe_read(
93 boolean_t
ml_probe_read_64(
97 /* Read physical address byte */
98 unsigned int ml_phys_read_byte(
100 unsigned int ml_phys_read_byte_64(
103 /* Read physical address half word */
104 unsigned int ml_phys_read_half(
106 unsigned int ml_phys_read_half_64(
109 /* Read physical address word*/
110 unsigned int ml_phys_read(
112 unsigned int ml_phys_read_64(
114 unsigned int ml_phys_read_word(
116 unsigned int ml_phys_read_word_64(
119 /* Read physical address double word */
120 unsigned long long ml_phys_read_double(
122 unsigned long long ml_phys_read_double_64(
125 /* Write physical address byte */
126 void ml_phys_write_byte(
127 vm_offset_t paddr
, unsigned int data
);
128 void ml_phys_write_byte_64(
129 addr64_t paddr
, unsigned int data
);
131 /* Write physical address half word */
132 void ml_phys_write_half(
133 vm_offset_t paddr
, unsigned int data
);
134 void ml_phys_write_half_64(
135 addr64_t paddr
, unsigned int data
);
137 /* Write physical address word */
139 vm_offset_t paddr
, unsigned int data
);
140 void ml_phys_write_64(
141 addr64_t paddr
, unsigned int data
);
142 void ml_phys_write_word(
143 vm_offset_t paddr
, unsigned int data
);
144 void ml_phys_write_word_64(
145 addr64_t paddr
, unsigned int data
);
147 /* Write physical address double word */
148 void ml_phys_write_double(
149 vm_offset_t paddr
, unsigned long long data
);
150 void ml_phys_write_double_64(
151 addr64_t paddr
, unsigned long long data
);
153 /* Struct for ml_processor_register */
154 struct ml_processor_info
{
157 vm_offset_t start_paddr
;
158 boolean_t supports_nap
;
159 unsigned long l2cr_value
;
160 time_base_enable_t time_base_enable
;
161 uint32_t power_mode_0
;
162 uint32_t power_mode_1
;
165 typedef struct ml_processor_info ml_processor_info_t
;
167 /* Register a processor */
168 kern_return_t
ml_processor_register(
169 ml_processor_info_t
*processor_info
,
170 processor_t
*processor
,
171 ipi_handler_t
*ipi_handler
);
173 /* Zero bytes starting at a physical address */
175 addr64_t phys_address
,
178 #endif /* __APPLE_API_UNSTABLE */
180 #ifdef __APPLE_API_PRIVATE
181 #if defined(PEXPERT_KERNEL_PRIVATE) || defined(MACH_KERNEL_PRIVATE)
182 /* IO memory map services */
184 /* Map memory map IO space */
185 vm_offset_t
ml_io_map(
186 vm_offset_t phys_addr
,
189 /* boot memory allocation */
190 vm_offset_t
ml_static_malloc(
193 #endif /* PEXPERT_KERNEL_PRIVATE || MACH_KERNEL_PRIVATE */
195 #ifdef MACH_KERNEL_PRIVATE
196 void ml_init_interrupt(void);
198 boolean_t
fake_get_interrupts_enabled(void);
200 boolean_t
fake_set_interrupts_enabled(
203 void machine_idle(void);
205 void machine_signal_idle(
206 processor_t processor
);
208 void cacheInit(void);
210 void cacheDisable(void);
212 void ml_thrm_init(void);
213 unsigned int ml_read_temp(void);
219 unsigned int ml_throttle(
222 void ml_init_lock_timeout(void);
224 #endif /* MACH_KERNEL_PRIVATE */
226 void ml_thread_policy(
229 unsigned policy_info
);
231 #define MACHINE_GROUP 0x00000001
232 #define MACHINE_NETWORK_GROUP 0x10000000
233 #define MACHINE_NETWORK_WORKLOOP 0x00000001
234 #define MACHINE_NETWORK_NETISR 0x00000002
236 /* Initialize the maximum number of CPUs */
237 void ml_init_max_cpus(
238 unsigned long max_cpus
);
240 /* Return the maximum number of CPUs set by ml_init_max_cpus() */
244 /* Return the current number of CPUs */
245 int ml_get_current_cpus(
248 /* Struct for ml_cpu_get_info */
250 unsigned long vector_unit
;
251 unsigned long cache_line_size
;
252 unsigned long l1_icache_size
;
253 unsigned long l1_dcache_size
;
254 unsigned long l2_settings
;
255 unsigned long l2_cache_size
;
256 unsigned long l3_settings
;
257 unsigned long l3_cache_size
;
260 typedef struct ml_cpu_info ml_cpu_info_t
;
262 /* Get processor info */
263 void ml_cpu_get_info(ml_cpu_info_t
*cpu_info
);
265 void ml_set_processor_speed(unsigned long speed
);
266 void ml_set_processor_voltage(unsigned long voltage
);
267 unsigned int ml_scom_write(uint32_t reg
, uint64_t data
);
268 unsigned int ml_scom_read(uint32_t reg
, uint64_t *data
);
270 #endif /* __APPLE_API_PRIVATE */
272 #endif /* _PPC_MACHINE_ROUTINES_H_ */