00001 /*************************************************************************** 00002 kpit.c - description 00003 ------------------- 00004 begin : Sat Jan 2 2004 00005 copyright : (C) 2003 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/kpit.h" 00019 #include "common/ktypes.h" 00020 00021 void pit0_init(DD num_of_times) 00022 { 00023 DW pit_data = 1; //65536 00024 00025 if(num_of_times > 0) 00026 { 00027 pit_data = (PIT_FREQ/num_of_times); 00028 } 00029 00030 outb(PIT_MCR_PORT, PIT_COUNTER_0|RW_LSB_MSB|MODE_3|BINARY); 00031 asm("jmp .+2"); 00032 outb(PIT_PORT_0, pit_data & 0xFF); 00033 asm("jmp .+2"); 00034 outb(PIT_PORT_0, (pit_data>>8) & 0xFF); 00035 00036 printf("\nPIT 0 Initialized @ %d Hz",num_of_times); 00037 }