78 lines
2.0 KiB
C++

// Copyright (C) 2004 Intel Corporation
#ifndef __HECI_WIN_H__
#define __HECI_WIN_H__
#include <windows.h>
#include "HECI.h"
#define HECI_MAX_LINE_LEN 300
static const unsigned long RECEIVE_MESSAGE_DEFAULT_TIMEOUT = 2000;
static const unsigned long SEND_MESSAGE_DEFAULT_TIMEOUT = 0xFFFFFFFF;
class HECIWin : public HECI {
public:
HECIWin(const GUID guid, bool verbose = false);
virtual ~HECIWin();
/*
* Open the related HECI driver file and connect to the FW HECI Client.
*
* Return value:
* True on success.
*/
virtual bool Init();
/*
* Close the related HECI driver file.
*
*/
virtual void Deinit();
/*
* Receive a message from the FW HECI client.
* Arguments:
* buffer - holds the message to be read.
* len - number of bytes to read.
* timeout - timeout for the read operation.
* Return value:
* The number of read bytes.
*/
virtual int ReceiveMessage(unsigned char *buffer, int len, unsigned long timeout = RECEIVE_MESSAGE_DEFAULT_TIMEOUT);
/*
* Send a message to the FW HECI client.
* Arguments:
* buffer - holds the message to be send.
* len - number of bytes to send.
* timeout - timeout for the send operation.
* Return value:
* The number of written bytes.
*/
virtual int SendMessage(unsigned char *buffer, int len, unsigned long timeout = SEND_MESSAGE_DEFAULT_TIMEOUT);
/*
* Return the max buffer size of the FW HECI client.
*
* Return value:
* The buffer size.
*/
virtual unsigned long GetBufferSize() { return _bufSize; }
//Return the file handle of the HECI driver.
HANDLE GetHandle();
private:
//Allow userspace code to communicate with HECI driver.
int _doIoctl(DWORD code, void *inbuf, int inlen, void *outbuf, int outlen);
//Return an appropriate message according to the err it gets.
static TCHAR *_getErrMsg(DWORD err);
//Display a HECI error message.
VOID _displayHECIError(UINT32 errorCode,DWORD lastError);
//Display a HECI data message.
VOID _displayHECIData(UINT32 messageId);
//file handle
HANDLE _handle;
};
#endif