irq_comm.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * irq_comm.c: Common API for in kernel interrupt controller
  3. * Copyright (c) 2007, Intel Corporation.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms and conditions of the GNU General Public License,
  7. * version 2, as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
  16. * Place - Suite 330, Boston, MA 02111-1307 USA.
  17. * Authors:
  18. * Yaozu (Eddie) Dong <Eddie.dong@intel.com>
  19. *
  20. */
  21. #include <linux/kvm_host.h>
  22. #include "irq.h"
  23. #include "ioapic.h"
  24. /* This should be called with the kvm->lock mutex held */
  25. void kvm_set_irq(struct kvm *kvm, int irq, int level)
  26. {
  27. /* Not possible to detect if the guest uses the PIC or the
  28. * IOAPIC. So set the bit in both. The guest will ignore
  29. * writes to the unused one.
  30. */
  31. kvm_ioapic_set_irq(kvm->arch.vioapic, irq, level);
  32. #ifdef CONFIG_X86
  33. kvm_pic_set_irq(pic_irqchip(kvm), irq, level);
  34. #endif
  35. }
  36. void kvm_notify_acked_irq(struct kvm *kvm, unsigned gsi)
  37. {
  38. struct kvm_irq_ack_notifier *kian;
  39. struct hlist_node *n;
  40. hlist_for_each_entry(kian, n, &kvm->arch.irq_ack_notifier_list, link)
  41. if (kian->gsi == gsi)
  42. kian->irq_acked(kian);
  43. }
  44. void kvm_register_irq_ack_notifier(struct kvm *kvm,
  45. struct kvm_irq_ack_notifier *kian)
  46. {
  47. hlist_add_head(&kian->link, &kvm->arch.irq_ack_notifier_list);
  48. }
  49. void kvm_unregister_irq_ack_notifier(struct kvm *kvm,
  50. struct kvm_irq_ack_notifier *kian)
  51. {
  52. hlist_del(&kian->link);
  53. }