/**
 * @file int.h
 * @brief Header file for int.c
 * 
 */
 
#ifndef _INT_H_
#define _INT_H_

#include "sys.h"
#include "thread.h"

/**
 * macro saves the CP0 status register and globally disables interrupts
 *
 */
 
/* 
#define save_and_disable_interrupts (status) \
	( { if (current_thread->interrupt_counter==0) { \
			current_thread->interrupt_previous_state = read_cp0_status() & 1;	\
		current_thread->interrupt_counter++;	\
		disable_interrupts();	\
	} ) 

*/
void save_and_disable_interrupts();

/**
 * macro restores interrupt into the same state as before calling 
 * save_and_disable_interrupts(); 
 */
 
 /*
#define restore_interrupts (status) \
		( { if (current_thread->interrupt_counter) {	\
			  current_thread->interrupt_counter--;		\
			  if ((current_thread->interrupt_counter == 0) && (current_thread->interrupt_previous_state)) \
			  	enable_interrupts(); \
		} )
*/
void restore_interrupts();

inline void disable_interrupts (void) ;
inline void enable_interrupts (void); 

void interrupt (void);

#endif /* _INT_H_ */
