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>
35 #if defined(PEXPERT_KERNEL_PRIVATE) || defined(MACH_KERNEL_PRIVATE)
36 /* IO memory map services */
38 /* Map memory map IO space */
39 vm_offset_t
ml_io_map(
40 vm_offset_t phys_addr
,
43 /* boot memory allocation */
44 vm_offset_t
ml_static_malloc(
56 /* virtual to physical on wired pages */
57 vm_offset_t
ml_vtophys(
61 void ml_install_interrupt_handler(
65 IOInterruptHandler handler
,
68 #ifdef MACH_KERNEL_PRIVATE
69 void ml_init_interrupt(void);
71 boolean_t
fake_get_interrupts_enabled(void);
73 boolean_t
fake_set_interrupts_enabled(
77 /* Get Interrupts Enabled */
78 boolean_t
ml_get_interrupts_enabled(void);
80 /* Set Interrupts Enabled */
81 boolean_t
ml_set_interrupts_enabled(boolean_t enable
);
83 /* Check if running at interrupt context */
84 boolean_t
ml_at_interrupt_context(void);
86 /* Generate a fake interrupt */
87 void ml_cause_interrupt(void);
89 void ml_thread_policy(
92 unsigned policy_info
);
94 #define MACHINE_GROUP 0x00000001
95 #define MACHINE_NETWORK_GROUP 0x10000000
96 #define MACHINE_NETWORK_WORKLOOP 0x00000001
97 #define MACHINE_NETWORK_NETISR 0x00000002
99 #ifdef MACH_KERNEL_PRIVATE
100 /* check pending timers */
101 void machine_clock_assist(void);
103 void machine_idle(void);
105 void machine_signal_idle(
106 processor_t processor
);
109 /* PCI config cycle probing */
110 boolean_t
ml_probe_read(
114 /* Read physical address byte */
115 unsigned int ml_phys_read_byte(
118 /* Read physical address */
119 unsigned int ml_phys_read(
122 /* Write physical address byte */
123 void ml_phys_write_byte(
124 vm_offset_t paddr
, unsigned int data
);
126 /* Write physical address */
128 vm_offset_t paddr
, unsigned int data
);
130 /* Type for the IPI Hander */
131 typedef void (*ipi_handler_t
)(void);
133 /* Type for the Time Base Enable function */
134 typedef void (*time_base_enable_t
)(cpu_id_t cpu_id
, boolean_t enable
);
136 /* Struct for ml_processor_register */
137 struct ml_processor_info_t
{
140 vm_offset_t start_paddr
;
141 boolean_t supports_nap
;
142 unsigned long l2cr_value
;
143 time_base_enable_t time_base_enable
;
146 typedef struct ml_processor_info_t ml_processor_info_t
;
148 /* Register a processor */
149 kern_return_t
ml_processor_register(
150 ml_processor_info_t
*processor_info
,
151 processor_t
*processor
,
152 ipi_handler_t
*ipi_handler
);
154 /* enables (or disables) the processor nap mode the function returns the previous value*/
155 boolean_t
ml_enable_nap(
157 boolean_t nap_enabled
);
159 /* Put the processor to sleep */
160 void ml_ppc_sleep(void);
162 /* Struct for ml_ppc_get_cpu_info */
163 struct ml_ppc_cpu_info_t
{
164 unsigned long vector_unit
;
165 unsigned long cache_line_size
;
166 unsigned long l1_icache_size
;
167 unsigned long l1_dcache_size
;
168 unsigned long l2_settings
;
169 unsigned long l2_cache_size
;
170 unsigned long l3_settings
;
171 unsigned long l3_cache_size
;
174 typedef struct ml_ppc_cpu_info_t ml_ppc_cpu_info_t
;
176 /* Get processor info */
177 void ml_ppc_get_info(ml_ppc_cpu_info_t
*cpu_info
);
179 #ifdef MACH_KERNEL_PRIVATE
180 void cacheInit(void);
182 void cacheDisable(void);
184 void ml_thrm_init(void);
185 unsigned int ml_read_temp(void);
191 unsigned int ml_throttle(
195 void ml_get_timebase(unsigned long long *timstamp
);
196 void ml_sense__nmi(void);
198 int ml_enable_cache_level(int cache_level
, int enable
);
199 void ml_set_processor_speed(unsigned long speed
);
201 #endif /* _PPC_MACHINE_ROUTINES_H_ */