VirtualBox

Changeset 68633 in vbox for trunk/include/VBox/VBoxGuest.h


Ignore:
Timestamp:
Sep 5, 2017 11:56:00 AM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
117863
Message:

Reduce number of VBoxGuest.h includes.

File:
1 edited

Legend:

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

    r68630 r68633  
    170170
    171171/**
    172  * Common In/Out header.
    173  *
    174  * This is a copy/mirror of VMMDevRequestHeader to prevent duplicating data and
    175  * needing to verify things multiple times.  For that reason this differs a bit
    176  * from SUPREQHDR.
    177  *
    178  * @sa VMMDevRequestHeader
    179  */
    180 typedef struct VBGLREQHDR
    181 {
    182     /** IN: The request input size, and output size if cbOut is zero.
    183      * @sa VMMDevRequestHeader::size  */
    184     uint32_t        cbIn;
    185     /** IN: Structure version (VBGLREQHDR_VERSION)
    186      * @sa VMMDevRequestHeader::version */
    187     uint32_t        uVersion;
    188     /** IN: The VMMDev request type, set to VBGLREQHDR_TYPE_DEFAULT unless this is a
    189      * kind of VMMDev request.
    190      * @sa VMMDevRequestType, VMMDevRequestHeader::requestType */
    191     uint32_t        uType;
    192     /** OUT: The VBox status code of the operation, out direction only. */
    193     int32_t         rc;
    194     /** IN: The output size.  This is optional - set to zero to use cbIn as the
    195      * output size. */
    196     uint32_t        cbOut;
    197     /** Reserved, MBZ. */
    198     uint32_t        uReserved;
    199 } VBGLREQHDR;
    200 AssertCompileSize(VBGLREQHDR, 24);
    201 /** Pointer to a IOC header. */
    202 typedef VBGLREQHDR RT_FAR *PVBGLREQHDR;
    203 
    204 /** Version of VMMDevRequestHeader structure. */
    205 #define VBGLREQHDR_VERSION          UINT32_C(0x10001)
    206 /** Default request type.  Use this for non-VMMDev requests. */
    207 #define VBGLREQHDR_TYPE_DEFAULT     UINT32_C(0)
    208 
    209 /** Initialize a VBGLREQHDR structure for a fixed size I/O control call.
    210  * @param   a_pHdr      Pointer to the header to initialize.
    211  * @param   a_IOCtl     The base I/O control name, no VBGL_IOCTL_ prefix.  We
    212  *                      have to skip the prefix to avoid it getting expanded
    213  *                      before we append _SIZE_IN and _SIZE_OUT to it.
    214  */
    215 #define VBGLREQHDR_INIT(a_pHdr, a_IOCtl) \
    216     VBGLREQHDR_INIT_EX(a_pHdr, RT_CONCAT3(VBGL_IOCTL_,a_IOCtl,_SIZE_IN), RT_CONCAT3(VBGL_IOCTL_,a_IOCtl,_SIZE_OUT))
    217 /** Initialize a VBGLREQHDR structure, extended version. */
    218 #define VBGLREQHDR_INIT_EX(a_pHdr, a_cbIn, a_cbOut) \
    219     do { \
    220         (a_pHdr)->cbIn      = (uint32_t)(a_cbIn); \
    221         (a_pHdr)->uVersion  = VBGLREQHDR_VERSION; \
    222         (a_pHdr)->uType     = VBGLREQHDR_TYPE_DEFAULT; \
    223         (a_pHdr)->rc        = VERR_INTERNAL_ERROR; \
    224         (a_pHdr)->cbOut     = (uint32_t)(a_cbOut); \
    225         (a_pHdr)->uReserved = 0; \
    226     } while (0)
    227 /** Initialize a VBGLREQHDR structure for a VMMDev request.
    228  * Same as VMMDEV_REQ_HDR_INIT().  */
    229 #define VBGLREQHDR_INIT_VMMDEV(a_pHdr, a_cb, a_enmType) \
    230     do { \
    231         (a_pHdr)->cbIn      = (a_cb); \
    232         (a_pHdr)->uVersion  = VBGLREQHDR_VERSION; \
    233         (a_pHdr)->uType     = (a_enmType); \
    234         (a_pHdr)->rc        = VERR_INTERNAL_ERROR; \
    235         (a_pHdr)->cbOut     = 0; \
    236         (a_pHdr)->uReserved = 0; \
    237     } while (0)
    238 
    239 
    240 
    241 /**
    242172 * The VBoxGuest I/O control version.
    243173 *
     
    425355# endif
    426356# define VBGL_IOCTL_HGCM_CALL_WITH_USER_DATA(a_cb)  VBGL_IOCTL_CODE_SIZE(8, (a_cb))
    427 /** @note This is used by alot of HGCM call structures. */
    428 typedef struct VBGLIOCHGCMCALL
    429 {
    430     /** Common header. */
    431     VBGLREQHDR  Hdr;
    432     /** Input: The id of the caller. */
    433     uint32_t    u32ClientID;
    434     /** Input: Function number. */
    435     uint32_t    u32Function;
    436     /** Input: How long to wait (milliseconds) for completion before cancelling the
    437      * call.  This is ignored if not a VBGL_IOCTL_HGCM_CALL_TIMED or
    438      * VBGL_IOCTL_HGCM_CALL_TIMED_32 request. */
    439     uint32_t    cMsTimeout;
    440     /** Input: Whether a timed call is interruptible (ring-0 only).  This is ignored
    441      * if not a VBGL_IOCTL_HGCM_CALL_TIMED or VBGL_IOCTL_HGCM_CALL_TIMED_32
    442      * request, or if made from user land. */
    443     bool        fInterruptible;
    444     /** Explicit padding, MBZ. */
    445     uint8_t     bReserved;
    446     /** Input: How many parameters following this structure.
    447      *
    448      * The parameters are either HGCMFunctionParameter64 or HGCMFunctionParameter32,
    449      * depending on whether we're receiving a 64-bit or 32-bit request.
    450      *
    451      * The current maximum is 61 parameters (given a 1KB max request size,
    452      * and a 64-bit parameter size of 16 bytes).
    453      *
    454      * @note This information is duplicated by Hdr.cbIn, but it's currently too much
    455      *       work to eliminate this. */
    456     uint16_t    cParms;
    457     /* Parameters follow in form HGCMFunctionParameter aParms[cParms] */
    458 } VBGLIOCHGCMCALL, RT_FAR *PVBGLIOCHGCMCALL;
    459 AssertCompileSize(VBGLIOCHGCMCALL, 24 + 16);
    460 typedef VBGLIOCHGCMCALL const RT_FAR *PCVBGLIOCHGCMCALL;
    461 
    462 /**
    463  * Initialize a HGCM header (VBGLIOCHGCMCALL) for a non-timed call.
    464  *
    465  * @param   a_pHdr          The header to initalize.
    466  * @param   a_idClient      The client connection ID to call thru.
    467  * @param   a_idFunction    The function we're calling
    468  * @param   a_cParameters   Number of parameters.
    469  */
    470 # define VBGL_HGCM_HDR_INIT(a_pHdr, a_idClient, a_idFunction, a_cParameters) \
    471     do { \
    472         VBGLREQHDR_INIT_EX(&(a_pHdr)->Hdr, \
    473                            sizeof(VBGLIOCHGCMCALL) + (a_cParameters) * sizeof(HGCMFunctionParameter), \
    474                            sizeof(VBGLIOCHGCMCALL) + (a_cParameters) * sizeof(HGCMFunctionParameter)); \
    475         (a_pHdr)->u32ClientID    = (a_idClient); \
    476         (a_pHdr)->u32Function    = (a_idFunction); \
    477         (a_pHdr)->cMsTimeout     = RT_INDEFINITE_WAIT; \
    478         (a_pHdr)->fInterruptible = true; \
    479         (a_pHdr)->bReserved      = 0; \
    480         (a_pHdr)->cParms         = (a_cParameters); \
    481     } while (0)
    482 
    483 /**
    484  * Initialize a HGCM header (VBGLIOCHGCMCALL) for a non-timed call, custom size.
    485  *
    486  * This is usually only needed when appending page lists to the call.
    487  *
    488  * @param   a_pHdr          The header to initalize.
    489  * @param   a_idClient      The client connection ID to call thru.
    490  * @param   a_idFunction    The function we're calling
    491  * @param   a_cParameters   Number of parameters.
    492  * @param   a_cbReq         The request size.
    493  */
    494 # define VBGL_HGCM_HDR_INIT_EX(a_pHdr, a_idClient, a_idFunction, a_cParameters, a_cbReq) \
    495     do { \
    496         Assert((a_cbReq) >= sizeof(VBGLIOCHGCMCALL) + (a_cParameters) * sizeof(HGCMFunctionParameter)); \
    497         VBGLREQHDR_INIT_EX(&(a_pHdr)->Hdr, (a_cbReq), (a_cbReq)); \
    498         (a_pHdr)->u32ClientID    = (a_idClient); \
    499         (a_pHdr)->u32Function    = (a_idFunction); \
    500         (a_pHdr)->cMsTimeout     = RT_INDEFINITE_WAIT; \
    501         (a_pHdr)->fInterruptible = true; \
    502         (a_pHdr)->bReserved      = 0; \
    503         (a_pHdr)->cParms         = (a_cParameters); \
    504     } while (0)
    505 
    506 /**
    507  * Initialize a HGCM header (VBGLIOCHGCMCALL), with timeout (interruptible).
    508  *
    509  * @param   a_pHdr          The header to initalize.
    510  * @param   a_idClient      The client connection ID to call thru.
    511  * @param   a_idFunction    The function we're calling
    512  * @param   a_cParameters   Number of parameters.
    513  * @param   a_cMsTimeout    The timeout in milliseconds.
    514  */
    515 # define VBGL_HGCM_HDR_INIT_TIMED(a_pHdr, a_idClient, a_idFunction, a_cParameters, a_cMsTimeout) \
    516     do { \
    517         (a_pHdr)->u32ClientID    = (a_idClient); \
    518         (a_pHdr)->u32Function    = (a_idFunction); \
    519         (a_pHdr)->cMsTimeout     = (a_cMsTimeout); \
    520         (a_pHdr)->fInterruptible = true; \
    521         (a_pHdr)->bReserved      = 0; \
    522         (a_pHdr)->cParms         = (a_cParameters); \
    523     } while (0)
    524 
    525 /** Get the pointer to the first HGCM parameter.  */
    526 # define VBGL_HGCM_GET_CALL_PARMS(a_pInfo)   ( (HGCMFunctionParameter   *)((uint8_t *)(a_pInfo) + sizeof(VBGLIOCHGCMCALL)) )
    527 /** Get the pointer to the first HGCM parameter in a 32-bit request.  */
    528 # define VBGL_HGCM_GET_CALL_PARMS32(a_pInfo) ( (HGCMFunctionParameter32 *)((uint8_t *)(a_pInfo) + sizeof(VBGLIOCHGCMCALL)) )
    529 
    530357/** @} */
    531358#endif /* VBOX_WITH_HGCM */
Note: See TracChangeset for help on using the changeset viewer.

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