/*
    Error.h, Copyright 6.3.97 (c) by Christian Conrad,
    Swiss Federal Institute of Technology,
    Computer Engineering and Networks Laboratory.
 
    TOPSY -- A Teachable Operating System.
             Implementation of a tiny and simple
             micro kernel for teaching purposes.
 
    For further information, please visit http://www.tik.ee.ethz.ch/~topsy
 
    This software is provided under the terms of the GNU General Public Licence.
 
    A full copy of the GNU GPL is provided in the file COPYING found in the 
    development root of Topsy.
*/
/*
	
	File:                  $Source: /home/ruf/cvs_Topsy/cvs/Topsy/Topsy/Error.h,v $
 	Author(s):             Christian Conrad
 	Affiliation:           ETH Zuerich, TIK
 	Version:               $Revision: 2935 $
 	Creation Date:         6.3.97
 	Last Date of Change:   $Date: 2007-03-21 11:58:17 +0100 (Mit, 21 Mär 2007) $      by: $Author: baderma $
*/

#ifndef __ERROR_H
#define __ERROR_H

#include "Threads.h"

/*
 * There are 3 debug levels:
 *       INFO_LEVEL     : for information
 *       WARNING_LEVEL  : anomality
 *       ERROR_LEVEL    : error (no panic nessary)
 */
#define INFO_LEVEL      1
#define WARNING_LEVEL   2
#define ERROR_LEVEL     3

/* Not possible to mask panic messages */
#define PANIC(s)       panic( getCurrentThreadName(), __FILE__, __LINE__, s)
#define CHECK(c,s)     check( getCurrentThreadName(), __FILE__, __LINE__, s, c)

#if DEBUG_LEVEL <= INFO_LEVEL
#define INFO(s)        info(getCurrentThreadName(), __FILE__, __LINE__, s)
#else
#define INFO(s)
#endif

#if DEBUG_LEVEL <= WARNING_LEVEL
#define WARNING(s)     warning(getCurrentThreadName(), __FILE__, __LINE__, s)
#else
#define WARNING(s)
#endif

#if DEBUG_LEVEL <= ERROR_LEVEL
#define ERROR(s)       error(getCurrentThreadName(), __FILE__, __LINE__, s)
#else
#define ERROR(s)
#endif


void panic( char* threadName,
            const char* fileName,
            int lineNumber,
            char* errorMessage);

void error( char* threadName,
            const char* fileName,
            int lineNumber,
            char* errorMessage);

void warning( char* threadName,
              const char* fileName,
              int lineNumber,
              char* errorMessage);

void info( char* threadName,
           const char* fileName,
           int lineNumber,
           char* errorMessage);

void printRegisters(void);

void check( char* threadName,
            const char* fileName,
            int lineNumber,
            char* errorMessage,
            int condition);

#endif
