8259.c
isa/8259.h
sys/io.h
lib/kprintf.h
ubixos/types.h
sys/_types.h
lib/kprintf.h
src/sys/isa/8259.c
sys/io.h
isa/8259.h
int int i8259_init () i8259_init

initialize the 8259 PIC

This will initialize both PICs for all of our IRQs

icw1
icw4
kprintf
mImr
mPic
mVec
outportByte
sImr
sPic
sVec
void void irqDisable (u_int16_t irqNo) irqDisable u_int16_t irqNo

disable specified IRQ

irqNo

IRQ to disable

irqMask
mPic
outportByte
sPic
void void irqEnable (u_int16_t irqNo) irqEnable u_int16_t irqNo

enable specified IRQ

irqNo

IRQ to enable

irqMask
mPic
outportByte
sPic
unsigned int unsigned int irqMask irqMask 0xFFFF irqDisable irqEnable

    /*****************************************************************************************
    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: 8259_8c.xml 88 2016-01-12 00:11:29Z reddawg $

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

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

    staticunsignedintirqMask=0xFFFF;

    inti8259_init(){
    outportByte(mPic,icw1);/*InitializeMasterPIC*/
    outportByte(sPic,icw1);/*InitializeSeconaryPIC*/
    outportByte(mPic+1,mVec);/*MasterInterrupVector*/
    outportByte(sPic+1,sVec);/*SecondaryInterruptVector*/
    outportByte(mPic+1,1<<2);/*BitmaskforcascadeonIRQ2*/
    outportByte(sPic+1,2);/*CascadeonIRQ2*/
    outportByte(mPic+1,icw4);/*FinishPrimaryInitialization*/
    outportByte(sPic+1,icw4);/*FinishSeconaryInitialization*/
    outportByte(mImr,0xff);/*MaskAllPrimaryInterrupts*/
    outportByte(sImr,0xff);/*MaskAllSeconaryInterrupts*/

    /*Printoutthesysteminfoforthis*/
    kprintf("pic0-Port:[0x%X]\n",mPic);
    kprintf("pic1-Port:[0x%X]\n",sPic);

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

    voidirqEnable(u_int16_tirqNo){
    irqMask&=~(1<<irqNo);
    if(irqNo>=8){
    irqMask&=~(1<<2);
    }
    outportByte(mPic+1,irqMask&0xFF);
    outportByte(sPic+1,(irqMask>>8)&0xFF);
    }

    voidirqDisable(u_int16_tirqNo){
    irqMask|=(1<<irqNo);
    if((irqMask&0xFF00)==0xFF00){
    irqMask|=(1<<2);
    }
    outportByte(mPic+1,irqMask&0xFF);
    outportByte(sPic+1,(irqMask>>8)&0xFF);
    }

    /***
    END
    ***/