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