VirtualBox

source: vbox/trunk/src/VBox/Devices/Serial/DrvHostSerial.cpp@ 12325

Last change on this file since 12325 was 12325, checked in by vboxsync, 16 years ago

DrvHostSerial: Ported to darwin (untested).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 40.3 KB
Line 
1/** $Id: DrvHostSerial.cpp 12325 2008-09-10 05:52:01Z vboxsync $ */
2/** @file
3 * VBox stream I/O devices: Host serial driver
4 *
5 * Contributed by: Alexander Eichner
6 */
7
8/*
9 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
10 *
11 * This file is part of VirtualBox Open Source Edition (OSE), as
12 * available from http://www.virtualbox.org. This file is free software;
13 * you can redistribute it and/or modify it under the terms of the GNU
14 * General Public License (GPL) as published by the Free Software
15 * Foundation, in version 2 as it comes in the "COPYING" file of the
16 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
20 * Clara, CA 95054 USA or visit http://www.sun.com if you need
21 * additional information or have any questions.
22 */
23
24
25
26/*******************************************************************************
27* Header Files *
28*******************************************************************************/
29#define LOG_GROUP LOG_GROUP_DRV_HOST_SERIAL
30#include <VBox/pdm.h>
31#include <VBox/err.h>
32
33#include <VBox/log.h>
34#include <iprt/asm.h>
35#include <iprt/assert.h>
36#include <iprt/stream.h>
37#include <iprt/semaphore.h>
38#include <iprt/file.h>
39#include <iprt/alloc.h>
40
41#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN)
42# include <errno.h>
43# include <termios.h>
44# include <sys/types.h>
45# include <fcntl.h>
46# include <string.h>
47# include <unistd.h>
48# include <sys/poll.h>
49# include <sys/ioctl.h>
50# include <pthread.h>
51# include <sys/signal.h>
52
53# ifdef RT_OS_LINUX
54/*
55 * TIOCM_LOOP is not defined in the above header files for some reason but in asm/termios.h.
56 * But inclusion of this file however leads to compilation errors because of redefinition of some
57 * structs. Thatswhy it is defined here until a better solution is found.
58 */
59# ifndef TIOCM_LOOP
60# define TIOCM_LOOP 0x8000
61# endif
62# endif /* linux */
63
64#elif defined(RT_OS_WINDOWS)
65# include <Windows.h>
66#endif
67
68#include "../Builtins.h"
69
70
71/** Size of the send fifo queue (in bytes) */
72#define CHAR_MAX_SEND_QUEUE 0x80
73#define CHAR_MAX_SEND_QUEUE_MASK 0x7f
74
75/*******************************************************************************
76* Structures and Typedefs *
77*******************************************************************************/
78
79/**
80 * Char driver instance data.
81 */
82typedef struct DRVHOSTSERIAL
83{
84 /** Pointer to the driver instance structure. */
85 PPDMDRVINS pDrvIns;
86 /** Pointer to the char port interface of the driver/device above us. */
87 PPDMICHARPORT pDrvCharPort;
88 /** Our char interface. */
89 PDMICHAR IChar;
90 /** Receive thread. */
91 PPDMTHREAD pRecvThread;
92 /** Send thread. */
93 PPDMTHREAD pSendThread;
94 /** Status lines monitor thread. */
95 PPDMTHREAD pMonitorThread;
96 /** Send event semephore */
97 RTSEMEVENT SendSem;
98
99 /** the device path */
100 char *pszDevicePath;
101
102#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN)
103 /** the device handle */
104 RTFILE DeviceFile;
105 /** The read end of the control pipe */
106 RTFILE WakeupPipeR;
107 /** The write end of the control pipe */
108 RTFILE WakeupPipeW;
109# ifndef RT_OS_LINUX
110 /** The current line status.
111 * Used by the polling version of drvHostSerialMonitorThread. */
112 int fStatusLines;
113# endif
114#elif defined(RT_OS_WINDOWS)
115 /** the device handle */
116 HANDLE hDeviceFile;
117 /** The event semaphore for waking up the receive thread */
118 HANDLE hHaltEventSem;
119 /** The event semaphore for overlapped receiving */
120 HANDLE hEventRecv;
121 /** For overlapped receiving */
122 OVERLAPPED overlappedRecv;
123 /** The event semaphore for overlapped sending */
124 HANDLE hEventSend;
125 /** For overlapped sending */
126 OVERLAPPED overlappedSend;
127#endif
128
129 /** Internal send FIFO queue */
130 uint8_t aSendQueue[CHAR_MAX_SEND_QUEUE];
131 uint32_t iSendQueueHead;
132 uint32_t iSendQueueTail;
133
134 /** Read/write statistics */
135 STAMCOUNTER StatBytesRead;
136 STAMCOUNTER StatBytesWritten;
137} DRVHOSTSERIAL, *PDRVHOSTSERIAL;
138
139
140/** Converts a pointer to DRVCHAR::IChar to a PDRVHOSTSERIAL. */
141#define PDMICHAR_2_DRVHOSTSERIAL(pInterface) ( (PDRVHOSTSERIAL)((uintptr_t)pInterface - RT_OFFSETOF(DRVHOSTSERIAL, IChar)) )
142
143
144/* -=-=-=-=- IBase -=-=-=-=- */
145
146/**
147 * Queries an interface to the driver.
148 *
149 * @returns Pointer to interface.
150 * @returns NULL if the interface was not supported by the driver.
151 * @param pInterface Pointer to this interface structure.
152 * @param enmInterface The requested interface identification.
153 */
154static DECLCALLBACK(void *) drvHostSerialQueryInterface(PPDMIBASE pInterface, PDMINTERFACE enmInterface)
155{
156 PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface);
157 PDRVHOSTSERIAL pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTSERIAL);
158 switch (enmInterface)
159 {
160 case PDMINTERFACE_BASE:
161 return &pDrvIns->IBase;
162 case PDMINTERFACE_CHAR:
163 return &pThis->IChar;
164 default:
165 return NULL;
166 }
167}
168
169
170/* -=-=-=-=- IChar -=-=-=-=- */
171
172/** @copydoc PDMICHAR::pfnWrite */
173static DECLCALLBACK(int) drvHostSerialWrite(PPDMICHAR pInterface, const void *pvBuf, size_t cbWrite)
174{
175 PDRVHOSTSERIAL pThis = PDMICHAR_2_DRVHOSTSERIAL(pInterface);
176 const uint8_t *pbBuffer = (const uint8_t *)pvBuf;
177
178 LogFlow(("%s: pvBuf=%#p cbWrite=%d\n", __FUNCTION__, pvBuf, cbWrite));
179
180 for (uint32_t i=0;i<cbWrite;i++)
181 {
182 uint32_t idx = pThis->iSendQueueHead;
183
184 pThis->aSendQueue[idx] = pbBuffer[i];
185 idx = (idx + 1) & CHAR_MAX_SEND_QUEUE_MASK;
186
187 STAM_COUNTER_INC(&pThis->StatBytesWritten);
188 ASMAtomicXchgU32(&pThis->iSendQueueHead, idx);
189 }
190 RTSemEventSignal(pThis->SendSem);
191 return VINF_SUCCESS;
192}
193
194static DECLCALLBACK(int) drvHostSerialSetParameters(PPDMICHAR pInterface, unsigned Bps, char chParity, unsigned cDataBits, unsigned cStopBits)
195{
196 PDRVHOSTSERIAL pThis = PDMICHAR_2_DRVHOSTSERIAL(pInterface);
197#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN)
198 struct termios *termiosSetup;
199 int baud_rate;
200#elif defined(RT_OS_WINDOWS)
201 LPDCB comSetup;
202#endif
203
204 LogFlow(("%s: Bps=%u chParity=%c cDataBits=%u cStopBits=%u\n", __FUNCTION__, Bps, chParity, cDataBits, cStopBits));
205
206#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN)
207 termiosSetup = (struct termios *)RTMemTmpAllocZ(sizeof(struct termios));
208
209 /* Enable receiver */
210 termiosSetup->c_cflag |= (CLOCAL | CREAD);
211
212 switch (Bps) {
213 case 50:
214 baud_rate = B50;
215 break;
216 case 75:
217 baud_rate = B75;
218 break;
219 case 110:
220 baud_rate = B110;
221 break;
222 case 134:
223 baud_rate = B134;
224 break;
225 case 150:
226 baud_rate = B150;
227 break;
228 case 200:
229 baud_rate = B200;
230 break;
231 case 300:
232 baud_rate = B300;
233 break;
234 case 600:
235 baud_rate = B600;
236 break;
237 case 1200:
238 baud_rate = B1200;
239 break;
240 case 1800:
241 baud_rate = B1800;
242 break;
243 case 2400:
244 baud_rate = B2400;
245 break;
246 case 4800:
247 baud_rate = B4800;
248 break;
249 case 9600:
250 baud_rate = B9600;
251 break;
252 case 19200:
253 baud_rate = B19200;
254 break;
255 case 38400:
256 baud_rate = B38400;
257 break;
258 case 57600:
259 baud_rate = B57600;
260 break;
261 case 115200:
262 baud_rate = B115200;
263 break;
264 default:
265 baud_rate = B9600;
266 }
267
268 cfsetispeed(termiosSetup, baud_rate);
269 cfsetospeed(termiosSetup, baud_rate);
270
271 switch (chParity) {
272 case 'E':
273 termiosSetup->c_cflag |= PARENB;
274 break;
275 case 'O':
276 termiosSetup->c_cflag |= (PARENB | PARODD);
277 break;
278 case 'N':
279 break;
280 default:
281 break;
282 }
283
284 switch (cDataBits) {
285 case 5:
286 termiosSetup->c_cflag |= CS5;
287 break;
288 case 6:
289 termiosSetup->c_cflag |= CS6;
290 break;
291 case 7:
292 termiosSetup->c_cflag |= CS7;
293 break;
294 case 8:
295 termiosSetup->c_cflag |= CS8;
296 break;
297 default:
298 break;
299 }
300
301 switch (cStopBits) {
302 case 2:
303 termiosSetup->c_cflag |= CSTOPB;
304 default:
305 break;
306 }
307
308 /* set serial port to raw input */
309 termiosSetup->c_lflag = ~(ICANON | ECHO | ECHOE | ISIG);
310
311 tcsetattr(pThis->DeviceFile, TCSANOW, termiosSetup);
312 RTMemTmpFree(termiosSetup);
313#elif defined(RT_OS_WINDOWS)
314 comSetup = (LPDCB)RTMemTmpAllocZ(sizeof(DCB));
315
316 comSetup->DCBlength = sizeof(DCB);
317
318 switch (Bps) {
319 case 110:
320 comSetup->BaudRate = CBR_110;
321 break;
322 case 300:
323 comSetup->BaudRate = CBR_300;
324 break;
325 case 600:
326 comSetup->BaudRate = CBR_600;
327 break;
328 case 1200:
329 comSetup->BaudRate = CBR_1200;
330 break;
331 case 2400:
332 comSetup->BaudRate = CBR_2400;
333 break;
334 case 4800:
335 comSetup->BaudRate = CBR_4800;
336 break;
337 case 9600:
338 comSetup->BaudRate = CBR_9600;
339 break;
340 case 14400:
341 comSetup->BaudRate = CBR_14400;
342 break;
343 case 19200:
344 comSetup->BaudRate = CBR_19200;
345 break;
346 case 38400:
347 comSetup->BaudRate = CBR_38400;
348 break;
349 case 57600:
350 comSetup->BaudRate = CBR_57600;
351 break;
352 case 115200:
353 comSetup->BaudRate = CBR_115200;
354 break;
355 default:
356 comSetup->BaudRate = CBR_9600;
357 }
358
359 comSetup->fBinary = TRUE;
360 comSetup->fOutxCtsFlow = FALSE;
361 comSetup->fOutxDsrFlow = FALSE;
362 comSetup->fDtrControl = DTR_CONTROL_DISABLE;
363 comSetup->fDsrSensitivity = FALSE;
364 comSetup->fTXContinueOnXoff = TRUE;
365 comSetup->fOutX = FALSE;
366 comSetup->fInX = FALSE;
367 comSetup->fErrorChar = FALSE;
368 comSetup->fNull = FALSE;
369 comSetup->fRtsControl = RTS_CONTROL_DISABLE;
370 comSetup->fAbortOnError = FALSE;
371 comSetup->wReserved = 0;
372 comSetup->XonLim = 5;
373 comSetup->XoffLim = 5;
374 comSetup->ByteSize = cDataBits;
375
376 switch (chParity) {
377 case 'E':
378 comSetup->Parity = EVENPARITY;
379 break;
380 case 'O':
381 comSetup->Parity = ODDPARITY;
382 break;
383 case 'N':
384 comSetup->Parity = NOPARITY;
385 break;
386 default:
387 break;
388 }
389
390 switch (cStopBits) {
391 case 1:
392 comSetup->StopBits = ONESTOPBIT;
393 break;
394 case 2:
395 comSetup->StopBits = TWOSTOPBITS;
396 break;
397 default:
398 break;
399 }
400
401 comSetup->XonChar = 0;
402 comSetup->XoffChar = 0;
403 comSetup->ErrorChar = 0;
404 comSetup->EofChar = 0;
405 comSetup->EvtChar = 0;
406
407 SetCommState(pThis->hDeviceFile, comSetup);
408 RTMemTmpFree(comSetup);
409#endif /* RT_OS_WINDOWS */
410
411 return VINF_SUCCESS;
412}
413
414/* -=-=-=-=- receive thread -=-=-=-=- */
415
416/**
417 * Send thread loop.
418 *
419 * @returns VINF_SUCCESS.
420 * @param ThreadSelf Thread handle to this thread.
421 * @param pvUser User argument.
422 */
423static DECLCALLBACK(int) drvHostSerialSendThread(PPDMDRVINS pDrvIns, PPDMTHREAD pThread)
424{
425 PDRVHOSTSERIAL pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTSERIAL);
426
427 if (pThread->enmState == PDMTHREADSTATE_INITIALIZING)
428 return VINF_SUCCESS;
429
430#ifdef RT_OS_WINDOWS
431 HANDLE haWait[2];
432 haWait[0] = pThis->hEventSend;
433 haWait[1] = pThis->hHaltEventSem;
434#endif
435
436 while (pThread->enmState == PDMTHREADSTATE_RUNNING)
437 {
438 int rc = RTSemEventWait(pThis->SendSem, RT_INDEFINITE_WAIT);
439 if (RT_FAILURE(rc))
440 break;
441
442 /*
443 * Write the character to the host device.
444 */
445 while ( pThread->enmState == PDMTHREADSTATE_RUNNING
446 && pThis->iSendQueueTail != pThis->iSendQueueHead)
447 {
448 unsigned cbProcessed = 1;
449
450#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN)
451
452 rc = RTFileWrite(pThis->DeviceFile, &pThis->aSendQueue[pThis->iSendQueueTail], cbProcessed, NULL);
453
454#elif defined(RT_OS_WINDOWS)
455
456 DWORD cbBytesWritten;
457 memset(&pThis->overlappedSend, 0, sizeof(pThis->overlappedSend));
458 pThis->overlappedSend.hEvent = pThis->hEventSend;
459
460 if (!WriteFile(pThis->hDeviceFile, &pThis->aSendQueue[pThis->iSendQueueTail], cbProcessed, &cbBytesWritten, &pThis->overlappedSend))
461 {
462 DWORD dwRet = GetLastError();
463 if (dwRet == ERROR_IO_PENDING)
464 {
465 /*
466 * write blocked, wait ...
467 */
468 dwRet = WaitForMultipleObjects(2, haWait, FALSE, INFINITE);
469 if (dwRet != WAIT_OBJECT_0)
470 break;
471 }
472 else
473 rc = RTErrConvertFromWin32(dwRet);
474 }
475
476#endif
477
478 if (RT_SUCCESS(rc))
479 {
480 Assert(cbProcessed);
481 pThis->iSendQueueTail++;
482 pThis->iSendQueueTail &= CHAR_MAX_SEND_QUEUE_MASK;
483 }
484 else if (RT_FAILURE(rc))
485 {
486 LogRel(("HostSerial#%d: Serial Write failed with %Rrc; terminating send thread\n", pDrvIns->iInstance, rc));
487 return VINF_SUCCESS;
488 }
489 }
490 }
491
492 return VINF_SUCCESS;
493}
494
495/**
496 * Unblock the send thread so it can respond to a state change.
497 *
498 * @returns a VBox status code.
499 * @param pDrvIns The driver instance.
500 * @param pThread The send thread.
501 */
502static DECLCALLBACK(int) drvHostSerialWakeupSendThread(PPDMDRVINS pDrvIns, PPDMTHREAD pThread)
503{
504 PDRVHOSTSERIAL pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTSERIAL);
505 int rc;
506
507 rc = RTSemEventSignal(pThis->SendSem);
508 if (RT_FAILURE(rc))
509 return rc;
510
511#ifdef RT_OS_WINDOWS
512 if (!SetEvent(pThis->hHaltEventSem))
513 return RTErrConvertFromWin32(GetLastError());
514#endif
515
516 return VINF_SUCCESS;
517}
518
519/* -=-=-=-=- receive thread -=-=-=-=- */
520
521/**
522 * Receive thread loop.
523 *
524 * This thread pushes data from the host serial device up the driver
525 * chain toward the serial device.
526 *
527 * @returns VINF_SUCCESS.
528 * @param ThreadSelf Thread handle to this thread.
529 * @param pvUser User argument.
530 */
531static DECLCALLBACK(int) drvHostSerialRecvThread(PPDMDRVINS pDrvIns, PPDMTHREAD pThread)
532{
533 PDRVHOSTSERIAL pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTSERIAL);
534 uint8_t abBuffer[256];
535 uint8_t *pbBuffer = NULL;
536 size_t cbRemaining = 0; /* start by reading host data */
537 int rc = VINF_SUCCESS;
538
539 if (pThread->enmState == PDMTHREADSTATE_INITIALIZING)
540 return VINF_SUCCESS;
541
542#ifdef RT_OS_WINDOWS
543 HANDLE haWait[2];
544 haWait[0] = pThis->hEventRecv;
545 haWait[1] = pThis->hHaltEventSem;
546#endif
547
548 while (pThread->enmState == PDMTHREADSTATE_RUNNING)
549 {
550 if (!cbRemaining)
551 {
552 /* Get a block of data from the host serial device. */
553
554#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN)
555
556 size_t cbRead;
557 struct pollfd aFDs[2];
558 aFDs[0].fd = pThis->DeviceFile;
559 aFDs[0].events = POLLIN;
560 aFDs[0].revents = 0;
561 aFDs[1].fd = pThis->WakeupPipeR;
562 aFDs[1].events = POLLIN | POLLERR | POLLHUP;
563 aFDs[1].revents = 0;
564 rc = poll(aFDs, RT_ELEMENTS(aFDs), -1);
565 if (rc < 0)
566 {
567 /* poll failed for whatever reason */
568 break;
569 }
570 /* this might have changed in the meantime */
571 if (pThread->enmState != PDMTHREADSTATE_RUNNING)
572 break;
573 if (rc > 0 && aFDs[1].revents)
574 {
575 if (aFDs[1].revents & (POLLHUP | POLLERR | POLLNVAL))
576 break;
577 /* notification to terminate -- drain the pipe */
578 char ch;
579 size_t cbRead;
580 RTFileRead(pThis->WakeupPipeR, &ch, 1, &cbRead);
581 continue;
582 }
583 rc = RTFileRead(pThis->DeviceFile, abBuffer, sizeof(abBuffer), &cbRead);
584 if (RT_FAILURE(rc))
585 {
586 LogRel(("HostSerial#%d: Read failed with %Rrc, terminating the worker thread.\n", pDrvIns->iInstance, rc));
587 break;
588 }
589 cbRemaining = cbRead;
590
591#elif defined(RT_OS_WINDOWS)
592
593 DWORD dwEventMask = 0;
594 DWORD dwNumberOfBytesTransferred;
595
596 memset(&pThis->overlappedRecv, 0, sizeof(pThis->overlappedRecv));
597 pThis->overlappedRecv.hEvent = pThis->hEventRecv;
598
599 if (!WaitCommEvent(pThis->hDeviceFile, &dwEventMask, &pThis->overlappedRecv))
600 {
601 DWORD dwRet = GetLastError();
602 if (dwRet == ERROR_IO_PENDING)
603 {
604 dwRet = WaitForMultipleObjects(2, haWait, FALSE, INFINITE);
605 if (dwRet != WAIT_OBJECT_0)
606 {
607 /* notification to terminate */
608 break;
609 }
610 }
611 else
612 {
613 LogRel(("HostSerial#%d: Wait failed with error %Rrc; terminating the worker thread.\n", pDrvIns->iInstance, RTErrConvertFromWin32(dwRet)));
614 break;
615 }
616 }
617 /* this might have changed in the meantime */
618 if (pThread->enmState != PDMTHREADSTATE_RUNNING)
619 break;
620
621 /* Check the event */
622 if (dwEventMask & EV_RXCHAR)
623 {
624 if (!ReadFile(pThis->hDeviceFile, abBuffer, sizeof(abBuffer), &dwNumberOfBytesTransferred, &pThis->overlappedRecv))
625 {
626 LogRel(("HostSerial#%d: Read failed with error %Rrc; terminating the worker thread.\n", pDrvIns->iInstance, RTErrConvertFromWin32(GetLastError())));
627 break;
628 }
629 cbRemaining = dwNumberOfBytesTransferred;
630 }
631 else
632 {
633 /* The status lines have changed. Notify the device. */
634 DWORD dwNewStatusLinesState = 0;
635 uint32_t uNewStatusLinesState = 0;
636
637 /* Get the new state */
638 if (GetCommModemStatus(pThis->hDeviceFile, &dwNewStatusLinesState))
639 {
640 if (dwNewStatusLinesState & MS_RLSD_ON)
641 uNewStatusLinesState |= PDM_ICHAR_STATUS_LINES_DCD;
642 if (dwNewStatusLinesState & MS_RING_ON)
643 uNewStatusLinesState |= PDM_ICHAR_STATUS_LINES_RI;
644 if (dwNewStatusLinesState & MS_DSR_ON)
645 uNewStatusLinesState |= PDM_ICHAR_STATUS_LINES_DSR;
646 if (dwNewStatusLinesState & MS_CTS_ON)
647 uNewStatusLinesState |= PDM_ICHAR_STATUS_LINES_CTS;
648 rc = pThis->pDrvCharPort->pfnNotifyStatusLinesChanged(pThis->pDrvCharPort, uNewStatusLinesState);
649 if (RT_FAILURE(rc))
650 {
651 /* Notifying device failed, continue but log it */
652 LogRel(("HostSerial#%d: Notifying device failed with error %Rrc; continuing.\n", pDrvIns->iInstance, rc));
653 }
654 }
655 else
656 {
657 /* Getting new state failed, continue but log it */
658 LogRel(("HostSerial#%d: Getting status lines state failed with error %Rrc; continuing.\n", pDrvIns->iInstance, RTErrConvertFromWin32(GetLastError())));
659 }
660 }
661#endif
662
663 Log(("Read %d bytes.\n", cbRemaining));
664 pbBuffer = abBuffer;
665 }
666 else
667 {
668 /* Send data to the guest. */
669 size_t cbProcessed = cbRemaining;
670 rc = pThis->pDrvCharPort->pfnNotifyRead(pThis->pDrvCharPort, pbBuffer, &cbProcessed);
671 if (RT_SUCCESS(rc))
672 {
673 Assert(cbProcessed); Assert(cbProcessed <= cbRemaining);
674 pbBuffer += cbProcessed;
675 cbRemaining -= cbProcessed;
676 STAM_COUNTER_ADD(&pThis->StatBytesRead, cbProcessed);
677 }
678 else if (rc == VERR_TIMEOUT)
679 {
680 /* Normal case, just means that the guest didn't accept a new
681 * character before the timeout elapsed. Just retry. */
682 rc = VINF_SUCCESS;
683 }
684 else
685 {
686 LogRel(("HostSerial#%d: NotifyRead failed with %Rrc, terminating the worker thread.\n", pDrvIns->iInstance, rc));
687 break;
688 }
689 }
690 }
691
692 return VINF_SUCCESS;
693}
694
695/**
696 * Unblock the send thread so it can respond to a state change.
697 *
698 * @returns a VBox status code.
699 * @param pDrvIns The driver instance.
700 * @param pThread The send thread.
701 */
702static DECLCALLBACK(int) drvHostSerialWakeupRecvThread(PPDMDRVINS pDrvIns, PPDMTHREAD pThread)
703{
704 PDRVHOSTSERIAL pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTSERIAL);
705#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN)
706 return RTFileWrite(pThis->WakeupPipeW, "", 1, NULL);
707#elif defined(RT_OS_WINDOWS)
708 if (!SetEvent(pThis->hHaltEventSem))
709 return RTErrConvertFromWin32(GetLastError());
710 return VINF_SUCCESS;
711#else
712# error adapt me!
713#endif
714}
715
716#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN)
717/* -=-=-=-=- Monitor thread -=-=-=-=- */
718
719/**
720 * Monitor thread loop.
721 *
722 * This thread monitors the status lines and notifies the device
723 * if they change.
724 *
725 * @returns VINF_SUCCESS.
726 * @param ThreadSelf Thread handle to this thread.
727 * @param pvUser User argument.
728 */
729static DECLCALLBACK(int) drvHostSerialMonitorThread(PPDMDRVINS pDrvIns, PPDMTHREAD pThread)
730{
731 PDRVHOSTSERIAL pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTSERIAL);
732 int rc = VINF_SUCCESS;
733 unsigned uStatusLinesToCheck = 0;
734
735 uStatusLinesToCheck = TIOCM_CAR | TIOCM_RNG | TIOCM_LE | TIOCM_CTS;
736
737 if (pThread->enmState == PDMTHREADSTATE_INITIALIZING)
738 return VINF_SUCCESS;
739
740 while (pThread->enmState == PDMTHREADSTATE_RUNNING)
741 {
742 uint32_t newStatusLine = 0;
743 unsigned int statusLines;
744
745# ifdef RT_OS_LINUX
746 /*
747 * Wait for status line change.
748 */
749 rc = ioctl(pThis->DeviceFile, TIOCMIWAIT, &uStatusLinesToCheck);
750 if (pThread->enmState != PDMTHREADSTATE_RUNNING)
751 break;
752 if (rc < 0)
753 {
754ioctl_error:
755 PDMDrvHlpVMSetRuntimeError(pDrvIns, false, "DrvHostSerialFail",
756 N_("Ioctl failed for serial host device '%s' (%Rrc). The device will not work properly"),
757 pThis->pszDevicePath, RTErrConvertFromErrno(errno));
758 break;
759 }
760
761 rc = ioctl(pThis->DeviceFile, TIOCMGET, &statusLines);
762 if (rc < 0)
763 goto ioctl_error;
764# else /* !RT_OS_LINUX */
765 /*
766 * Poll for the status line change.
767 */
768 rc = ioctl(pThis->DeviceFile, TIOCMGET, &statusLines);
769 if (rc < 0)
770 {
771 PDMDrvHlpVMSetRuntimeError(pDrvIns, false, "DrvHostSerialFail",
772 N_("Ioctl failed for serial host device '%s' (%Rrc). The device will not work properly"),
773 pThis->pszDevicePath, RTErrConvertFromErrno(errno));
774 break;
775 }
776 if ((statusLines ^ pThis->fStatusLines) & uStatusLinesToCheck)
777 {
778 PDMR3ThreadSleep(pThread, 1000); /* 1 sec */
779 continue;
780 }
781# endif /* !RT_OS_LINUX */
782
783 if (statusLines & TIOCM_CAR)
784 newStatusLine |= PDM_ICHAR_STATUS_LINES_DCD;
785 if (statusLines & TIOCM_RNG)
786 newStatusLine |= PDM_ICHAR_STATUS_LINES_RI;
787 if (statusLines & TIOCM_LE)
788 newStatusLine |= PDM_ICHAR_STATUS_LINES_DSR;
789 if (statusLines & TIOCM_CTS)
790 newStatusLine |= PDM_ICHAR_STATUS_LINES_CTS;
791 rc = pThis->pDrvCharPort->pfnNotifyStatusLinesChanged(pThis->pDrvCharPort, newStatusLine);
792 }
793
794 return VINF_SUCCESS;
795}
796
797
798# ifdef RT_OS_LINUX
799/** Signal handler for SIGUSR2.
800 * Used to interrupt ioctl(TIOCMIWAIT). */
801static void drvHostSerialSignalHandler(int iSignal)
802{
803 /* Do nothing. */
804 return;
805}
806# endif
807
808/**
809 * Unblock the monitor thread so it can respond to a state change.
810 * We need to execute this code exactly once during initialization.
811 * But we don't want to block --- therefore this dedicated thread.
812 *
813 * @returns a VBox status code.
814 * @param pDrvIns The driver instance.
815 * @param pThread The send thread.
816 */
817static DECLCALLBACK(int) drvHostSerialWakeupMonitorThread(PPDMDRVINS pDrvIns, PPDMTHREAD pThread)
818{
819# ifdef RT_OS_LINUX
820 PDRVHOSTSERIAL pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTSERIAL);
821 int rc = VINF_SUCCESS;
822# if 0
823 unsigned int uSerialLineFlags;
824 unsigned int uSerialLineStatus;
825 unsigned int uIoctl;
826# endif
827
828 /*
829 * Linux is a bit difficult as the thread is sleeping in an ioctl call.
830 * So there is no way to have a wakeup pipe.
831 *
832 * 1. Thatswhy we set the serial device into loopback mode and change one of the
833 * modem control bits.
834 * This should make the ioctl call return.
835 *
836 * 2. We still got reports about long shutdown times. It may bepossible
837 * that the loopback mode is not implemented on all devices.
838 * The next possible solution is to close the device file to make the ioctl
839 * return with EBADF and be able to suspend the thread.
840 *
841 * 3. The second approach doesn't work too, the ioctl doesn't return.
842 * But it seems that the ioctl is interruptible (return code in errno is EINTR).
843 * We get the native thread id of the PDM thread and send a signal with pthread_kill().
844 */
845
846# if 0 /* Disabled because it does not work for all. */
847 /* Get current status of control lines. */
848 rc = ioctl(pThis->DeviceFile, TIOCMGET, &uSerialLineStatus);
849 if (rc < 0)
850 goto ioctl_error;
851
852 uSerialLineFlags = TIOCM_LOOP;
853 rc = ioctl(pThis->DeviceFile, TIOCMBIS, &uSerialLineFlags);
854 if (rc < 0)
855 goto ioctl_error;
856
857 /*
858 * Change current level on the RTS pin to make the ioctl call return in the
859 * monitor thread.
860 */
861 uIoctl = (uSerialLineStatus & TIOCM_CTS) ? TIOCMBIC : TIOCMBIS;
862 uSerialLineFlags = TIOCM_RTS;
863
864 rc = ioctl(pThis->DeviceFile, uIoctl, &uSerialLineFlags);
865 if (rc < 0)
866 goto ioctl_error;
867
868 /* Change RTS back to the previous level. */
869 uIoctl = (uIoctl == TIOCMBIC) ? TIOCMBIS : TIOCMBIC;
870
871 rc = ioctl(pThis->DeviceFile, uIoctl, &uSerialLineFlags);
872 if (rc < 0)
873 goto ioctl_error;
874
875 /*
876 * Set serial device into normal state.
877 */
878 uSerialLineFlags = TIOCM_LOOP;
879 rc = ioctl(pThis->DeviceFile, TIOCMBIC, &uSerialLineFlags);
880 if (rc >= 0)
881 return VINF_SUCCESS;
882
883ioctl_error:
884 PDMDrvHlpVMSetRuntimeError(pDrvIns, false, "DrvHostSerialFail",
885 N_("Ioctl failed for serial host device '%s' (%Rrc). The device will not work properly"),
886 pThis->pszDevicePath, RTErrConvertFromErrno(errno));
887# endif
888
889# if 0
890 /* Close file to make ioctl return. */
891 RTFileClose(pData->DeviceFile);
892 /* Open again to make use after suspend possible again. */
893 rc = RTFileOpen(&pData->DeviceFile, pData->pszDevicePath, RTFILE_O_OPEN | RTFILE_O_READWRITE);
894 AssertMsg(RT_SUCCESS(rc), ("Opening device file again failed rc=%Vrc\n", rc));
895
896 if (RT_FAILURE(rc))
897 PDMDrvHlpVMSetRuntimeError(pDrvIns, false, "DrvHostSerialFail",
898 N_("Opening failed for serial host device '%s' (%Vrc). The device will not work"),
899 pData->pszDevicePath, rc);
900# endif
901
902 pthread_t ThreadId = (pthread_t)RTThreadGetNative(pThread->Thread);
903 struct sigaction SigactionThread;
904 struct sigaction SigactionThreadOld;
905
906 memset(&SigactionThread, 0, sizeof(struct sigaction));
907 sigemptyset(&SigactionThread.sa_mask);
908 SigactionThread.sa_flags = 0;
909 SigactionThread.sa_handler = drvHostSerialSignalHandler;
910 rc = sigaction(SIGUSR2, &SigactionThread, &SigactionThreadOld);
911 if (rc < 0)
912 PDMDrvHlpVMSetRuntimeError(pDrvIns, false, "DrvHostSerialFail",
913 N_("Suspending serial monitor thread failed for serial device '%s' (%Vrc). The shutdown may take extremly long"),
914 pThis->pszDevicePath, RTErrConvertFromErrno(errno));
915
916 rc = pthread_kill(ThreadId, SIGUSR2);
917 if (rc < 0)
918 PDMDrvHlpVMSetRuntimeError(pDrvIns, false, "DrvHostSerialFail",
919 N_("Suspending serial monitor thread failed for serial device '%s' (%Vrc). The shutdown may take extremly long"),
920 pThis->pszDevicePath, RTErrConvertFromErrno(rc));
921
922 /* Restore old action handler. */
923 sigaction(SIGUSR2, &SigactionThreadOld, NULL);
924
925# else /* !RT_OS_LINUX*/
926 /* In polling mode there is nobody to wake up (PDMThread will cancel the sleep). */
927 NOREF(pDrvIns);
928 NOREF(pThread);
929
930# endif /* RT_OS_LINUX */
931
932 return VINF_SUCCESS;
933}
934#endif /* RT_OS_LINUX || RT_OS_DARWIN */
935
936/**
937 * Set the modem lines.
938 *
939 * @returns VBox status code
940 * @param pInterface Pointer to the interface structure.
941 * @param RequestToSend Set to true if this control line should be made active.
942 * @param DataTerminalReady Set to true if this control line should be made active.
943 */
944static DECLCALLBACK(int) drvHostSerialSetModemLines(PPDMICHAR pInterface, bool RequestToSend, bool DataTerminalReady)
945{
946 PDRVHOSTSERIAL pThis = PDMICHAR_2_DRVHOSTSERIAL(pInterface);
947
948#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN)
949 int modemStateSet = 0;
950 int modemStateClear = 0;
951
952 if (RequestToSend)
953 modemStateSet |= TIOCM_RTS;
954 else
955 modemStateClear |= TIOCM_RTS;
956
957 if (DataTerminalReady)
958 modemStateSet |= TIOCM_DTR;
959 else
960 modemStateClear |= TIOCM_DTR;
961
962 if (modemStateSet)
963 ioctl(pThis->DeviceFile, TIOCMBIS, &modemStateSet);
964
965 if (modemStateClear)
966 ioctl(pThis->DeviceFile, TIOCMBIC, &modemStateClear);
967#elif defined(RT_OS_WINDOWS)
968 if (RequestToSend)
969 EscapeCommFunction(pThis->hDeviceFile, SETRTS);
970 else
971 EscapeCommFunction(pThis->hDeviceFile, CLRRTS);
972
973 if (DataTerminalReady)
974 EscapeCommFunction(pThis->hDeviceFile, SETDTR);
975 else
976 EscapeCommFunction(pThis->hDeviceFile, CLRDTR);
977#endif
978
979 return VINF_SUCCESS;
980}
981
982/* -=-=-=-=- driver interface -=-=-=-=- */
983
984/**
985 * Construct a char driver instance.
986 *
987 * @returns VBox status.
988 * @param pDrvIns The driver instance data.
989 * If the registration structure is needed,
990 * pDrvIns->pDrvReg points to it.
991 * @param pCfgHandle Configuration node handle for the driver. Use this to
992 * obtain the configuration of the driver instance. It's
993 * also found in pDrvIns->pCfgHandle as it's expected to
994 * be used frequently in this function.
995 */
996static DECLCALLBACK(int) drvHostSerialConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle)
997{
998 PDRVHOSTSERIAL pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTSERIAL);
999 LogFlow(("%s: iInstance=%d\n", __FUNCTION__, pDrvIns->iInstance));
1000
1001 /*
1002 * Init basic data members and interfaces.
1003 */
1004#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN)
1005 pThis->DeviceFile = NIL_RTFILE;
1006 pThis->WakeupPipeR = NIL_RTFILE;
1007 pThis->WakeupPipeW = NIL_RTFILE;
1008#endif
1009 /* IBase. */
1010 pDrvIns->IBase.pfnQueryInterface = drvHostSerialQueryInterface;
1011 /* IChar. */
1012 pThis->IChar.pfnWrite = drvHostSerialWrite;
1013 pThis->IChar.pfnSetParameters = drvHostSerialSetParameters;
1014 pThis->IChar.pfnSetModemLines = drvHostSerialSetModemLines;
1015
1016/** @todo Initialize all members with NIL values!! The destructor is ALWAYS called. */
1017
1018 /*
1019 * Query configuration.
1020 */
1021 /* Device */
1022 int rc = CFGMR3QueryStringAlloc(pCfgHandle, "DevicePath", &pThis->pszDevicePath);
1023 if (RT_FAILURE(rc))
1024 {
1025 AssertMsgFailed(("Configuration error: query for \"DevicePath\" string returned %Rra.\n", rc));
1026 return rc;
1027 }
1028
1029 /*
1030 * Open the device
1031 */
1032#ifdef RT_OS_WINDOWS
1033
1034 pThis->hHaltEventSem = CreateEvent(NULL, FALSE, FALSE, NULL);
1035 AssertReturn(pThis->hHaltEventSem != NULL, VERR_NO_MEMORY);
1036
1037 pThis->hEventRecv = CreateEvent(NULL, FALSE, FALSE, NULL);
1038 AssertReturn(pThis->hEventRecv != NULL, VERR_NO_MEMORY);
1039
1040 pThis->hEventSend = CreateEvent(NULL, FALSE, FALSE, NULL);
1041 AssertReturn(pThis->hEventSend != NULL, VERR_NO_MEMORY);
1042
1043 HANDLE hFile = CreateFile(pThis->pszDevicePath,
1044 GENERIC_READ | GENERIC_WRITE,
1045 0, // must be opened with exclusive access
1046 NULL, // no SECURITY_ATTRIBUTES structure
1047 OPEN_EXISTING, // must use OPEN_EXISTING
1048 FILE_FLAG_OVERLAPPED, // overlapped I/O
1049 NULL); // no template file
1050 if (hFile == INVALID_HANDLE_VALUE)
1051 rc = RTErrConvertFromWin32(GetLastError());
1052 else
1053 {
1054 pThis->hDeviceFile = hFile;
1055 /* for overlapped read */
1056 if (!SetCommMask(hFile, EV_RXCHAR | EV_CTS | EV_DSR | EV_RING | EV_RLSD))
1057 {
1058 LogRel(("HostSerial#%d: SetCommMask failed with error %d.\n", pDrvIns->iInstance, GetLastError()));
1059 return VERR_FILE_IO_ERROR;
1060 }
1061 rc = VINF_SUCCESS;
1062 }
1063
1064#else
1065
1066 rc = RTFileOpen(&pThis->DeviceFile, pThis->pszDevicePath, RTFILE_O_OPEN | RTFILE_O_READWRITE);
1067
1068#endif
1069
1070 if (RT_FAILURE(rc))
1071 {
1072 AssertMsgFailed(("Could not open host device %s, rc=%Rrc\n", pThis->pszDevicePath, rc));
1073 switch (rc)
1074 {
1075 case VERR_ACCESS_DENIED:
1076 return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS,
1077#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN)
1078 N_("Cannot open host device '%s' for read/write access. Check the permissions "
1079 "of that device ('/bin/ls -l %s'): Most probably you need to be member "
1080 "of the device group. Make sure that you logout/login after changing "
1081 "the group settings of the current user"),
1082#else
1083 N_("Cannot open host device '%s' for read/write access. Check the permissions "
1084 "of that device"),
1085#endif
1086 pThis->pszDevicePath, pThis->pszDevicePath);
1087 default:
1088 return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS,
1089 N_("Failed to open host device '%s'"),
1090 pThis->pszDevicePath);
1091 }
1092 }
1093
1094 /* Set to non blocking I/O */
1095#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN)
1096
1097 fcntl(pThis->DeviceFile, F_SETFL, O_NONBLOCK);
1098 int aFDs[2];
1099 if (pipe(aFDs) != 0)
1100 {
1101 int rc = RTErrConvertFromErrno(errno);
1102 AssertRC(rc);
1103 return rc;
1104 }
1105 pThis->WakeupPipeR = aFDs[0];
1106 pThis->WakeupPipeW = aFDs[1];
1107
1108#elif defined(RT_OS_WINDOWS)
1109
1110 /* Set the COMMTIMEOUTS to get non blocking I/O */
1111 COMMTIMEOUTS comTimeout;
1112
1113 comTimeout.ReadIntervalTimeout = MAXDWORD;
1114 comTimeout.ReadTotalTimeoutMultiplier = 0;
1115 comTimeout.ReadTotalTimeoutConstant = 0;
1116 comTimeout.WriteTotalTimeoutMultiplier = 0;
1117 comTimeout.WriteTotalTimeoutConstant = 0;
1118
1119 SetCommTimeouts(pThis->hDeviceFile, &comTimeout);
1120
1121#endif
1122
1123 /*
1124 * Get the ICharPort interface of the above driver/device.
1125 */
1126 pThis->pDrvCharPort = (PPDMICHARPORT)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase, PDMINTERFACE_CHAR_PORT);
1127 if (!pThis->pDrvCharPort)
1128 return PDMDrvHlpVMSetError(pDrvIns, VERR_PDM_MISSING_INTERFACE_ABOVE, RT_SRC_POS, N_("HostSerial#%d has no char port interface above"), pDrvIns->iInstance);
1129
1130 /*
1131 * Create the receive, send and monitor threads pluss the related send semaphore.
1132 */
1133 rc = PDMDrvHlpPDMThreadCreate(pDrvIns, &pThis->pRecvThread, pThis, drvHostSerialRecvThread, drvHostSerialWakeupRecvThread, 0, RTTHREADTYPE_IO, "SerRecv");
1134 if (RT_FAILURE(rc))
1135 return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, N_("HostSerial#%d cannot create receive thread"), pDrvIns->iInstance);
1136
1137 rc = RTSemEventCreate(&pThis->SendSem);
1138 AssertRC(rc);
1139
1140 rc = PDMDrvHlpPDMThreadCreate(pDrvIns, &pThis->pSendThread, pThis, drvHostSerialSendThread, drvHostSerialWakeupSendThread, 0, RTTHREADTYPE_IO, "SerSend");
1141 if (RT_FAILURE(rc))
1142 return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, N_("HostSerial#%d cannot create send thread"), pDrvIns->iInstance);
1143
1144#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN)
1145 /* Linux & darwin needs a separate thread which monitors the status lines. */
1146# ifndef RT_OS_LINUX
1147 ioctl(pThis->DeviceFile, TIOCMGET, &pThis->fStatusLines);
1148# endif
1149 rc = PDMDrvHlpPDMThreadCreate(pDrvIns, &pThis->pMonitorThread, pThis, drvHostSerialMonitorThread, drvHostSerialWakeupMonitorThread, 0, RTTHREADTYPE_IO, "SerMon");
1150 if (RT_FAILURE(rc))
1151 return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, N_("HostSerial#%d cannot create monitor thread"), pDrvIns->iInstance);
1152#endif
1153
1154 /*
1155 * Register release statistics.
1156 */
1157 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatBytesWritten, STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_BYTES, "Nr of bytes written", "/Devices/HostSerial%d/Written", pDrvIns->iInstance);
1158 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatBytesRead, STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_BYTES, "Nr of bytes read", "/Devices/HostSerial%d/Read", pDrvIns->iInstance);
1159
1160 return VINF_SUCCESS;
1161}
1162
1163
1164/**
1165 * Destruct a char driver instance.
1166 *
1167 * Most VM resources are freed by the VM. This callback is provided so that
1168 * any non-VM resources can be freed correctly.
1169 *
1170 * @param pDrvIns The driver instance data.
1171 */
1172static DECLCALLBACK(void) drvHostSerialDestruct(PPDMDRVINS pDrvIns)
1173{
1174 PDRVHOSTSERIAL pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTSERIAL);
1175
1176 LogFlow(("%s: iInstance=%d\n", __FUNCTION__, pDrvIns->iInstance));
1177
1178 /* Empty the send queue */
1179 pThis->iSendQueueTail = pThis->iSendQueueHead = 0;
1180
1181 RTSemEventDestroy(pThis->SendSem);
1182 pThis->SendSem = NIL_RTSEMEVENT;
1183
1184#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN)
1185
1186 if (pThis->WakeupPipeW != NIL_RTFILE)
1187 {
1188 int rc = RTFileClose(pThis->WakeupPipeW);
1189 AssertRC(rc);
1190 pThis->WakeupPipeW = NIL_RTFILE;
1191 }
1192 if (pThis->WakeupPipeR != NIL_RTFILE)
1193 {
1194 int rc = RTFileClose(pThis->WakeupPipeR);
1195 AssertRC(rc);
1196 pThis->WakeupPipeR = NIL_RTFILE;
1197 }
1198 if (pThis->DeviceFile != NIL_RTFILE)
1199 {
1200 int rc = RTFileClose(pThis->DeviceFile);
1201 AssertRC(rc);
1202 pThis->DeviceFile = NIL_RTFILE;
1203 }
1204
1205#elif defined(RT_OS_WINDOWS)
1206
1207 CloseHandle(pThis->hEventRecv);
1208 CloseHandle(pThis->hEventSend);
1209 CancelIo(pThis->hDeviceFile);
1210 CloseHandle(pThis->hDeviceFile);
1211
1212#endif
1213}
1214
1215/**
1216 * Char driver registration record.
1217 */
1218const PDMDRVREG g_DrvHostSerial =
1219{
1220 /* u32Version */
1221 PDM_DRVREG_VERSION,
1222 /* szDriverName */
1223 "Host Serial",
1224 /* pszDescription */
1225 "Host serial driver.",
1226 /* fFlags */
1227 PDM_DRVREG_FLAGS_HOST_BITS_DEFAULT,
1228 /* fClass. */
1229 PDM_DRVREG_CLASS_CHAR,
1230 /* cMaxInstances */
1231 ~0,
1232 /* cbInstance */
1233 sizeof(DRVHOSTSERIAL),
1234 /* pfnConstruct */
1235 drvHostSerialConstruct,
1236 /* pfnDestruct */
1237 drvHostSerialDestruct,
1238 /* pfnIOCtl */
1239 NULL,
1240 /* pfnPowerOn */
1241 NULL,
1242 /* pfnReset */
1243 NULL,
1244 /* pfnSuspend */
1245 NULL,
1246 /* pfnResume */
1247 NULL,
1248 /* pfnDetach */
1249 NULL,
1250 /** pfnPowerOff */
1251 NULL
1252};
1253
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette