1 | /** @file
|
---|
2 | * PDM - Pluggable Device Manager, Serial port related interfaces.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2018 Oracle Corporation
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License (GPL) as published by the Free Software
|
---|
12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | *
|
---|
16 | * The contents of this file may alternatively be used under the terms
|
---|
17 | * of the Common Development and Distribution License Version 1.0
|
---|
18 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
19 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
20 | * CDDL are applicable instead of those of the GPL.
|
---|
21 | *
|
---|
22 | * You may elect to license modified versions of this file under the
|
---|
23 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
24 | */
|
---|
25 |
|
---|
26 | #ifndef ___VBox_vmm_pdmserialifs_h
|
---|
27 | #define ___VBox_vmm_pdmserialifs_h
|
---|
28 |
|
---|
29 | #include <VBox/types.h>
|
---|
30 |
|
---|
31 | RT_C_DECLS_BEGIN
|
---|
32 |
|
---|
33 | /** @defgroup grp_pdm_ifs_serial PDM Serial Port Interfaces
|
---|
34 | * @ingroup grp_pdm_interfaces
|
---|
35 | * @{
|
---|
36 | */
|
---|
37 |
|
---|
38 |
|
---|
39 | /** @name Bit mask definitions for status line type.
|
---|
40 | * @{ */
|
---|
41 | #define PDMISERIALPORT_STS_LINE_DCD RT_BIT(0)
|
---|
42 | #define PDMISERIALPORT_STS_LINE_RI RT_BIT(1)
|
---|
43 | #define PDMISERIALPORT_STS_LINE_DSR RT_BIT(2)
|
---|
44 | #define PDMISERIALPORT_STS_LINE_CTS RT_BIT(3)
|
---|
45 | /** @} */
|
---|
46 |
|
---|
47 | /** Pointer to a serial port interface. */
|
---|
48 | typedef struct PDMISERIALPORT *PPDMISERIALPORT;
|
---|
49 | /**
|
---|
50 | * Serial port interface (down).
|
---|
51 | */
|
---|
52 | typedef struct PDMISERIALPORT
|
---|
53 | {
|
---|
54 | /**
|
---|
55 | * Notifies the upper device/driver that data is available for reading.
|
---|
56 | *
|
---|
57 | * @returns VBox status code.
|
---|
58 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
59 | * @param cbAvail The amount of data available to be written.
|
---|
60 | */
|
---|
61 | DECLR3CALLBACKMEMBER(int, pfnDataAvailRdrNotify, (PPDMISERIALPORT pInterface, size_t cbAvail));
|
---|
62 |
|
---|
63 | /**
|
---|
64 | * Notifies the upper device/driver that all data was sent.
|
---|
65 | *
|
---|
66 | * @returns VBox status code.
|
---|
67 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
68 | */
|
---|
69 | DECLR3CALLBACKMEMBER(int, pfnDataSentNotify, (PPDMISERIALPORT pInterface));
|
---|
70 |
|
---|
71 | /**
|
---|
72 | * Try to read data from the device/driver above for writing.
|
---|
73 | *
|
---|
74 | * @returns VBox status code.
|
---|
75 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
76 | * @param pvBuf Where to store the read data.
|
---|
77 | * @param cbRead How much to read.
|
---|
78 | * @param pcbRead Where to store the amount of data actually read on success.
|
---|
79 | */
|
---|
80 | DECLR3CALLBACKMEMBER(int, pfnReadWr, (PPDMISERIALPORT pInterface, void *pvBuf, size_t cbRead, size_t *pcbRead));
|
---|
81 |
|
---|
82 | /**
|
---|
83 | * Notify the device/driver when the status lines changed.
|
---|
84 | *
|
---|
85 | * @returns VBox status code.
|
---|
86 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
87 | * @param fNewStatusLines New state of the status line pins.
|
---|
88 | * @thread Any thread.
|
---|
89 | */
|
---|
90 | DECLR3CALLBACKMEMBER(int, pfnNotifyStsLinesChanged, (PPDMISERIALPORT pInterface, uint32_t fNewStatusLines));
|
---|
91 |
|
---|
92 | /**
|
---|
93 | * Notify the device/driver that a break condition occurred.
|
---|
94 | *
|
---|
95 | * @returns VBox statsus code.
|
---|
96 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
97 | * @thread Any thread.
|
---|
98 | */
|
---|
99 | DECLR3CALLBACKMEMBER(int, pfnNotifyBrk, (PPDMISERIALPORT pInterface));
|
---|
100 |
|
---|
101 | } PDMISERIALPORT;
|
---|
102 | /** PDMISERIALPORT interface ID. */
|
---|
103 | #define PDMISERIALPORT_IID "44540323-06ca-44c1-8eb2-f5a387704dbd"
|
---|
104 |
|
---|
105 |
|
---|
106 | /**
|
---|
107 | * Supported parity modes.
|
---|
108 | */
|
---|
109 | typedef enum PDMSERIALPARITY
|
---|
110 | {
|
---|
111 | /** Invalid parity setting. */
|
---|
112 | PDMSERIALPARITY_INVALID = 0,
|
---|
113 | /** No parity. */
|
---|
114 | PDMSERIALPARITY_NONE,
|
---|
115 | /** Even parity. */
|
---|
116 | PDMSERIALPARITY_EVEN,
|
---|
117 | /** Odd parity. */
|
---|
118 | PDMSERIALPARITY_ODD,
|
---|
119 | /** Mark parity. */
|
---|
120 | PDMSERIALPARITY_MARK,
|
---|
121 | /** Space parity. */
|
---|
122 | PDMSERIALPARITY_SPACE,
|
---|
123 | /** 32bit hack. */
|
---|
124 | PDMSERIALPARITY_32BIT_HACK = 0x7fffffff
|
---|
125 | } PDMSERIALPARITY;
|
---|
126 |
|
---|
127 |
|
---|
128 | /**
|
---|
129 | * Supported number of stop bits.
|
---|
130 | */
|
---|
131 | typedef enum PDMSERIALSTOPBITS
|
---|
132 | {
|
---|
133 | /** Invalid stop bits setting. */
|
---|
134 | PDMSERIALSTOPBITS_INVALID = 0,
|
---|
135 | /** One stop bit is used. */
|
---|
136 | PDMSERIALSTOPBITS_ONE,
|
---|
137 | /** 1.5 stop bits are used. */
|
---|
138 | PDMSERIALSTOPBITS_ONEPOINTFIVE,
|
---|
139 | /** 2 stop bits are used. */
|
---|
140 | PDMSERIALSTOPBITS_TWO,
|
---|
141 | /** 32bit hack. */
|
---|
142 | PDMSERIALSTOPBITS_32BIT_HACK = 0x7fffffff
|
---|
143 | } PDMSERIALSTOPBITS;
|
---|
144 |
|
---|
145 |
|
---|
146 | /** Pointer to a serial interface. */
|
---|
147 | typedef struct PDMISERIALCONNECTOR *PPDMISERIALCONNECTOR;
|
---|
148 | /**
|
---|
149 | * Serial interface (up).
|
---|
150 | * Pairs with PDMISERIALPORT.
|
---|
151 | */
|
---|
152 | typedef struct PDMISERIALCONNECTOR
|
---|
153 | {
|
---|
154 | /**
|
---|
155 | * Notifies the lower layer that data is available for writing.
|
---|
156 | *
|
---|
157 | * @returns VBox status code.
|
---|
158 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
159 | */
|
---|
160 | DECLR3CALLBACKMEMBER(int, pfnDataAvailWrNotify, (PPDMISERIALCONNECTOR pInterface));
|
---|
161 |
|
---|
162 | /**
|
---|
163 | * Try to read data from the underyling driver.
|
---|
164 | *
|
---|
165 | * @returns VBox status code.
|
---|
166 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
167 | * @param pvBuf Where to store the read data.
|
---|
168 | * @param cbRead How much to read.
|
---|
169 | * @param pcbRead Where to store the amount of data actually read on success.
|
---|
170 | */
|
---|
171 | DECLR3CALLBACKMEMBER(int, pfnReadRdr, (PPDMISERIALCONNECTOR pInterface, void *pvBuf, size_t cbRead, size_t *pcbRead));
|
---|
172 |
|
---|
173 | /**
|
---|
174 | * Change device parameters.
|
---|
175 | *
|
---|
176 | * @returns VBox status code.
|
---|
177 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
178 | * @param uBps Speed of the serial connection. (bits per second)
|
---|
179 | * @param enmParity Parity method.
|
---|
180 | * @param cDataBits Number of data bits.
|
---|
181 | * @param enmStopBits Number of stop bits.
|
---|
182 | * @thread Any thread.
|
---|
183 | */
|
---|
184 | DECLR3CALLBACKMEMBER(int, pfnChgParams, (PPDMISERIALCONNECTOR pInterface, uint32_t uBps,
|
---|
185 | PDMSERIALPARITY enmParity, unsigned cDataBits,
|
---|
186 | PDMSERIALSTOPBITS enmStopBits));
|
---|
187 |
|
---|
188 | /**
|
---|
189 | * Set the state of the modem lines.
|
---|
190 | *
|
---|
191 | * @returns VBox status code.
|
---|
192 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
193 | * @param fRts Set to true to make the Request to Send line active otherwise to 0.
|
---|
194 | * @param fDtr Set to true to make the Data Terminal Ready line active otherwise 0.
|
---|
195 | * @thread Any thread.
|
---|
196 | */
|
---|
197 | DECLR3CALLBACKMEMBER(int, pfnChgModemLines, (PPDMISERIALCONNECTOR pInterface, bool fRts, bool fDtr));
|
---|
198 |
|
---|
199 | /**
|
---|
200 | * Changes the TD line into the requested break condition.
|
---|
201 | *
|
---|
202 | * @returns VBox status code.
|
---|
203 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
204 | * @param fBrk Set to true to let the device send a break false to put into normal operation.
|
---|
205 | * @thread Any thread.
|
---|
206 | */
|
---|
207 | DECLR3CALLBACKMEMBER(int, pfnChgBrk, (PPDMISERIALCONNECTOR pInterface, bool fBrk));
|
---|
208 |
|
---|
209 | /**
|
---|
210 | * Queries the current state of the status lines.
|
---|
211 | *
|
---|
212 | * @returns VBox status code.
|
---|
213 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
214 | * @param pfStsLines Where to store the status line states on success.
|
---|
215 | */
|
---|
216 | DECLR3CALLBACKMEMBER(int, pfnQueryStsLines, (PPDMISERIALCONNECTOR pInterface, uint32_t *pfStsLines));
|
---|
217 |
|
---|
218 | /**
|
---|
219 | * Flushes the indicated queues.
|
---|
220 | *
|
---|
221 | * @returns VBox status code.
|
---|
222 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
223 | * @param fQueueRecv Flag whether to flush the receive queue.
|
---|
224 | * @param fQueueXmit Flag whether to flush the transmit queue.
|
---|
225 | */
|
---|
226 | DECLR3CALLBACKMEMBER(int, pfnQueuesFlush, (PPDMISERIALCONNECTOR pInterface, bool fQueueRecv, bool fQueueXmit));
|
---|
227 |
|
---|
228 | } PDMISERIALCONNECTOR;
|
---|
229 | /** PDMIMEDIA interface ID. */
|
---|
230 | #define PDMISERIALCONNECTOR_IID "d024f170-c00d-11e8-b568-0800200c9a66"
|
---|
231 |
|
---|
232 | /** @} */
|
---|
233 |
|
---|
234 | RT_C_DECLS_END
|
---|
235 |
|
---|
236 | #endif
|
---|