VirtualBox

Changeset 75547 in vbox for trunk/include


Ignore:
Timestamp:
Nov 18, 2018 4:50:34 AM (6 years ago)
Author:
vboxsync
Message:

VBoxGuest: Added an IDC interface for faster HGCM calls (VBGL_IOCTL_IDC_HGCM_FAST_CALL, VbglR0HGCMFastCall). This expects the caller to construct a valid call and only concerns itself with issuing it to the host and waiting for the result to arrive. bugref:9172

Location:
trunk/include/VBox
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/VBoxGuest.h

    r72627 r75547  
    5252 *
    5353 * - I/O controls for user and/or kernel mode starts at 0.
    54  * - IDC specific requests descends from 127.
     54 * - IDC specific requests descends from 63.
    5555 * - Bits 7 and 6 are currently reserved for future hacks.
    5656 *
     
    285285/** @} */
    286286
    287 
    288287#ifdef VBOX_WITH_HGCM
     288
    289289/** @name VBGL_IOCTL_HGCM_CONNECT
    290290 * Connect to a HGCM service.
     
    344344/** @name VBGL_IOCTL_HGCM_CALL, VBGL_IOCTL_HGCM_CALL_WITH_USER_DATA
    345345 *
    346  * Make a call to a HGCM servicesure.  There are several variations here.
     346 * Make a call to a HGCM service.  There are several variations here.
    347347 *
    348348 * The VBGL_IOCTL_HGCM_CALL_WITH_USER_DATA variation is for other drivers (like
     
    360360# define VBGL_IOCTL_HGCM_CALL_WITH_USER_DATA(a_cb)  VBGL_IOCTL_CODE_SIZE(8, (a_cb))
    361361/** @} */
     362
     363
     364/** @name VBGL_IOCTL_IDC_HGCM_FAST_CALL
     365 *
     366 * Variant of VBGL_IOCTL_HGCM_CALL for drivers that submits the request as-is to
     367 * the host and handles the waiting, the caller does all the rest.
     368 *
     369 * @note ring-0 only.
     370 * @note Size is not encoded in the I/O control code.
     371 * @{
     372 */
     373#define VBGL_IOCTL_IDC_HGCM_FAST_CALL               VBGL_IOCTL_CODE_SIZE(62, sizeof(VBGLIOCIDCHGCMFASTCALL))
     374#define VBGL_IOCTL_IDC_HGCM_FAST_CALL_SIZE(a_cb)    (a_cb)
     375#define VBGL_IOCTL_IDC_HGCM_FAST_CALL_SIZE_IN(a_cb) (a_cb)
     376#define VBGL_IOCTL_IDC_HGCM_FAST_CALL_SIZE_OUT(a_cb) (a_cb)
     377#pragma pack(4) /* Want it to fit nicely with the 44 byte VMMDevHGCMCall and optimally align 64-bit parameters structures.  */
     378typedef struct VBGLIOCIDCHGCMFASTCALL
     379{
     380    /** The header. */
     381    VBGLREQHDR      Hdr;
     382    /** The physical address of the following VMMDevHGCMCall structure. */
     383    RTGCPHYS32      GCPhysReq;
     384    /** Set if interruptible. */
     385    bool            fInterruptible;
     386    /** Reserved. */
     387    uint8_t         abReserved0[3];
     388    uint64_t        uTimestamp[2];
     389    uint8_t         abReserved1[4];
     390    /* After this structure follows a VMMDevHGCMCall strcuture (44 bytes), then
     391       zero or more HGCMFunctionParameter structures (12 or 16 bytes), and finally
     392       page lists and embedded buffers. */
     393} VBGLIOCIDCHGCMFASTCALL, RT_FAR *PVBGLIOCIDCHGCMFASTCALL;
     394#pragma pack()
     395AssertCompileSize(VBGLIOCIDCHGCMFASTCALL, /* 24 + 4 + 1 + 3 + 2*8 + 4 = 0x34 (52) = */ 0x34);
     396
     397/**
     398 * Macro for initializing VBGLIOCIDCHGCMFASTCALL and the following
     399 * VMMDevHGCMCall structures.
     400 *
     401 * @param   a_pHdr      The request header to initialize.
     402 * @param   a_HdrPhys   The 32-bit physical address corresponding to @a a_pHdr.
     403 * @param   a_pCall     Pointer to the VMMDevHGCMCall structure.
     404 * @param   a_idClient  The HGCM client ID.
     405 * @param   a_uFunction The HGCM function number.
     406 * @param   a_cParms    The number of parameters following @a a_pCall.
     407 * @param   a_cbReq     The size of the whole request.
     408 */
     409#define VBGLIOCIDCHGCMFASTCALL_INIT(a_pHdr, a_HdrPhys, a_pCall, a_idClient, a_uFunction, a_cParms, a_cbReq) \
     410    do { \
     411        Assert((uintptr_t)(a_pHdr) + sizeof(VBGLIOCIDCHGCMFASTCALL) == (uintptr_t)(a_pCall)); \
     412        VBGLREQHDR_INIT_EX(&(a_pHdr)->Hdr, a_cbReq, a_cbReq); \
     413        pReq->Hdr.GCPhysReq      = (a_HdrPhys) + sizeof(VBGLIOCIDCHGCMFASTCALL); \
     414        pReq->Hdr.fInterruptible = false; \
     415        \
     416        (a_pCall)->header.header.size       = (a_cbReq) - sizeof(VBGLIOCIDCHGCMFASTCALL); \
     417        (a_pCall)->header.header.version    = VBGLREQHDR_VERSION; \
     418        (a_pCall)->header.header.requestType= (ARCH_BITS == 32 ? VMMDevReq_HGCMCall32 : VMMDevReq_HGCMCall64); \
     419        (a_pCall)->header.header.rc         = VERR_INTERNAL_ERROR; \
     420        (a_pCall)->header.header.reserved1  = 0; \
     421        (a_pCall)->header.header.fRequestor = VMMDEV_REQUESTOR_KERNEL        | VMMDEV_REQUESTOR_USR_DRV_OTHER \
     422                                            | VMMDEV_REQUESTOR_CON_DONT_KNOW | VMMDEV_REQUESTOR_TRUST_NOT_GIVEN; \
     423        (a_pCall)->header.fu32Flags         = 0; \
     424        (a_pCall)->header.result            = VERR_INTERNAL_ERROR; \
     425        (a_pCall)->u32ClientID              = (a_idClient); \
     426        (a_pCall)->u32Function              = (a_uFunction); \
     427        (a_pCall)->cParms                   = (a_cParms); \
     428    } while (0)
     429
     430
     431/** @} */
     432
    362433#endif /* VBOX_WITH_HGCM */
    363434
     
    798869 *
    799870 * @note ring-0 only.
     871 * @{
    800872 */
    801873#define VBGL_IOCTL_IDC_CONNECT                      VBGL_IOCTL_CODE_SIZE(63, VBGL_IOCTL_IDC_CONNECT_SIZE)
     
    859931 *
    860932 * @note ring-0 only.
     933 * @{
    861934 */
    862935#define VBGL_IOCTL_IDC_DISCONNECT                   VBGL_IOCTL_CODE_SIZE(62, VBGL_IOCTL_IDC_DISCONNECT_SIZE)
  • trunk/include/VBox/VBoxGuestLib.h

    r75407 r75547  
    212212# ifdef VBOX_WITH_HGCM
    213213struct VBGLIOCHGCMCALL;
     214struct VBGLIOCIDCHGCMFASTCALL;
    214215
    215216#  ifdef VBGL_VBOXGUEST
     
    325326#  else  /* !VBGL_VBOXGUEST */
    326327
     328#ifndef VBGL_VBOXGUEST
     329/** @internal  */
     330typedef struct VBGLHGCMHANDLEDATA
     331{
     332    uint32_t fAllocated;
     333    VBGLIDCHANDLE IdcHandle;
     334} VBGLHGCMHANDLEDATA;
     335#else
    327336struct VBGLHGCMHANDLEDATA;
     337#endif
     338
    328339typedef struct VBGLHGCMHANDLEDATA *VBGLHGCMHANDLE;
    329340
     
    382393 * @return VBox status code.
    383394 */
    384 DECLR0VBGL(int) VbglR0HGCMCallRaw(VBGLHGCMHANDLE handle, struct VBGLIOCHGCMCALL*pData, uint32_t cbData);
     395DECLR0VBGL(int) VbglR0HGCMCallRaw(VBGLHGCMHANDLE handle, struct VBGLIOCHGCMCALL *pData, uint32_t cbData);
    385396
    386397/**
     
    394405 *         or the HGCM status code (pData->Hdr.rc).
    395406 */
    396 DECLR0VBGL(int) VbglR0HGCMCall(VBGLHGCMHANDLE handle, struct VBGLIOCHGCMCALL*pData, uint32_t cbData);
     407DECLR0VBGL(int) VbglR0HGCMCall(VBGLHGCMHANDLE handle, struct VBGLIOCHGCMCALL *pData, uint32_t cbData);
    397408
    398409/**
     
    406417 * @return VBox status code.
    407418 */
    408 DECLR0VBGL(int) VbglR0HGCMCallUserDataRaw(VBGLHGCMHANDLE handle, struct VBGLIOCHGCMCALL*pData, uint32_t cbData);
     419DECLR0VBGL(int) VbglR0HGCMCallUserDataRaw(VBGLHGCMHANDLE handle, struct VBGLIOCHGCMCALL *pData, uint32_t cbData);
     420
     421/**
     422 * Call to a service, w/o any repacking and buffer locking in VBoxGuest,
     423 * returning the only request related status code (not HGCM).
     424 *
     425 * The driver only submits the request and waits for completion, nothing else.
     426 *
     427 * @param   hHandle     The connection handle.
     428 * @param   pCallReq    The call request.  Will be passed directly to the host.
     429 * @param   cbCallReq   The size of the whole call request.
     430 *
     431 * @return VBox status code.
     432 *
     433 * @remarks The result of the HGCM call is found in
     434 *          @a pCallReq->HgcmCallReq.header.result on a successful return.  The
     435 *          @a pCallReq->Hdr.rc and @a pCallReq->HgcmCallReq.header.header.rc
     436 *          fields are the same as the return value and can safely be ignored.
     437 */
     438DECLR0VBGL(int) VbglR0HGCMFastCall(VBGLHGCMHANDLE hHandle, struct VBGLIOCIDCHGCMFASTCALL *pCallReq, uint32_t cbCallReq);
    409439
    410440/** @} */
Note: See TracChangeset for help on using the changeset viewer.

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