iPXE
pic8259.c
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License as
00006  * published by the Free Software Foundation; either version 2 of the
00007  * License, or any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017  * 02110-1301, USA.
00018  */
00019 
00020 FILE_LICENCE ( GPL2_OR_LATER );
00021 
00022 #include <ipxe/io.h>
00023 #include <pic8259.h>
00024 
00025 /** @file
00026  *
00027  * Minimal support for the 8259 Programmable Interrupt Controller
00028  *
00029  */
00030 
00031 /**
00032  * Send non-specific EOI(s)
00033  *
00034  * @v irq               IRQ number
00035  *
00036  * This seems to be inherently unsafe.
00037  */
00038 static inline void send_nonspecific_eoi ( unsigned int irq ) {
00039         DBG ( "Sending non-specific EOI for IRQ %d\n", irq );
00040         if ( irq >= IRQ_PIC_CUTOFF ) {
00041                 outb ( ICR_EOI_NON_SPECIFIC, PIC2_ICR );
00042         }               
00043         outb ( ICR_EOI_NON_SPECIFIC, PIC1_ICR );
00044 }
00045 
00046 /**
00047  * Send specific EOI(s)
00048  *
00049  * @v irq               IRQ number
00050  */
00051 static inline void send_specific_eoi ( unsigned int irq ) {
00052         DBG ( "Sending specific EOI for IRQ %d\n", irq );
00053         if ( irq >= IRQ_PIC_CUTOFF ) {
00054                 outb ( ( ICR_EOI_SPECIFIC | ICR_VALUE ( CHAINED_IRQ ) ),
00055                        ICR_REG ( CHAINED_IRQ ) );
00056         }
00057         outb ( ( ICR_EOI_SPECIFIC | ICR_VALUE ( irq ) ), ICR_REG ( irq ) );
00058 }
00059 
00060 /**
00061  * Send End-Of-Interrupt to the PIC
00062  *
00063  * @v irq               IRQ number
00064  */
00065 void send_eoi ( unsigned int irq ) {
00066         send_specific_eoi ( irq );
00067 }