pic.c

Go to the documentation of this file.
00001 /* pic.c */
00002 
00003 #include "routix/system.h"
00004 #include "routix/8259.h"
00005 #include <routix/kstdio.h>
00006 
00007 #define PIC1_A0 0x20
00008 #define PIC1_A1 0x21
00009 #define PIC2_A0 0xa0
00010 #define PIC2_A1 0xa1
00011 
00012 void inicializarPics(unsigned char int1, unsigned char int2)
00013 {
00014 
00015 // Inicializamos con ICW1
00016 outportb(PIC1_A0,0x11);
00017 outportb(PIC2_A0,0x11);
00018 
00019 // Movemos las interrupciones (ICW2)
00020 outportb(PIC1_A1,int1);
00021 outportb(PIC2_A1,int2);
00022 
00023 // Seteamos la posicion del PIC slave (ICW3)
00024 outportb(PIC1_A1,0x4);
00025 outportb(PIC2_A1,0x2);
00026 
00027 // Otros seteos: EOI, modo 8086 (ICW4)
00028 outportb(PIC1_A1,0x1);
00029 outportb(PIC2_A1,0x1);
00030 
00031 // Deshabilitamos todas las interrupciones
00032 outportb(PIC1_A1,0xff);
00033 outportb(PIC2_A1,0xff);
00034 
00035 }
00036 
00037 
00038 
00039 void mascarasPics(unsigned char mask1, unsigned char mask2)
00040 {
00041 outportb(PIC1_A1,mask1);
00042 outportb(PIC2_A1,mask2);
00043 }
00044 
00045 
00046 
00047 void endOfInterrupt(void)
00048 {
00049 outportb(PIC1_A0,0x20);
00050 }
00051 
00052 void enable_irq (byte irqn)
00053 {
00054     word picn= PIC1_A1;
00055     if ( irqn > 7)
00056     {
00057             picn = PIC2_A1;
00058     }
00059     outportb (picn, inportb(picn ) &  ~ ( 1 << irqn) );
00060  
00061 }       
00062 
00063 void disable_irq (byte irqn)
00064 {
00065     word picn= PIC1_A1;
00066     if ( irqn > 7)
00067     {
00068             picn = PIC2_A1;
00069     }
00070     outportb (picn, inportb(picn ) | ( 1 << irqn) );
00071  
00072 }       
00073 

Generated on Sun May 30 18:38:35 2004 for Routix OS by doxygen 1.3.6