1 | /* |
---|
2 | * This program is free software; you can redistribute it and/or modify |
---|
3 | * it under the terms of the GNU General Public License as published by |
---|
4 | * the Free Software Foundation; either version 2 of the License, or |
---|
5 | * (at your option) any later version. |
---|
6 | * |
---|
7 | * This program is distributed in the hope that it will be useful, |
---|
8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
10 | * GNU General Public License for more details. |
---|
11 | * |
---|
12 | * You should have received a copy of the GNU General Public License |
---|
13 | * along with this program; if not, write to the Free Software |
---|
14 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
15 | * |
---|
16 | * Copyright (C) IBM Corp. 2005, 2006 |
---|
17 | * |
---|
18 | * Authors: Hollis Blanchard <hollisb@us.ibm.com> |
---|
19 | * Jimi Xenidis <jimix@watson.ibm.com> |
---|
20 | */ |
---|
21 | |
---|
22 | #include <xen/config.h> |
---|
23 | #include <xen/softirq.h> |
---|
24 | #include <xen/sched.h> |
---|
25 | #include <xen/serial.h> |
---|
26 | #include <xen/gdbstub.h> |
---|
27 | #include <xen/console.h> |
---|
28 | #include <xen/shutdown.h> |
---|
29 | #include <asm/time.h> |
---|
30 | #include <asm/processor.h> |
---|
31 | #include <asm/debugger.h> |
---|
32 | |
---|
33 | #undef DEBUG |
---|
34 | |
---|
35 | extern ulong ppc_do_softirq(ulong orig_msr); |
---|
36 | extern void do_timer(struct cpu_user_regs *regs); |
---|
37 | extern void do_dec(struct cpu_user_regs *regs); |
---|
38 | extern void program_exception(struct cpu_user_regs *regs, |
---|
39 | unsigned long cookie); |
---|
40 | extern int reprogram_timer(s_time_t timeout); |
---|
41 | |
---|
42 | int hdec_sample = 0; |
---|
43 | |
---|
44 | void do_timer(struct cpu_user_regs *regs) |
---|
45 | { |
---|
46 | /* Set HDEC high so it stops firing and can be reprogrammed by |
---|
47 | * set_preempt() */ |
---|
48 | /* FIXME! HACK ALERT! |
---|
49 | * |
---|
50 | * We have a bug in that if we switch domains in schedule() we |
---|
51 | * switch right away regardless of whatever else is pending. This |
---|
52 | * means that if the timer goes off while in schedule(), the next |
---|
53 | * domain will be preempted by the interval defined below. So |
---|
54 | * until we fix our cotnext_switch(), the follow workaround will |
---|
55 | * make sure that the domain we switch to does not run for to long |
---|
56 | * so we can continue to service the other timers in the timer |
---|
57 | * queue and that the value is long enough to escape this |
---|
58 | * particular timer event. |
---|
59 | */ |
---|
60 | reprogram_timer(NOW() + MILLISECS(1)); |
---|
61 | |
---|
62 | raise_softirq(TIMER_SOFTIRQ); |
---|
63 | } |
---|
64 | |
---|
65 | void do_dec(struct cpu_user_regs *regs) |
---|
66 | { |
---|
67 | if (!(regs->msr & MSR_HV)) { |
---|
68 | panic("HV dec from domain\n"); |
---|
69 | } |
---|
70 | printk("DEC_HV: pc: 0x%lx lr: 0x%lx \n", regs->pc, regs->lr); |
---|
71 | mtdec(INT_MAX); |
---|
72 | } |
---|
73 | |
---|
74 | void program_exception(struct cpu_user_regs *regs, unsigned long cookie) |
---|
75 | { |
---|
76 | if (cookie == 0x200) { |
---|
77 | if (cpu_machinecheck(regs)) |
---|
78 | return; |
---|
79 | |
---|
80 | printk("%s: machine check\n", __func__); |
---|
81 | } else { |
---|
82 | #ifdef CRASH_DEBUG |
---|
83 | if (__trap_to_gdb(regs, cookie) == 0) |
---|
84 | return; |
---|
85 | #endif /* CRASH_DEBUG */ |
---|
86 | |
---|
87 | printk("%s: type: 0x%lx\n", __func__, cookie); |
---|
88 | show_backtrace_regs(regs); |
---|
89 | } |
---|
90 | machine_halt(); |
---|
91 | } |
---|