You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

pic8259.c 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 of the
  7. * License, or any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18. FILE_LICENCE ( GPL2_OR_LATER );
  19. #include <ipxe/io.h>
  20. #include <pic8259.h>
  21. /** @file
  22. *
  23. * Minimal support for the 8259 Programmable Interrupt Controller
  24. *
  25. */
  26. /**
  27. * Send non-specific EOI(s)
  28. *
  29. * @v irq IRQ number
  30. *
  31. * This seems to be inherently unsafe.
  32. */
  33. static inline void send_nonspecific_eoi ( unsigned int irq ) {
  34. DBG ( "Sending non-specific EOI for IRQ %d\n", irq );
  35. if ( irq >= IRQ_PIC_CUTOFF ) {
  36. outb ( ICR_EOI_NON_SPECIFIC, PIC2_ICR );
  37. }
  38. outb ( ICR_EOI_NON_SPECIFIC, PIC1_ICR );
  39. }
  40. /**
  41. * Send specific EOI(s)
  42. *
  43. * @v irq IRQ number
  44. */
  45. static inline void send_specific_eoi ( unsigned int irq ) {
  46. DBG ( "Sending specific EOI for IRQ %d\n", irq );
  47. if ( irq >= IRQ_PIC_CUTOFF ) {
  48. outb ( ( ICR_EOI_SPECIFIC | ICR_VALUE ( CHAINED_IRQ ) ),
  49. ICR_REG ( CHAINED_IRQ ) );
  50. }
  51. outb ( ( ICR_EOI_SPECIFIC | ICR_VALUE ( irq ) ), ICR_REG ( irq ) );
  52. }
  53. /**
  54. * Send End-Of-Interrupt to the PIC
  55. *
  56. * @v irq IRQ number
  57. */
  58. void send_eoi ( unsigned int irq ) {
  59. send_specific_eoi ( irq );
  60. }