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