From: John Hodge Date: Mon, 28 Sep 2009 01:07:08 +0000 (+0800) Subject: Cut down on debug, fixed tabs, made process tree be killed when root is killed X-Git-Tag: rel0.06~412 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=1a96e0dd77d6922078edd703fc7c2e809b9499b8;p=tpg%2Facess2.git Cut down on debug, fixed tabs, made process tree be killed when root is killed --- diff --git a/Kernel/arch/x86/mm_virt.c b/Kernel/arch/x86/mm_virt.c index 7db7cedd..d2d4e4bf 100644 --- a/Kernel/arch/x86/mm_virt.c +++ b/Kernel/arch/x86/mm_virt.c @@ -40,6 +40,7 @@ // === IMPORTS === extern Uint32 gaInitPageDir[1024]; extern Uint32 gaInitPageTable[1024]; +extern void Threads_SegFault(Uint Addr); // === PROTOTYPES === void MM_PreinitVirtual(); @@ -124,6 +125,12 @@ void MM_PageFault(Uint Addr, Uint ErrorCode, tRegs *Regs) return; } + // If it was a user, tell the thread handler + if(ErrorCode & 4) { + Threads_SegFault(Addr); + return ; + } + // -- Check Error Code -- if(ErrorCode & 8) Warning("Reserved Bits Trashed!"); diff --git a/Kernel/drv/vterm.c b/Kernel/drv/vterm.c index af927176..304de691 100644 --- a/Kernel/drv/vterm.c +++ b/Kernel/drv/vterm.c @@ -472,7 +472,7 @@ void VT_int_PutChar(tVTerm *Term, Uint32 Ch) switch(Ch) { - case 0: return; // Ignore NULL byte + case '\0': return; // Ignore NULL byte case '\n': Term->WritePos += Term->Width; case '\r': @@ -481,7 +481,7 @@ void VT_int_PutChar(tVTerm *Term, Uint32 Ch) case '\t': do { - Term->Text[ Term->WritePos ].Ch = '\t'; + Term->Text[ Term->WritePos ].Ch = '\0'; Term->Text[ Term->WritePos ].Colour = Term->CurColour; Term->WritePos ++; } while(Term->WritePos & 7); @@ -493,7 +493,7 @@ void VT_int_PutChar(tVTerm *Term, Uint32 Ch) Term->WritePos --; // Singe Character - if(Term->Text[ Term->WritePos ].Ch != '\t') { + if(Term->Text[ Term->WritePos ].Ch != '\0') { Term->Text[ Term->WritePos ].Ch = 0; Term->Text[ Term->WritePos ].Colour = Term->CurColour; break; @@ -504,7 +504,7 @@ void VT_int_PutChar(tVTerm *Term, Uint32 Ch) Term->Text[ Term->WritePos ].Ch = 0; Term->Text[ Term->WritePos ].Colour = Term->CurColour; Term->WritePos --; - } while(Term->WritePos && i-- && Term->Text[ Term->WritePos ].Ch == '\t'); + } while(Term->WritePos && i-- && Term->Text[ Term->WritePos ].Ch == '\0'); break; default: diff --git a/Kernel/threads.c b/Kernel/threads.c index 824cb169..bcea3fa9 100644 --- a/Kernel/threads.c +++ b/Kernel/threads.c @@ -256,7 +256,10 @@ tThread *Threads_int_GetPrev(tThread **List, tThread *Thread) */ void Threads_Exit(int TID, int Status) { - Threads_Kill( Proc_GetCurThread(), (Uint)Status & 0xFF ); + if( TID == 0 ) + Threads_Kill( Proc_GetCurThread(), (Uint)Status & 0xFF ); + else + Threads_Kill( Threads_GetThread(TID), (Uint)Status & 0xFF ); } /** @@ -270,14 +273,14 @@ void Threads_Kill(tThread *Thread, int Status) tMsg *msg; // Kill all children - #if 0 + #if 1 { tThread *child; for(child = gActiveThreads; child; child = child->Next) { - if(child->PTID == gCurrentThread->TID) + if(child->PTID == Thread->TID) Threads_Kill(child, -1); } } @@ -453,6 +456,7 @@ void Threads_SetSignalHandler(int Num, void *Handler) /** * \fn void Threads_SendSignal(int TID, int Num) + * \brief Send a signal to a thread */ void Threads_SendSignal(int TID, int Num) { @@ -574,3 +578,13 @@ tThread *Threads_GetNextToRun(int CPU) return thread; } + +/** + * \fn void Threads_SegFault(tVAddr Addr) + * \brief Called when a Segment Fault occurs + */ +void Threads_SegFault(tVAddr Addr) +{ + //Threads_SendSignal( Proc_GetCurThread()->TID, SIGSEGV ); + Threads_Kill( Proc_GetCurThread(), 0 ); +} diff --git a/Kernel/vfs/open.c b/Kernel/vfs/open.c index f8274738..0494294d 100644 --- a/Kernel/vfs/open.c +++ b/Kernel/vfs/open.c @@ -121,7 +121,7 @@ char *VFS_GetAbsPath(char *Path) // `ret` should now be the absolute path LEAVE('s', ret); - Log("VFS_GetAbsPath: RETURN '%s'", ret); + //Log("VFS_GetAbsPath: RETURN '%s'", ret); return ret; } diff --git a/Usermode/Applications/CLIShell_src/main.c b/Usermode/Applications/CLIShell_src/main.c index 8298c2a0..4fe8a4a2 100644 --- a/Usermode/Applications/CLIShell_src/main.c +++ b/Usermode/Applications/CLIShell_src/main.c @@ -28,13 +28,15 @@ struct { {"colour", Command_Colour}, {"clear", Command_Clear}, {"cd", Command_Cd}, {"dir", Command_Dir} }; +static char *cDEFAULT_PATH[] = {"/Acess"}; #define BUILTIN_COUNT (sizeof(cBUILTINS)/sizeof(cBUILTINS[0])) // ==== LOCAL VARIABLES ==== + int giNumPathDirs = 1; +char **gasPathDirs = cDEFAULT_PATH; char **gasEnvironment; char gsCommandBuffer[1024]; char *gsCurrentDirectory = NULL; -char gsTmpBuffer[1024]; char **gasCommandHistory; int giLastCommand = 0; int giCommandSpace = 0; @@ -45,6 +47,7 @@ int main(int argc, char *argv[], char *envp[]) char *sCommandStr; char *saArgs[32]; int length = 0; + int i; int iArgCount = 0; int bCached = 1; @@ -105,17 +108,15 @@ int main(int argc, char *argv[], char *envp[]) if(saArgs[1][0] == '\0') continue; // Check Built-In Commands - // [HACK] Mem Usage - Use Length in place of `i' - for(length=0;length []\n"); Print("Valid Colours are "); for(fg=0;fg<8;fg++) { @@ -345,6 +374,10 @@ usage: return; } +/** + * \fn void Command_Clear(int argc, char **argv) + * \brief Clear the screen + */ void Command_Clear(int argc, char **argv) { write(_stdout, 4, "\x1B[2J"); //Clear Screen diff --git a/Usermode/Applications/cat_src/main.c b/Usermode/Applications/cat_src/main.c index a7f3ab32..8fc8463f 100644 --- a/Usermode/Applications/cat_src/main.c +++ b/Usermode/Applications/cat_src/main.c @@ -7,6 +7,10 @@ #define BUF_SIZE 1024 +/** + * \fn int main(int argc, char *argv[]) + * \brief Entrypoint + */ int main(int argc, char *argv[]) { int fd; @@ -18,7 +22,6 @@ int main(int argc, char *argv[]) return -1; } - //printf("Contents of `%s'\n", argv[1]); fd = open(argv[1], OPENFLAG_READ); if(fd == -1) { printf("Unable to open '%s' for reading\n", argv[1]); @@ -27,7 +30,6 @@ int main(int argc, char *argv[]) do { num = read(fd, BUF_SIZE, buf); - //printf("num = %i\n", num); buf[num] = '\0'; printf("%s", buf); } while(num == BUF_SIZE);