pit.c
isa/pit.h
sys/io.h
lib/kprintf.h
ubixos/types.h
sys/_types.h
src/sys/isa/pit.c
lib/kprintf.h
isa/pit.h
sys/io.h
int int pit_init () pit_init kprintf outportByte outportByteP PIT_TIMER

    /*****************************************************************************************
    Copyright(c)2002-2004TheUbixOSProject
    Allrightsreserved.

    Redistributionanduseinsourceandbinaryforms,withorwithoutmodification,are
    permittedprovidedthatthefollowingconditionsaremet:

    Redistributionsofsourcecodemustretaintheabovecopyrightnotice,thislistof
    conditions,thefollowingdisclaimerandthelistofauthors.Redistributionsinbinary
    formmustreproducetheabovecopyrightnotice,thislistofconditions,thefollowing
    disclaimerandthelistofauthorsinthedocumentationand/orothermaterialsprovided
    withthedistribution.NeitherthenameoftheUbixOSProjectnorthenamesofits
    contributorsmaybeusedtoendorseorpromoteproductsderivedfromthissoftware
    withoutspecificpriorwrittenpermission.

    THISSOFTWAREISPROVIDEDBYTHECOPYRIGHTHOLDERSANDCONTRIBUTORS"ASIS"ANDANY
    EXPRESSORIMPLIEDWARRANTIES,INCLUDING,BUTNOTLIMITEDTO,THEIMPLIEDWARRANTIESOF
    MERCHANTABILITYANDFITNESSFORAPARTICULARPURPOSEAREDISCLAIMED.INNOEVENTSHALL
    THECOPYRIGHTOWNERORCONTRIBUTORSBELIABLEFORANYDIRECT,INDIRECT,INCIDENTAL,
    SPECIAL,EXEMPLARY,ORCONSEQUENTIALDAMAGES(INCLUDING,BUTNOTLIMITEDTO,PROCUREMENT
    OFSUBSTITUTEGOODSORSERVICES;LOSSOFUSE,DATA,ORPROFITS;ORBUSINESSINTERRUPTION)
    HOWEVERCAUSEDANDONANYTHEORYOFLIABILITY,WHETHERINCONTRACT,STRICTLIABILITY,OR
    TORT(INCLUDINGNEGLIGENCEOROTHERWISE)ARISINGINANYWAYOUTOFTHEUSEOFTHIS
    SOFTWARE,EVENIFADVISEDOFTHEPOSSIBILITYOFSUCHDAMAGE.

    $Id: pit_8c.xml 88 2016-01-12 00:11:29Z reddawg $

    *****************************************************************************************/

    #include<isa/pit.h>
    #include<sys/io.h>
    #include<lib/kprintf.h>

    /*****************************************************************************************

    Function:intpitInit()

    Description:ThisFunctionWillInitializeTheProgrammableTimer

    Notes:

    0040r/wPITcounter0,counterdivisor(XT,AT,PS/2)
    0041r/wPITcounter1,RAMrefreshcounter(XT,AT)
    0042r/wPITcounter2,cassette&speaker(XT,AT,PS/2)
    0043r/wPITmodeport,controlwordregisterforcounters0-2

    bit7-6=00counter0select
    =01counter1select(notPS/2)
    =10counter2select
    bit5-4=00counterlatchcommand
    =01read/writecounterbits0-7only
    =10read/writecounterbits8-15only
    =11read/writecounterbits0-7first,then8-15
    bit3-1=000mode0select
    =001mode1select-programmableoneshot
    =x10mode2select-rategenerator
    =x11mode3select-squarewavegenerator
    =100mode4select-softwaretriggeredstrobe
    =101mode5select-hardwaretriggeredstrobe
    bit0=0binarycounter16bits
    =1BCDcounter

    *****************************************************************************************/
    intpit_init(){
    outportByteP(0x43,0x36);
    outportByteP(0x40,((1193180/PIT_TIMER)&0xFF));
    outportByte(0x40,(((1193180/PIT_TIMER)>>8)&0xFF));

    /*PrintoutinformationonthePIT*/
    kprintf("pit0-Port[0x%X],TimerHz:[%iHz]\n",0x43,PIT_TIMER);

    /*Returnsoweknoweverythingwentwell*/
    return(0x0);
    }

    /***
    $Log: pit_8c.xml,v $
    Revision 1.6  2006/12/19 14:12:52  reddawg
    rtld-elf almost workign

    Revision1.1.1.12006/06/0112:46:12reddawg
    ubix2

    Revision1.22005/10/1200:13:37reddawg
    Removed

    Revision1.1.1.12005/09/2617:24:03reddawg
    nomessage

    Revision1.72004/07/1604:06:32reddawg
    Tuneupsthisstuffshouldofbeentakencareofmonthsago

    Revision1.62004/07/1601:08:58reddawg
    Whewweworkonceagain

    Revision1.52004/07/0913:29:15reddawg
    pit:pitInittopit_init
    Adjustedinitializationroutines

    Revision1.42004/05/2112:48:22reddawg
    Cleanedup

    Revision1.32004/05/2022:51:09reddawg
    CleanedUpWarnings

    Revision1.22004/05/1002:23:24reddawg
    MinorChangesToSourceCodeToPrepareItForOpenSourceRelease

    END
    ***/