VirtualBox

source: vbox/trunk/include/VBox/vmm/pdmserialifs.h

Last change on this file was 98103, checked in by vboxsync, 16 months ago

Copyright year updates by scm.

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

© 2023 Oracle
ContactPrivacy policyTerms of Use