VirtualBox

Changeset 66679 in vbox for trunk/src/VBox/Additions


Ignore:
Timestamp:
Apr 26, 2017 3:24:20 PM (8 years ago)
Author:
vboxsync
Message:

bugref:8524: Additions/linux: play nicely with distribution-installed Additions
[PATCH] Additions/common/VBoxVideo/HGSMIBase: Group setup functions

with related functions

Group the VBoxHGSMISetupHostContext function together with the
functions using PHGSMIHOSTCOMMANDCONTEXT and group
VBoxHGSMISetupGuestContext together with the functions using
PHGSMIGUESTCOMMANDCONTEXT. This makes it easier to later #ifdef
out the bits we are not going to use in the Linux vboxvideo drm driver.

Note this commit makes no functional changes it just moves a few
blocks of code around.

Signed-off-by: Hans de Goede <hdegoede@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxVideo/HGSMIBase.cpp

    r66544 r66679  
    3131#include <VBoxVideoIPRT.h>
    3232
     33/**
     34 * Initialise the host context structure.
     35 *
     36 * @param  pCtx               the context structure to initialise
     37 * @param  pvBaseMapping      where the basic HGSMI structures are mapped at
     38 * @param  offHostFlags       the offset of the host flags into the basic HGSMI
     39 *                            structures
     40 * @param  pvHostAreaMapping  where the area for the host heap is mapped at
     41 * @param  offVRAMHostArea    offset of the host heap area into VRAM
     42 * @param  cbHostArea         size in bytes of the host heap area
     43 */
     44DECLHIDDEN(void) VBoxHGSMISetupHostContext(PHGSMIHOSTCOMMANDCONTEXT pCtx,
     45                                           void *pvBaseMapping,
     46                                           uint32_t offHostFlags,
     47                                           void *pvHostAreaMapping,
     48                                           uint32_t offVRAMHostArea,
     49                                           uint32_t cbHostArea)
     50{
     51    uint8_t *pu8HostFlags = ((uint8_t *)pvBaseMapping) + offHostFlags;
     52    pCtx->pfHostFlags = (HGSMIHOSTFLAGS *)pu8HostFlags;
     53    /** @todo should we really be using a fixed ISA port value here? */
     54    pCtx->port        = (RTIOPORT)VGA_PORT_HGSMI_HOST;
     55    HGSMIAreaInitialize(&pCtx->areaCtx, pvHostAreaMapping, cbHostArea,
     56                         offVRAMHostArea);
     57}
     58
     59
    3360/** Send completion notification to the host for the command located at offset
    3461 * @a offt into the host command buffer. */
     
    103130
    104131
    105 /** Detect whether HGSMI is supported by the host. */
    106 DECLHIDDEN(bool) VBoxHGSMIIsSupported(void)
    107 {
    108     uint16_t DispiId;
    109 
    110     VBVO_PORT_WRITE_U16(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_ID);
    111     VBVO_PORT_WRITE_U16(VBE_DISPI_IOPORT_DATA, VBE_DISPI_ID_HGSMI);
    112 
    113     DispiId = VBVO_PORT_READ_U16(VBE_DISPI_IOPORT_DATA);
    114 
    115     return (DispiId == VBE_DISPI_ID_HGSMI);
     132/**
     133 * Set up the HGSMI guest-to-host command context.
     134 * @returns iprt status value
     135 * @param  pCtx                    the context to set up
     136 * @param  pvGuestHeapMemory       a pointer to the mapped backing memory for
     137 *                                 the guest heap
     138 * @param  cbGuestHeapMemory       the size of the backing memory area
     139 * @param  offVRAMGuestHeapMemory  the offset of the memory pointed to by
     140 *                                 @a pvGuestHeapMemory within the video RAM
     141 * @param  pEnv                    HGSMI environment.
     142 */
     143DECLHIDDEN(int) VBoxHGSMISetupGuestContext(PHGSMIGUESTCOMMANDCONTEXT pCtx,
     144                                           void *pvGuestHeapMemory,
     145                                           uint32_t cbGuestHeapMemory,
     146                                           uint32_t offVRAMGuestHeapMemory,
     147                                           const HGSMIENV *pEnv)
     148{
     149    /** @todo should we be using a fixed ISA port value here? */
     150    pCtx->port = (RTIOPORT)VGA_PORT_HGSMI_GUEST;
     151#ifdef VBOX_WDDM_MINIPORT
     152    return VBoxSHGSMIInit(&pCtx->heapCtx, pvGuestHeapMemory,
     153                          cbGuestHeapMemory, offVRAMGuestHeapMemory, pEnv);
     154#else
     155    return HGSMIHeapSetup(&pCtx->heapCtx, pvGuestHeapMemory,
     156                          cbGuestHeapMemory, offVRAMGuestHeapMemory, pEnv);
     157#endif
    116158}
    117159
     
    180222
    181223    return VERR_INVALID_PARAMETER;
     224}
     225
     226
     227/** Detect whether HGSMI is supported by the host. */
     228DECLHIDDEN(bool) VBoxHGSMIIsSupported(void)
     229{
     230    uint16_t DispiId;
     231
     232    VBVO_PORT_WRITE_U16(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_ID);
     233    VBVO_PORT_WRITE_U16(VBE_DISPI_IOPORT_DATA, VBE_DISPI_ID_HGSMI);
     234
     235    DispiId = VBVO_PORT_READ_U16(VBE_DISPI_IOPORT_DATA);
     236
     237    return (DispiId == VBE_DISPI_ID_HGSMI);
    182238}
    183239
     
    346402
    347403/**
    348  * Set up the HGSMI guest-to-host command context.
    349  * @returns iprt status value
    350  * @param  pCtx                    the context to set up
    351  * @param  pvGuestHeapMemory       a pointer to the mapped backing memory for
    352  *                                 the guest heap
    353  * @param  cbGuestHeapMemory       the size of the backing memory area
    354  * @param  offVRAMGuestHeapMemory  the offset of the memory pointed to by
    355  *                                 @a pvGuestHeapMemory within the video RAM
    356  * @param  pEnv                    HGSMI environment.
    357  */
    358 DECLHIDDEN(int) VBoxHGSMISetupGuestContext(PHGSMIGUESTCOMMANDCONTEXT pCtx,
    359                                            void *pvGuestHeapMemory,
    360                                            uint32_t cbGuestHeapMemory,
    361                                            uint32_t offVRAMGuestHeapMemory,
    362                                            const HGSMIENV *pEnv)
    363 {
    364     /** @todo should we be using a fixed ISA port value here? */
    365     pCtx->port = (RTIOPORT)VGA_PORT_HGSMI_GUEST;
    366 #ifdef VBOX_WDDM_MINIPORT
    367     return VBoxSHGSMIInit(&pCtx->heapCtx, pvGuestHeapMemory,
    368                           cbGuestHeapMemory, offVRAMGuestHeapMemory, pEnv);
    369 #else
    370     return HGSMIHeapSetup(&pCtx->heapCtx, pvGuestHeapMemory,
    371                           cbGuestHeapMemory, offVRAMGuestHeapMemory, pEnv);
    372 #endif
    373 }
    374 
    375 
    376 /**
    377404 * Get the information needed to map the area used by the host to send back
    378405 * requests.
     
    418445    // LogFunc(("offVRAMHostArea = 0x%08X, cbHostArea = 0x%08X\n",
    419446    //          offVRAMHostArea, cbHostArea));
    420 }
    421 
    422 
    423 /**
    424  * Initialise the host context structure.
    425  *
    426  * @param  pCtx               the context structure to initialise
    427  * @param  pvBaseMapping      where the basic HGSMI structures are mapped at
    428  * @param  offHostFlags       the offset of the host flags into the basic HGSMI
    429  *                            structures
    430  * @param  pvHostAreaMapping  where the area for the host heap is mapped at
    431  * @param  offVRAMHostArea    offset of the host heap area into VRAM
    432  * @param  cbHostArea         size in bytes of the host heap area
    433  */
    434 DECLHIDDEN(void) VBoxHGSMISetupHostContext(PHGSMIHOSTCOMMANDCONTEXT pCtx,
    435                                            void *pvBaseMapping,
    436                                            uint32_t offHostFlags,
    437                                            void *pvHostAreaMapping,
    438                                            uint32_t offVRAMHostArea,
    439                                            uint32_t cbHostArea)
    440 {
    441     uint8_t *pu8HostFlags = ((uint8_t *)pvBaseMapping) + offHostFlags;
    442     pCtx->pfHostFlags = (HGSMIHOSTFLAGS *)pu8HostFlags;
    443     /** @todo should we really be using a fixed ISA port value here? */
    444     pCtx->port        = (RTIOPORT)VGA_PORT_HGSMI_HOST;
    445     HGSMIAreaInitialize(&pCtx->areaCtx, pvHostAreaMapping, cbHostArea,
    446                          offVRAMHostArea);
    447447}
    448448
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