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@
25 #include <i386/machine_routines.h>
26 #include <i386/io_map_entries.h>
27 #include <kern/cpu_data.h>
28 #include <kern/thread_act.h>
30 /* IO memory map services */
32 /* Map memory map IO space */
33 vm_offset_t
ml_io_map(
34 vm_offset_t phys_addr
,
37 return(io_map(phys_addr
,size
));
40 /* boot memory allocation */
41 vm_offset_t
ml_static_malloc(
44 return((vm_offset_t
)NULL
);
51 return phystokv(paddr
);
62 /* virtual to physical on wired pages */
63 vm_offset_t
ml_vtophys(
66 return kvtophys(vaddr
);
69 /* Interrupt handling */
71 /* Get Interrupts Enabled */
72 boolean_t
ml_get_interrupts_enabled(void)
76 __asm__
volatile("pushf; popl %0" : "=r" (flags
));
77 return (flags
& EFL_IF
) != 0;
80 /* Set Interrupts Enabled */
81 boolean_t
ml_set_interrupts_enabled(boolean_t enable
)
85 __asm__
volatile("pushf; popl %0" : "=r" (flags
));
88 __asm__
volatile("sti");
90 __asm__
volatile("cli");
92 return (flags
& EFL_IF
) != 0;
95 /* Check if running at interrupt context */
96 boolean_t
ml_at_interrupt_context(void)
98 return get_interrupt_level() != 0;
101 /* Generate a fake interrupt */
102 void ml_cause_interrupt(void)
104 panic("ml_cause_interrupt not defined yet on Intel");
107 void ml_thread_policy(
110 unsigned policy_info
)
115 /* Initialize Interrupts */
116 void ml_install_interrupt_handler(
120 IOInterruptHandler handler
,
123 boolean_t current_state
;
125 current_state
= ml_get_interrupts_enabled();
127 PE_install_interrupt_handler(nub
, source
, target
,
128 (IOInterruptHandler
) handler
, refCon
);
130 (void) ml_set_interrupts_enabled(current_state
);
135 processor_t processor
)
140 ml_cpu_get_info(ml_cpu_info_t
*cpu_info
)
145 ml_init_max_cpus(unsigned long max_cpus
)
150 ml_get_max_cpus(void)
152 return(machine_info
.max_cpus
);
156 ml_get_current_cpus(void)
158 return machine_info
.avail_cpus
;
161 /* Stubs for pc tracing mechanism */
164 int pc_trace_cnt
= 0;
188 return(current_act_fast());