|
[ source navigation ] [ diff markup ] [ identifier search ] [ general search ] |
|||
|
001 /* Copyright (C) 2004 The KOS Team 001 /* Copyright (C) 2004 The KOS Team 002 Copyright (C) 1999 Free Software Foundatio 002 Copyright (C) 1999 Free Software Foundation, Inc. 003 003 004 This program is free software; you can redi 004 This program is free software; you can redistribute it and/or 005 modify it under the terms of the GNU Genera 005 modify it under the terms of the GNU General Public License 006 as published by the Free Software Foundatio 006 as published by the Free Software Foundation; either version 2 007 of the License, or (at your option) any lat 007 of the License, or (at your option) any later version. 008 008 009 This program is distributed in the hope tha 009 This program is distributed in the hope that it will be useful, 010 but WITHOUT ANY WARRANTY; without even the 010 but WITHOUT ANY WARRANTY; without even the implied warranty of 011 MERCHANTABILITY or FITNESS FOR A PARTICULAR 011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 012 GNU General Public License for more details 012 GNU General Public License for more details. 013 013 014 You should have received a copy of the GNU 014 You should have received a copy of the GNU General Public License 015 along with this program; if not, write to t 015 along with this program; if not, write to the Free Software 016 Foundation, Inc., 59 Temple Place - Suite 3 016 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 017 USA. 017 USA. 018 */ 018 */ 019 #include "ioports.h" 019 #include "ioports.h" 020 020 021 #include "i8259.h" 021 #include "i8259.h" 022 022 023 #define PIC_MASTER 0x20 023 #define PIC_MASTER 0x20 024 #define PIC_SLAVE 0xa0 024 #define PIC_SLAVE 0xa0 025 025 026 /** Setup the 8259 PIC */ 026 /** Setup the 8259 PIC */ 027 sos_ret_t sos_i8259_subsystem_setup(void) !! 027 sos_ret_t sos_i8259_setup(void) 028 { 028 { 029 /* Send ICW1: 8086 mode + NOT Single ctrl + 029 /* Send ICW1: 8086 mode + NOT Single ctrl + call address 030 interval=8 */ 030 interval=8 */ 031 outb(0x11, PIC_MASTER); 031 outb(0x11, PIC_MASTER); 032 outb(0x11, PIC_SLAVE); 032 outb(0x11, PIC_SLAVE); 033 033 034 /* Send ICW2: ctrl base address */ 034 /* Send ICW2: ctrl base address */ 035 outb(0x20, PIC_MASTER+1); 035 outb(0x20, PIC_MASTER+1); 036 outb(0x28, PIC_SLAVE+1); 036 outb(0x28, PIC_SLAVE+1); 037 037 038 /* Send ICW3 master: mask where slaves are c 038 /* Send ICW3 master: mask where slaves are connected */ 039 outb(0x4, PIC_MASTER+1); 039 outb(0x4, PIC_MASTER+1); 040 /* Send ICW3 slave: index where the slave is 040 /* Send ICW3 slave: index where the slave is connected on master */ 041 outb(0x2, PIC_SLAVE+1); 041 outb(0x2, PIC_SLAVE+1); 042 042 043 /* Send ICW4: 8086 mode, fully nested, not b 043 /* Send ICW4: 8086 mode, fully nested, not buffered, no implicit EOI */ 044 outb(0x1, PIC_MASTER+1); 044 outb(0x1, PIC_MASTER+1); 045 outb(0x1, PIC_SLAVE+1); 045 outb(0x1, PIC_SLAVE+1); 046 046 047 /* Send OCW1: 047 /* Send OCW1: 048 * Closing all IRQs : waiting for a correct 048 * Closing all IRQs : waiting for a correct handler The only IRQ 049 * enabled is the cascade (that's why we use 049 * enabled is the cascade (that's why we use 0xFB for the master) */ 050 outb(0xFB, PIC_MASTER+1); 050 outb(0xFB, PIC_MASTER+1); 051 outb(0xFF, PIC_SLAVE+1); 051 outb(0xFF, PIC_SLAVE+1); 052 052 053 return SOS_OK; 053 return SOS_OK; 054 } 054 } 055 055 056 056 057 sos_ret_t sos_i8259_enable_irq_line(int numirq 057 sos_ret_t sos_i8259_enable_irq_line(int numirq) 058 { 058 { 059 if(numirq < 8) 059 if(numirq < 8) 060 /* irq on master PIC */ 060 /* irq on master PIC */ 061 outb((inb(PIC_MASTER+1) & ~(1 << numirq)), 061 outb((inb(PIC_MASTER+1) & ~(1 << numirq)), PIC_MASTER+1); 062 else 062 else 063 /* irq on slave PIC */ 063 /* irq on slave PIC */ 064 outb((inb(PIC_SLAVE+1) & ~(1 << (numirq-8) 064 outb((inb(PIC_SLAVE+1) & ~(1 << (numirq-8))), PIC_SLAVE+1); 065 065 066 return SOS_OK; 066 return SOS_OK; 067 } 067 } 068 068 069 069 070 sos_ret_t sos_i8259_disable_irq_line(int numir 070 sos_ret_t sos_i8259_disable_irq_line(int numirq) 071 { 071 { 072 if(numirq < 8) 072 if(numirq < 8) 073 /* irq on master PIC */ 073 /* irq on master PIC */ 074 outb((inb(PIC_MASTER+1) | (1 << numirq)), 074 outb((inb(PIC_MASTER+1) | (1 << numirq)), PIC_MASTER+1); 075 else 075 else 076 /* irq on slave PIC */ 076 /* irq on slave PIC */ 077 outb((inb(PIC_SLAVE+1) | (1 << (numirq-8)) 077 outb((inb(PIC_SLAVE+1) | (1 << (numirq-8))), PIC_SLAVE+1); 078 078 079 return SOS_OK; 079 return SOS_OK; 080 } 080 }
[ source navigation ] | [ diff markup ] | [ identifier search ] | [ general search ] |