/***************************************************************************************** Copyright (c) 2002-2004 The UbixOS Project All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. $Id$ *****************************************************************************************/ #include <ubixos/systemtask.h> #include <ubixos/kpanic.h> #include <ubixos/vitals.h> #include <ubixos/exec.h> #include <ubixos/tty.h> #include <ubixos/sched.h> #include <lib/kmalloc.h> #include <lib/kprintf.h> #include <lib/bioscall.h> #include <sde/sde.h> #include <sys/io.h> #include <mpi/mpi.h> #include <string.h> void systemTask() { mpi_message_t myMsg; uInt32 counter = 0x0; int i = 0x0; int *x = 0x0; kTask_t *tmpTask = 0x0; if (mpi_createMbox("system") != 0x0) { kpanic("Error: Error creating mailbox: system\n"); } while(1) { if (mpi_fetchMessage("system",&myMsg) == 0x0) { kprintf("A"); switch(myMsg.header) { case 0x69: x = (int *)&myMsg.data; kprintf("Switching to term: [%i][%i]\n",*x,myMsg.pid); schedFindTask(myMsg.pid)->term = tty_find(*x); break; case 1000: kprintf("Restarting the system in 5 seconds\n"); counter = systemVitals->sysUptime + 5; while (systemVitals->sysUptime < counter) { sched_yield(); } kprintf("Rebooting NOW!!!\n"); while(inportByte(0x64) & 0x02); outportByte(0x64, 0xFE); break; case 31337: kprintf("system: backdoor opened\n"); break; case 0x80: if (!strcmp(myMsg.data,"sdeStart")) { kprintf("Starting SDE\n"); execThread(sdeThread,(uInt32)(kmalloc(0x2000)+0x2000),0x0); } else if (!strcmp(myMsg.data,"freePage")) { kprintf("Free Page: %i\n",systemVitals->freePages); } else if (!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: Received message %i:%s\n",myMsg.header,myMsg.data); break; } } tmpTask = sched_getDelTask(); if (tmpTask != 0x0) { //kprintf("Deleting Task: %i\n",tmpTask->id); vmmFreeProcessPages(tmpTask->id); if (tmpTask->imageFd != 0x0) fclose(tmpTask->imageFd); if (tmpTask->oInfo.cwd != 0x0) kfree(tmpTask->oInfo.cwd); kfree(tmpTask); } sched_yield(); } return; } /*** $Log$ Revision 1.22 2004/09/11 14:23:34 reddawg ok Revision 1.21 2004/09/08 23:19:58 reddawg hmm Revision 1.20 2004/09/08 22:16:02 reddawg Fixens Revision 1.19 2004/09/07 21:54:38 reddawg ok reverted back to old scheduling for now.... Revision 1.18 2004/09/06 22:01:28 reddawg Created functions sched_addDelTask and sched_getDelTask so we can lock the delete task list to prevent corruption of pointers.... a very random case but possible none the less Revision 1.17 2004/09/06 21:39:21 reddawg Fixes: Changed the order in which tasks are deleted from the queues. Also fixed backspace to work in the virtual ttys.... Revision 1.16 2004/08/29 21:43:06 reddawg sched: we now yeild almost propper syscall: it still uses ebx,ecx,edx Boys don't cry Revision 1.15 2004/08/26 22:51:18 reddawg TCA touched me :( i think he likes men.... sched.h: kTask_t added parentPid endtask.c: fixed term back to parentPid exec.c: cleaned warnings fork.c: fixed term to childPid sched.c: clean up for dead tasks systemtask.c: clean up dead tasks kmalloc.c: cleaned up warnings udp.c: cleaned up warnings bot.c: cleaned up warnings shell.c: cleaned up warnings tcpdump.c: took a dump hd.c: cleaned up warnings ubixfs.c: stopped prning debug info Revision 1.14 2004/08/24 23:33:45 reddawg Fixed Revision 1.13 2004/08/24 05:24:37 reddawg TCA Is A BONER!!!! Revision 1.12 2004/08/14 11:23:02 reddawg Changes Revision 1.11 2004/08/06 22:43:04 reddawg ok Revision 1.10 2004/08/06 22:32:16 reddawg Ubix Works Again Revision 1.8 2004/07/28 17:07:25 reddawg MPI: moved the syscalls Revision 1.7 2004/07/20 22:29:55 reddawg assert: remade assert Revision 1.6 2004/06/29 11:27:30 reddawg sdeStop - Turn printf off until modes have changed Revision 1.5 2004/06/29 11:23:22 reddawg sdeStop - Does this patch help? Revision 1.4 2004/06/29 11:18:11 reddawg sdeStop Revision 1.3 2004/06/28 23:12:58 reddawg file format now container:/path/to/file Revision 1.2 2004/06/25 17:25:52 reddawg I am cleaning too Revision 1.1 2004/06/04 17:33:33 reddawg Changed idle task to system task Revision 1.9 2004/06/04 13:29:56 reddawg libc: modified mkdir(); interface kpanic: kPanic(); now says kPanic: %s system: now reboots when receives message for reboot also when command start sde is received by system the STD is started Revision 1.8 2004/05/26 23:48:33 reddawg idletask: tweaked reboot for performance Revision 1.7 2004/05/26 23:28:29 reddawg idletask: This task now also receives all of the systems message We also gained reboot suport that is msg send type 1000 Revision 1.6 2004/05/25 18:42:28 reddawg Idle task now just does what it is suposed to Revision 1.5 2004/05/25 17:30:16 reddawg IDLE task will be our toy task to test things with Revision 1.4 2004/05/25 15:49:03 reddawg Added Syscall Interface For MPI Revision 1.3 2004/05/21 12:36:53 reddawg Cleaned Up Revision 1.2 2004/05/15 02:30:28 reddawg Lots of changes END ***/