]> git.saurik.com Git - apple/xnu.git/blob - osfmk/ppc/machine_routines.h
xnu-124.13.tar.gz
[apple/xnu.git] / osfmk / ppc / machine_routines.h
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
34
35 #if defined(PEXPERT_KERNEL_PRIVATE) || defined(MACH_KERNEL_PRIVATE)
36 /* IO memory map services */
37
38 /* Map memory map IO space */
39 vm_offset_t ml_io_map(
40 vm_offset_t phys_addr,
41 vm_size_t size);
42
43 /* boot memory allocation */
44 vm_offset_t ml_static_malloc(
45 vm_size_t size);
46 #endif
47
48 vm_offset_t
49 ml_static_ptovirt(
50 vm_offset_t);
51
52 void ml_static_mfree(
53 vm_offset_t,
54 vm_size_t);
55
56 /* virtual to physical on wired pages */
57 vm_offset_t ml_vtophys(
58 vm_offset_t vaddr);
59
60 /* Init Interrupts */
61 void ml_install_interrupt_handler(
62 void *nub,
63 int source,
64 void *target,
65 IOInterruptHandler handler,
66 void *refCon);
67
68 #ifdef MACH_KERNEL_PRIVATE
69 void ml_init_interrupt(void);
70
71 boolean_t fake_get_interrupts_enabled(void);
72
73 boolean_t fake_set_interrupts_enabled(
74 boolean_t enable);
75 #endif
76
77 /* Get Interrupts Enabled */
78 boolean_t ml_get_interrupts_enabled(void);
79
80 /* Set Interrupts Enabled */
81 boolean_t ml_set_interrupts_enabled(boolean_t enable);
82
83 /* Check if running at interrupt context */
84 boolean_t ml_at_interrupt_context(void);
85
86 /* Generate a fake interrupt */
87 void ml_cause_interrupt(void);
88
89 #ifdef MACH_KERNEL_PRIVATE
90 /* check pending timers */
91 void machine_clock_assist(void);
92
93 void machine_idle(void);
94
95 void machine_signal_idle(
96 processor_t processor);
97 #endif
98
99 /* PCI config cycle probing */
100 boolean_t ml_probe_read(
101 vm_offset_t paddr,
102 unsigned int *val);
103
104 /* Read physical address byte */
105 unsigned int ml_phys_read_byte(
106 vm_offset_t paddr);
107
108 /* Read physical address */
109 unsigned int ml_phys_read(
110 vm_offset_t paddr);
111
112 /* Write physical address byte */
113 void ml_phys_write_byte(
114 vm_offset_t paddr, unsigned int data);
115
116 /* Write physical address */
117 void ml_phys_write(
118 vm_offset_t paddr, unsigned int data);
119
120 /* Type for the IPI Hander */
121 typedef void (*ipi_handler_t)(void);
122
123 /* Type for the Time Base Enable function */
124 typedef void (*time_base_enable_t)(cpu_id_t cpu_id, boolean_t enable);
125
126 /* Struct for ml_processor_register */
127 struct ml_processor_info_t {
128 cpu_id_t cpu_id;
129 boolean_t boot_cpu;
130 vm_offset_t start_paddr;
131 boolean_t supports_nap;
132 unsigned long l2cr_value;
133 time_base_enable_t time_base_enable;
134 };
135
136 typedef struct ml_processor_info_t ml_processor_info_t;
137
138 /* Register a processor */
139 kern_return_t ml_processor_register(
140 ml_processor_info_t *processor_info,
141 processor_t *processor,
142 ipi_handler_t *ipi_handler);
143
144 /* enables (or disables) the processor nap mode the function returns the previous value*/
145 boolean_t ml_enable_nap(
146 int target_cpu,
147 boolean_t nap_enabled);
148
149 /* Put the processor to sleep */
150 void ml_ppc_sleep(void);
151
152 /* Struct for ml_ppc_get_cpu_info */
153 struct ml_ppc_cpu_info_t {
154 unsigned long vector_unit;
155 unsigned long cache_line_size;
156 unsigned long l1_icache_size;
157 unsigned long l1_dcache_size;
158 unsigned long l2_settings;
159 unsigned long l2_cache_size;
160 unsigned long l3_settings;
161 unsigned long l3_cache_size;
162 };
163
164 typedef struct ml_ppc_cpu_info_t ml_ppc_cpu_info_t;
165
166 /* Get processor info */
167 void ml_ppc_get_info(ml_ppc_cpu_info_t *cpu_info);
168
169 #ifdef MACH_KERNEL_PRIVATE
170 void cacheInit(void);
171
172 void cacheDisable(void);
173
174 void ml_thrm_init(void);
175 unsigned int ml_read_temp(void);
176
177 void ml_thrm_set(
178 unsigned int low,
179 unsigned int high);
180
181 unsigned int ml_throttle(
182 unsigned int);
183 #endif
184
185 void ml_get_timebase(unsigned long long *timstamp);
186 void ml_sense__nmi(void);
187
188 #endif /* _PPC_MACHINE_ROUTINES_H_ */