]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
3a60a9f5 | 2 | * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved. |
1c79356b A |
3 | * |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
37839358 A |
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. | |
1c79356b | 11 | * |
37839358 A |
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 | |
1c79356b A |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
37839358 A |
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. | |
1c79356b A |
19 | * |
20 | * @APPLE_LICENSE_HEADER_END@ | |
21 | */ | |
22 | /* | |
23 | * @OSF_COPYRIGHT@ | |
24 | */ | |
25 | /* | |
26 | * @APPLE_FREE_COPYRIGHT@ | |
27 | */ | |
28 | #include <kern/misc_protos.h> | |
29 | #include <kern/assert.h> | |
30 | #include <kern/thread.h> | |
31 | #include <kern/counters.h> | |
c0fea474 A |
32 | #include <kern/etimer.h> |
33 | #include <kern/pms.h> | |
1c79356b | 34 | #include <ppc/misc_protos.h> |
55e303ae | 35 | #include <ppc/trap.h> |
1c79356b A |
36 | #include <ppc/proc_reg.h> |
37 | #include <ppc/exception.h> | |
38 | #include <ppc/savearea.h> | |
39 | #include <pexpert/pexpert.h> | |
1c79356b A |
40 | #include <sys/kdebug.h> |
41 | ||
91447636 A |
42 | perfCallback perfIntHook = 0; /* Pointer to CHUD trap hook routine */ |
43 | ||
44 | void unresolved_kernel_trap(int trapno, | |
45 | struct savearea *ssp, | |
46 | unsigned int dsisr, | |
47 | addr64_t dar, | |
48 | const char *message); | |
55e303ae | 49 | |
9bccf70c | 50 | struct savearea * interrupt( |
1c79356b | 51 | int type, |
9bccf70c | 52 | struct savearea *ssp, |
1c79356b A |
53 | unsigned int dsisr, |
54 | unsigned int dar) | |
55 | { | |
483a1d10 | 56 | int current_cpu; |
91447636 | 57 | struct per_proc_info *proc_info; |
0b4e3aa0 | 58 | uint64_t now; |
91447636 | 59 | thread_t thread; |
1c79356b A |
60 | |
61 | disable_preemption(); | |
55e303ae A |
62 | |
63 | if(perfIntHook) { /* Is there a hook? */ | |
64 | if(perfIntHook(type, ssp, dsisr, dar) == KERN_SUCCESS) return ssp; /* If it succeeds, we are done... */ | |
65 | } | |
1c79356b | 66 | |
9bccf70c A |
67 | #if 0 |
68 | { | |
69 | extern void fctx_text(void); | |
70 | fctx_test(); | |
71 | } | |
72 | #endif | |
91447636 A |
73 | |
74 | ||
1c79356b | 75 | current_cpu = cpu_number(); |
91447636 | 76 | proc_info = getPerProc(); |
1c79356b A |
77 | |
78 | switch (type) { | |
79 | ||
1c79356b A |
80 | case T_DECREMENTER: |
81 | KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_DECI, 0) | DBG_FUNC_NONE, | |
55e303ae | 82 | isync_mfdec(), (unsigned int)ssp->save_srr0, 0, 0, 0); |
1c79356b A |
83 | |
84 | #if 0 | |
85 | if (pcsample_enable) { | |
91447636 A |
86 | if (find_user_regs(current_thread())) |
87 | add_pcsamples (user_pc(current_thread())); | |
1c79356b A |
88 | } |
89 | #endif | |
90 | ||
3a60a9f5 A |
91 | now = mach_absolute_time(); /* Find out what time it is */ |
92 | ||
93 | if(now >= proc_info->pms.pmsPop) { /* Is it time for power management state change? */ | |
94 | pmsStep(1); /* Yes, advance step */ | |
95 | now = mach_absolute_time(); /* Get the time again since we ran a bit */ | |
96 | } | |
97 | ||
91447636 A |
98 | thread = current_thread(); /* Find ourselves */ |
99 | if(thread->machine.qactTimer != 0) { /* Is the timer set? */ | |
91447636 A |
100 | if (thread->machine.qactTimer <= now) { /* It is set, has it popped? */ |
101 | thread->machine.qactTimer = 0; /* Clear single shot timer */ | |
102 | if((unsigned int)thread->machine.vmmControl & 0xFFFFFFFE) { /* Are there any virtual machines? */ | |
103 | vmm_timer_pop(thread); /* Yes, check out them out... */ | |
1c79356b A |
104 | } |
105 | } | |
106 | } | |
107 | ||
c0fea474 | 108 | etimer_intr(USER_MODE(ssp->save_srr1), ssp->save_srr0); /* Handle event timer */ |
1c79356b A |
109 | break; |
110 | ||
111 | case T_INTERRUPT: | |
112 | /* Call the platform interrupt routine */ | |
113 | counter_always(c_incoming_interrupts++); | |
114 | ||
115 | KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_INTR, 0) | DBG_FUNC_START, | |
55e303ae | 116 | current_cpu, (unsigned int)ssp->save_srr0, 0, 0, 0); |
1c79356b | 117 | |
91447636 A |
118 | proc_info->interrupt_handler( |
119 | proc_info->interrupt_target, | |
120 | proc_info->interrupt_refCon, | |
121 | proc_info->interrupt_nub, | |
122 | proc_info->interrupt_source); | |
1c79356b A |
123 | |
124 | KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_INTR, 0) | DBG_FUNC_END, | |
125 | 0, 0, 0, 0, 0); | |
126 | ||
127 | break; | |
128 | ||
129 | case T_SIGP: | |
130 | /* Did the other processor signal us? */ | |
131 | cpu_signal_handler(); | |
132 | break; | |
133 | ||
134 | case T_SHUTDOWN: | |
135 | cpu_doshutdown(); | |
136 | panic("returning from cpu_doshutdown()\n"); | |
137 | break; | |
138 | ||
139 | ||
140 | default: | |
3a60a9f5 A |
141 | if (!Call_Debugger(type, ssp)) |
142 | unresolved_kernel_trap(type, ssp, dsisr, dar, NULL); | |
1c79356b A |
143 | break; |
144 | } | |
145 | ||
146 | enable_preemption(); | |
147 | return ssp; | |
148 | } |