kpic.c

00001 /***************************************************************************
00002                           kpic.c  -  description
00003                              -------------------
00004     begin                : Fri Jan 2 2004
00005     copyright            : (C) 2004 by Dynacube Team
00006     email                : mdshah82@yahoo.com
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018  #include "dev/core/kpic.h"
00019 
00020  void pic_init()
00021  {
00022         DB a1, a2;
00023 
00024         a1=inb(PIC1_DATA);
00025         a2=inb(PIC2_DATA);
00026 
00027         outb(PIC1_COMMAND, ICW1_INIT+ICW1_ICW4);
00028         outb(PIC2_COMMAND, ICW1_INIT+ICW1_ICW4);
00029         outb(PIC1_DATA, 0x20);
00030         outb(PIC2_DATA, 0x28);
00031         outb(PIC1_DATA, 4);
00032         outb(PIC2_DATA, 2);
00033         outb(PIC1_DATA, ICW4_8086);
00034         outb(PIC2_DATA, ICW4_8086);
00035 
00036         outb(PIC1_DATA, a1|TIMER|KEYBOARD);
00037         outb(PIC2_DATA, a2 & ~2);
00038  }
00039 
00040  void pic_enable(DW dev_code)
00041  {
00042         DB flags1 = inb(0x21), flags2 = inb(0xA1);
00043 
00044   if(dev_code & 0xFF)
00045   {
00046     dev_code &= 0xFF;
00047     outb(0x21,flags1 & ~dev_code); // | TIMER); //Enable Keyboard & Disable Timer | TIMER
00048   }
00049   else if(dev_code & 0xFF00)
00050   {
00051     dev_code >>= 8;
00052     outb(0xA1,flags2 & ~dev_code);
00053   }
00054   else
00055     printf("\nUnknown Device number %d",dev_code);
00056  }
00057 
00058  void pic_disable(DW dev_code)
00059  {
00060         DB flags1 = inb(0x21), flags2 = inb(0xA1);
00061 
00062   if(dev_code & 0xFF)
00063   {
00064     dev_code &= 0xFF;
00065     outb(0x21,flags1 | dev_code);
00066   }
00067   else if(dev_code & 0xFF00)
00068   {
00069     dev_code >>= 8;
00070     outb(0xA1,flags2 | dev_code);
00071   }
00072   else
00073     printf("\nUnknown Device number %d",dev_code);
00074  }
00075  

Generated on Thu Jul 27 23:52:27 2006 for Dynacube by  doxygen 1.4.7