]> git.saurik.com Git - apple/xnu.git/blame - osfmk/i386/machine_routines.c
xnu-201.42.3.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>
25
26/* IO memory map services */
27
28/* Map memory map IO space */
29vm_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 */
37vm_offset_t ml_static_malloc(
38 vm_size_t size)
39{
40 return((vm_offset_t)NULL);
41}
42
43vm_offset_t
44ml_static_ptovirt(
45 vm_offset_t paddr)
46{
47 return phystokv(paddr);
48}
49
50void
51ml_static_mfree(
52 vm_offset_t vaddr,
53 vm_size_t size)
54{
55 return;
56}
57
58/* virtual to physical on wired pages */
59vm_offset_t ml_vtophys(
60 vm_offset_t vaddr)
61{
62 return kvtophys(vaddr);
63}
64
65/* Interrupt handling */
66
67/* Get Interrupts Enabled */
68boolean_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 */
77boolean_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 */
92boolean_t ml_at_interrupt_context(void)
93{
94 return get_interrupt_level() != 0;
95}
96
97/* Generate a fake interrupt */
98void ml_cause_interrupt(void)
99{
100 panic("ml_cause_interrupt not defined yet on Intel");
101}
102
d52fe63f
A
103void ml_thread_policy(
104 thread_t thread,
105 unsigned policy_id,
106 unsigned policy_info)
107{
108 return;
109}
110
1c79356b
A
111/* Initialize Interrupts */
112void ml_install_interrupt_handler(
113 void *nub,
114 int source,
115 void *target,
116 IOInterruptHandler handler,
117 void *refCon)
118{
119 boolean_t current_state;
120
121 current_state = ml_get_interrupts_enabled();
122
123 PE_install_interrupt_handler(nub, source, target,
124 (IOInterruptHandler) handler, refCon);
125
126 (void) ml_set_interrupts_enabled(current_state);
127}
128
129void
130machine_signal_idle(
131 processor_t processor)
132{
133}
134
135/* Stubs for pc tracing mechanism */
136
137int *pc_trace_buf;
138int pc_trace_cnt = 0;
139
140int
141set_be_bit()
142{
143 return(0);
144}
145
146int
147clr_be_bit()
148{
149 return(0);
150}
151
152int
153be_tracing()
154{
155 return(0);
156}