#ifndef __cdmachannel_h__
#define __cdmachannel_h__

#define PC_IMPLEMENTATION

#include <ntddk.h>
#include <portcls.h>

#ifdef __cplusplus

class CDmaChannel : public IDmaChannel
{
public:
	static IDmaChannel* Create(ULONG size, PHYSICAL_ADDRESS highestAddress);
	~CDmaChannel();

	STDMETHODIMP_(ULONG) AddRef();
	STDMETHODIMP_(ULONG) Release();
	STDMETHODIMP_(HRESULT) QueryInterface(REFIID iid, void** obj);

	IMP_IDmaChannel;

   void operator delete(void*);
   void* operator new(unsigned int n);

   static const ULONG memTag = '10K1';

private:
	CDmaChannel(PVOID buffer, ULONG size);

	ULONG ref;
	PVOID buffer;
	PHYSICAL_ADDRESS physicalBufstart;
	const ULONG allocatedSize;
	ULONG bufferSize;
};

extern "C"
{

#endif // __cplusplus

IDmaChannel* CreateCDmaChannel(ULONG size, PHYSICAL_ADDRESS highestAddress);

#ifdef __cplusplus
}
#endif

#endif // __cdmachannel_h__

