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 <pexpert/pexpert.h>
34 #include <sys/appleapiopts.h>
36 /* Get Interrupts Enabled */
37 boolean_t
ml_get_interrupts_enabled(void);
39 /* Set Interrupts Enabled */
40 boolean_t
ml_set_interrupts_enabled(boolean_t enable
);
42 /* Check if running at interrupt context */
43 boolean_t
ml_at_interrupt_context(void);
45 /* Generate a fake interrupt */
46 void ml_cause_interrupt(void);
48 /* Type for the IPI Hander */
49 typedef void (*ipi_handler_t
)(void);
51 /* Type for the Time Base Enable function */
52 typedef void (*time_base_enable_t
)(cpu_id_t cpu_id
, boolean_t enable
);
54 /* enables (or disables) the processor nap mode the function returns the previous value*/
55 boolean_t
ml_enable_nap(
57 boolean_t nap_enabled
);
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);
64 int ml_enable_cache_level(int cache_level
, int enable
);
71 void ml_install_interrupt_handler(
75 IOInterruptHandler handler
,
78 #ifdef __APPLE_API_UNSTABLE
84 /* virtual to physical on wired pages */
85 vm_offset_t
ml_vtophys(
88 /* PCI config cycle probing */
89 boolean_t
ml_probe_read(
93 /* Read physical address byte */
94 unsigned int ml_phys_read_byte(
97 /* Read physical address */
98 unsigned int ml_phys_read(
101 /* Write physical address byte */
102 void ml_phys_write_byte(
103 vm_offset_t paddr
, unsigned int data
);
105 /* Write physical address */
107 vm_offset_t paddr
, unsigned int data
);
109 /* Struct for ml_processor_register */
110 struct ml_processor_info_t
{
113 vm_offset_t start_paddr
;
114 boolean_t supports_nap
;
115 unsigned long l2cr_value
;
116 time_base_enable_t time_base_enable
;
119 typedef struct ml_processor_info_t ml_processor_info_t
;
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
);
127 #endif /* __APPLE_API_UNSTABLE */
129 #ifdef __APPLE_API_PRIVATE
130 #if defined(PEXPERT_KERNEL_PRIVATE) || defined(MACH_KERNEL_PRIVATE)
131 /* IO memory map services */
133 /* Map memory map IO space */
134 vm_offset_t
ml_io_map(
135 vm_offset_t phys_addr
,
138 /* boot memory allocation */
139 vm_offset_t
ml_static_malloc(
142 #endif /* PEXPERT_KERNEL_PRIVATE || MACH_KERNEL_PRIVATE */
144 #ifdef MACH_KERNEL_PRIVATE
145 void ml_init_interrupt(void);
147 boolean_t
fake_get_interrupts_enabled(void);
149 boolean_t
fake_set_interrupts_enabled(
152 /* check pending timers */
153 void machine_clock_assist(void);
155 void machine_idle(void);
157 void machine_signal_idle(
158 processor_t processor
);
160 void cacheInit(void);
162 void cacheDisable(void);
164 void ml_thrm_init(void);
165 unsigned int ml_read_temp(void);
171 unsigned int ml_throttle(
174 #endif /* MACH_KERNEL_PRIVATE */
176 void ml_thread_policy(
179 unsigned policy_info
);
181 #define MACHINE_GROUP 0x00000001
182 #define MACHINE_NETWORK_GROUP 0x10000000
183 #define MACHINE_NETWORK_WORKLOOP 0x00000001
184 #define MACHINE_NETWORK_NETISR 0x00000002
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
;
198 typedef struct ml_ppc_cpu_info_t ml_ppc_cpu_info_t
;
200 /* Get processor info */
201 void ml_ppc_get_info(ml_ppc_cpu_info_t
*cpu_info
);
203 void ml_set_processor_speed(unsigned long speed
);
205 #endif /* __APPLE_API_PRIVATE */
207 #endif /* _PPC_MACHINE_ROUTINES_H_ */