server: Implement IOCTL_SERIAL_GET_TIMEOUTS as an ioctl on the server side.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2017-05-05 12:18:55 +02:00
parent 2f5968875e
commit a682420b58
6 changed files with 41 additions and 62 deletions

View File

@ -390,26 +390,6 @@ static NTSTATUS get_status(int fd, SERIAL_STATUS* ss)
return status;
}
static NTSTATUS get_timeouts(HANDLE handle, SERIAL_TIMEOUTS* st)
{
NTSTATUS status;
SERVER_START_REQ( get_serial_info )
{
req->handle = wine_server_obj_handle( handle );
req->flags = 0;
if (!(status = wine_server_call( req )))
{
st->ReadIntervalTimeout = reply->readinterval;
st->ReadTotalTimeoutMultiplier = reply->readmult;
st->ReadTotalTimeoutConstant = reply->readconst;
st->WriteTotalTimeoutMultiplier = reply->writemult;
st->WriteTotalTimeoutConstant = reply->writeconst;
}
}
SERVER_END_REQ;
return status;
}
static void stop_waiting( HANDLE handle )
{
NTSTATUS status;
@ -1245,14 +1225,7 @@ static inline NTSTATUS io_control(HANDLE hDevice,
else status = STATUS_INVALID_PARAMETER;
break;
case IOCTL_SERIAL_GET_TIMEOUTS:
if (lpOutBuffer && nOutBufferSize == sizeof(SERIAL_TIMEOUTS))
{
if (!(status = get_timeouts(hDevice, lpOutBuffer)))
sz = sizeof(SERIAL_TIMEOUTS);
}
else
status = STATUS_INVALID_PARAMETER;
break;
return STATUS_NOT_SUPPORTED;
case IOCTL_SERIAL_GET_WAIT_MASK:
if (lpOutBuffer && nOutBufferSize == sizeof(DWORD))
{

View File

@ -3151,14 +3151,10 @@ struct get_serial_info_request
struct get_serial_info_reply
{
struct reply_header __header;
unsigned int readinterval;
unsigned int readconst;
unsigned int readmult;
unsigned int writeconst;
unsigned int writemult;
unsigned int eventmask;
unsigned int cookie;
unsigned int pending_write;
char __pad_20[4];
};
@ -6407,6 +6403,6 @@ union generic_reply
struct terminate_job_reply terminate_job_reply;
};
#define SERVER_PROTOCOL_VERSION 527
#define SERVER_PROTOCOL_VERSION 528
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */

View File

@ -2299,11 +2299,6 @@ enum message_type
obj_handle_t handle; /* handle to comm port */
int flags;
@REPLY
unsigned int readinterval;
unsigned int readconst;
unsigned int readmult;
unsigned int writeconst;
unsigned int writemult;
unsigned int eventmask;
unsigned int cookie;
unsigned int pending_write;

View File

@ -1553,15 +1553,10 @@ C_ASSERT( sizeof(struct is_window_hung_reply) == 16 );
C_ASSERT( FIELD_OFFSET(struct get_serial_info_request, handle) == 12 );
C_ASSERT( FIELD_OFFSET(struct get_serial_info_request, flags) == 16 );
C_ASSERT( sizeof(struct get_serial_info_request) == 24 );
C_ASSERT( FIELD_OFFSET(struct get_serial_info_reply, readinterval) == 8 );
C_ASSERT( FIELD_OFFSET(struct get_serial_info_reply, readconst) == 12 );
C_ASSERT( FIELD_OFFSET(struct get_serial_info_reply, readmult) == 16 );
C_ASSERT( FIELD_OFFSET(struct get_serial_info_reply, writeconst) == 20 );
C_ASSERT( FIELD_OFFSET(struct get_serial_info_reply, writemult) == 24 );
C_ASSERT( FIELD_OFFSET(struct get_serial_info_reply, eventmask) == 28 );
C_ASSERT( FIELD_OFFSET(struct get_serial_info_reply, cookie) == 32 );
C_ASSERT( FIELD_OFFSET(struct get_serial_info_reply, pending_write) == 36 );
C_ASSERT( sizeof(struct get_serial_info_reply) == 40 );
C_ASSERT( FIELD_OFFSET(struct get_serial_info_reply, eventmask) == 8 );
C_ASSERT( FIELD_OFFSET(struct get_serial_info_reply, cookie) == 12 );
C_ASSERT( FIELD_OFFSET(struct get_serial_info_reply, pending_write) == 16 );
C_ASSERT( sizeof(struct get_serial_info_reply) == 24 );
C_ASSERT( FIELD_OFFSET(struct set_serial_info_request, handle) == 12 );
C_ASSERT( FIELD_OFFSET(struct set_serial_info_request, flags) == 16 );
C_ASSERT( FIELD_OFFSET(struct set_serial_info_request, readinterval) == 20 );

View File

@ -50,6 +50,8 @@
#define WIN32_NO_STATUS
#include "windef.h"
#include "winternl.h"
#include "winioctl.h"
#include "ddk/ntddser.h"
#include "file.h"
#include "handle.h"
@ -61,6 +63,7 @@ static struct fd *serial_get_fd( struct object *obj );
static void serial_destroy(struct object *obj);
static enum server_fd_type serial_get_fd_type( struct fd *fd );
static obj_handle_t serial_ioctl( struct fd *fd, ioctl_code_t code, struct async *async );
static void serial_queue_async( struct fd *fd, struct async *async, int type, int count );
static void serial_reselect_async( struct fd *fd, struct async_queue *queue );
@ -118,7 +121,7 @@ static const struct fd_ops serial_fd_ops =
no_fd_read, /* read */
no_fd_write, /* write */
no_fd_flush, /* flush */
default_fd_ioctl, /* ioctl */
serial_ioctl, /* ioctl */
serial_queue_async, /* queue_async */
serial_reselect_async /* reselect_async */
};
@ -183,6 +186,32 @@ static enum server_fd_type serial_get_fd_type( struct fd *fd )
return FD_TYPE_SERIAL;
}
static obj_handle_t serial_ioctl( struct fd *fd, ioctl_code_t code, struct async *async )
{
struct serial *serial = get_fd_user( fd );
switch (code)
{
case IOCTL_SERIAL_GET_TIMEOUTS:
if (get_reply_max_size() >= sizeof(SERIAL_TIMEOUTS))
{
SERIAL_TIMEOUTS *timeouts = set_reply_data_size( sizeof(*timeouts ));
timeouts->ReadIntervalTimeout = serial->readinterval;
timeouts->ReadTotalTimeoutConstant = serial->readconst;
timeouts->ReadTotalTimeoutMultiplier = serial->readmult;
timeouts->WriteTotalTimeoutConstant = serial->writeconst;
timeouts->WriteTotalTimeoutMultiplier = serial->writemult;
}
else set_error( STATUS_BUFFER_TOO_SMALL );
return 0;
default:
set_error( STATUS_NOT_SUPPORTED );
return 0;
}
}
static void serial_queue_async( struct fd *fd, struct async *async, int type, int count )
{
struct serial *serial = get_fd_user( fd );
@ -252,13 +281,6 @@ DECL_HANDLER(get_serial_info)
serial->pending_wait = 1;
}
/* timeouts */
reply->readinterval = serial->readinterval;
reply->readconst = serial->readconst;
reply->readmult = serial->readmult;
reply->writeconst = serial->writeconst;
reply->writemult = serial->writemult;
/* event mask */
reply->eventmask = serial->eventmask;
reply->cookie = serial->generation;

