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.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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., 51 Franklin Street, Fifth Floor, Boston, MA
  17. * 02110-1301, USA.
  18. */
  19. FILE_LICENCE ( GPL2_OR_LATER );
  20. #include <ipxe/io.h>
  21. #include <pic8259.h>
  22. /** @file
  23. *
  24. * Minimal support for the 8259 Programmable Interrupt Controller
  25. *
  26. */
  27. /**
  28. * Send non-specific EOI(s)
  29. *
  30. * @v irq IRQ number
  31. *
  32. * This seems to be inherently unsafe.
  33. */
  34. static inline void send_nonspecific_eoi ( unsigned int irq ) {
  35. DBG ( "Sending non-specific EOI for IRQ %d\n", irq );
  36. if ( irq >= IRQ_PIC_CUTOFF ) {
  37. outb ( ICR_EOI_NON_SPECIFIC, PIC2_ICR );
  38. }
  39. outb ( ICR_EOI_NON_SPECIFIC, PIC1_ICR );
  40. }
  41. /**
  42. * Send specific EOI(s)
  43. *
  44. * @v irq IRQ number
  45. */
  46. static inline void send_specific_eoi ( unsigned int irq ) {
  47. DBG ( "Sending specific EOI for IRQ %d\n", irq );
  48. if ( irq >= IRQ_PIC_CUTOFF ) {
  49. outb ( ( ICR_EOI_SPECIFIC | ICR_VALUE ( CHAINED_IRQ ) ),
  50. ICR_REG ( CHAINED_IRQ ) );
  51. }
  52. outb ( ( ICR_EOI_SPECIFIC | ICR_VALUE ( irq ) ), ICR_REG ( irq ) );
  53. }
  54. /**
  55. * Send End-Of-Interrupt to the PIC
  56. *
  57. * @v irq IRQ number
  58. */
  59. void send_eoi ( unsigned int irq ) {
  60. send_specific_eoi ( irq );
  61. }