Kernel - Fixing bugs from previous commig
authorJohn Hodge (sonata) <[email protected]>
Tue, 13 Nov 2012 06:00:07 +0000 (14:00 +0800)
committerJohn Hodge (sonata) <[email protected]>
Tue, 13 Nov 2012 06:00:07 +0000 (14:00 +0800)
KernelLand/Kernel/arch/x86/mboot.c
KernelLand/Kernel/include/logdebug.h
KernelLand/Kernel/libc.c
KernelLand/Kernel/logging.c
KernelLand/Modules/USB/Core/usb.c
KernelLand/Modules/USB/Core/usb_devinit.c

index 897c9bb..7403f38 100644 (file)
@@ -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
index 13d3b82..80cb1c9 100644 (file)
@@ -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)
index ea70579..1b6f371 100644 (file)
@@ -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)
index 323e84b..aab25a1 100644 (file)
@@ -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];
index eb1aa39..c4e1680 100644 (file)
@@ -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;
index 0da8c85..c9655cb 100644 (file)
@@ -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)))

UCC git Repository :: git.ucc.asn.au