HostChannel.h revision c6cfa4860d893a2cfde3c4148879456093af57bf
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync/* @file
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync *
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync * Host Channel
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync */
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync/*
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync * Copyright (C) 2012 Oracle Corporation
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync *
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync * available from http://www.virtualbox.org. This file is free software;
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync * you can redistribute it and/or modify it under the terms of the GNU
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync * General Public License (GPL) as published by the Free Software
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync */
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync#ifndef __VBOXHOSTCHANNEL__H
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync#define __VBOXHOSTCHANNEL__H
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync#include <iprt/list.h>
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync#define LOG_GROUP LOG_GROUP_HGCM
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync#include <VBox/log.h>
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync#include <VBox/HostServices/VBoxHostChannel.h>
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync#define HOSTCHLOG Log
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync#ifdef DEBUG_sunlover
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync# undef HOSTCHLOG
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync# define HOSTCHLOG LogRel
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync#endif /* DEBUG_sunlover */
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsyncstruct VBOXHOSTCHCTX;
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsynctypedef struct VBOXHOSTCHCTX VBOXHOSTCHCTX;
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsynctypedef struct VBOXHOSTCHCLIENT
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync{
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync RTLISTNODE nodeClient;
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync VBOXHOSTCHCTX *pCtx;
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync uint32_t u32ClientID;
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync RTLISTANCHOR listChannels;
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync uint32_t volatile u32HandleSrc;
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync
f486cea04d3045b35f843ddd19eb2de45a9929fevboxsync RTLISTANCHOR listContexts; /* Callback contexts. */
f486cea04d3045b35f843ddd19eb2de45a9929fevboxsync
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync RTLISTANCHOR listEvents;
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync bool fAsync; /* Guest is waiting for a message. */
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync struct {
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync VBOXHGCMCALLHANDLE callHandle;
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync VBOXHGCMSVCPARM *paParms;
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync } async;
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync} VBOXHOSTCHCLIENT;
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync/*
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync * The service functions. Locking is between the service thread and the host channel provider thread.
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync */
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsyncint vboxHostChannelLock(void);
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsyncvoid vboxHostChannelUnlock(void);
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsyncint vboxHostChannelInit(void);
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsyncvoid vboxHostChannelDestroy(void);
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsyncint vboxHostChannelClientConnect(VBOXHOSTCHCLIENT *pClient);
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsyncvoid vboxHostChannelClientDisconnect(VBOXHOSTCHCLIENT *pClient);
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsyncint vboxHostChannelAttach(VBOXHOSTCHCLIENT *pClient,
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync uint32_t *pu32Handle,
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync const char *pszName,
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync uint32_t u32Flags);
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsyncint vboxHostChannelDetach(VBOXHOSTCHCLIENT *pClient,
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync uint32_t u32Handle);
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsyncint vboxHostChannelSend(VBOXHOSTCHCLIENT *pClient,
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync uint32_t u32Handle,
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync const void *pvData,
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync uint32_t cbData);
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsyncint vboxHostChannelRecv(VBOXHOSTCHCLIENT *pClient,
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync uint32_t u32Handle,
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync void *pvData,
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync uint32_t cbData,
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync uint32_t *pu32DataReceived,
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync uint32_t *pu32DataRemaining);
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsyncint vboxHostChannelControl(VBOXHOSTCHCLIENT *pClient,
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync uint32_t u32Handle,
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync uint32_t u32Code,
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync void *pvParm,
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync uint32_t cbParm,
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync void *pvData,
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync uint32_t cbData,
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync uint32_t *pu32SizeDataReturned);
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync
c6cfa4860d893a2cfde3c4148879456093af57bfvboxsyncint vboxHostChannelEventWait(VBOXHOSTCHCLIENT *pClient,
c6cfa4860d893a2cfde3c4148879456093af57bfvboxsync bool *pfEvent,
c6cfa4860d893a2cfde3c4148879456093af57bfvboxsync VBOXHGCMCALLHANDLE callHandle,
c6cfa4860d893a2cfde3c4148879456093af57bfvboxsync VBOXHGCMSVCPARM *paParms);
c6cfa4860d893a2cfde3c4148879456093af57bfvboxsync
c6cfa4860d893a2cfde3c4148879456093af57bfvboxsyncint vboxHostChannelEventCancel(VBOXHOSTCHCLIENT *pClient);
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync
f675364bced7de2a98408e697da210bc6e6ddb2avboxsyncint vboxHostChannelQuery(VBOXHOSTCHCLIENT *pClient,
f675364bced7de2a98408e697da210bc6e6ddb2avboxsync const char *pszName,
f675364bced7de2a98408e697da210bc6e6ddb2avboxsync uint32_t u32Code,
f675364bced7de2a98408e697da210bc6e6ddb2avboxsync void *pvParm,
f675364bced7de2a98408e697da210bc6e6ddb2avboxsync uint32_t cbParm,
f675364bced7de2a98408e697da210bc6e6ddb2avboxsync void *pvData,
f675364bced7de2a98408e697da210bc6e6ddb2avboxsync uint32_t cbData,
f675364bced7de2a98408e697da210bc6e6ddb2avboxsync uint32_t *pu32SizeDataReturned);
f675364bced7de2a98408e697da210bc6e6ddb2avboxsync
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsyncint vboxHostChannelRegister(const char *pszName,
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync const VBOXHOSTCHANNELINTERFACE *pInterface,
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync uint32_t cbInterface);
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsyncint vboxHostChannelUnregister(const char *pszName);
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync
c6cfa4860d893a2cfde3c4148879456093af57bfvboxsyncvoid vboxHostChannelEventParmsSet(VBOXHGCMSVCPARM *paParms,
c6cfa4860d893a2cfde3c4148879456093af57bfvboxsync uint32_t u32ChannelHandle,
c6cfa4860d893a2cfde3c4148879456093af57bfvboxsync uint32_t u32Id,
c6cfa4860d893a2cfde3c4148879456093af57bfvboxsync const void *pvEvent,
c6cfa4860d893a2cfde3c4148879456093af57bfvboxsync uint32_t cbEvent);
c6cfa4860d893a2cfde3c4148879456093af57bfvboxsync
c6cfa4860d893a2cfde3c4148879456093af57bfvboxsyncvoid vboxHostChannelReportAsync(VBOXHOSTCHCLIENT *pClient,
c6cfa4860d893a2cfde3c4148879456093af57bfvboxsync uint32_t u32ChannelHandle,
c6cfa4860d893a2cfde3c4148879456093af57bfvboxsync uint32_t u32Id,
c6cfa4860d893a2cfde3c4148879456093af57bfvboxsync const void *pvEvent,
c6cfa4860d893a2cfde3c4148879456093af57bfvboxsync uint32_t cbEvent);
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync
e2a4ff87ea2e2e95350793b5fccb143c1819fadcvboxsync#endif /* __VBOXHOSTCHANNEL__H */