From: John Hodge (sonata) Date: Tue, 13 Nov 2012 06:00:07 +0000 (+0800) Subject: Kernel - Fixing bugs from previous commig X-Git-Tag: rel0.15~660 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=8c2139762f72576650cb5d07f5d9152b781e2643;p=tpg%2Facess2.git Kernel - Fixing bugs from previous commig --- diff --git a/KernelLand/Kernel/arch/x86/mboot.c b/KernelLand/Kernel/arch/x86/mboot.c index 897c9bbb..7403f387 100644 --- a/KernelLand/Kernel/arch/x86/mboot.c +++ b/KernelLand/Kernel/arch/x86/mboot.c @@ -30,6 +30,7 @@ int Multiboot_LoadMemoryMap(tMBoot_Info *MBInfo, tVAddr MapOffset, tPMemMapEnt * if( !MM_GetPhysAddr(ent) ) Log_KernelPanic("MBoot", "MBoot Map entry %i addres bad (%p)", nPMemMapEnts, ent); + LOG("%llx+%llx", ent->Base, ent->Length); nent->Start = ent->Base; nent->Length = ent->Length; @@ -68,15 +69,18 @@ int Multiboot_LoadMemoryMap(tMBoot_Info *MBInfo, tVAddr MapOffset, tPMemMapEnt * } // Ensure it's valid + LOG("Validating"); nPMemMapEnts = PMemMap_ValidateMap(Map, nPMemMapEnts, MapSize); // TODO: Error handling // Replace kernel with PMEMTYPE_USED + LOG("Marking kernel"); nPMemMapEnts = PMemMap_MarkRangeUsed( Map, nPMemMapEnts, MapSize, KStart, KEnd - KStart ); + LOG("Dumping"); PMemMap_DumpBlocks(Map, nPMemMapEnts); // Check if boot modules were passed diff --git a/KernelLand/Kernel/include/logdebug.h b/KernelLand/Kernel/include/logdebug.h index 13d3b82b..80cb1c93 100644 --- a/KernelLand/Kernel/include/logdebug.h +++ b/KernelLand/Kernel/include/logdebug.h @@ -56,7 +56,7 @@ extern void Debug_HexDump(const char *Header, const void *Data, size_t Length); # define LEAVE_RET(_t,_v...) return (_v) # define LEAVE_RET0() return #endif -#if SANITY +#if !DISABLE_ASSERTS # define ASSERT(expr) do{if(!(expr))Panic("%s:%i - %s: Assertion '"#expr"' failed",__FILE__,__LINE__,(char*)__func__);}while(0) #else # define ASSERT(expr) diff --git a/KernelLand/Kernel/libc.c b/KernelLand/Kernel/libc.c index ea705795..1b6f3716 100644 --- a/KernelLand/Kernel/libc.c +++ b/KernelLand/Kernel/libc.c @@ -187,6 +187,8 @@ void itoa(char *buf, Uint64 num, int base, int minLength, char pad) #define PUTCH(ch) do { \ if(pos < __maxlen) { \ if(__s) __s[pos] = ch; \ + } else { \ + (void)ch;\ } \ pos ++; \ } while(0) diff --git a/KernelLand/Kernel/logging.c b/KernelLand/Kernel/logging.c index 323e84b3..aab25a10 100644 --- a/KernelLand/Kernel/logging.c +++ b/KernelLand/Kernel/logging.c @@ -91,12 +91,10 @@ void Log_AddEvent(const char *Ident, int Level, const char *Format, va_list Args va_list args_tmp; if( Level >= NUM_LOG_LEVELS ) return; - + va_copy(args_tmp, Args); len = vsnprintf(NULL, 256, Format, args_tmp); - //Log("len = %i", len); - #if USE_RING_BUFFER || !CACHE_MESSAGES { char buf[sizeof(tLogEntry)+len+1]; diff --git a/KernelLand/Modules/USB/Core/usb.c b/KernelLand/Modules/USB/Core/usb.c index eb1aa391..c4e16809 100644 --- a/KernelLand/Modules/USB/Core/usb.c +++ b/KernelLand/Modules/USB/Core/usb.c @@ -31,7 +31,7 @@ tUSBHub *USB_RegisterHost(tUSBHostDef *HostDef, void *ControllerPtr, int nPorts) { tUSBHost *host; - host = malloc(sizeof(tUSBHost) + sizeof(tUSBDevice) + sizeof(tUSBInterface) + nPorts*sizeof(tUSBHubPort)); + host = malloc(sizeof(tUSBHost) + nPorts*sizeof(tUSBHubPort) + sizeof(tUSBDevice) + sizeof(tUSBInterface)); if(!host) { // Oh, bugger. return NULL; @@ -40,15 +40,15 @@ tUSBHub *USB_RegisterHost(tUSBHostDef *HostDef, void *ControllerPtr, int nPorts) host->Ptr = ControllerPtr; memset(host->AddressBitmap, 0, sizeof(host->AddressBitmap)); - host->RootHubDev = (void*)(host + 1); + host->RootHubDev = (void*)(host->RootHub.Ports + nPorts); host->RootHubDev->ParentHub = NULL; host->RootHubDev->Host = host; host->RootHubDev->Address = 0; ASSERT(HostDef->InitControl); host->RootHubDev->EndpointHandles[0] = HostDef->InitControl(ControllerPtr, 0, 64); + host->RootHubDev->nInterfaces = 0; host->RootHubIf = (void*)(host->RootHubDev + 1); -// host->RootHubIf->Next = NULL; host->RootHubIf->Dev = host->RootHubDev; host->RootHubIf->Driver = NULL; host->RootHubIf->Data = NULL; diff --git a/KernelLand/Modules/USB/Core/usb_devinit.c b/KernelLand/Modules/USB/Core/usb_devinit.c index 0da8c85c..c9655cb3 100644 --- a/KernelLand/Modules/USB/Core/usb_devinit.c +++ b/KernelLand/Modules/USB/Core/usb_devinit.c @@ -362,6 +362,7 @@ void USB_SetDeviceDataPtr(tUSBInterface *Dev, void *Ptr) { Dev->Data = Ptr; } int USB_int_AllocateAddress(tUSBHost *Host) { int i; + ASSERT(Host); for( i = 1; i < 128; i ++ ) { if(Host->AddressBitmap[i/8] & (1 << (i%8)))