#ifndef _CONTEXT_H_
#define _CONTEXT_H_

#include <linux/types.h>
#include <linux/sched.h>
#include <linux/interrupt.h>

#include <eti/mm.h>

#define RUN_BOTTOM							\
   if ( bh_active & bh_mask )					        \
	 do_bottom_half();


#define isNonNmi(ctx) \
     ( ((ctx)->header.u.s.type != ETI_EXCEPTION_CONTEXT)  \
       || (((ctxExceptionContext_t)(ctx))->nonNmi) \
     )


#define DO_RESCHED(ctx)							\
   if ( user_mode(ctx) && isNonNmi(ctx) && current->need_resched )	\
	 schedule();
   
   
#define DO_SIGNAL(ctx)		                	                \
   if ( user_mode(ctx) && isNonNmi(ctx) && current->sigpending )	\
	 do_signal(0,ctx);
   
   
#define SIGRETURN_TRAP_ADDRESS  0x80000000


//#define NDEBUG
#ifndef NDEBUG
    #define CHECK_STACK(x) __CHECK_STACK(x)
#else
    #define CHECK_STACK(x)
#endif


#endif _CONTEXT_H_
