xref: /qemu/hw/intc/kvm_irqcount.c (revision a8d6abe1292e1db1ad9be5b2b124b9c01bcda094)
1*2b85e0cdSThomas Huth /*
2*2b85e0cdSThomas Huth  * KVM PIC functions for counting the delivered IRQs.
3*2b85e0cdSThomas Huth  *
4*2b85e0cdSThomas Huth  * This library is free software; you can redistribute it and/or
5*2b85e0cdSThomas Huth  * modify it under the terms of the GNU Lesser General Public
6*2b85e0cdSThomas Huth  * License as published by the Free Software Foundation; either
7*2b85e0cdSThomas Huth  * version 2.1 of the License, or (at your option) any later version.
8*2b85e0cdSThomas Huth  *
9*2b85e0cdSThomas Huth  * This library is distributed in the hope that it will be useful,
10*2b85e0cdSThomas Huth  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11*2b85e0cdSThomas Huth  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12*2b85e0cdSThomas Huth  * Lesser General Public License for more details.
13*2b85e0cdSThomas Huth  *
14*2b85e0cdSThomas Huth  * You should have received a copy of the GNU Lesser General Public
15*2b85e0cdSThomas Huth  * License along with this library; if not, see <http://www.gnu.org/licenses/>
16*2b85e0cdSThomas Huth  */
17*2b85e0cdSThomas Huth 
18*2b85e0cdSThomas Huth #include "qemu/osdep.h"
19*2b85e0cdSThomas Huth #include "hw/intc/kvm_irqcount.h"
20*2b85e0cdSThomas Huth #include "trace.h"
21*2b85e0cdSThomas Huth 
22*2b85e0cdSThomas Huth static int kvm_irq_delivered;
23*2b85e0cdSThomas Huth 
kvm_report_irq_delivered(int delivered)24*2b85e0cdSThomas Huth void kvm_report_irq_delivered(int delivered)
25*2b85e0cdSThomas Huth {
26*2b85e0cdSThomas Huth     kvm_irq_delivered += delivered;
27*2b85e0cdSThomas Huth 
28*2b85e0cdSThomas Huth     trace_kvm_report_irq_delivered(kvm_irq_delivered);
29*2b85e0cdSThomas Huth }
30*2b85e0cdSThomas Huth 
kvm_reset_irq_delivered(void)31*2b85e0cdSThomas Huth void kvm_reset_irq_delivered(void)
32*2b85e0cdSThomas Huth {
33*2b85e0cdSThomas Huth     /*
34*2b85e0cdSThomas Huth      * Copy this into a local variable to encourage gcc to emit a plain
35*2b85e0cdSThomas Huth      * register for a sys/sdt.h marker.  For details on this workaround, see:
36*2b85e0cdSThomas Huth      * https://sourceware.org/bugzilla/show_bug.cgi?id=13296
37*2b85e0cdSThomas Huth      */
38*2b85e0cdSThomas Huth     volatile int k_i_d = kvm_irq_delivered;
39*2b85e0cdSThomas Huth     trace_kvm_reset_irq_delivered(k_i_d);
40*2b85e0cdSThomas Huth 
41*2b85e0cdSThomas Huth     kvm_irq_delivered = 0;
42*2b85e0cdSThomas Huth }
43*2b85e0cdSThomas Huth 
kvm_get_irq_delivered(void)44*2b85e0cdSThomas Huth int kvm_get_irq_delivered(void)
45*2b85e0cdSThomas Huth {
46*2b85e0cdSThomas Huth     trace_kvm_get_irq_delivered(kvm_irq_delivered);
47*2b85e0cdSThomas Huth 
48*2b85e0cdSThomas Huth     return kvm_irq_delivered;
49*2b85e0cdSThomas Huth }
50