systemtask.c
ubixos/systemtask.h
ubixos/kpanic.h
ubixos/exec.h
ubixos/tty.h
ubixos/sched.h
ubixos/vitals.h
lib/kmalloc.h
lib/kprintf.h
lib/bioscall.h
sde/sde.h
sys/io.h
vmm/vmm.h
mpi/mpi.h
string.h
sys/thread.h
ubixos/kpanic.h
ubixos/sched.h
lib/bioscall.h
ubixos/vitals.h
ubixos/systemtask.h
ubixos/types.h
sys/_types.h
src/sys/kernel/systemtask.c
vmm/paging.h
string.h
ubixos/time.h
vfs/file.h
sys/tss.h
lib/kmalloc.h
vmm/vmm.h
mpi/mpi.h
vfs/vfs.h
vfs/mount.h
lib/kprintf.h
ubixos/ubthread.h
ubixfs/dirCache.h
sde/sde.h
ubixos/exec.h
sys/sysproto.h
sys/signal.h
ubixos/tty.h
sys/io.h
void void systemTask () systemTask biosCall mpi_message::data fclose mpi_message::header taskStruct::id taskStruct::imageFd inportByte kfree kpanic kprintf mpi_createMbox mpi_fetchMessage outportByte mpi_message::pid printOff sched_getDelTask sched_yield schedFindTask strcmp systemVitals vitalsStruct::sysTicks vitalsStruct::sysUptime taskStruct::term tty_find videoBuffer vmmFreeProcessPages x10 kmain
unsigned char * unsigned char* videoBuffer videoBuffer (char *)0xB8000 backSpace clearScreen kprint systemTask

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

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

    #include<ubixos/systemtask.h>
    #include<ubixos/kpanic.h>
    #include<ubixos/exec.h>
    #include<ubixos/tty.h>
    #include<ubixos/sched.h>
    #include<ubixos/vitals.h>
    #include<lib/kmalloc.h>
    #include<lib/kprintf.h>
    #include<lib/bioscall.h>
    #include<sde/sde.h>
    #include<sys/io.h>
    #include<vmm/vmm.h>
    #include<mpi/mpi.h>
    #include<string.h>

    staticunsignedchar*videoBuffer=(char*)0xB8000;

    voidsystemTask(){
    mpi_message_tmyMsg;
    uInt32counter=0x0;
    inti=0x0;
    int*x=0x0;
    kTask_t*tmpTask=0x0;

    if(mpi_createMbox("system")!=0x0){
    kpanic("Error:Errorcreatingmailbox:system\n");
    }

    while(1){
    if(mpi_fetchMessage("system",&myMsg)==0x0){
    kprintf("A");
    switch(myMsg.header){
    case0x69:
    x=(int*)&myMsg.data;
    kprintf("Switchingtoterm:[%i][%i]\n",*x,myMsg.pid);
    schedFindTask(myMsg.pid)->term=tty_find(*x);
    break;
    case1000:
    kprintf("Restartingthesystemin5seconds\n");
    counter=systemVitals->sysUptime+5;
    while(systemVitals->sysUptime<counter){
    sched_yield();
    }
    kprintf("RebootingNOW!!!\n");
    while(inportByte(0x64)&0x02);
    outportByte(0x64,0xFE);
    break;
    case31337:
    kprintf("system:backdooropened\n");
    break;
    case0x80:
    if(!strcmp(myMsg.data,"sdeStart")){
    kprintf("StartingSDE\n");
    //execThread(sdeThread,(uInt32)(kmalloc(0x2000)+0x2000),0x0);
    }
    elseif(!strcmp(myMsg.data,"freePage")){
    kprintf("kkkFreePages");
    }
    elseif(!strcmp(myMsg.data,"sdeStop")){
    printOff=0x0;
    biosCall(0x10,0x3,0x0,0x0,0x0,0x0,0x0,0x0,0x0);
    for(i=0x0;i<100;i++)asm("hlt");
    }
    break;
    default:
    kprintf("system:Receivedmessage%i:%s\n",myMsg.header,myMsg.data);
    break;
    }
    }

    /*
    Herewegetthenexttaskfromthedeletetaskqueue
    wefirstchecktoseeifithasanfdattachedforthebinaryandafterthat
    wefreethepagesfortheprocessandthenfreethetask
    */
    tmpTask=sched_getDelTask();
    if(tmpTask!=0x0){
    if(tmpTask->imageFd!=0x0)
    fclose(tmpTask->imageFd);
    vmmFreeProcessPages(tmpTask->id);
    kfree(tmpTask);
    }
    videoBuffer[0]=systemVitals->sysTicks;
    sched_yield();
    }

    return;
    }

    /***
    END
    ***/