From: John Hodge Date: Tue, 17 Jul 2012 08:05:29 +0000 (+0800) Subject: Kernel - Fixing bugs exposed with `qemu -nographic` X-Git-Tag: rel0.15~611^2~24 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=d8b31df1121ff75fe218f83574eb600c47f8d2d5;p=tpg%2Facess2.git Kernel - Fixing bugs exposed with `qemu -nographic` --- diff --git a/KernelLand/Kernel/arch/x86/main.c b/KernelLand/Kernel/arch/x86/main.c index 75db3740..92fef22c 100644 --- a/KernelLand/Kernel/arch/x86/main.c +++ b/KernelLand/Kernel/arch/x86/main.c @@ -48,8 +48,6 @@ int kmain(Uint MbMagic, void *MbInfoPtr) LogF("Acess2 x86-"PLATFORM" v"EXPAND_STR(KERNEL_VERSION)"\r\n"); LogF(" Build %i, Git Hash %s\r\n", BUILD_NUM, gsGitHash); - Log("MbMagic = %08x, MbInfoPtr = %p", MbMagic, MbInfoPtr); - // Set up non-boot info dependent stuff Desctab_Install(); // Set up GDT and IDT MM_PreinitVirtual(); // Initialise virtual mappings @@ -121,6 +119,7 @@ int kmain(Uint MbMagic, void *MbInfoPtr) } else gaArch_BootModules[i].ArgString = (char *)mods[i].String + KERNEL_BASE; + Log_Log("Arch", " - %s", gaArch_BootModules[i].ArgString); } // Pass on to Independent Loader diff --git a/KernelLand/Kernel/arch/x86/mm_phys.c b/KernelLand/Kernel/arch/x86/mm_phys.c index 49d7a1a7..bd1cafcd 100644 --- a/KernelLand/Kernel/arch/x86/mm_phys.c +++ b/KernelLand/Kernel/arch/x86/mm_phys.c @@ -118,7 +118,7 @@ void MM_Install(tMBoot_Info *MBoot) gaPageReferences = (void*)MM_REFCOUNT_BASE; Log_Log("PMem", "Physical memory set up (%lli pages of ~%lli MiB used)", - giPhysAlloc, (giTotalMemorySize*4)/1024 + giPhysAlloc, (giTotalMemorySize*PAGE_SIZE)/(1024*1024) ); } diff --git a/KernelLand/Kernel/arch/x86/proc.c b/KernelLand/Kernel/arch/x86/proc.c index 281b6288..cd5316e5 100644 --- a/KernelLand/Kernel/arch/x86/proc.c +++ b/KernelLand/Kernel/arch/x86/proc.c @@ -863,6 +863,10 @@ void Proc_DumpThreadCPUState(tThread *Thread) __asm__ __volatile__ ("mov %%ebp, %0" : "=r" (stack)); while( maxBacktraceDistance -- ) { + if( !CheckMem(stack, 8) ) { + regs = NULL; + break; + } // [ebp] = oldEbp // [ebp+4] = retaddr diff --git a/KernelLand/Kernel/modules.c b/KernelLand/Kernel/modules.c index 8202b086..dd8a3ae1 100644 --- a/KernelLand/Kernel/modules.c +++ b/KernelLand/Kernel/modules.c @@ -8,6 +8,7 @@ #define USE_EDI 0 #define USE_UDI 0 +#define MODULE_FLAG_LOADERROR 0x1 // === PROTOTYPES === int Module_int_Initialise(tModule *Module, const char *ArgString); @@ -80,6 +81,15 @@ int Module_int_Initialise(tModule *Module, const char *ArgString) "Module %p (%s) is for another architecture (%i)", Module, Module->Name, Module->Arch ); + LEAVE('i', MODULE_ERR_BADMODULE); + return MODULE_ERR_BADMODULE; + } + + LOG("Module->Flags = %x", Module->Flags); + if(Module->Flags & MODULE_FLAG_LOADERROR ) { + Log_Warning("Module", "%s has already attempted to load and encountered errors", Module->Name); + LEAVE('i', MODULE_ERR_MISC); + return MODULE_ERR_MISC; } deps = Module->Dependencies; @@ -168,7 +178,7 @@ int Module_int_Initialise(tModule *Module, const char *ArgString) Log_Warning("Module", "Unable to load, reason: Miscelanious"); break; case MODULE_ERR_NOTNEEDED: -// Log_Debug("Module", "Unable to load, reason: Module not needed"); + Log_Debug("Module", "Unable to load, reason: Module not needed"); break; case MODULE_ERR_MALLOC: Log_Warning("Module", "Unable to load, reason: Error in malloc/realloc/calloc, probably not good"); @@ -177,6 +187,7 @@ int Module_int_Initialise(tModule *Module, const char *ArgString) Log_Warning("Module", "Unable to load reason - Unknown code %i", ret); break; } + Module->Flags |= MODULE_FLAG_LOADERROR; LEAVE_RET('i', ret); return ret; } diff --git a/KernelLand/Modules/Input/Keyboard/main.c b/KernelLand/Modules/Input/Keyboard/main.c index f49d8ea5..9c2e20e6 100644 --- a/KernelLand/Modules/Input/Keyboard/main.c +++ b/KernelLand/Modules/Input/Keyboard/main.c @@ -164,6 +164,15 @@ void Keyboard_HandleKey(tKeyboard *Source, Uint32 HIDKeySym) Uint32 flag; Uint8 layer; + if( !Source ) { + Log_Error("Keyboard", "Passed NULL handle"); + return ; + } + if( !Source->Node ) { + Log_Error("Keyboard", "Passed handle with NULL node"); + return ; + } + bPressed = !(HIDKeySym & (1 << 31)); HIDKeySym &= 0x7FFFFFFF;