2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
29 #ifndef _I386_MACHINE_ROUTINES_H_
30 #define _I386_MACHINE_ROUTINES_H_
32 #include <mach/mach_types.h>
33 #include <mach/boolean.h>
34 #include <kern/kern_types.h>
35 #include <pexpert/pexpert.h>
37 #include <sys/appleapiopts.h>
39 /* Interrupt handling */
41 /* Get Interrupts Enabled */
42 boolean_t
ml_get_interrupts_enabled(void);
44 /* Set Interrupts Enabled */
45 boolean_t
ml_set_interrupts_enabled(boolean_t enable
);
47 /* Check if running at interrupt context */
48 boolean_t
ml_at_interrupt_context(void);
50 /* Generate a fake interrupt */
51 void ml_cause_interrupt(void);
53 void ml_get_timebase(unsigned long long *timestamp
);
55 /* Type for the IPI Hander */
56 typedef void (*ipi_handler_t
)(void);
58 /* Register a processor */
59 kern_return_t
ml_processor_register(
61 vm_offset_t start_paddr
,
62 processor_t
*processor
,
63 ipi_handler_t
*ipi_handler
,
66 /* Initialize Interrupts */
67 void ml_install_interrupt_handler(
71 IOInterruptHandler handler
,
74 #ifdef __APPLE_API_UNSTABLE
79 /* PCI config cycle probing */
80 boolean_t
ml_probe_read(
84 /* Read physical address byte */
85 unsigned int ml_phys_read_byte(
88 /* Read physical address half word */
89 unsigned int ml_phys_read_half(
92 /* Read physical address word*/
93 unsigned int ml_phys_read(
95 unsigned int ml_phys_read_word(
98 /* Read physical address double word */
99 unsigned long long ml_phys_read_double(
102 /* Write physical address byte */
103 void ml_phys_write_byte(
104 vm_offset_t paddr
, unsigned int data
);
106 /* Write physical address half word */
107 void ml_phys_write_half(
108 vm_offset_t paddr
, unsigned int data
);
110 /* Write physical address word */
112 vm_offset_t paddr
, unsigned int data
);
113 void ml_phys_write_word(
114 vm_offset_t paddr
, unsigned int data
);
116 /* Write physical address double word */
117 void ml_phys_write_double(
118 vm_offset_t paddr
, unsigned long long data
);
120 void ml_static_mfree(
124 /* virtual to physical on wired pages */
125 vm_offset_t
ml_vtophys(
128 /* Struct for ml_cpu_get_info */
130 unsigned long vector_unit
;
131 unsigned long cache_line_size
;
132 unsigned long l1_icache_size
;
133 unsigned long l1_dcache_size
;
134 unsigned long l2_settings
;
135 unsigned long l2_cache_size
;
136 unsigned long l3_settings
;
137 unsigned long l3_cache_size
;
140 typedef struct ml_cpu_info ml_cpu_info_t
;
142 /* Get processor info */
143 void ml_cpu_get_info(ml_cpu_info_t
*cpu_info
);
145 #endif /* __APPLE_API_UNSTABLE */
147 #ifdef __APPLE_API_PRIVATE
148 #if defined(PEXPERT_KERNEL_PRIVATE) || defined(MACH_KERNEL_PRIVATE)
149 /* IO memory map services */
151 /* Map memory map IO space */
152 vm_offset_t
ml_io_map(
153 vm_offset_t phys_addr
,
156 /* boot memory allocation */
157 vm_offset_t
ml_static_malloc(
160 #endif /* PEXPERT_KERNEL_PRIVATE || MACH_KERNEL_PRIVATE */
162 #ifdef MACH_KERNEL_PRIVATE
163 /* check pending timers */
164 #define machine_clock_assist()
166 void machine_idle(void);
168 void machine_signal_idle(
169 processor_t processor
);
170 #endif /* MACH_KERNEL_PRIVATE */
172 void ml_thread_policy(
175 unsigned policy_info
);
177 #define MACHINE_GROUP 0x00000001
178 #define MACHINE_NETWORK_GROUP 0x10000000
179 #define MACHINE_NETWORK_WORKLOOP 0x00000001
180 #define MACHINE_NETWORK_NETISR 0x00000002
182 /* Initialize the maximum number of CPUs */
183 void ml_init_max_cpus(
184 unsigned long max_cpus
);
186 /* Return the maximum number of CPUs set by ml_init_max_cpus() */
190 /* Return the current number of CPUs */
191 int ml_get_current_cpus(
194 #endif /* __APPLE_API_PRIVATE */
196 #endif /* _I386_MACHINE_ROUTINES_H_ */