Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / hypervisor / src / greatlakes / ontario / src / intr_ontario.s
CommitLineData
920dae64
AT
1/*
2* ========== Copyright Header Begin ==========================================
3*
4* Hypervisor Software File: intr_ontario.s
5*
6* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
7*
8* - Do no alter or remove copyright notices
9*
10* - Redistribution and use of this software in source and binary forms, with
11* or without modification, are permitted provided that the following
12* conditions are met:
13*
14* - Redistribution of source code must retain the above copyright notice,
15* this list of conditions and the following disclaimer.
16*
17* - Redistribution in binary form must reproduce the above copyright notice,
18* this list of conditions and the following disclaimer in the
19* documentation and/or other materials provided with the distribution.
20*
21* Neither the name of Sun Microsystems, Inc. or the names of contributors
22* may be used to endorse or promote products derived from this software
23* without specific prior written permission.
24*
25* This software is provided "AS IS," without a warranty of any kind.
26* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
27* INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
28* PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
29* MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
30* ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
31* DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
32* OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
33* FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
34* DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
35* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
36* SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
37*
38* You acknowledge that this software is not designed, licensed or
39* intended for use in the design, construction, operation or maintenance of
40* any nuclear facility.
41*
42* ========== Copyright Header End ============================================
43*/
44/*
45 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
46 * Use is subject to license terms.
47 */
48
49 .ident "@(#)intr_ontario.s 1.43 07/05/03 SMI"
50
51#include <sys/asm_linkage.h>
52#include <sys/htypes.h>
53#include <asi.h>
54#include <hprivregs.h>
55#include <sun4v/asi.h>
56#include <offsets.h>
57#include <vdev_intr.h>
58#include <util.h>
59#include <iob.h>
60
61/*
62 * cpu_in_error_finish - invoked from a cpu about to enter the error
63 * state so another cpu can finish cleaning up.
64 */
65 ENTRY(cpu_in_error_finish)
66 CPU_PUSH(%g7, %g2, %g3, %g4) ! save return address
67 STRAND_STRUCT(%g1)
68
69 /*
70 * Send a resumable erpt to the guest. The fault cpu should have
71 * left a valid erpt in the current cpu's ce err buf.
72 */
73 add %g1, STRAND_CE_RPT, %g2
74
75 ! get the error CPUID to do the necessary cleanup
76 lduh [%g2 + STRAND_SUN4V_ERPT + ESUN4V_G_CPUID], %g1
77
78 ! get the vcpu and strand for the vcpu that took the error
79 GUEST_STRUCT(%g3)
80 sllx %g1, GUEST_VCPUS_SHIFT, %g1
81 add %g1, %g3, %g1
82 add %g1, GUEST_VCPUS, %g1
83 ldx [%g1], %g1 ! err vcpu struct
84 ldx [%g1 + CPU_STRAND], %g2 ! err strand struct
85
86 ! deschedule and stop the vcpu
87 ! %g1 - vcpu struct
88 ! %g2 - strand struct
89 HVCALL(desched_n_stop_vcpu)
90
91 STRAND_STRUCT(%g1) ! this strand
92 add %g1, STRAND_CE_RPT, %g2
93 HVCALL(queue_resumable_erpt)
94
95 /*
96 * If the heartbeat is disabled then it was running on the failed
97 * cpu and needs to be restarted on this cpu.
98 */
99 ROOT_STRUCT(%g2)
100 ldx [%g2 + CONFIG_HEARTBEAT_CPU], %g2
101 cmp %g2, -1
102 bne,pt %xcc, 1f
103 nop
104 HVCALL(heartbeat_enable)
1051:
106 CPU_POP(%g7, %g1, %g2, %g5)
107 retry
108 SET_SIZE(cpu_in_error_finish)
109
110
111/*
112 * vdev_mondo - deliver a virtual mondo on the current cpu's
113 * devmondo queue.
114 *
115 * %g1 - cpup
116 * %g7 - return address
117 * --
118 *
119 * Note: This function is called from the interrupt handler and also
120 * as a tail function
121 */
122
123 ! the mondo starting point.
124 ! %g1 cpup
125 ! %g2 intr-type
126 ENTRY_NP(vecintr)
127 cmp %g2, VECINTR_XCALL
128 beq,pt %xcc, cpu_mondo
129 cmp %g2, VECINTR_HVXCALL
130 beq,pt %xcc, hvxcall_mondo
131 cmp %g2, VECINTR_DEV
132 beq,pt %xcc, dev_mondo
133#ifdef CONFIG_FPGA
134 cmp %g2, VECINTR_FPGA
135 beq,pt %xcc, fpga_intr
136#endif
137#ifdef T1_FPGA_SNET
138 cmp %g2, VECINTR_SNET
139 beq,pt %xcc, snet_mondo
140#endif
141 cmp %g2, VECINTR_VDEV
142 bne,pt %xcc, 1f
143 nop
144
145 HVCALL(vdev_mondo)
146 retry
1471:
148 cmp %g2, VECINTR_ERROR_XCALL
149 beq,pt %xcc, cpu_err_rerouted
150
151 cmp %g2, VECINTR_SSIERR
152 beq,pt %xcc, ssi_mondo
153 cmp %g2, VECINTR_CPUINERR
154 beq,pt %xcc, cpu_in_error_finish
155 nop
156
157 ! XXX unclaimed interrupt
158irq_unclaimed:
159.vecintr_qfull: ! XXX need to do the right thing here
160 retry
161 SET_SIZE(vecintr)