]> git.saurik.com Git - apple/xnu.git/blob - pexpert/i386/pe_interrupt.c
xnu-517.tar.gz
[apple/xnu.git] / pexpert / i386 / pe_interrupt.c
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
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
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.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25 #include <pexpert/pexpert.h>
26 #include <pexpert/protos.h>
27 #include <machine/machine_routines.h>
28 #include <i386/machine_cpu.h>
29 #include <i386/mp.h>
30 #include <sys/kdebug.h>
31
32 struct i386_interrupt_handler {
33 IOInterruptHandler handler;
34 void *nub;
35 void *target;
36 void *refCon;
37 };
38
39 typedef struct i386_interrupt_handler i386_interrupt_handler_t;
40
41 i386_interrupt_handler_t PE_interrupt_handler;
42
43 void PE_platform_interrupt_initialize(void)
44 {
45 }
46
47
48
49 void
50 PE_incoming_interrupt(int interrupt, void *state)
51 {
52 i386_interrupt_handler_t *vector;
53
54 KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_INTR, 0) | DBG_FUNC_START,
55 0, ((unsigned int *)state)[5], 0, 0, 0);
56
57 vector = &PE_interrupt_handler;
58
59 switch (interrupt) {
60 case APIC_ERROR_INTERRUPT:
61 case SPURIOUS_INTERRUPT:
62 case INTERPROCESS_INTERRUPT:
63 lapic_interrupt(interrupt, state);
64 break;
65 default:
66 vector->handler(vector->target, state, vector->nub, interrupt);
67 }
68
69 KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_INTR, 0) | DBG_FUNC_END,
70 0, 0, 0, 0, 0);
71 }
72
73 void PE_install_interrupt_handler(void *nub, int source,
74 void *target,
75 IOInterruptHandler handler,
76 void *refCon)
77 {
78 i386_interrupt_handler_t *vector;
79
80 vector = &PE_interrupt_handler;
81
82 /*vector->source = source; IGNORED */
83 vector->handler = handler;
84 vector->nub = nub;
85 vector->target = target;
86 vector->refCon = refCon;
87 }