View File

@ -39,6 +39,7 @@
#include "winuser.h"
#include "winioctl.h"
#include "ddk/wdm.h"
#include "ddk/ntddser.h"
#define USE_WS_PREFIX
#include "winsock2.h"
#include "file.h"
@ -116,7 +117,9 @@ static void dump_ioctl_code( const char *prefix, const ioctl_code_t *code )
CASE(FSCTL_DISMOUNT_VOLUME);
CASE(FSCTL_PIPE_DISCONNECT);
CASE(FSCTL_PIPE_LISTEN);
CASE(FSCTL_PIPE_PEEK);
CASE(FSCTL_PIPE_WAIT);
CASE(IOCTL_SERIAL_GET_TIMEOUTS);
CASE(WS_SIO_ADDRESS_LIST_CHANGE);
default: fprintf( stderr, "%s%08x", prefix, *code ); break;
#undef CASE
@ -2830,12 +2833,7 @@ static void dump_get_serial_info_request( const struct get_serial_info_request *
static void dump_get_serial_info_reply( const struct get_serial_info_reply *req )
{
fprintf( stderr, " readinterval=%08x", req->readinterval );
fprintf( stderr, ", readconst=%08x", req->readconst );
fprintf( stderr, ", readmult=%08x", req->readmult );
fprintf( stderr, ", writeconst=%08x", req->writeconst );
fprintf( stderr, ", writemult=%08x", req->writemult );
fprintf( stderr, ", eventmask=%08x", req->eventmask );
fprintf( stderr, " eventmask=%08x", req->eventmask );
fprintf( stderr, ", cookie=%08x", req->cookie );
fprintf( stderr, ", pending_write=%08x", req->pending_write );
}