mouse.c
isa/mouse.h
isa/8259.h
sys/idt.h
sys/gdt.h
sys/io.h
lib/kprintf.h
ubixos/types.h
ubixos/types.h
sys/_types.h
isa/mouse.h
sys/idt.h
lib/kprintf.h
sys/gdt.h
sys/io.h
isa/8259.h
src/sys/isa/mouse.c
asm
(".globl mouseISR \n""mouseISR: \n"" pusha \n"" call mouseHandler \n"" popa \n"" iret \n")
asm
".globl mouseISR \n""mouseISR: \n"" pusha \n"" call mouseHandler \n"" popa \n"" iret \n"
uInt8 static uInt8 kbdRead () kbdRead inportByte kbdWriteRead mouseInit
void static void kbdWrite (uInt16 port, uInt8 data) kbdWrite uInt16 port uInt8 data inportByte outportByte kbdWriteRead mouseInit
uInt8 static uInt8 kbdWriteRead (uInt16 port, uInt8 data, const char *expect) kbdWriteRead uInt16 port uInt8 data const char * expect kbdRead kbdWrite mouseInit
void void mouseHandler () mouseHandler eoi kprintf mPic outportByte sPic
int int mouseInit () mouseInit dDpl3 dInt dPresent eoi irqEnable kbdRead kbdWrite kbdWriteRead kprintf mouseISR mPic mVec outportByte setVector sPic

    /*****************************************************************************************
    Copyright(c)2002TheUbixOSProject
    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: mouse_8c.xml 88 2016-01-12 00:11:29Z reddawg $

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

    #include<isa/mouse.h>
    #include<isa/8259.h>
    #include<sys/idt.h>
    #include<sys/gdt.h>
    #include<sys/io.h>
    #include<lib/kprintf.h>
    #include<ubixos/types.h>

    staticuInt8kbdRead(){
    unsignedlongTimeout;
    uInt8Stat,Data;

    for(Timeout=50000L;Timeout!=0;Timeout--){
    Stat=inportByte(0x64);

    /*loopuntil8042outputbufferfull*/
    if((Stat&0x01)!=0)
    {
    Data=inportByte(0x60);

    /*loopifparityerrororreceivetimeout*/
    if((Stat&0xC0)==0)
    returnData;
    }
    }

    return-1;
    }

    staticvoidkbdWrite(uInt16port,uInt8data){
    uInt32timeout;
    uInt8stat;

    for(timeout=500000L;timeout!=0;timeout--)
    {
    stat=inportByte(0x64);

    if((stat&0x02)==0)
    break;
    }

    if(timeout!=0)
    outportByte(port,data);
    }

    staticuInt8kbdWriteRead(uInt16port,uInt8data,constchar*expect)
    {
    intRetVal;

    kbdWrite(port,data);
    for(;*expect;expect++)
    {
    RetVal=kbdRead();
    if((uInt8)*expect!=RetVal)
    {
    returnRetVal;
    }
    }

    return0;
    }

    intmouseInit(){
    staticuInt8s1[]={0xF3,0xC8,0xF3,0x64,0xF3,0x50,0};
    staticuInt8s2[]={0xF6,0xE6,0xF4,0xF3,0x64,0xE8,0x03,0};
    constuInt8*ch;
    Int8cmd=0x0;

    kbdWrite(0x64,0xA8);
    for(ch=s1;*ch;ch++){
    kbdWrite(0x64,0xD4);
    kbdWriteRead(0x60,*ch,"\xFA");
    }
    for(ch=s2;*ch;ch++){
    kbdWrite(0x64,0xD4);
    kbdWriteRead(0x60,*ch,"\xFA");
    }
    kbdWrite(0x64,0xD4);
    if(kbdWriteRead(0x60,0xF2,"\xFA")!=0x0){
    kprintf("ErrorWithMouse\n");
    }
    cmd=kbdRead();
    kprintf("CMD:[0x%X]\n",cmd);
    kbdWrite(0x64,0xD4);
    kbdWriteRead(0x60,0xF4,"\xFA");

    setVector(&mouseISR,mVec+12,dPresent+dInt+dDpl3);

    outportByte(mPic,eoi);
    outportByte(sPic,eoi);
    irqEnable(12);
    outportByte(mPic,eoi);
    outportByte(sPic,eoi);

    kprintf("psm0-Address:[0x%X]\n",&mouseISR);

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

    asm(
    ".globlmouseISR\n"
    "mouseISR:\n"
    "pusha\n"/*Saveallregisters*/
    "callmouseHandler\n"
    "popa\n"
    "iret\n"/*Exitinterrupt*/
    );

    voidmouseHandler(){
    kprintf("MOUSE!!!\n");

    outportByte(mPic,eoi);
    outportByte(sPic,eoi);
    /*Return*/
    return;
    }

    /***
    $Log: mouse_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:02reddawg
    nomessage

    Revision1.32004/09/0721:54:38reddawg
    okrevertedbacktooldschedulingfornow....

    Revision1.22004/09/0615:13:25reddawg
    LastcommitbeforeFreeBSD6.0

    Revision1.12004/06/0410:20:53reddawg
    mousedrive:fixedafewbugsworksabitbetternow

    END
    ***/