Home | History | Annotate | Download | only in core
      1 /*
      2  * Copyright (C) 2007 Michael Brown <mbrown (at) 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 
     19 FILE_LICENCE ( GPL2_OR_LATER );
     20 
     21 #include <gpxe/io.h>
     22 #include <pic8259.h>
     23 
     24 /** @file
     25  *
     26  * Minimal support for the 8259 Programmable Interrupt Controller
     27  *
     28  */
     29 
     30 /**
     31  * Send non-specific EOI(s)
     32  *
     33  * @v irq		IRQ number
     34  *
     35  * This seems to be inherently unsafe.
     36  */
     37 static inline void send_nonspecific_eoi ( unsigned int irq ) {
     38 	DBG ( "Sending non-specific EOI for IRQ %d\n", irq );
     39 	if ( irq >= IRQ_PIC_CUTOFF ) {
     40 		outb ( ICR_EOI_NON_SPECIFIC, PIC2_ICR );
     41 	}
     42 	outb ( ICR_EOI_NON_SPECIFIC, PIC1_ICR );
     43 }
     44 
     45 /**
     46  * Send specific EOI(s)
     47  *
     48  * @v irq		IRQ number
     49  */
     50 static inline void send_specific_eoi ( unsigned int irq ) {
     51 	DBG ( "Sending specific EOI for IRQ %d\n", irq );
     52 	if ( irq >= IRQ_PIC_CUTOFF ) {
     53 		outb ( ( ICR_EOI_SPECIFIC | ICR_VALUE ( CHAINED_IRQ ) ),
     54 		       ICR_REG ( CHAINED_IRQ ) );
     55 	}
     56 	outb ( ( ICR_EOI_SPECIFIC | ICR_VALUE ( irq ) ), ICR_REG ( irq ) );
     57 }
     58 
     59 /**
     60  * Send End-Of-Interrupt to the PIC
     61  *
     62  * @v irq		IRQ number
     63  */
     64 void send_eoi ( unsigned int irq ) {
     65 	send_specific_eoi ( irq );
     66 }
     67