]> git.saurik.com Git - apple/xnu.git/blame - osfmk/i386/machine_routines.c
xnu-344.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 *
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#include <i386/machine_routines.h>
23#include <i386/io_map_entries.h>
24#include <kern/cpu_data.h>
9bccf70c 25#include <kern/thread_act.h>
1c79356b
A
26
27/* IO memory map services */
28
29/* Map memory map IO space */
30vm_offset_t ml_io_map(
31 vm_offset_t phys_addr,
32 vm_size_t size)
33{
34 return(io_map(phys_addr,size));
35}
36
37/* boot memory allocation */
38vm_offset_t ml_static_malloc(
39 vm_size_t size)
40{
41 return((vm_offset_t)NULL);
42}
43
44vm_offset_t
45ml_static_ptovirt(
46 vm_offset_t paddr)
47{
48 return phystokv(paddr);
49}
50
51void
52ml_static_mfree(
53 vm_offset_t vaddr,
54 vm_size_t size)
55{
56 return;
57}
58
59/* virtual to physical on wired pages */
60vm_offset_t ml_vtophys(
61 vm_offset_t vaddr)
62{
63 return kvtophys(vaddr);
64}
65
66/* Interrupt handling */
67
68/* Get Interrupts Enabled */
69boolean_t ml_get_interrupts_enabled(void)
70{
71 unsigned long flags;
72
73 __asm__ volatile("pushf; popl %0" : "=r" (flags));
74 return (flags & EFL_IF) != 0;
75}
76
77/* Set Interrupts Enabled */
78boolean_t ml_set_interrupts_enabled(boolean_t enable)
79{
80 unsigned long flags;
81
82 __asm__ volatile("pushf; popl %0" : "=r" (flags));
83
84 if (enable)
85 __asm__ volatile("sti");
86 else
87 __asm__ volatile("cli");
88
89 return (flags & EFL_IF) != 0;
90}
91
92/* Check if running at interrupt context */
93boolean_t ml_at_interrupt_context(void)
94{
95 return get_interrupt_level() != 0;
96}
97
98/* Generate a fake interrupt */
99void ml_cause_interrupt(void)
100{
101 panic("ml_cause_interrupt not defined yet on Intel");
102}
103
d52fe63f
A
104void ml_thread_policy(
105 thread_t thread,
106 unsigned policy_id,
107 unsigned policy_info)
108{
109 return;
110}
111
1c79356b
A
112/* Initialize Interrupts */
113void ml_install_interrupt_handler(
114 void *nub,
115 int source,
116 void *target,
117 IOInterruptHandler handler,
118 void *refCon)
119{
120 boolean_t current_state;
121
122 current_state = ml_get_interrupts_enabled();
123
124 PE_install_interrupt_handler(nub, source, target,
125 (IOInterruptHandler) handler, refCon);
126
127 (void) ml_set_interrupts_enabled(current_state);
128}
129
130void
131machine_signal_idle(
132 processor_t processor)
133{
134}
135
136/* Stubs for pc tracing mechanism */
137
138int *pc_trace_buf;
139int pc_trace_cnt = 0;
140
141int
142set_be_bit()
143{
144 return(0);
145}
146
147int
148clr_be_bit()
149{
150 return(0);
151}
152
153int
154be_tracing()
155{
156 return(0);
157}
9bccf70c
A
158
159#undef current_act
160thread_act_t
161current_act(void)
162{
163 return(current_act_fast());
164}