VirtualBox

source: vbox/trunk/src/VBox/Devices/Trace/DrvIfsTrace-serial.cpp@ 91703

Last change on this file since 91703 was 82791, checked in by vboxsync, 5 years ago

Devices/Trace: Fix trace IDs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 17.0 KB
Line 
1/* $Id: DrvIfsTrace-serial.cpp 82791 2020-01-19 12:27:43Z vboxsync $ */
2/** @file
3 * VBox interface callback tracing driver.
4 */
5
6/*
7 * Copyright (C) 2020 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18
19/*********************************************************************************************************************************
20* Header Files *
21*********************************************************************************************************************************/
22#define LOG_GROUP LOG_GROUP_MISC
23#include <VBox/log.h>
24#include <VBox/version.h>
25
26#include <iprt/errcore.h>
27#include <iprt/tracelog.h>
28
29#include "DrvIfsTraceInternal.h"
30
31
32/*
33 *
34 * ISerialPort Implementation.
35 *
36 */
37static const RTTRACELOGEVTITEMDESC g_ISerialPortDataAvailRdrNotifyEvtItems[] =
38{
39 {"cbAvail", "Number of bytes available", RTTRACELOGTYPE_SIZE, 0},
40 {"rc", "Status code returned by the upper device/driver", RTTRACELOGTYPE_INT32, 0}
41};
42
43static const RTTRACELOGEVTDESC g_ISerialPortDataAvailRdrNotifyEvtDesc =
44{
45 "ISerialPort.DataAvailRdrNotify",
46 "",
47 RTTRACELOGEVTSEVERITY_DEBUG,
48 RT_ELEMENTS(g_ISerialPortDataAvailRdrNotifyEvtItems),
49 g_ISerialPortDataAvailRdrNotifyEvtItems
50};
51
52/**
53 * @interface_method_impl{PDMISERIALPORT,pfnDataAvailRdrNotify}
54 */
55static DECLCALLBACK(int) drvIfTraceISerialPort_DataAvailRdrNotify(PPDMISERIALPORT pInterface, size_t cbAvail)
56{
57 PDRVIFTRACE pThis = RT_FROM_MEMBER(pInterface, DRVIFTRACE, ISerialPort);
58 int rc = pThis->pISerialPortAbove->pfnDataAvailRdrNotify(pThis->pISerialPortAbove, cbAvail);
59
60 int rcTraceLog = RTTraceLogWrEvtAddL(pThis->hTraceLog, &g_ISerialPortDataAvailRdrNotifyEvtDesc, 0, 0, 0, cbAvail, rc);
61 if (RT_FAILURE(rcTraceLog))
62 LogRelMax(10, ("DrvIfTrace#%d: Failed to add event to trace log %Rrc\n", pThis->pDrvIns->iInstance, rcTraceLog));
63
64 return rc;
65}
66
67
68static const RTTRACELOGEVTITEMDESC g_ISerialPortDataSentNotifyEvtItems[] =
69{
70 {"rc", "Status code returned by the upper device/driver", RTTRACELOGTYPE_INT32, 0}
71};
72
73static const RTTRACELOGEVTDESC g_ISerialPortDataSentNotifyEvtDesc =
74{
75 "ISerialPort.DataSentNotify",
76 "",
77 RTTRACELOGEVTSEVERITY_DEBUG,
78 RT_ELEMENTS(g_ISerialPortDataSentNotifyEvtItems),
79 g_ISerialPortDataSentNotifyEvtItems
80};
81
82/**
83 * @interface_method_impl{PDMISERIALPORT,pfnDataSentNotify}
84 */
85static DECLCALLBACK(int) drvIfTraceISerialPort_DataSentNotify(PPDMISERIALPORT pInterface)
86{
87 PDRVIFTRACE pThis = RT_FROM_MEMBER(pInterface, DRVIFTRACE, ISerialPort);
88 int rc = pThis->pISerialPortAbove->pfnDataSentNotify(pThis->pISerialPortAbove);
89
90 int rcTraceLog = RTTraceLogWrEvtAddL(pThis->hTraceLog, &g_ISerialPortDataSentNotifyEvtDesc, 0, 0, 0, rc);
91 if (RT_FAILURE(rcTraceLog))
92 LogRelMax(10, ("DrvIfTrace#%d: Failed to add event to trace log %Rrc\n", pThis->pDrvIns->iInstance, rcTraceLog));
93
94 return rc;
95}
96
97
98static const RTTRACELOGEVTITEMDESC g_ISerialPortReadWrEvtItems[] =
99{
100 {"cbRead", "Number of bytes to read max", RTTRACELOGTYPE_SIZE, 0},
101 {"pcbRead", "Number of bytes actually read", RTTRACELOGTYPE_SIZE, 0},
102 {"rc", "Status code returned by the upper device/driver", RTTRACELOGTYPE_INT32, 0}
103};
104
105static const RTTRACELOGEVTDESC g_ISerialPortReadWrEvtDesc =
106{
107 "ISerialPort.ReadWr",
108 "",
109 RTTRACELOGEVTSEVERITY_DEBUG,
110 RT_ELEMENTS(g_ISerialPortReadWrEvtItems),
111 g_ISerialPortReadWrEvtItems
112};
113
114/**
115 * @interface_method_impl{PDMISERIALPORT,pfnReadWr}
116 */
117static DECLCALLBACK(int) drvIfTraceISerialPort_ReadWr(PPDMISERIALPORT pInterface, void *pvBuf, size_t cbRead, size_t *pcbRead)
118{
119 PDRVIFTRACE pThis = RT_FROM_MEMBER(pInterface, DRVIFTRACE, ISerialPort);
120 int rc = pThis->pISerialPortAbove->pfnReadWr(pThis->pISerialPortAbove, pvBuf, cbRead, pcbRead);
121
122 int rcTraceLog = RTTraceLogWrEvtAddL(pThis->hTraceLog, &g_ISerialPortReadWrEvtDesc, 0, 0, 0, cbRead, *pcbRead, rc);
123 if (RT_FAILURE(rcTraceLog))
124 LogRelMax(10, ("DrvIfTrace#%d: Failed to add event to trace log %Rrc\n", pThis->pDrvIns->iInstance, rcTraceLog));
125
126 return rc;
127}
128
129
130static const RTTRACELOGEVTITEMDESC g_ISerialPortNotifyStsLinesChangedEvtItems[] =
131{
132 {"fNewStsLines", "Status line mask", RTTRACELOGTYPE_UINT32, 0},
133 {"rc", "Status code returned by the upper device/driver", RTTRACELOGTYPE_INT32, 0}
134};
135
136static const RTTRACELOGEVTDESC g_ISerialPortNotifyStsLinesChangedEvtDesc =
137{
138 "ISerialPort.NotifyStsLinesChanged",
139 "",
140 RTTRACELOGEVTSEVERITY_DEBUG,
141 RT_ELEMENTS(g_ISerialPortNotifyStsLinesChangedEvtItems),
142 g_ISerialPortNotifyStsLinesChangedEvtItems
143};
144
145/**
146 * @interface_method_impl{PDMISERIALPORT,pfnNotifyStsLinesChanged}
147 */
148static DECLCALLBACK(int) drvIfTraceISerialPort_NotifyStsLinesChanged(PPDMISERIALPORT pInterface, uint32_t fNewStatusLines)
149{
150 PDRVIFTRACE pThis = RT_FROM_MEMBER(pInterface, DRVIFTRACE, ISerialPort);
151 int rc = pThis->pISerialPortAbove->pfnNotifyStsLinesChanged(pThis->pISerialPortAbove, fNewStatusLines);
152
153 int rcTraceLog = RTTraceLogWrEvtAddL(pThis->hTraceLog, &g_ISerialPortNotifyStsLinesChangedEvtDesc, 0, 0, 0, fNewStatusLines, rc);
154 if (RT_FAILURE(rcTraceLog))
155 LogRelMax(10, ("DrvIfTrace#%d: Failed to add event to trace log %Rrc\n", pThis->pDrvIns->iInstance, rcTraceLog));
156
157 return rc;
158}
159
160
161static const RTTRACELOGEVTITEMDESC g_ISerialPortNotifyBrkEvtItems[] =
162{
163 {"rc", "Status code returned by the upper device/driver", RTTRACELOGTYPE_INT32, 0}
164};
165
166static const RTTRACELOGEVTDESC g_ISerialPortNotifyBrkEvtDesc =
167{
168 "ISerialPort.NotifyBrk",
169 "",
170 RTTRACELOGEVTSEVERITY_DEBUG,
171 RT_ELEMENTS(g_ISerialPortNotifyBrkEvtItems),
172 g_ISerialPortNotifyBrkEvtItems
173};
174
175/**
176 * @interface_method_impl{PDMISERIALPORT,pfnNotifyBrk}
177 */
178static DECLCALLBACK(int) drvIfTraceISerialPort_NotifyBrk(PPDMISERIALPORT pInterface)
179{
180 PDRVIFTRACE pThis = RT_FROM_MEMBER(pInterface, DRVIFTRACE, ISerialPort);
181 int rc = pThis->pISerialPortAbove->pfnNotifyBrk(pThis->pISerialPortAbove);
182
183 int rcTraceLog = RTTraceLogWrEvtAddL(pThis->hTraceLog, &g_ISerialPortNotifyBrkEvtDesc, 0, 0, 0, rc);
184 if (RT_FAILURE(rcTraceLog))
185 LogRelMax(10, ("DrvIfTrace#%d: Failed to add event to trace log %Rrc\n", pThis->pDrvIns->iInstance, rcTraceLog));
186
187 return rc;
188}
189
190
191/*
192 *
193 * ISerialConnector Implementation.
194 *
195 */
196static const RTTRACELOGEVTITEMDESC g_ISerialConnectorDataAvailWrNotifyEvtItems[] =
197{
198 {"rc", "Status code returned by the lower driver", RTTRACELOGTYPE_INT32, 0}
199};
200
201static const RTTRACELOGEVTDESC g_ISerialConnectorDataAvailWrNotifyEvtDesc =
202{
203 "ISerialConnector.DataAvailWrNotify",
204 "",
205 RTTRACELOGEVTSEVERITY_DEBUG,
206 RT_ELEMENTS(g_ISerialConnectorDataAvailWrNotifyEvtItems),
207 g_ISerialConnectorDataAvailWrNotifyEvtItems
208};
209
210/** @interface_method_impl{PDMISERIALCONNECTOR,pfnDataAvailWrNotify} */
211static DECLCALLBACK(int) drvIfTraceISerialConnector_DataAvailWrNotify(PPDMISERIALCONNECTOR pInterface)
212{
213 PDRVIFTRACE pThis = RT_FROM_MEMBER(pInterface, DRVIFTRACE, ISerialConnector);
214 int rc = pThis->pISerialConBelow->pfnDataAvailWrNotify(pThis->pISerialConBelow);
215
216 int rcTraceLog = RTTraceLogWrEvtAddL(pThis->hTraceLog, &g_ISerialConnectorDataAvailWrNotifyEvtDesc, 0, 0, 0, rc);
217 if (RT_FAILURE(rcTraceLog))
218 LogRelMax(10, ("DrvIfTrace#%d: Failed to add event to trace log %Rrc\n", pThis->pDrvIns->iInstance, rcTraceLog));
219
220 return rc;
221}
222
223
224static const RTTRACELOGEVTITEMDESC g_ISerialConnectorReadRdrEvtItems[] =
225{
226 {"cbRead", "Number of bytes to read max", RTTRACELOGTYPE_SIZE, 0},
227 {"pcbRead", "Number of bytes actually read", RTTRACELOGTYPE_SIZE, 0},
228 {"rc", "Status code returned by the lower driver", RTTRACELOGTYPE_INT32, 0}
229};
230
231static const RTTRACELOGEVTDESC g_ISerialConnectorReadRdrEvtDesc =
232{
233 "ISerialConnector.ReadRdr",
234 "",
235 RTTRACELOGEVTSEVERITY_DEBUG,
236 RT_ELEMENTS(g_ISerialConnectorReadRdrEvtItems),
237 g_ISerialConnectorReadRdrEvtItems
238};
239
240/**
241 * @interface_method_impl{PDMISERIALCONNECTOR,pfnReadRdr}
242 */
243static DECLCALLBACK(int) drvIfTraceISerialConnector_ReadRdr(PPDMISERIALCONNECTOR pInterface, void *pvBuf,
244 size_t cbRead, size_t *pcbRead)
245{
246 PDRVIFTRACE pThis = RT_FROM_MEMBER(pInterface, DRVIFTRACE, ISerialConnector);
247 int rc = pThis->pISerialConBelow->pfnReadRdr(pThis->pISerialConBelow, pvBuf, cbRead, pcbRead);
248
249 int rcTraceLog = RTTraceLogWrEvtAddL(pThis->hTraceLog, &g_ISerialConnectorReadRdrEvtDesc, 0, 0, 0, cbRead, *pcbRead, rc);
250 if (RT_FAILURE(rcTraceLog))
251 LogRelMax(10, ("DrvIfTrace#%d: Failed to add event to trace log %Rrc\n", pThis->pDrvIns->iInstance, rcTraceLog));
252
253 return rc;
254}
255
256
257static const RTTRACELOGEVTITEMDESC g_ISerialConnectorChgParamsEvtItems[] =
258{
259 {"uBps", "Baudrate", RTTRACELOGTYPE_UINT32, 0},
260 {"enmParity", "The parity to configure", RTTRACELOGTYPE_UINT32, 0},
261 {"cDataBits", "Number of data bits for each symbol", RTTRACELOGTYPE_UINT32, 0},
262 {"enmStopBits", "Number of stop bits for each symbol", RTTRACELOGTYPE_UINT32, 0},
263 {"rc", "Status code returned by the lower driver", RTTRACELOGTYPE_INT32, 0}
264};
265
266static const RTTRACELOGEVTDESC g_ISerialConnectorChgParamsEvtDesc =
267{
268 "ISerialConnector.ChgParams",
269 "",
270 RTTRACELOGEVTSEVERITY_DEBUG,
271 RT_ELEMENTS(g_ISerialConnectorChgParamsEvtItems),
272 g_ISerialConnectorChgParamsEvtItems
273};
274
275/**
276 * @interface_method_impl{PDMISERIALCONNECTOR,pfnChgParams}
277 */
278static DECLCALLBACK(int) drvIfTraceISerialConnector_ChgParams(PPDMISERIALCONNECTOR pInterface, uint32_t uBps,
279 PDMSERIALPARITY enmParity, unsigned cDataBits,
280 PDMSERIALSTOPBITS enmStopBits)
281{
282 PDRVIFTRACE pThis = RT_FROM_MEMBER(pInterface, DRVIFTRACE, ISerialConnector);
283 int rc = pThis->pISerialConBelow->pfnChgParams(pThis->pISerialConBelow, uBps, enmParity, cDataBits, enmStopBits);
284
285 int rcTraceLog = RTTraceLogWrEvtAddL(pThis->hTraceLog, &g_ISerialConnectorChgParamsEvtDesc, 0, 0, 0,
286 uBps, enmParity, cDataBits, enmStopBits, rc);
287 if (RT_FAILURE(rcTraceLog))
288 LogRelMax(10, ("DrvIfTrace#%d: Failed to add event to trace log %Rrc\n", pThis->pDrvIns->iInstance, rcTraceLog));
289
290 return rc;
291}
292
293
294static const RTTRACELOGEVTITEMDESC g_ISerialConnectorChgModemLinesEvtItems[] =
295{
296 {"fRts", "State of RTS line", RTTRACELOGTYPE_BOOL, 0},
297 {"fDtr", "State of DTR line", RTTRACELOGTYPE_BOOL, 0},
298 {"rc", "Status code returned by the lower driver", RTTRACELOGTYPE_INT32, 0}
299};
300
301static const RTTRACELOGEVTDESC g_ISerialConnectorChgModemLinesEvtDesc =
302{
303 "ISerialConnector.ChgModemLines",
304 "",
305 RTTRACELOGEVTSEVERITY_DEBUG,
306 RT_ELEMENTS(g_ISerialConnectorChgModemLinesEvtItems),
307 g_ISerialConnectorChgModemLinesEvtItems
308};
309
310/**
311 * @interface_method_impl{PDMISERIALCONNECTOR,pfnChgModemLines}
312 */
313static DECLCALLBACK(int) drvIfTraceISerialConnector_ChgModemLines(PPDMISERIALCONNECTOR pInterface, bool fRts, bool fDtr)
314{
315 PDRVIFTRACE pThis = RT_FROM_MEMBER(pInterface, DRVIFTRACE, ISerialConnector);
316 int rc = pThis->pISerialConBelow->pfnChgModemLines(pThis->pISerialConBelow, fRts, fDtr);
317
318 int rcTraceLog = RTTraceLogWrEvtAddL(pThis->hTraceLog, &g_ISerialConnectorChgModemLinesEvtDesc, 0, 0, 0, fRts, fDtr, rc);
319 if (RT_FAILURE(rcTraceLog))
320 LogRelMax(10, ("DrvIfTrace#%d: Failed to add event to trace log %Rrc\n", pThis->pDrvIns->iInstance, rcTraceLog));
321
322 return rc;
323}
324
325
326static const RTTRACELOGEVTITEMDESC g_ISerialConnectorChgBrkEvtItems[] =
327{
328 {"fBrk", "Signal break flag", RTTRACELOGTYPE_BOOL, 0},
329 {"rc", "Status code returned by the lower driver", RTTRACELOGTYPE_INT32, 0}
330};
331
332static const RTTRACELOGEVTDESC g_ISerialConnectorChgBrkEvtDesc =
333{
334 "ISerialConnector.ChgBrk",
335 "",
336 RTTRACELOGEVTSEVERITY_DEBUG,
337 RT_ELEMENTS(g_ISerialConnectorChgBrkEvtItems),
338 g_ISerialConnectorChgBrkEvtItems
339};
340
341/**
342 * @interface_method_impl{PDMISERIALCONNECTOR,pfnChgBrk}
343 */
344static DECLCALLBACK(int) drvIfTraceISerialConnector_ChgBrk(PPDMISERIALCONNECTOR pInterface, bool fBrk)
345{
346 PDRVIFTRACE pThis = RT_FROM_MEMBER(pInterface, DRVIFTRACE, ISerialConnector);
347 int rc = pThis->pISerialConBelow->pfnChgBrk(pThis->pISerialConBelow, fBrk);
348
349 int rcTraceLog = RTTraceLogWrEvtAddL(pThis->hTraceLog, &g_ISerialConnectorChgBrkEvtDesc, 0, 0, 0, fBrk, rc);
350 if (RT_FAILURE(rcTraceLog))
351 LogRelMax(10, ("DrvIfTrace#%d: Failed to add event to trace log %Rrc\n", pThis->pDrvIns->iInstance, rcTraceLog));
352
353 return rc;
354}
355
356
357static const RTTRACELOGEVTITEMDESC g_ISerialConnectorQueryStsLinesEvtItems[] =
358{
359 {"fStsLines", "Status line flags", RTTRACELOGTYPE_UINT32, 0},
360 {"rc", "Status code returned by the lower driver", RTTRACELOGTYPE_INT32, 0}
361};
362
363static const RTTRACELOGEVTDESC g_ISerialConnectorQueryStsLinesEvtDesc =
364{
365 "ISerialConnector.QueryStsLines",
366 "",
367 RTTRACELOGEVTSEVERITY_DEBUG,
368 RT_ELEMENTS(g_ISerialConnectorQueryStsLinesEvtItems),
369 g_ISerialConnectorQueryStsLinesEvtItems
370};
371
372/**
373 * @interface_method_impl{PDMISERIALCONNECTOR,pfnQueryStsLines}
374 */
375static DECLCALLBACK(int) drvIfTraceISerialConnector_QueryStsLines(PPDMISERIALCONNECTOR pInterface, uint32_t *pfStsLines)
376{
377 PDRVIFTRACE pThis = RT_FROM_MEMBER(pInterface, DRVIFTRACE, ISerialConnector);
378 int rc = pThis->pISerialConBelow->pfnQueryStsLines(pThis->pISerialConBelow, pfStsLines);
379
380 int rcTraceLog = RTTraceLogWrEvtAddL(pThis->hTraceLog, &g_ISerialConnectorQueryStsLinesEvtDesc, 0, 0, 0, *pfStsLines, rc);
381 if (RT_FAILURE(rcTraceLog))
382 LogRelMax(10, ("DrvIfTrace#%d: Failed to add event to trace log %Rrc\n", pThis->pDrvIns->iInstance, rcTraceLog));
383
384 return rc;
385}
386
387
388static const RTTRACELOGEVTITEMDESC g_ISerialConnectorQueuesFlushEvtItems[] =
389{
390 {"fQueueRecv", "Whether to flush the receive queue", RTTRACELOGTYPE_BOOL, 0},
391 {"fQueueXmit", "Whether to flush the transmit queue", RTTRACELOGTYPE_BOOL, 0},
392 {"rc", "Status code returned by the lower driver", RTTRACELOGTYPE_INT32, 0}
393};
394
395static const RTTRACELOGEVTDESC g_ISerialConnectorQueuesFlushEvtDesc =
396{
397 "ISerialConnector.QueuesFlush",
398 "",
399 RTTRACELOGEVTSEVERITY_DEBUG,
400 RT_ELEMENTS(g_ISerialConnectorQueuesFlushEvtItems),
401 g_ISerialConnectorQueuesFlushEvtItems
402};
403
404/**
405 * @callback_method_impl{PDMISERIALCONNECTOR,pfnQueuesFlush}
406 */
407static DECLCALLBACK(int) drvIfTraceISerialConnector_QueuesFlush(PPDMISERIALCONNECTOR pInterface, bool fQueueRecv, bool fQueueXmit)
408{
409 PDRVIFTRACE pThis = RT_FROM_MEMBER(pInterface, DRVIFTRACE, ISerialConnector);
410 int rc = pThis->pISerialConBelow->pfnQueuesFlush(pThis->pISerialConBelow, fQueueRecv, fQueueXmit);
411
412 int rcTraceLog = RTTraceLogWrEvtAddL(pThis->hTraceLog, &g_ISerialConnectorQueuesFlushEvtDesc, 0, 0, 0, fQueueRecv, fQueueXmit, rc);
413 if (RT_FAILURE(rcTraceLog))
414 LogRelMax(10, ("DrvIfTrace#%d: Failed to add event to trace log %Rrc\n", pThis->pDrvIns->iInstance, rcTraceLog));
415
416 return rc;
417}
418
419
420/**
421 * Initializes serial port relaated interfaces.
422 *
423 * @returns nothing.
424 * @param pThis The interface callback trace driver instance.
425 */
426DECLHIDDEN(void) drvIfsTrace_SerialIfInit(PDRVIFTRACE pThis)
427{
428 pThis->ISerialPort.pfnDataAvailRdrNotify = drvIfTraceISerialPort_DataAvailRdrNotify;
429 pThis->ISerialPort.pfnDataSentNotify = drvIfTraceISerialPort_DataSentNotify;
430 pThis->ISerialPort.pfnReadWr = drvIfTraceISerialPort_ReadWr;
431 pThis->ISerialPort.pfnNotifyStsLinesChanged = drvIfTraceISerialPort_NotifyStsLinesChanged;
432 pThis->ISerialPort.pfnNotifyBrk = drvIfTraceISerialPort_NotifyBrk;
433
434 pThis->ISerialConnector.pfnDataAvailWrNotify = drvIfTraceISerialConnector_DataAvailWrNotify;
435 pThis->ISerialConnector.pfnReadRdr = drvIfTraceISerialConnector_ReadRdr;
436 pThis->ISerialConnector.pfnChgParams = drvIfTraceISerialConnector_ChgParams;
437 pThis->ISerialConnector.pfnChgModemLines = drvIfTraceISerialConnector_ChgModemLines;
438 pThis->ISerialConnector.pfnChgBrk = drvIfTraceISerialConnector_ChgBrk;
439 pThis->ISerialConnector.pfnQueryStsLines = drvIfTraceISerialConnector_QueryStsLines;
440 pThis->ISerialConnector.pfnQueuesFlush = drvIfTraceISerialConnector_QueuesFlush;
441}
442
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