VirtualBox

source: vbox/trunk/src/VBox/Devices/Parallel/DrvHostParallel.cpp@ 57358

Last change on this file since 57358 was 57358, checked in by vboxsync, 10 years ago

*: scm cleanup run.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 36.7 KB
Line 
1/* $Id: DrvHostParallel.cpp 57358 2015-08-14 15:16:38Z vboxsync $ */
2/** @file
3 * VirtualBox Host Parallel Port Driver.
4 *
5 * Initial Linux-only code contributed by: Alexander Eichner
6 */
7
8/*
9 * Copyright (C) 2006-2015 Oracle Corporation
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
20
21/*********************************************************************************************************************************
22* Header Files *
23*********************************************************************************************************************************/
24#define LOG_GROUP LOG_GROUP_DRV_HOST_PARALLEL
25#include <VBox/vmm/pdmdrv.h>
26#include <VBox/vmm/pdmthread.h>
27#include <iprt/asm.h>
28#include <iprt/assert.h>
29#include <iprt/file.h>
30#include <iprt/pipe.h>
31#include <iprt/semaphore.h>
32#include <iprt/stream.h>
33#include <iprt/uuid.h>
34#include <iprt/cdefs.h>
35#include <iprt/ctype.h>
36
37#ifdef RT_OS_LINUX
38# include <sys/ioctl.h>
39# include <sys/types.h>
40# include <sys/stat.h>
41# include <sys/poll.h>
42# include <fcntl.h>
43# include <unistd.h>
44# include <linux/ppdev.h>
45# include <linux/parport.h>
46# include <errno.h>
47#endif
48
49/** @def VBOX_WITH_WIN_PARPORT_SUP *
50 * Indicates whether to use the generic direct hardware access or host specific
51 * code to access the parallel port.
52 */
53#if defined(RT_OS_LINUX)
54# undef VBOX_WITH_WIN_PARPORT_SUP
55#elif defined(RT_OS_WINDOWS)
56#else
57# error "Not ported"
58#endif
59
60#if defined(VBOX_WITH_WIN_PARPORT_SUP) && defined(IN_RING0)
61# include <iprt/asm-amd64-x86.h>
62#endif
63
64#if defined(VBOX_WITH_WIN_PARPORT_SUP) && defined(IN_RING3)
65# include <Windows.h>
66# include <setupapi.h>
67# include <cfgmgr32.h>
68# include <iprt/mem.h>
69# include <iprt/string.h>
70#endif
71
72#include "VBoxDD.h"
73
74
75/*********************************************************************************************************************************
76* Structures and Typedefs *
77*********************************************************************************************************************************/
78/**
79 * Host parallel port driver instance data.
80 * @implements PDMIHOSTPARALLELCONNECTOR
81 */
82typedef struct DRVHOSTPARALLEL
83{
84 /** Pointer to the driver instance structure. */
85 PPDMDRVINS pDrvIns;
86 /** Pointer to the driver instance. */
87 PPDMDRVINSR3 pDrvInsR3;
88 PPDMDRVINSR0 pDrvInsR0;
89 /** Pointer to the char port interface of the driver/device above us. */
90 PPDMIHOSTPARALLELPORT pDrvHostParallelPort;
91 /** Our host device interface. */
92 PDMIHOSTPARALLELCONNECTOR IHostParallelConnector;
93 /** Our host device interface. */
94 PDMIHOSTPARALLELCONNECTOR IHostParallelConnectorR3;
95 /** Device Path */
96 char *pszDevicePath;
97 /** Device Handle */
98 RTFILE hFileDevice;
99#ifndef VBOX_WITH_WIN_PARPORT_SUP
100 /** Thread waiting for interrupts. */
101 PPDMTHREAD pMonitorThread;
102 /** Wakeup pipe read end. */
103 RTPIPE hWakeupPipeR;
104 /** Wakeup pipe write end. */
105 RTPIPE hWakeupPipeW;
106 /** Current mode the parallel port is in. */
107 PDMPARALLELPORTMODE enmModeCur;
108#endif
109
110#ifdef VBOX_WITH_WIN_PARPORT_SUP
111 /** Data register. */
112 uint32_t u32LptAddr;
113 /** Status register. */
114 uint32_t u32LptAddrStatus;
115 /** Control register. */
116 uint32_t u32LptAddrControl;
117 /** Data read buffer. */
118 uint8_t u8ReadIn;
119 /** Control read buffer. */
120 uint8_t u8ReadInControl;
121 /** Status read buffer. */
122 uint8_t u8ReadInStatus;
123 /** Parallel port name */
124 char szParportName[6];
125 /** Whether the parallel port is available or not. */
126 bool fParportAvail;
127 /** Device Handle */
128 RTFILE hWinFileDevice;
129#endif /* VBOX_WITH_WIN_PARPORT_SUP */
130} DRVHOSTPARALLEL, *PDRVHOSTPARALLEL;
131
132
133/**
134 * Ring-0 operations.
135 */
136typedef enum DRVHOSTPARALLELR0OP
137{
138 /** Invalid zero value. */
139 DRVHOSTPARALLELR0OP_INVALID = 0,
140 /** Perform R0 initialization. */
141 DRVHOSTPARALLELR0OP_INITR0STUFF,
142 /** Read data. */
143 DRVHOSTPARALLELR0OP_READ,
144 /** Read status register. */
145 DRVHOSTPARALLELR0OP_READSTATUS,
146 /** Read control register. */
147 DRVHOSTPARALLELR0OP_READCONTROL,
148 /** Write data. */
149 DRVHOSTPARALLELR0OP_WRITE,
150 /** Write control register. */
151 DRVHOSTPARALLELR0OP_WRITECONTROL,
152 /** Set port direction. */
153 DRVHOSTPARALLELR0OP_SETPORTDIRECTION
154} DRVHOSTPARALLELR0OP;
155
156/** Converts a pointer to DRVHOSTPARALLEL::IHostDeviceConnector to a PDRHOSTPARALLEL. */
157#define PDMIHOSTPARALLELCONNECTOR_2_DRVHOSTPARALLEL(pInterface) ( (PDRVHOSTPARALLEL)((uintptr_t)pInterface - RT_OFFSETOF(DRVHOSTPARALLEL, CTX_SUFF(IHostParallelConnector))) )
158
159
160/*********************************************************************************************************************************
161* Defined Constants And Macros *
162*********************************************************************************************************************************/
163#define CTRL_REG_OFFSET 2
164#define STATUS_REG_OFFSET 1
165#define LPT_CONTROL_ENABLE_BIDIRECT 0x20
166
167
168
169#ifdef VBOX_WITH_WIN_PARPORT_SUP
170# ifdef IN_RING0
171
172/**
173 * R0 mode function to write byte value to data port.
174 * @returns VBox status code.
175 * @param pDrvIns Driver instance.
176 * @param u64Arg Data to be written to data register.
177 *
178 */
179static int drvR0HostParallelReqWrite(PPDMDRVINS pDrvIns, uint64_t u64Arg)
180{
181 PDRVHOSTPARALLEL pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTPARALLEL);
182 LogFlowFunc(("write to data port=%#x val=%#x\n", pThis->u32LptAddr, u64Arg));
183 ASMOutU8(pThis->u32LptAddr, (uint8_t)(u64Arg));
184 return VINF_SUCCESS;
185}
186
187/**
188 * R0 mode function to write byte value to parallel port control
189 * register.
190 * @returns VBox status code.
191 * @param pDrvIns Driver instance.
192 * @param u64Arg Data to be written to control register.
193 */
194static int drvR0HostParallelReqWriteControl(PPDMDRVINS pDrvIns, uint64_t u64Arg)
195{
196 PDRVHOSTPARALLEL pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTPARALLEL);
197 LogFlowFunc(("write to ctrl port=%#x val=%#x\n", pThis->u32LptAddrControl, u64Arg));
198 ASMOutU8(pThis->u32LptAddrControl, (uint8_t)(u64Arg));
199 return VINF_SUCCESS;
200}
201
202/**
203 * R0 mode function to ready byte value from the parallel port
204 * data register
205 * @returns VBox status code.
206 * @param pDrvIns Driver instance.
207 * @param u64Arg Not used.
208 */
209static int drvR0HostParallelReqRead(PPDMDRVINS pDrvIns, uint64_t u64Arg)
210{
211 uint8_t u8Data;
212 PDRVHOSTPARALLEL pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTPARALLEL);
213 u8Data = ASMInU8(pThis->u32LptAddr);
214 LogFlowFunc(("read from data port=%#x val=%#x\n", pThis->u32LptAddr, u8Data));
215 pThis->u8ReadIn = u8Data;
216 return VINF_SUCCESS;
217}
218
219/**
220 * R0 mode function to ready byte value from the parallel port
221 * control register.
222 * @returns VBox status code.
223 * @param pDrvIns Driver instance.
224 * @param u64Arg Not used.
225 */
226static int drvR0HostParallelReqReadControl(PPDMDRVINS pDrvIns, uint64_t u64Arg)
227{
228 uint8_t u8Data;
229 PDRVHOSTPARALLEL pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTPARALLEL);
230 u8Data = ASMInU8(pThis->u32LptAddrControl);
231 LogFlowFunc(("read from ctrl port=%#x val=%#x\n", pThis->u32LptAddr, u8Data));
232 pThis->u8ReadInControl = u8Data;
233 return VINF_SUCCESS;
234}
235
236/**
237 * R0 mode function to ready byte value from the parallel port
238 * status register.
239 * @returns VBox status code.
240 * @param pDrvIns Driver instance.
241 * @param u64Arg Not used.
242 */
243static int drvR0HostParallelReqReadStatus(PPDMDRVINS pDrvIns, uint64_t u64Arg)
244{
245 uint8_t u8Data;
246 PDRVHOSTPARALLEL pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTPARALLEL);
247 u8Data = ASMInU8(pThis->u32LptAddrStatus);
248 LogFlowFunc(("read from status port=%#x val=%#x\n", pThis->u32LptAddr, u8Data));
249 pThis->u8ReadInStatus = u8Data;
250 return VINF_SUCCESS;
251}
252
253/**
254 * R0 mode function to set the direction of parallel port -
255 * operate in bidirectional mode or single direction.
256 * @returns VBox status code.
257 * @param pDrvIns Driver instance.
258 * @param u64Arg Mode.
259 */
260static int drvR0HostParallelReqSetPortDir(PPDMDRVINS pDrvIns, uint64_t u64Arg)
261{
262 PDRVHOSTPARALLEL pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTPARALLEL);
263 uint8_t u8ReadControlVal;
264 uint8_t u8WriteControlVal;
265
266 if (u64Arg)
267 {
268 u8ReadControlVal = ASMInU8(pThis->u32LptAddrControl);
269 u8WriteControlVal = u8ReadControlVal | LPT_CONTROL_ENABLE_BIDIRECT; /* enable input direction */
270 ASMOutU8(pThis->u32LptAddrControl, u8WriteControlVal);
271 }
272 else
273 {
274 u8ReadControlVal = ASMInU8(pThis->u32LptAddrControl);
275 u8WriteControlVal = u8ReadControlVal & ~LPT_CONTROL_ENABLE_BIDIRECT; /* disable input direction */
276 ASMOutU8(pThis->u32LptAddrControl, u8WriteControlVal);
277 }
278 return VINF_SUCCESS;
279}
280
281/**
282 * @interface_method_impl{FNPDMDRVREQHANDLERR0}
283 */
284PDMBOTHCBDECL(int) drvR0HostParallelReqHandler(PPDMDRVINS pDrvIns, uint32_t uOperation, uint64_t u64Arg)
285{
286 int rc;
287
288 LogFlowFuncEnter();
289 /* I have included break after each case. Need to work on this. */
290 switch ((DRVHOSTPARALLELR0OP)uOperation)
291 {
292 case DRVHOSTPARALLELR0OP_READ:
293 rc = drvR0HostParallelReqRead(pDrvIns, u64Arg);
294 break;
295 case DRVHOSTPARALLELR0OP_READSTATUS:
296 rc = drvR0HostParallelReqReadStatus(pDrvIns, u64Arg);
297 break;
298 case DRVHOSTPARALLELR0OP_READCONTROL:
299 rc = drvR0HostParallelReqReadControl(pDrvIns, u64Arg);
300 break;
301 case DRVHOSTPARALLELR0OP_WRITE:
302 rc = drvR0HostParallelReqWrite(pDrvIns, u64Arg);
303 break;
304 case DRVHOSTPARALLELR0OP_WRITECONTROL:
305 rc = drvR0HostParallelReqWriteControl(pDrvIns, u64Arg);
306 break;
307 case DRVHOSTPARALLELR0OP_SETPORTDIRECTION:
308 rc = drvR0HostParallelReqSetPortDir(pDrvIns, u64Arg);
309 break;
310 default: /* not supported */
311 rc = VERR_NOT_SUPPORTED;
312 }
313 LogFlowFuncLeave();
314 return rc;
315}
316
317# endif /* IN_RING0 */
318#endif /* VBOX_WITH_WIN_PARPORT_SUP */
319
320#ifdef IN_RING3
321# ifdef VBOX_WITH_WIN_PARPORT_SUP
322
323/**
324 * Find IO port range for the parallel port and return the lower address.
325 *
326 * @returns parallel port IO address.
327 * @param DevInst Device Instance for parallel port.
328 */
329static uint32_t drvHostWinFindIORangeResource(const DEVINST DevInst)
330{
331 uint8_t *pBuf = NULL;
332 short wHeaderSize;
333 uint32_t u32Size;
334 CONFIGRET cmRet;
335 LOG_CONF firstLogConf;
336 LOG_CONF nextLogConf;
337 RES_DES rdPrevResDes;
338 uint32_t u32ParportAddr = 0;
339
340 wHeaderSize = sizeof(IO_DES);
341 cmRet = CM_Get_First_Log_Conf(&firstLogConf, DevInst, ALLOC_LOG_CONF);
342 if (cmRet != CR_SUCCESS)
343 {
344 cmRet = CM_Get_First_Log_Conf(&firstLogConf, DevInst, BOOT_LOG_CONF);
345 if (cmRet != CR_SUCCESS)
346 return 0;
347 }
348 cmRet = CM_Get_Next_Res_Des(&nextLogConf, firstLogConf, 2, 0L, 0L);
349 if (cmRet != CR_SUCCESS)
350 {
351 CM_Free_Res_Des_Handle(firstLogConf);
352 return 0;
353 }
354 /* This loop is based on the fact that only one resourece is assigned to
355 * the LPT port. If multiple resources (address range) are assigned to
356 * to LPT port, it will pick and return the last one
357 */
358 for (;;)
359 {
360 u32Size = 0;
361 cmRet = CM_Get_Res_Des_Data_Size((PULONG)(&u32Size), nextLogConf, 0L);
362 if (cmRet != CR_SUCCESS)
363 {
364 LogFlowFunc(("Failed to get Size \n"));
365 CM_Free_Res_Des_Handle(nextLogConf);
366 break;
367 }
368
369 pBuf = (uint8_t *)RTMemAlloc(u32Size + 1);
370 if (!pBuf)
371 {
372 LogFlowFunc(("Failed to get Buf %d\n", u32Size));
373 CM_Free_Res_Des_Handle(nextLogConf);
374 break;
375 }
376 cmRet = CM_Get_Res_Des_Data(nextLogConf, pBuf, u32Size, 0L);
377 if (cmRet != CR_SUCCESS)
378 {
379 LogFlowFunc(("Failed to get Des Data \n"));
380 CM_Free_Res_Des_Handle(nextLogConf);
381 if (pBuf)
382 RTMemFree(pBuf);
383 break;
384 }
385
386 LogFlowFunc(("call GetIOResource\n"));
387 if (pBuf)
388 u32ParportAddr = ((IO_DES *)pBuf)->IOD_Alloc_Base;
389 LogFlowFunc(("called GetIOResource, ret=%#x\n", u32ParportAddr));
390 rdPrevResDes = 0;
391 cmRet = CM_Get_Next_Res_Des(&rdPrevResDes,
392 nextLogConf,
393 2,
394 0L,
395 0L);
396 if (pBuf)
397 RTMemFree(pBuf);
398 if (cmRet != CR_SUCCESS)
399 break;
400
401 CM_Free_Res_Des_Handle(nextLogConf);
402 nextLogConf = rdPrevResDes;
403 }
404 CM_Free_Res_Des_Handle(nextLogConf);
405 LogFlowFunc(("return u32ParportAddr=%#x", u32ParportAddr));
406 return u32ParportAddr;
407}
408
409/**
410 * Get Parallel port address and update the shared data
411 * structure.
412 * @returns VBox status code.
413 * @param pThis The host parallel port instance data.
414 */
415static int drvWinHostGetparportAddr(PDRVHOSTPARALLEL pThis)
416{
417 HDEVINFO hDevInfo;
418 SP_DEVINFO_DATA DeviceInfoData;
419 uint32_t u32Idx;
420 uint32_t u32ParportAddr;
421 int rc = VINF_SUCCESS;
422
423 hDevInfo = SetupDiGetClassDevs(NULL, 0, 0, DIGCF_PRESENT | DIGCF_ALLCLASSES);
424 if (hDevInfo == INVALID_HANDLE_VALUE)
425 return VERR_INVALID_HANDLE;
426
427 /* Enumerate through all devices in Set. */
428 DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
429 for (u32Idx = 0; SetupDiEnumDeviceInfo(hDevInfo, u32Idx, &DeviceInfoData); u32Idx++)
430 {
431 DWORD dwDataType;
432 uint8_t *pBuf = NULL;
433 DWORD dwBufSize = 0;
434
435 while (!SetupDiGetDeviceRegistryProperty(hDevInfo, &DeviceInfoData, SPDRP_FRIENDLYNAME,
436 (PDWORD)&dwDataType, (uint8_t *)pBuf,
437 dwBufSize, (PDWORD)&dwBufSize))
438 {
439 if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
440 {
441 LogFlow(("ERROR_INSUFF_BUFF = %d. dwBufSz = %d\n", GetLastError(), dwBufSize));
442 if (pBuf)
443 RTMemFree(pBuf);
444 pBuf = (uint8_t *)RTMemAlloc(dwBufSize * 2);
445 }
446 else
447 {
448 /* No need to bother about this error (in most cases its errno=13,
449 * INVALID_DATA . Just break from here and proceed to next device
450 * enumerated item
451 */
452 LogFlow(("GetDevProp Error = %d & dwBufSz = %d\n", GetLastError(), dwBufSize));
453 break;
454 }
455 }
456
457 if (RTStrStr((char*)pBuf, "LPT"))
458 {
459 u32ParportAddr = drvHostWinFindIORangeResource(DeviceInfoData.DevInst);
460 if (u32ParportAddr)
461 {
462 /* Find parallel port name and update the shared data struncture */
463 char *pCh = RTStrStr((char*)pBuf, "(");
464 char *pTmpCh = RTStrStr((char *)pBuf, ")");
465 /* check for the confirmation for the availability of parallel port */
466 if (!(pCh && pTmpCh))
467 {
468 LogFlowFunc(("Parallel port Not Found. \n"));
469 return VERR_NOT_FOUND;
470
471 }
472 if (((pTmpCh - (char *)pBuf) - (pCh - (char *)pBuf)) < 0) {
473 LogFlowFunc(("Parallel port string not properly formatted.\n"));
474 return VERR_NOT_FOUND;
475 }
476 /* check for the confirmation for the availability of parallel port */
477 if (RTStrCopyEx((char *)(pThis->szParportName), sizeof(pThis->szParportName),
478 pCh+1, ((pTmpCh - (char *)pBuf) - (pCh - (char *)pBuf)) - 1))
479 {
480 LogFlowFunc(("Parallel Port Not Found.\n"));
481 return VERR_NOT_FOUND;
482 }
483 *((char *)pThis->szParportName + (pTmpCh - (char *)pBuf) - (pCh - (char *)pBuf) + 1 ) = '\0';
484
485 /* checking again to make sure that we have got a valid name and in valid format too. */
486 if (RTStrNCmp((char *)pThis->szParportName, "LPT", 3)) {
487 LogFlowFunc(("Parallel Port name \"LPT\" Not Found.\n"));
488 return VERR_NOT_FOUND;
489 }
490 if (!RTStrStr((char *)pThis->szParportName, "LPT")
491 || !(pThis->szParportName[3] >= '0'
492 && pThis->szParportName[3] <= '9'))
493 {
494 RT_BZERO(pThis->szParportName, sizeof(pThis->szParportName));
495 LogFlowFunc(("Printer Port Name Not Found.\n"));
496 return VERR_NOT_FOUND;
497 }
498 pThis->fParportAvail = true;
499 pThis->u32LptAddr = u32ParportAddr;
500 pThis->u32LptAddrControl = pThis->u32LptAddr + CTRL_REG_OFFSET;
501 pThis->u32LptAddrStatus = pThis->u32LptAddr + STATUS_REG_OFFSET;
502 }
503 else
504 LogFlowFunc(("u32Parport Addr No Available \n"));
505 if (pThis->fParportAvail)
506 break;
507 }
508 if (pBuf)
509 RTMemFree(pBuf);
510 if (pThis->fParportAvail)
511 {
512 /* Parallel port address has been found. No need to iterate further. */
513 break;
514 }
515 }
516
517 if (GetLastError() != NO_ERROR && GetLastError() != ERROR_NO_MORE_ITEMS)
518 rc = VERR_GENERAL_FAILURE;
519
520 SetupDiDestroyDeviceInfoList(hDevInfo);
521 return rc;
522
523}
524# endif /* VBOX_WITH_WIN_PARPORT_SUP */
525
526/**
527 * Changes the current mode of the host parallel port.
528 *
529 * @returns VBox status code.
530 * @param pThis The host parallel port instance data.
531 * @param enmMode The mode to change the port to.
532 */
533static int drvHostParallelSetMode(PDRVHOSTPARALLEL pThis, PDMPARALLELPORTMODE enmMode)
534{
535 int iMode = 0;
536 int rc = VINF_SUCCESS;
537 LogFlowFunc(("mode=%d\n", enmMode));
538
539# ifndef VBOX_WITH_WIN_PARPORT_SUP
540 int rcLnx;
541 if (pThis->enmModeCur != enmMode)
542 {
543 switch (enmMode)
544 {
545 case PDM_PARALLEL_PORT_MODE_SPP:
546 iMode = IEEE1284_MODE_COMPAT;
547 break;
548 case PDM_PARALLEL_PORT_MODE_EPP_DATA:
549 iMode = IEEE1284_MODE_EPP | IEEE1284_DATA;
550 break;
551 case PDM_PARALLEL_PORT_MODE_EPP_ADDR:
552 iMode = IEEE1284_MODE_EPP | IEEE1284_ADDR;
553 break;
554 case PDM_PARALLEL_PORT_MODE_ECP:
555 case PDM_PARALLEL_PORT_MODE_INVALID:
556 default:
557 return VERR_NOT_SUPPORTED;
558 }
559
560 rcLnx = ioctl(RTFileToNative(pThis->hFileDevice), PPSETMODE, &iMode);
561 if (RT_UNLIKELY(rcLnx < 0))
562 rc = RTErrConvertFromErrno(errno);
563 else
564 pThis->enmModeCur = enmMode;
565 }
566
567 return rc;
568# else /* VBOX_WITH_WIN_PARPORT_SUP */
569 return VINF_SUCCESS;
570# endif /* VBOX_WITH_WIN_PARPORT_SUP */
571}
572
573/* -=-=-=-=- IBase -=-=-=-=- */
574
575/**
576 * @interface_method_impl{PDMIBASE,pfnQueryInterface}
577 */
578static DECLCALLBACK(void *) drvHostParallelQueryInterface(PPDMIBASE pInterface, const char *pszIID)
579{
580 PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface);
581 PDRVHOSTPARALLEL pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTPARALLEL);
582
583 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDrvIns->IBase);
584 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIHOSTPARALLELCONNECTOR, &pThis->CTX_SUFF(IHostParallelConnector));
585 return NULL;
586}
587
588
589/* -=-=-=-=- IHostDeviceConnector -=-=-=-=- */
590
591/** @copydoc PDMICHARCONNECTOR::pfnWrite */
592static DECLCALLBACK(int) drvHostParallelWrite(PPDMIHOSTPARALLELCONNECTOR pInterface, const void *pvBuf, size_t cbWrite, PDMPARALLELPORTMODE enmMode)
593{
594 PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface);
595 //PDRVHOSTPARALLEL pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTPARALLEL);
596 PDRVHOSTPARALLEL pThis = RT_FROM_MEMBER(pInterface, DRVHOSTPARALLEL, CTX_SUFF(IHostParallelConnector));
597 int rc = VINF_SUCCESS;
598 int rcLnx = 0;
599
600 LogFlowFunc(("pvBuf=%#p cbWrite=%d\n", pvBuf, cbWrite));
601
602 rc = drvHostParallelSetMode(pThis, enmMode);
603 if (RT_FAILURE(rc))
604 return rc;
605# ifndef VBOX_WITH_WIN_PARPORT_SUP
606 if (enmMode == PDM_PARALLEL_PORT_MODE_SPP)
607 {
608 /* Set the data lines directly. */
609 rcLnx = ioctl(RTFileToNative(pThis->hFileDevice), PPWDATA, pvBuf);
610 }
611 else
612 {
613 /* Use write interface. */
614 rcLnx = write(RTFileToNative(pThis->hFileDevice), pvBuf, cbWrite);
615 }
616 if (RT_UNLIKELY(rcLnx < 0))
617 rc = RTErrConvertFromErrno(errno);
618# else /* VBOX_WITH_WIN_PARPORT_SUP */
619 if (pThis->fParportAvail)
620 {
621 for (size_t i = 0; i < cbWrite; i++)
622 {
623 uint64_t u64Data = (uint8_t) *((uint8_t *)(pvBuf) + i);
624 LogFlowFunc(("calling R0 to write to parallel port, data=%#x\n", u64Data));
625 rc = PDMDrvHlpCallR0(pThis->CTX_SUFF(pDrvIns), DRVHOSTPARALLELR0OP_WRITE, u64Data);
626 AssertRC(rc);
627 }
628 }
629# endif /* VBOX_WITH_WIN_PARPORT_SUP */
630 return rc;
631}
632
633/**
634 * @interface_method_impl{PDMIBASE,pfnRead}
635 */
636static DECLCALLBACK(int) drvHostParallelRead(PPDMIHOSTPARALLELCONNECTOR pInterface, void *pvBuf, size_t cbRead, PDMPARALLELPORTMODE enmMode)
637{
638 PDRVHOSTPARALLEL pThis = RT_FROM_MEMBER(pInterface, DRVHOSTPARALLEL, CTX_SUFF(IHostParallelConnector));
639 int rc = VINF_SUCCESS;
640
641# ifndef VBOX_WITH_WIN_PARPORT_SUP
642 int rcLnx = 0;
643 LogFlowFunc(("pvBuf=%#p cbRead=%d\n", pvBuf, cbRead));
644
645 rc = drvHostParallelSetMode(pThis, enmMode);
646 if (RT_FAILURE(rc))
647 return rc;
648
649 if (enmMode == PDM_PARALLEL_PORT_MODE_SPP)
650 {
651 /* Set the data lines directly. */
652 rcLnx = ioctl(RTFileToNative(pThis->hFileDevice), PPWDATA, pvBuf);
653 }
654 else
655 {
656 /* Use write interface. */
657 rcLnx = read(RTFileToNative(pThis->hFileDevice), pvBuf, cbRead);
658 }
659 if (RT_UNLIKELY(rcLnx < 0))
660 rc = RTErrConvertFromErrno(errno);
661# else /* VBOX_WITH_WIN_PARPORT_SUP */
662 if (pThis->fParportAvail)
663 {
664 *((uint8_t*)(pvBuf)) = 0; /* Initialize the buffer. */
665 for (size_t i = 0; i < cbRead; i++)
666 {
667 LogFlowFunc(("calling R0 to read from parallel port\n"));
668 int rc = PDMDrvHlpCallR0(pThis->CTX_SUFF(pDrvIns), DRVHOSTPARALLELR0OP_READ, 0);
669 AssertRC(rc);
670 *((uint8_t *)pvBuf + i) = (uint8_t)pThis->u8ReadIn;
671 }
672 }
673# endif /* VBOX_WITH_WIN_PARPORT_SUP */
674 return rc;
675}
676
677static DECLCALLBACK(int) drvHostParallelSetPortDirection(PPDMIHOSTPARALLELCONNECTOR pInterface, bool fForward)
678{
679 PDRVHOSTPARALLEL pThis = RT_FROM_MEMBER(pInterface, DRVHOSTPARALLEL, CTX_SUFF(IHostParallelConnector));
680 int rc = VINF_SUCCESS;
681 int iMode = 0;
682 if (!fForward)
683 iMode = 1;
684# ifndef VBOX_WITH_WIN_PARPORT_SUP
685 int rcLnx = ioctl(RTFileToNative(pThis->hFileDevice), PPDATADIR, &iMode);
686 if (RT_UNLIKELY(rcLnx < 0))
687 rc = RTErrConvertFromErrno(errno);
688
689# else /* VBOX_WITH_WIN_PARPORT_SUP */
690 uint64_t u64Data;
691 u64Data = (uint8_t)iMode;
692 if (pThis->fParportAvail)
693 {
694 LogFlowFunc(("calling R0 to write CTRL, data=%#x\n", u64Data));
695 rc = PDMDrvHlpCallR0(pThis->CTX_SUFF(pDrvIns), DRVHOSTPARALLELR0OP_SETPORTDIRECTION, u64Data);
696 AssertRC(rc);
697 }
698# endif /* VBOX_WITH_WIN_PARPORT_SUP */
699 return rc;
700}
701
702/**
703 * @interface_method_impl{PDMIBASE,pfnWriteControl}
704 */
705static DECLCALLBACK(int) drvHostParallelWriteControl(PPDMIHOSTPARALLELCONNECTOR pInterface, uint8_t fReg)
706{
707 PDRVHOSTPARALLEL pThis = RT_FROM_MEMBER(pInterface, DRVHOSTPARALLEL, CTX_SUFF(IHostParallelConnector));
708 int rc = VINF_SUCCESS;
709 int rcLnx = 0;
710
711 LogFlowFunc(("fReg=%#x\n", fReg));
712# ifndef VBOX_WITH_WIN_PARPORT_SUP
713 rcLnx = ioctl(RTFileToNative(pThis->hFileDevice), PPWCONTROL, &fReg);
714 if (RT_UNLIKELY(rcLnx < 0))
715 rc = RTErrConvertFromErrno(errno);
716# else /* VBOX_WITH_WIN_PARPORT_SUP */
717 uint64_t u64Data;
718 u64Data = (uint8_t)fReg;
719 if (pThis->fParportAvail)
720 {
721 LogFlowFunc(("calling R0 to write CTRL, data=%#x\n", u64Data));
722 rc = PDMDrvHlpCallR0(pThis->CTX_SUFF(pDrvIns), DRVHOSTPARALLELR0OP_WRITECONTROL, u64Data);
723 AssertRC(rc);
724 }
725# endif /* VBOX_WITH_WIN_PARPORT_SUP */
726 return rc;
727}
728
729
730/**
731 * @interface_method_impl{PDMIBASE,pfnReadControl}
732 */
733static DECLCALLBACK(int) drvHostParallelReadControl(PPDMIHOSTPARALLELCONNECTOR pInterface, uint8_t *pfReg)
734{
735 PDRVHOSTPARALLEL pThis = RT_FROM_MEMBER(pInterface, DRVHOSTPARALLEL, CTX_SUFF(IHostParallelConnector));
736 int rc = VINF_SUCCESS;
737 int rcLnx = 0;
738 uint8_t fReg = 0;
739
740# ifndef VBOX_WITH_WIN_PARPORT_SUP
741 rcLnx = ioctl(RTFileToNative(pThis->hFileDevice), PPRCONTROL, &fReg);
742 if (RT_UNLIKELY(rcLnx < 0))
743 rc = RTErrConvertFromErrno(errno);
744 else
745 {
746 LogFlowFunc(("fReg=%#x\n", fReg));
747 *pfReg = fReg;
748 }
749# else /* VBOX_WITH_WIN_PARPORT_SUP */
750 *pfReg = 0; /* Initialize the buffer*/
751 if (pThis->fParportAvail)
752 {
753 LogFlowFunc(("calling R0 to read control from parallel port\n"));
754 rc = PDMDrvHlpCallR0(pThis-> CTX_SUFF(pDrvIns), DRVHOSTPARALLELR0OP_READCONTROL, 0);
755 AssertRC(rc);
756 *pfReg = pThis->u8ReadInControl;
757 }
758# endif /* VBOX_WITH_WIN_PARPORT_SUP */
759 return rc;
760}
761
762/**
763 * @interface_method_impl{PDMIBASE,pfnReadStatus}
764 */
765static DECLCALLBACK(int) drvHostParallelReadStatus(PPDMIHOSTPARALLELCONNECTOR pInterface, uint8_t *pfReg)
766{
767 PDRVHOSTPARALLEL pThis = RT_FROM_MEMBER(pInterface, DRVHOSTPARALLEL, CTX_SUFF(IHostParallelConnector));
768 int rc = VINF_SUCCESS;
769 int rcLnx = 0;
770 uint8_t fReg = 0;
771# ifndef VBOX_WITH_WIN_PARPORT_SUP
772 rcLnx = ioctl(RTFileToNative(pThis->hFileDevice), PPRSTATUS, &fReg);
773 if (RT_UNLIKELY(rcLnx < 0))
774 rc = RTErrConvertFromErrno(errno);
775 else
776 {
777 LogFlowFunc(("fReg=%#x\n", fReg));
778 *pfReg = fReg;
779 }
780# else /* VBOX_WITH_WIN_PARPORT_SUP */
781 *pfReg = 0; /* Intialize the buffer. */
782 if (pThis->fParportAvail)
783 {
784 LogFlowFunc(("calling R0 to read status from parallel port\n"));
785 rc = PDMDrvHlpCallR0(pThis->CTX_SUFF(pDrvIns), DRVHOSTPARALLELR0OP_READSTATUS, 0);
786 AssertRC(rc);
787 *pfReg = pThis->u8ReadInStatus;
788 }
789# endif /* VBOX_WITH_WIN_PARPORT_SUP */
790 return rc;
791}
792
793# ifndef VBOX_WITH_WIN_PARPORT_SUP
794
795static DECLCALLBACK(int) drvHostParallelMonitorThread(PPDMDRVINS pDrvIns, PPDMTHREAD pThread)
796{
797 PDRVHOSTPARALLEL pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTPARALLEL);
798 struct pollfd aFDs[2];
799
800 /*
801 * We can wait for interrupts using poll on linux hosts.
802 */
803 while (pThread->enmState == PDMTHREADSTATE_RUNNING)
804 {
805 int rc;
806
807 aFDs[0].fd = RTFileToNative(pThis->hFileDevice);
808 aFDs[0].events = POLLIN;
809 aFDs[0].revents = 0;
810 aFDs[1].fd = RTPipeToNative(pThis->hWakeupPipeR);
811 aFDs[1].events = POLLIN | POLLERR | POLLHUP;
812 aFDs[1].revents = 0;
813 rc = poll(aFDs, RT_ELEMENTS(aFDs), -1);
814 if (rc < 0)
815 {
816 AssertMsgFailed(("poll failed with rc=%d\n", RTErrConvertFromErrno(errno)));
817 return RTErrConvertFromErrno(errno);
818 }
819
820 if (pThread->enmState != PDMTHREADSTATE_RUNNING)
821 break;
822 if (rc > 0 && aFDs[1].revents)
823 {
824 if (aFDs[1].revents & (POLLHUP | POLLERR | POLLNVAL))
825 break;
826 /* notification to terminate -- drain the pipe */
827 char ch;
828 size_t cbRead;
829 RTPipeRead(pThis->hWakeupPipeR, &ch, 1, &cbRead);
830 continue;
831 }
832
833 /* Interrupt occurred. */
834 rc = pThis->pDrvHostParallelPort->pfnNotifyInterrupt(pThis->pDrvHostParallelPort);
835 AssertRC(rc);
836 }
837
838 return VINF_SUCCESS;
839}
840
841/**
842 * Unblock the monitor thread so it can respond to a state change.
843 *
844 * @returns a VBox status code.
845 * @param pDrvIns The driver instance.
846 * @param pThread The send thread.
847 */
848static DECLCALLBACK(int) drvHostParallelWakeupMonitorThread(PPDMDRVINS pDrvIns, PPDMTHREAD pThread)
849{
850 PDRVHOSTPARALLEL pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTPARALLEL);
851 size_t cbIgnored;
852 return RTPipeWrite(pThis->hWakeupPipeW, "", 1, &cbIgnored);
853}
854
855# endif /* VBOX_WITH_WIN_PARPORT_SUP */
856
857/**
858 * Destruct a host parallel driver instance.
859 *
860 * Most VM resources are freed by the VM. This callback is provided so that
861 * any non-VM resources can be freed correctly.
862 *
863 * @param pDrvIns The driver instance data.
864 */
865static DECLCALLBACK(void) drvHostParallelDestruct(PPDMDRVINS pDrvIns)
866{
867 int rc;
868 PDRVHOSTPARALLEL pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTPARALLEL);
869 LogFlowFunc(("iInstance=%d\n", pDrvIns->iInstance));
870 PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns);
871
872#ifndef VBOX_WITH_WIN_PARPORT_SUP
873 if (pThis->hFileDevice != NIL_RTFILE)
874 ioctl(RTFileToNative(pThis->hFileDevice), PPRELEASE);
875
876 if (pThis->hWakeupPipeW != NIL_RTPIPE)
877 {
878 rc = RTPipeClose(pThis->hWakeupPipeW); AssertRC(rc);
879 pThis->hWakeupPipeW = NIL_RTPIPE;
880 }
881
882 if (pThis->hWakeupPipeR != NIL_RTPIPE)
883 {
884 rc = RTPipeClose(pThis->hWakeupPipeR); AssertRC(rc);
885 pThis->hWakeupPipeR = NIL_RTPIPE;
886 }
887
888 if (pThis->hFileDevice != NIL_RTFILE)
889 {
890 rc = RTFileClose(pThis->hFileDevice); AssertRC(rc);
891 pThis->hFileDevice = NIL_RTFILE;
892 }
893
894 if (pThis->pszDevicePath)
895 {
896 MMR3HeapFree(pThis->pszDevicePath);
897 pThis->pszDevicePath = NULL;
898 }
899#else /* VBOX_WITH_WIN_PARPORT_SUP */
900 if (pThis->hWinFileDevice != NIL_RTFILE)
901 {
902 rc = RTFileClose(pThis->hWinFileDevice); AssertRC(rc);
903 pThis->hWinFileDevice = NIL_RTFILE;
904 }
905#endif /* VBOX_WITH_WIN_PARPORT_SUP */
906}
907
908/**
909 * Construct a host parallel driver instance.
910 *
911 * @copydoc FNPDMDRVCONSTRUCT
912 */
913static DECLCALLBACK(int) drvHostParallelConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags)
914{
915 PDRVHOSTPARALLEL pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTPARALLEL);
916 LogFlowFunc(("iInstance=%d\n", pDrvIns->iInstance));
917
918 PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns);
919
920 /*
921 * Init basic data members and interfaces.
922 *
923 * Must be done before returning any failure because we've got a destructor.
924 */
925 pThis->hFileDevice = NIL_RTFILE;
926#ifndef VBOX_WITH_WIN_PARPORT_SUP
927 pThis->hWakeupPipeR = NIL_RTPIPE;
928 pThis->hWakeupPipeW = NIL_RTPIPE;
929#else
930 pThis->hWinFileDevice = NIL_RTFILE;
931#endif
932
933 pThis->pDrvInsR3 = pDrvIns;
934#ifdef VBOX_WITH_DRVINTNET_IN_R0
935 pThis->pDrvInsR0 = PDMDRVINS_2_R0PTR(pDrvIns);
936#endif
937
938 /* IBase. */
939 pDrvIns->IBase.pfnQueryInterface = drvHostParallelQueryInterface;
940 /* IHostParallelConnector. */
941 pThis->IHostParallelConnectorR3.pfnWrite = drvHostParallelWrite;
942 pThis->IHostParallelConnectorR3.pfnRead = drvHostParallelRead;
943 pThis->IHostParallelConnectorR3.pfnSetPortDirection = drvHostParallelSetPortDirection;
944 pThis->IHostParallelConnectorR3.pfnWriteControl = drvHostParallelWriteControl;
945 pThis->IHostParallelConnectorR3.pfnReadControl = drvHostParallelReadControl;
946 pThis->IHostParallelConnectorR3.pfnReadStatus = drvHostParallelReadStatus;
947
948 /*
949 * Validate the config.
950 */
951 if (!CFGMR3AreValuesValid(pCfg, "DevicePath\0"))
952 return PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES,
953 N_("Unknown host parallel configuration option, only supports DevicePath"));
954
955 /*
956 * Query configuration.
957 */
958 /* Device */
959 int rc = CFGMR3QueryStringAlloc(pCfg, "DevicePath", &pThis->pszDevicePath);
960 if (RT_FAILURE(rc))
961 {
962 AssertMsgFailed(("Configuration error: query for \"DevicePath\" string returned %Rra.\n", rc));
963 return rc;
964 }
965
966 /*
967 * Open the device
968 */
969 rc = RTFileOpen(&pThis->hFileDevice, pThis->pszDevicePath, RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
970 if (RT_FAILURE(rc))
971 return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, N_("Parallel#%d could not open '%s'"),
972 pDrvIns->iInstance, pThis->pszDevicePath);
973
974#ifndef VBOX_WITH_WIN_PARPORT_SUP
975 /*
976 * Try to get exclusive access to parallel port
977 */
978 rc = ioctl(RTFileToNative(pThis->hFileDevice), PPEXCL);
979 if (rc < 0)
980 return PDMDrvHlpVMSetError(pDrvIns, RTErrConvertFromErrno(errno), RT_SRC_POS,
981 N_("Parallel#%d could not get exclusive access for parallel port '%s'"
982 "Be sure that no other process or driver accesses this port"),
983 pDrvIns->iInstance, pThis->pszDevicePath);
984
985 /*
986 * Claim the parallel port
987 */
988 rc = ioctl(RTFileToNative(pThis->hFileDevice), PPCLAIM);
989 if (rc < 0)
990 return PDMDrvHlpVMSetError(pDrvIns, RTErrConvertFromErrno(errno), RT_SRC_POS,
991 N_("Parallel#%d could not claim parallel port '%s'"
992 "Be sure that no other process or driver accesses this port"),
993 pDrvIns->iInstance, pThis->pszDevicePath);
994
995 /*
996 * Get the IHostParallelPort interface of the above driver/device.
997 */
998 pThis->pDrvHostParallelPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMIHOSTPARALLELPORT);
999 if (!pThis->pDrvHostParallelPort)
1000 return PDMDrvHlpVMSetError(pDrvIns, VERR_PDM_MISSING_INTERFACE_ABOVE, RT_SRC_POS, N_("Parallel#%d has no parallel port interface above"),
1001 pDrvIns->iInstance);
1002
1003 /*
1004 * Create wakeup pipe.
1005 */
1006 rc = RTPipeCreate(&pThis->hWakeupPipeR, &pThis->hWakeupPipeW, 0 /*fFlags*/);
1007 AssertRCReturn(rc, rc);
1008
1009 /*
1010 * Start in SPP mode.
1011 */
1012 pThis->enmModeCur = PDM_PARALLEL_PORT_MODE_INVALID;
1013 rc = drvHostParallelSetMode(pThis, PDM_PARALLEL_PORT_MODE_SPP);
1014 if (RT_FAILURE(rc))
1015 return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, N_("HostParallel#%d cannot change mode of parallel mode to SPP"), pDrvIns->iInstance);
1016
1017 /*
1018 * Start waiting for interrupts.
1019 */
1020 rc = PDMDrvHlpThreadCreate(pDrvIns, &pThis->pMonitorThread, pThis, drvHostParallelMonitorThread, drvHostParallelWakeupMonitorThread, 0,
1021 RTTHREADTYPE_IO, "ParMon");
1022 if (RT_FAILURE(rc))
1023 return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, N_("HostParallel#%d cannot create monitor thread"), pDrvIns->iInstance);
1024
1025#else /* VBOX_WITH_WIN_PARPORT_SUP */
1026 pThis->fParportAvail = false;
1027 pThis->u32LptAddr = 0;
1028 pThis->u32LptAddrControl = 0;
1029 pThis->u32LptAddrStatus = 0;
1030 rc = drvWinHostGetparportAddr(pThis);
1031
1032 /* If we have the char port availabe use it , else I am not getting exclusive access to parallel port.
1033 Read and write will be done only if addresses are available
1034 */
1035 if (pThis->szParportName)
1036 {
1037 rc = RTFileOpen(&pThis->hWinFileDevice, (char *)pThis->szParportName,
1038 RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
1039 }
1040#endif
1041 return VINF_SUCCESS;
1042}
1043
1044
1045/**
1046 * Char driver registration record.
1047 */
1048const PDMDRVREG g_DrvHostParallel =
1049{
1050 /* u32Version */
1051 PDM_DRVREG_VERSION,
1052 /* szName */
1053 "HostParallel",
1054 /* szRCMod */
1055 "",
1056 /* szR0Mod */
1057 "VBoxDDR0.r0",
1058 /* pszDescription */
1059 "Parallel host driver.",
1060 /* fFlags */
1061# if defined(VBOX_WITH_WIN_PARPORT_SUP)
1062 PDM_DRVREG_FLAGS_HOST_BITS_DEFAULT | PDM_DRVREG_FLAGS_R0,
1063# else
1064 PDM_DRVREG_FLAGS_HOST_BITS_DEFAULT,
1065# endif
1066 /* fClass. */
1067 PDM_DRVREG_CLASS_CHAR,
1068 /* cMaxInstances */
1069 ~0U,
1070 /* cbInstance */
1071 sizeof(DRVHOSTPARALLEL),
1072 /* pfnConstruct */
1073 drvHostParallelConstruct,
1074 /* pfnDestruct */
1075 drvHostParallelDestruct,
1076 /* pfnRelocate */
1077 NULL,
1078 /* pfnIOCtl */
1079 NULL,
1080 /* pfnPowerOn */
1081 NULL,
1082 /* pfnReset */
1083 NULL,
1084 /* pfnSuspend */
1085 NULL,
1086 /* pfnResume */
1087 NULL,
1088 /* pfnAttach */
1089 NULL,
1090 /* pfnDetach */
1091 NULL,
1092 /* pfnPowerOff */
1093 NULL,
1094 /* pfnSoftReset */
1095 NULL,
1096 /* u32EndVersion */
1097 PDM_DRVREG_VERSION
1098};
1099#endif /*IN_RING3*/
1100
Note: See TracBrowser for help on using the repository browser.

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