diff --git a/src/sys/include/isa/pit.h b/src/sys/include/isa/pit.h new file mode 100644 index 0000000..4c6bab3 --- /dev/null +++ b/src/sys/include/isa/pit.h @@ -0,0 +1,43 @@ +/***************************************************************************************** + Copyright (c) 2002-2004 The UbixOS Project + All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, are + permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this list of + conditions, the following disclaimer and the list of authors. Redistributions in binary + form must reproduce the above copyright notice, this list of conditions, the following + disclaimer and the list of authors in the documentation and/or other materials provided + with the distribution. Neither the name of the UbixOS Project nor the names of its + contributors may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id$ + +*****************************************************************************************/ + +#ifndef _PIT_H +#define _PIT_H + +#define PIT_TIMER 1000 + +int pit_init(); + +#endif + +/*** + $Log$ + END + ***/ + diff --git a/src/sys/include/ubixos/init.h b/src/sys/include/ubixos/init.h index cd6933b..1255a8a 100644 --- a/src/sys/include/ubixos/init.h +++ b/src/sys/include/ubixos/init.h @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -53,6 +54,7 @@ vitals_init, mpi_init, sched_init, + pit_init, device_init, fdc_init, }; diff --git a/src/sys/isa/Makefile b/src/sys/isa/Makefile index f323da7..00a820e 100644 --- a/src/sys/isa/Makefile +++ b/src/sys/isa/Makefile @@ -7,7 +7,7 @@ include ../Makefile.inc # Objects -OBJS = fdc.o +OBJS = pit.o fdc.o all: $(OBJS) diff --git a/src/sys/isa/pit.c b/src/sys/isa/pit.c new file mode 100644 index 0000000..699014d --- /dev/null +++ b/src/sys/isa/pit.c @@ -0,0 +1,99 @@ +/***************************************************************************************** + Copyright (c) 2002-2004 The UbixOS Project + All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, are + permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this list of + conditions, the following disclaimer and the list of authors. Redistributions in binary + form must reproduce the above copyright notice, this list of conditions, the following + disclaimer and the list of authors in the documentation and/or other materials provided + with the distribution. Neither the name of the UbixOS Project nor the names of its + contributors may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id$ + +*****************************************************************************************/ + +#include +#include +#include + +/***************************************************************************************** + + Function: int pitInit() + + Description: This Function Will Initialize The Programmable Timer + + Notes: + + 0040 r/w PIT counter 0, counter divisor (XT, AT, PS/2) + 0041 r/w PIT counter 1, RAM refresh counter (XT, AT) + 0042 r/w PIT counter 2, cassette & speaker (XT, AT, PS/2) + 0043 r/w PIT mode port, control word register for counters 0-2 + + bit 7-6 = 00 counter 0 select + = 01 counter 1 select (not PS/2) + = 10 counter 2 select + bit 5-4 = 00 counter latch command + = 01 read/write counter bits 0-7 only + = 10 read/write counter bits 8-15 only + = 11 read/write counter bits 0-7 first, then 8-15 + bit 3-1 = 000 mode 0 select + = 001 mode 1 select - programmable one shot + = x10 mode 2 select - rate generator + = x11 mode 3 select - square wave generator + = 100 mode 4 select - software triggered strobe + = 101 mode 5 select - hardware triggered strobe + bit 0 = 0 binary counter 16 bits + = 1 BCD counter + +*****************************************************************************************/ +int pit_init() { + outportByteP(0x43,0x36); + outportByteP(0x40,((1193180/PIT_TIMER) & 0xFF)); + outportByte(0x40,(((1193180/PIT_TIMER) >> 8) & 0xFF)); + + /* Print out information on the PIT */ + kprintf("pit0 - Port [0x%X], Timer Hz: [%iHz]\n",0x43,PIT_TIMER); + + /* Return so we know everything went well */ + return(0x0); + } + +/*** + $Log$ + Revision 1.7 2004/07/16 04:06:32 reddawg + Tune ups this stuff should of been taken care of months ago + + Revision 1.6 2004/07/16 01:08:58 reddawg + Whew we work once again + + Revision 1.5 2004/07/09 13:29:15 reddawg + pit: pitInit to pit_init + Adjusted initialization routines + + Revision 1.4 2004/05/21 12:48:22 reddawg + Cleaned up + + Revision 1.3 2004/05/20 22:51:09 reddawg + Cleaned Up Warnings + + Revision 1.2 2004/05/10 02:23:24 reddawg + Minor Changes To Source Code To Prepare It For Open Source Release + + END + ***/ + diff --git a/src/sys/kernel/sched.c b/src/sys/kernel/sched.c index 95576db..b3f50d2 100644 --- a/src/sys/kernel/sched.c +++ b/src/sys/kernel/sched.c @@ -28,14 +28,22 @@ *****************************************************************************************/ #include +#include +#include #include +void timerInt(); + int sched_init() { + setVector(timerInt, 0x68, (dInt + dPresent + dDpl0)); + irqEnable(0x0); kprintf("initalizing scheduler\n"); + return(0x0); } void sched() { + kprintf("."); return; } diff --git a/src/sys/kernel/timer.S b/src/sys/kernel/timer.S new file mode 100644 index 0000000..1b6ecdd --- /dev/null +++ b/src/sys/kernel/timer.S @@ -0,0 +1,61 @@ +/***************************************************************************************** + Copyright (c) 2002-2004 The UbixOS Project + All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, are + permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this list of + conditions, the following disclaimer and the list of authors. Redistributions in binary + form must reproduce the above copyright notice, this list of conditions, the following + disclaimer and the list of authors in the documentation and/or other materials provided + with the distribution. Neither the name of the UbixOS Project nor the names of its + contributors may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id$ + +*****************************************************************************************/ + +.globl timerInt +.text +.code32 +timerInt: + pusha /* Save all of the registers */ + mov $0x20,%dx /* The Following Sends Our EOI To The MPIC */ + mov $0x20,%ax + outb %al,%dx + movl systemVitals,%ecx /* Put Location Of System Vitals Into ECX */ + incl 0(%ecx) /* Increment sysTicks our 1000ms counter */ + movl 0(%ecx),%eax /* Increment our sysUptime by 1S if 1000MS */ + movl $200,%ebx /* Have Passed */ + xor %edx,%edx + div %ebx + test %edx,%edx + jnz next + incl 4(%ecx) +next: + movl 0(%ecx),%eax /* Test If quantum Has Passed If So Then */ + movl 8(%ecx),%ebx /* We Can CALL sched */ + xor %edx,%edx + div %ebx + test %edx,%edx + jnz done + call sched +done: + popa /* Restore Registers */ + iret + +/*** + END + ***/ diff --git a/src/sys/kernel/vitals.c b/src/sys/kernel/vitals.c index 40dafab..8f3d1dc 100644 --- a/src/sys/kernel/vitals.c +++ b/src/sys/kernel/vitals.c @@ -57,7 +57,7 @@ /* Set all default values */ memset(systemVitals,0x0,sizeof(vitalsNode)); - systemVitals->quantum = 8; + systemVitals->quantum = 200; /* Print Out Info For Vitals: */ kprintf("vitals0 - Address: [0x%X]\n",systemVitals);