]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
3a60a9f5 | 2 | * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved. |
1c79356b | 3 | * |
8f6c56a5 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
1c79356b | 5 | * |
8f6c56a5 A |
6 | * This file contains Original Code and/or Modifications of Original Code |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. The rights granted to you under the License | |
10 | * may not be used to create, or enable the creation or redistribution of, | |
11 | * unlawful or unlicensed copies of an Apple operating system, or to | |
12 | * circumvent, violate, or enable the circumvention or violation of, any | |
13 | * terms of an Apple operating system software license agreement. | |
14 | * | |
15 | * Please obtain a copy of the License at | |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
17 | * | |
18 | * The Original Code and all software distributed under the License are | |
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
23 | * Please see the License for the specific language governing rights and | |
8ad349bb | 24 | * limitations under the License. |
8f6c56a5 A |
25 | * |
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ | |
1c79356b A |
27 | */ |
28 | /* | |
29 | * @OSF_COPYRIGHT@ | |
30 | */ | |
31 | /* | |
32 | * @APPLE_FREE_COPYRIGHT@ | |
33 | */ | |
34 | #include <kern/misc_protos.h> | |
35 | #include <kern/assert.h> | |
36 | #include <kern/thread.h> | |
37 | #include <kern/counters.h> | |
38 | #include <ppc/misc_protos.h> | |
55e303ae | 39 | #include <ppc/trap.h> |
1c79356b A |
40 | #include <ppc/proc_reg.h> |
41 | #include <ppc/exception.h> | |
42 | #include <ppc/savearea.h> | |
43 | #include <pexpert/pexpert.h> | |
1c79356b A |
44 | #include <sys/kdebug.h> |
45 | ||
91447636 A |
46 | perfCallback perfIntHook = 0; /* Pointer to CHUD trap hook routine */ |
47 | ||
48 | void unresolved_kernel_trap(int trapno, | |
49 | struct savearea *ssp, | |
50 | unsigned int dsisr, | |
51 | addr64_t dar, | |
52 | const char *message); | |
55e303ae | 53 | |
9bccf70c | 54 | struct savearea * interrupt( |
1c79356b | 55 | int type, |
9bccf70c | 56 | struct savearea *ssp, |
1c79356b A |
57 | unsigned int dsisr, |
58 | unsigned int dar) | |
59 | { | |
483a1d10 | 60 | int current_cpu; |
91447636 | 61 | struct per_proc_info *proc_info; |
0b4e3aa0 | 62 | uint64_t now; |
91447636 | 63 | thread_t thread; |
1c79356b A |
64 | |
65 | disable_preemption(); | |
55e303ae A |
66 | |
67 | if(perfIntHook) { /* Is there a hook? */ | |
68 | if(perfIntHook(type, ssp, dsisr, dar) == KERN_SUCCESS) return ssp; /* If it succeeds, we are done... */ | |
69 | } | |
1c79356b | 70 | |
9bccf70c A |
71 | #if 0 |
72 | { | |
73 | extern void fctx_text(void); | |
74 | fctx_test(); | |
75 | } | |
76 | #endif | |
91447636 A |
77 | |
78 | ||
1c79356b | 79 | current_cpu = cpu_number(); |
91447636 | 80 | proc_info = getPerProc(); |
1c79356b A |
81 | |
82 | switch (type) { | |
83 | ||
1c79356b A |
84 | case T_DECREMENTER: |
85 | KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_DECI, 0) | DBG_FUNC_NONE, | |
55e303ae | 86 | isync_mfdec(), (unsigned int)ssp->save_srr0, 0, 0, 0); |
1c79356b A |
87 | |
88 | #if 0 | |
89 | if (pcsample_enable) { | |
91447636 A |
90 | if (find_user_regs(current_thread())) |
91 | add_pcsamples (user_pc(current_thread())); | |
1c79356b A |
92 | } |
93 | #endif | |
94 | ||
3a60a9f5 A |
95 | now = mach_absolute_time(); /* Find out what time it is */ |
96 | ||
97 | if(now >= proc_info->pms.pmsPop) { /* Is it time for power management state change? */ | |
98 | pmsStep(1); /* Yes, advance step */ | |
99 | now = mach_absolute_time(); /* Get the time again since we ran a bit */ | |
100 | } | |
101 | ||
91447636 A |
102 | thread = current_thread(); /* Find ourselves */ |
103 | if(thread->machine.qactTimer != 0) { /* Is the timer set? */ | |
91447636 A |
104 | if (thread->machine.qactTimer <= now) { /* It is set, has it popped? */ |
105 | thread->machine.qactTimer = 0; /* Clear single shot timer */ | |
106 | if((unsigned int)thread->machine.vmmControl & 0xFFFFFFFE) { /* Are there any virtual machines? */ | |
107 | vmm_timer_pop(thread); /* Yes, check out them out... */ | |
1c79356b A |
108 | } |
109 | } | |
110 | } | |
111 | ||
8f6c56a5 | 112 | rtclock_intr(ssp); |
1c79356b A |
113 | break; |
114 | ||
115 | case T_INTERRUPT: | |
116 | /* Call the platform interrupt routine */ | |
117 | counter_always(c_incoming_interrupts++); | |
118 | ||
119 | KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_INTR, 0) | DBG_FUNC_START, | |
55e303ae | 120 | current_cpu, (unsigned int)ssp->save_srr0, 0, 0, 0); |
1c79356b | 121 | |
91447636 A |
122 | proc_info->interrupt_handler( |
123 | proc_info->interrupt_target, | |
124 | proc_info->interrupt_refCon, | |
125 | proc_info->interrupt_nub, | |
126 | proc_info->interrupt_source); | |
1c79356b A |
127 | |
128 | KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_INTR, 0) | DBG_FUNC_END, | |
129 | 0, 0, 0, 0, 0); | |
130 | ||
131 | break; | |
132 | ||
133 | case T_SIGP: | |
134 | /* Did the other processor signal us? */ | |
135 | cpu_signal_handler(); | |
136 | break; | |
137 | ||
138 | case T_SHUTDOWN: | |
139 | cpu_doshutdown(); | |
140 | panic("returning from cpu_doshutdown()\n"); | |
141 | break; | |
142 | ||
143 | ||
144 | default: | |
3a60a9f5 A |
145 | if (!Call_Debugger(type, ssp)) |
146 | unresolved_kernel_trap(type, ssp, dsisr, dar, NULL); | |
1c79356b A |
147 | break; |
148 | } | |
149 | ||
150 | enable_preemption(); | |
151 | return ssp; | |
152 | } |