ntdll: Implemented IOCTL for serial: SET_WAIT_MASK, GET_WAIT_MASK.

This commit is contained in:
Eric Pouech 2006-02-06 11:37:06 +01:00 committed by Alexandre Julliard
parent b83c5ead16
commit 58e719ce93
2 changed files with 61 additions and 31 deletions

View File

@ -952,28 +952,20 @@ BOOL WINAPI SetupComm(
* Obtain the events associated with a communication device that will cause
* a call WaitCommEvent to return.
*
* PARAMS
*
* handle [in] The communications device
* evtmask [out] The events which cause WaitCommEvent to return
*
* RETURNS
*
* True on success, fail on bad device handle etc.
*/
BOOL WINAPI GetCommMask(
HANDLE handle, /* [in] The communications device. */
LPDWORD evtmask) /* [out] The events which cause WaitCommEvent to return. */
BOOL WINAPI GetCommMask(HANDLE handle, LPDWORD evtmask)
{
BOOL ret;
TRACE("handle %p, mask %p\n", handle, evtmask);
SERVER_START_REQ( get_serial_info )
{
req->handle = handle;
if ((ret = !wine_server_call_err( req )))
{
if (evtmask) *evtmask = reply->eventmask;
}
}
SERVER_END_REQ;
return ret;
return DeviceIoControl(handle, IOCTL_SERIAL_GET_WAIT_MASK,
NULL, 0, evtmask, sizeof(*evtmask), NULL, NULL);
}
/*****************************************************************************
@ -983,27 +975,20 @@ BOOL WINAPI GetCommMask(
* (Set which events associated with a communication device should cause
* a call WaitCommEvent to return.)
*
* PARAMS
*
* handle [in] The communications device
* evtmask [in] The events that are to be monitored
*
* RETURNS
*
* True on success, false on bad handle etc.
*/
BOOL WINAPI SetCommMask(
HANDLE handle, /* [in] The communications device. */
DWORD evtmask) /* [in] The events that are to be monitored. */
BOOL WINAPI SetCommMask(HANDLE handle, DWORD evtmask)
{
BOOL ret;
TRACE("handle %p, mask %lx\n", handle, evtmask);
SERVER_START_REQ( set_serial_info )
{
req->handle = handle;
req->flags = SERIALINFO_SET_MASK;
req->eventmask = evtmask;
ret = !wine_server_call_err( req );
}
SERVER_END_REQ;
return ret;
return DeviceIoControl(handle, IOCTL_SERIAL_SET_WAIT_MASK,
&evtmask, sizeof(evtmask), NULL, 0, NULL, NULL);
}
/*****************************************************************************

View File

@ -129,6 +129,20 @@ static const char* iocode2str(DWORD ioc)
}
}
static NTSTATUS get_wait_mask(HANDLE hDevice, DWORD* mask)
{
NTSTATUS status;
SERVER_START_REQ( get_serial_info )
{
req->handle = hDevice;
if (!(status = wine_server_call( req )))
*mask = reply->eventmask;
}
SERVER_END_REQ;
return status;
}
static NTSTATUS purge(int fd, DWORD flags)
{
/*
@ -143,6 +157,21 @@ static NTSTATUS purge(int fd, DWORD flags)
return STATUS_SUCCESS;
}
static NTSTATUS set_wait_mask(HANDLE hDevice, DWORD mask)
{
NTSTATUS status;
SERVER_START_REQ( set_serial_info )
{
req->handle = hDevice;
req->flags = SERIALINFO_SET_MASK;
req->eventmask = mask;
status = wine_server_call( req );
}
SERVER_END_REQ;
return status;
}
/******************************************************************
* COMM_DeviceIoControl
*
@ -170,6 +199,15 @@ NTSTATUS COMM_DeviceIoControl(HANDLE hDevice,
switch (dwIoControlCode)
{
case IOCTL_SERIAL_GET_WAIT_MASK:
if (lpOutBuffer && nOutBufferSize == sizeof(DWORD))
{
if (!(status = get_wait_mask(hDevice, (DWORD*)lpOutBuffer)))
sz = sizeof(DWORD);
}
else
status = STATUS_INVALID_PARAMETER;
break;
case IOCTL_SERIAL_PURGE:
if (lpInBuffer && nInBufferSize == sizeof(DWORD))
status = purge(fd, *(DWORD*)lpInBuffer);
@ -200,6 +238,13 @@ NTSTATUS COMM_DeviceIoControl(HANDLE hDevice,
status = STATUS_NOT_SUPPORTED;
#endif
break;
case IOCTL_SERIAL_SET_WAIT_MASK:
if (lpInBuffer && nInBufferSize == sizeof(DWORD))
{
status = set_wait_mask(hDevice, *(DWORD*)lpInBuffer);
}
else status = STATUS_INVALID_PARAMETER;
break;
default:
FIXME("Unsupported IOCTL %lx (type=%lx access=%lx func=%lx meth=%lx)\n",
dwIoControlCode, dwIoControlCode >> 16, (dwIoControlCode >> 14) & 3,