Kernel - Add debug_hooks.h header to contain hooks used by keyboard/serial debug...
authorJohn Hodge <[email protected]>
Sun, 9 Feb 2014 05:43:20 +0000 (13:43 +0800)
committerJohn Hodge <[email protected]>
Sun, 9 Feb 2014 05:43:20 +0000 (13:43 +0800)
KernelLand/Kernel/heap.c
KernelLand/Kernel/include/debug_hooks.h [new file with mode: 0644]
KernelLand/Kernel/threads.c
KernelLand/Modules/Input/Keyboard/main.c

index 20729d8..6e0a4c1 100755 (executable)
@@ -9,6 +9,7 @@
 #include <mm_virt.h>
 #include <heap_int.h>
 #include <limits.h>
+#include <debug_hooks.h>
 
 #define WARNINGS       1       // Warn and dump on heap errors
 #define        DEBUG_TRACE     0       // Enable tracing of allocations
@@ -37,8 +38,9 @@ void  *Heap_Merge(tHeapHead *Head);
 //void *Heap_AllocateZero(const char *File, int Line, size_t Bytes);
 //void *Heap_Reallocate(const char *File, int Line, void *Ptr, size_t Bytes);
 //void Heap_Deallocate(const char *File, int Line, void *Ptr);
-void   Heap_Dump(int bVerbose);
-void   Heap_Stats(void);
+//void Heap_Dump(void);
+void   Heap_ValidateDump(int bVerbose);
+//void Heap_Stats(void);
 
 // === GLOBALS ===
 tMutex glHeap;
@@ -98,7 +100,7 @@ void *Heap_Extend(size_t Bytes)
                if( !MM_Allocate( (tVAddr)gHeapEnd+(i<<12) ) )
                {
                        Warning("OOM - Heap_Extend (%i bytes)");
-                       Heap_Dump(1);
+                       Heap_Dump();
                        return NULL;
                }
        }
@@ -181,7 +183,7 @@ void *Heap_Allocate(const char *File, int Line, size_t __Bytes)
        }
 
        #if VALIDATE_ON_ALLOC
-       Heap_Dump(0);
+       Heap_Validate();
        #endif
        
        // Get required size
@@ -209,7 +211,7 @@ void *Heap_Allocate(const char *File, int Line, size_t __Bytes)
                        Log_Warning("Heap", "Size of heap address %p is invalid"
                                " - not aligned (0x%x) [at paddr 0x%x]",
                                head, head->Size, MM_GetPhysAddr(&head->Size));
-                       Heap_Dump(VERBOSE_DUMP);
+                       Heap_ValidateDump(VERBOSE_DUMP);
                        #endif
                        return NULL;
                }
@@ -218,7 +220,7 @@ void *Heap_Allocate(const char *File, int Line, size_t __Bytes)
                        Log_Warning("Heap", "Size of heap address %p is invalid"
                                " - Too small (0x%x) [at paddr 0x%x]",
                                head, head->Size, MM_GetPhysAddr(&head->Size));
-                       Heap_Dump(VERBOSE_DUMP);
+                       Heap_ValidateDump(VERBOSE_DUMP);
                        return NULL;
                }
                if( head->Size > (2<<30) ) {
@@ -226,7 +228,7 @@ void *Heap_Allocate(const char *File, int Line, size_t __Bytes)
                        Log_Warning("Heap", "Size of heap address %p is invalid"
                                " - Over 2GiB (0x%x) [at paddr 0x%x]",
                                head, head->Size, MM_GetPhysAddr(&head->Size));
-                       Heap_Dump(VERBOSE_DUMP);
+                       Heap_ValidateDump(VERBOSE_DUMP);
                        return NULL;
                }
                
@@ -238,7 +240,7 @@ void *Heap_Allocate(const char *File, int Line, size_t __Bytes)
                        #if WARNINGS
                        Log_Warning("Heap", "Magic of heap address %p is invalid (%p = 0x%x)",
                                head, &head->Magic, head->Magic);
-                       Heap_Dump(VERBOSE_DUMP);
+                       Heap_ValidateDump(VERBOSE_DUMP);
                        #endif
                        return NULL;
                }
@@ -559,10 +561,15 @@ void Heap_Validate(void)
 {
        // Call dump non-verbosely.
        // - If a heap error is detected, it'll print
-       Heap_Dump(0);
+       Heap_ValidateDump(0);
 }
 
-void Heap_Dump(int bVerbose)
+void Heap_Dump(void)
+{
+       Heap_ValidateDump(1);
+}
+
+void Heap_ValidateDump(int bVerbose)
 {
        tHeapHead       *head, *badHead;
        tHeapFoot       *foot = NULL;
diff --git a/KernelLand/Kernel/include/debug_hooks.h b/KernelLand/Kernel/include/debug_hooks.h
new file mode 100644 (file)
index 0000000..8ea4211
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * Acess2 Kernel
+ * - By John Hodge (thePowersGang)
+ *
+ * debug_hooks.h
+ * - Prototypes for methods used by keyboard/serial debugging
+ */
+#ifndef _DEBUG_HOOKS_H_
+#define _DEBUG_HOOKS_H_
+
+extern void    Heap_Dump(void);
+extern void    Threads_Dump(void);
+extern void    Threads_ToggleTrace(int TID);
+extern void    Heap_Stats(void);
+
+#endif
index 193ddfe..12613a2 100644 (file)
@@ -13,6 +13,7 @@
 #include <rwlock.h>
 #include <vfs_threads.h>       // VFS Handle maintainence
 #include <events.h>
+#include <debug_hooks.h>
 
 // Configuration
 #define DEBUG_TRACE_ACTIVEQUEUE        0       // Trace adds/removals from the active queue
@@ -70,8 +71,8 @@ void  Threads_Sleep(void);
  int   Threads_Wake(tThread *Thread);
 void   Threads_AddActive(tThread *Thread);
 tThread        *Threads_RemActive(void);
-#endif
 void   Threads_ToggleTrace(int TID);
+#endif
 void   Threads_Fault(int Num);
 void   Threads_SegFault(tVAddr Addr);
 void   Threads_PostSignalTo(tThread *Thread, int SignalNum);
@@ -91,7 +92,9 @@ tGID  Threads_GetGID(void);
  int   Threads_SetGID(Uint *Errno, tUID ID);
 #endif
 void   Threads_int_DumpThread(tThread *thread);
+#if 0
 void   Threads_Dump(void);
+#endif
 void   Threads_DumpActive(void);
 tThread        *Threads_int_GetRunnable(void);
 
index 16602be..31d155f 100644 (file)
 #include "keymap_int.h"
 #include "layout_kbdus.h"
 #include <hal_proc.h>
+#include <debug_hooks.h>
 
 #define USE_KERNEL_MAGIC       1
 
-// === IMPORTS ===
-#if USE_KERNEL_MAGIC
-extern void    Threads_ToggleTrace(int TID);
-extern void    Threads_Dump(void);
-extern void    Heap_Stats(void);
-#endif
-
 // === PROTOTYPES ===
  int   Keyboard_Install(char **Arguments);
  int   Keyboard_Cleanup(void);

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