]> git.saurik.com Git - apple/xnu.git/blame - osfmk/i386/machine_routines.c
xnu-344.21.73.tar.gz
[apple/xnu.git] / osfmk / i386 / machine_routines.c
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
d7e50217 6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
1c79356b 7 *
d7e50217
A
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
13 * file.
14 *
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
1c79356b
A
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
d7e50217
A
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.
1c79356b
A
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25#include <i386/machine_routines.h>
26#include <i386/io_map_entries.h>
27#include <kern/cpu_data.h>
9bccf70c 28#include <kern/thread_act.h>
1c79356b
A
29
30/* IO memory map services */
31
32/* Map memory map IO space */
33vm_offset_t ml_io_map(
34 vm_offset_t phys_addr,
35 vm_size_t size)
36{
37 return(io_map(phys_addr,size));
38}
39
40/* boot memory allocation */
41vm_offset_t ml_static_malloc(
42 vm_size_t size)
43{
44 return((vm_offset_t)NULL);
45}
46
47vm_offset_t
48ml_static_ptovirt(
49 vm_offset_t paddr)
50{
51 return phystokv(paddr);
52}
53
54void
55ml_static_mfree(
56 vm_offset_t vaddr,
57 vm_size_t size)
58{
59 return;
60}
61
62/* virtual to physical on wired pages */
63vm_offset_t ml_vtophys(
64 vm_offset_t vaddr)
65{
66 return kvtophys(vaddr);
67}
68
69/* Interrupt handling */
70
71/* Get Interrupts Enabled */
72boolean_t ml_get_interrupts_enabled(void)
73{
74 unsigned long flags;
75
76 __asm__ volatile("pushf; popl %0" : "=r" (flags));
77 return (flags & EFL_IF) != 0;
78}
79
80/* Set Interrupts Enabled */
81boolean_t ml_set_interrupts_enabled(boolean_t enable)
82{
83 unsigned long flags;
84
85 __asm__ volatile("pushf; popl %0" : "=r" (flags));
86
87 if (enable)
88 __asm__ volatile("sti");
89 else
90 __asm__ volatile("cli");
91
92 return (flags & EFL_IF) != 0;
93}
94
95/* Check if running at interrupt context */
96boolean_t ml_at_interrupt_context(void)
97{
98 return get_interrupt_level() != 0;
99}
100
101/* Generate a fake interrupt */
102void ml_cause_interrupt(void)
103{
104 panic("ml_cause_interrupt not defined yet on Intel");
105}
106
d52fe63f
A
107void ml_thread_policy(
108 thread_t thread,
109 unsigned policy_id,
110 unsigned policy_info)
111{
112 return;
113}
114
1c79356b
A
115/* Initialize Interrupts */
116void ml_install_interrupt_handler(
117 void *nub,
118 int source,
119 void *target,
120 IOInterruptHandler handler,
121 void *refCon)
122{
123 boolean_t current_state;
124
125 current_state = ml_get_interrupts_enabled();
126
127 PE_install_interrupt_handler(nub, source, target,
128 (IOInterruptHandler) handler, refCon);
129
130 (void) ml_set_interrupts_enabled(current_state);
131}
132
133void
134machine_signal_idle(
135 processor_t processor)
136{
137}
138
d7e50217
A
139void
140ml_cpu_get_info(ml_cpu_info_t *cpu_info)
141{
142}
143
144void
145ml_init_max_cpus(unsigned long max_cpus)
146{
147}
148
149int
150ml_get_max_cpus(void)
151{
152 return(machine_info.max_cpus);
153}
154
155int
156ml_get_current_cpus(void)
157{
158 return machine_info.avail_cpus;
159}
160
1c79356b
A
161/* Stubs for pc tracing mechanism */
162
163int *pc_trace_buf;
164int pc_trace_cnt = 0;
165
166int
167set_be_bit()
168{
169 return(0);
170}
171
172int
173clr_be_bit()
174{
175 return(0);
176}
177
178int
179be_tracing()
180{
181 return(0);
182}
9bccf70c
A
183
184#undef current_act
185thread_act_t
186current_act(void)
187{
188 return(current_act_fast());
189}