/**
 * @file debug.c
 * @brief Functions for support debugging
 * 
 * debugging info
 * NDEBUG - no debugging
 * DEBUG - automatically set up when NDEBUG not defined
 * 
 */
 
#include "debug.h"
#include "io.h"

/*
 * makro assert(EXPR)
 * makro dprintk(ARGS...)
 * void panic (const char * format, ...)
 *
 */

/**
 * @brief Kernel panic function
 * @param format - formatted string same as printk
 * @param ... - arguments 
 * 
 * Print formated null-terminated string, print current running thread ID, print 
 * CPU registers and halt machine.
 */

void panic(const char* format, ...){
	printk("Kernel panic: \n"); 
	printk_unwind(format, (void*) (&format +1));
	printk("Current running thread ID: %d", current_thread->id);
	___reg_view();
	___halt();	
}

