#ifndef __DEV_INTCONTROLLER_H
#define __DEV_INTCONTROLLER_H

#include <sys/types.h>
#include <dev/DeviceNode.h>
#include <kernel/Spinlock.h>

namespace OS {
namespace Dev {

class Device;
	
class IntController : public DeviceNode {
public:
	IntController(const char *name);
	virtual ~IntController();

	virtual status_t MaskInterrupt(unsigned int vector, bool *oldstate = NULL) = 0;
	virtual status_t UnmaskInterrupt(unsigned int vector, bool *oldstate = NULL) = 0;

	virtual unsigned int VectorCount() = 0;

	virtual status_t RegisterHandler(unsigned int vector, Device *d);

protected:
	// needs to be called before RegisterHandler 
	void AllocHandlerTable();

	enum handlerReturn DispatchInterrupt(unsigned int vector);
	
private:
	Device **mHandlerTable;
	Kernel::Spinlock mHandlerLock;
};

}} // OS::Dev

#endif
