📄 gptmdd.cpp
字号:
// This function suspends power to the device. It is useful only with
// devices that can power down under software control.
//
// Parameters:
// hDeviceContext
// [in] Handle to the device context.
//
// Returns:
// None.
//
//------------------------------------------------------------------------------
void GPT_PowerDown(DWORD hDeviceContext)
{
gptClass * pGpt=(gptClass *)hDeviceContext;
GPT_FUNCTION_ENTRY();
// Just clock gate the GPT when powering down.
BSPGptSetClockGatingMode(pGpt->m_dwIOBase, FALSE);
GPT_FUNCTION_EXIT();
}
//------------------------------------------------------------------------------
//
// Function: GPT_PowerUp
//
// This function restores power to a device.
//
// Parameters:
// hDeviceContext
// [in] Handle to the device context.
//
// Returns:
// None.
//
//------------------------------------------------------------------------------
void GPT_PowerUp(DWORD hDeviceContext)
{
gptClass * pGpt=(gptClass *)hDeviceContext;
GPT_FUNCTION_ENTRY();
BSPGptSetClockGatingMode(pGpt->m_dwIOBase, TRUE);
GPT_FUNCTION_EXIT();
}
//------------------------------------------------------------------------------
//
// Function: GPT_Read
//
// This function reads data from the device identified by the open
// context.
//
// Parameters:
// hOpenContext
// [in] Handle to the open context of the device. The XXX_Open
// function creates and returns this identifier.
//
// pBuffer
// [out] Pointer to the buffer that stores the data read from the
// device. This buffer should be at least Count bytes long.
//
// Count
// [in] Number of bytes to read from the device into pBuffer.
//
// Returns:
// Returns zero to indicate end-of-file. Returns -1 to indicate an
// error. Returns the number of bytes read to indicate success.
//
//------------------------------------------------------------------------------
DWORD GPT_Read(DWORD hOpenContext, LPVOID pBuffer, DWORD Count)
{
GPT_FUNCTION_ENTRY();
GPT_FUNCTION_EXIT();
return 0;
}
//------------------------------------------------------------------------------
//
// Function: GPT_Write
//
// This function writes data to the device.
//
// Parameters:
// hOpenContext
// [in] Handle to the open context of the device. The XXX_Open
// function creates and returns this identifier.
//
// pBuffer
// [out] Pointer to the buffer that contains the data to write.
//
// Count
// [in] Number of bytes to write from the pBuffer buffer into the
// device.
//
// Returns:
// The number of bytes written indicates success. A value of -1 indicates
// failure.
//
//------------------------------------------------------------------------------
DWORD GPT_Write(DWORD Handle, LPCVOID pBuffer, DWORD dwNumBytes)
{
GPT_FUNCTION_ENTRY();
GPT_FUNCTION_EXIT();
return 0;
}
//------------------------------------------------------------------------------
//
// Function: GPT_Seek
//
// This function moves the data pointer in the device.
//
// Parameters:
// hOpenContext
// [in] Handle to the open context of the device. The XXX_Open
// function creates and returns this identifier.
//
// Amount
// [in] Number of bytes to move the data pointer in the device.
// A positive value moves the data pointer toward the end of the
// file, and a negative value moves it toward the beginning.
//
// Type
// [in] Starting point for the data pointer.
//
// Returns:
// The new data pointer for the device indicates success. A value of -1
// indicates failure.
//
//------------------------------------------------------------------------------
DWORD GPT_Seek(DWORD hOpenContext, long Amount, WORD Type)
{
GPT_FUNCTION_ENTRY();
GPT_FUNCTION_EXIT();
return -1;
}
//------------------------------------------------------------------------------
//
// Function: GPT_IOControl
//
// This function sends a command to a device.
//
// Parameters:
// hOpenContext
// [in] Handle to the open context of the device. The XXX_Open
// function creates and returns this identifier.
//
// dwCode
// [in] I/O control operation to perform. These codes are
// device-specific and are usually exposed to developers through
// a header file.
//
// pBufIn
// [in] Pointer to the buffer containing data to transfer to the
// device.
//
// dwLenIn
// [in] Number of bytes of data in the buffer specified for pBufIn.
//
// pBufOut
// [out] Pointer to the buffer used to transfer the output data
// from the device.
//
// dwLenOut
// [in] Maximum number of bytes in the buffer specified by pBufOut.
//
// pdwActualOut
// [out] Pointer to the DWORD buffer that this function uses to
// return the actual number of bytes received from the device.
//
// Returns:
// The new data pointer for the device indicates success. A value of -1
// indicates failure.
//
//------------------------------------------------------------------------------
BOOL GPT_IOControl(DWORD hOpenContext, DWORD dwCode, PBYTE pBufIn,
DWORD dwLenIn, PBYTE pBufOut, DWORD dwLenOut,
PDWORD pdwActualOut)
{
BOOL bRet = FALSE;
LPTSTR pStr = NULL;
gptClass * pGpt=(gptClass *)hOpenContext;
switch(dwCode)
{
case GPT_IOCTL_TIMER_CREATE_EVENT:
//CE5 pStr = (LPTSTR) MapCallerPtr(pBufIn, dwLenIn);
// bRet = pGpt->GptTimerCreateEvent(pStr);
bRet = pGpt->GptTimerCreateEvent((LPTSTR)pBufIn);
DEBUGMSG(ZONE_IOCTL, (TEXT("GPT_IOControl: GPT_IOCTL_TIMER_CREATE_EVENT occurred\r\n")));
break;
case GPT_IOCTL_TIMER_RELEASE_EVENT:
//CE5 pStr = (LPTSTR) MapCallerPtr(pBufIn, dwLenIn);
// bRet = pGpt->GptTimerReleaseEvent(pStr);
bRet = pGpt->GptTimerReleaseEvent((LPTSTR)pBufIn);
DEBUGMSG(ZONE_IOCTL, (TEXT("GPT_IOControl: GPT_IOCTL_TIMER_CLOSE_HANDLE occurred\r\n")));
break;
case GPT_IOCTL_INT_ENABLE:
pGpt->GptEnableTimerInterrupt();
bRet = TRUE;
DEBUGMSG(ZONE_IOCTL, (TEXT("GPT_IOControl: GPT_IOCTL_INT_ENABLE occurred\r\n")));
break;
case GPT_IOCTL_INT_DISABLE:
pGpt->GptDisableTimerInterrupt();
bRet = TRUE;
DEBUGMSG(ZONE_IOCTL, (TEXT("GPT_IOControl: GPT_IOCTL_INT_DISABLE occurred\r\n")));
break;
case GPT_IOCTL_TIMER_START:
bRet = pGpt->GptStartTimer();
DEBUGMSG(ZONE_IOCTL, (TEXT("GPT_IOControl: GPT_IOCTL_TIMER_START occurred\r\n")));
break;
case GPT_IOCTL_TIMER_STOP:
pGpt->GptStopTimer();
bRet = TRUE;
DEBUGMSG(ZONE_IOCTL, (TEXT("GPT_IOControl: GPT_IOCTL_TIMER_STOP occurred\r\n")));
break;
case GPT_IOCTL_TIMER_SET_DELAY:
bRet = pGpt->GptSetTimerDelay((PGPT_TIMER_SET_PKT) pBufIn);
DEBUGMSG(ZONE_IOCTL, (TEXT("GPT_IOControl: GPT_IOCTL_TIMER_SET_DELAY occurred\r\n")));
break;
default:
DEBUGMSG(ZONE_WARN, (TEXT("GPT_IOControl: No matching IOCTL.\r\n")));
break;
}
return bRet;
}
BOOL WINAPI GPT_DllEntry(HANDLE hInstDll, DWORD dwReason, LPVOID lpvReserved)
{
switch (dwReason)
{
case DLL_PROCESS_ATTACH:
//Register Debug Zones
DEBUGREGISTER((HINSTANCE) hInstDll);
DEBUGMSG(ZONE_INFO, (TEXT("GPT_DllEntry: DLL_PROCESS_ATTACH lpvReserved(0x%x)\r\n"),lpvReserved));
DisableThreadLibraryCalls((HMODULE) hInstDll);
break;
case DLL_PROCESS_DETACH:
DEBUGMSG(ZONE_INFO, (TEXT("GPT_DllEntry: DLL_PROCESS_DETACH lpvReserved(0x%x)\r\n"),lpvReserved));
break;
}
// Return TRUE for success
return TRUE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -