00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 #include <ubixos/systemtask.h>
00031 #include <ubixos/kpanic.h>
00032 #include <ubixos/exec.h>
00033 #include <ubixos/tty.h>
00034 #include <ubixos/sched.h>
00035 #include <ubixos/vitals.h>
00036 #include <lib/kmalloc.h>
00037 #include <lib/kprintf.h>
00038 #include <lib/bioscall.h>
00039 #include <sde/sde.h>
00040 #include <sys/io.h>
00041 #include <vmm/vmm.h>
00042 #include <mpi/mpi.h>
00043 #include <string.h>
00044 
00045 static unsigned char  *videoBuffer = (char *)0xB8000;
00046 
00047 
00048 void systemTask() {
00049   mpi_message_t myMsg;
00050   uInt32       counter  = 0x0;
00051   int          i        = 0x0;
00052   int          *x       = 0x0;
00053   kTask_t      *tmpTask = 0x0;
00054 
00055   if (mpi_createMbox("system") != 0x0) {
00056     kpanic("Error: Error creating mailbox: system\n");
00057     }
00058 
00059   while(1) {
00060     if (mpi_fetchMessage("system",&myMsg) == 0x0) {
00061       kprintf("A");
00062       switch(myMsg.header) {
00063         case 0x69:
00064           x = (int *)&myMsg.data;
00065           kprintf("Switching to term: [%i][%i]\n",*x,myMsg.pid);
00066           schedFindTask(myMsg.pid)->term = tty_find(*x);
00067           break;
00068         case 1000:
00069           kprintf("Restarting the system in 5 seconds\n");
00070           counter = systemVitals->sysUptime + 5;
00071           while (systemVitals->sysUptime < counter) {
00072             sched_yield();
00073             }
00074           kprintf("Rebooting NOW!!!\n");
00075           while(inportByte(0x64) & 0x02);
00076           outportByte(0x64, 0xFE);
00077           break;
00078         case 31337:
00079            kprintf("system: backdoor opened\n");
00080            break;       
00081         case 0x80:
00082            if (!strcmp(myMsg.data,"sdeStart")) {
00083              kprintf("Starting SDE\n");
00084              
00085              }
00086            else if (!strcmp(myMsg.data,"freePage")) {
00087             kprintf("kkk Free Pages");
00088              }
00089            else if (!strcmp(myMsg.data,"sdeStop")) {
00090              printOff = 0x0;
00091              biosCall(0x10,0x3,0x0,0x0,0x0,0x0,0x0,0x0,0x0);
00092              for (i=0x0;i<100;i++) asm("hlt");
00093              }
00094            break;
00095         default:
00096           kprintf("system: Received message %i:%s\n",myMsg.header,myMsg.data);
00097           break;
00098         }
00099       }
00100 
00101     
00102 
00103 
00104 
00105 
00106     tmpTask = sched_getDelTask();    
00107     if (tmpTask != 0x0) {
00108       if (tmpTask->imageFd != 0x0)
00109         fclose(tmpTask->imageFd);
00110       vmmFreeProcessPages(tmpTask->id);
00111       kfree(tmpTask);
00112       }
00113     videoBuffer[0] = systemVitals->sysTicks;     
00114     sched_yield();
00115     }    
00116   
00117   return;
00118   }
00119 
00120 
00121 
00122 
00123