VirtualBox

Changeset 44358 in vbox


Ignore:
Timestamp:
Jan 24, 2013 4:05:55 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
83325
Message:

PDMAsyncCompletion: PVM -> PUVM (one instance), internalize internal APIs where possible (not all because of test cases). API docs lives where the implmentation lives, NOT in headers (IPRT is the exception).

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/pdmasynccompletion.h

    r36573 r44358  
    44
    55/*
    6  * Copyright (C) 2007-2010 Oracle Corporation
     6 * Copyright (C) 2007-2013 Oracle Corporation
    77 *
    88 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    105105typedef FNPDMASYNCCOMPLETEINT *PFNPDMASYNCCOMPLETEINT;
    106106
    107 
    108 /**
    109  * Creates an async completion template for a device instance.
    110  *
    111  * The template is used when creating new completion tasks.
    112  *
    113  * @returns VBox status code.
    114  * @param   pVM             Pointer to the shared VM structure.
    115  * @param   pDevIns         The device instance.
    116  * @param   ppTemplate      Where to store the template pointer on success.
    117  * @param   pfnCompleted    The completion callback routine.
    118  * @param   pszDesc         Description.
    119  */
    120 VMMR3DECL(int) PDMR3AsyncCompletionTemplateCreateDevice(PVM pVM, PPDMDEVINS pDevIns, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate, PFNPDMASYNCCOMPLETEDEV pfnCompleted, const char *pszDesc);
    121 
    122 /**
    123  * Creates an async completion template for a driver instance.
    124  *
    125  * The template is used when creating new completion tasks.
    126  *
    127  * @returns VBox status code.
    128  * @param   pVM             Pointer to the shared VM structure.
    129  * @param   pDrvIns         The driver instance.
    130  * @param   ppTemplate      Where to store the template pointer on success.
    131  * @param   pfnCompleted    The completion callback routine.
    132  * @param   pvTemplateUser  Template user argument.
    133  * @param   pszDesc         Description.
    134  */
    135 VMMR3DECL(int) PDMR3AsyncCompletionTemplateCreateDriver(PVM pVM, PPDMDRVINS pDrvIns, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate, PFNPDMASYNCCOMPLETEDRV pfnCompleted, void *pvTemplateUser, const char *pszDesc);
    136 
    137 /**
    138  * Creates an async completion template for a USB device instance.
    139  *
    140  * The template is used when creating new completion tasks.
    141  *
    142  * @returns VBox status code.
    143  * @param   pVM             Pointer to the shared VM structure.
    144  * @param   pUsbIns         The USB device instance.
    145  * @param   ppTemplate      Where to store the template pointer on success.
    146  * @param   pfnCompleted    The completion callback routine.
    147  * @param   pszDesc         Description.
    148  */
    149 VMMR3DECL(int) PDMR3AsyncCompletionTemplateCreateUsb(PVM pVM, PPDMUSBINS pUsbIns, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate, PFNPDMASYNCCOMPLETEUSB pfnCompleted, const char *pszDesc);
    150 
    151 /**
    152  * Creates an async completion template for internally by the VMM.
    153  *
    154  * The template is used when creating new completion tasks.
    155  *
    156  * @returns VBox status code.
    157  * @param   pVM             Pointer to the shared VM structure.
    158  * @param   ppTemplate      Where to store the template pointer on success.
    159  * @param   pfnCompleted    The completion callback routine.
    160  * @param   pvUser2         The 2nd user argument for the callback.
    161  * @param   pszDesc         Description.
    162  */
    163107VMMR3DECL(int) PDMR3AsyncCompletionTemplateCreateInternal(PVM pVM, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate, PFNPDMASYNCCOMPLETEINT pfnCompleted, void *pvUser2, const char *pszDesc);
    164 
    165 /**
    166  * Destroys the specified async completion template.
    167  *
    168  * @returns VBox status codes:
    169  * @retval  VINF_SUCCESS on success.
    170  * @retval  VERR_PDM_ASYNC_TEMPLATE_BUSY if the template is still in use.
    171  *
    172  * @param   pTemplate       The template in question.
    173  */
    174108VMMR3DECL(int) PDMR3AsyncCompletionTemplateDestroy(PPDMASYNCCOMPLETIONTEMPLATE pTemplate);
    175 
    176 /**
    177  * Destroys all the specified async completion templates for the given device instance.
    178  *
    179  * @returns VBox status codes:
    180  * @retval  VINF_SUCCESS on success.
    181  * @retval  VERR_PDM_ASYNC_TEMPLATE_BUSY if one or more of the templates are still in use.
    182  *
    183  * @param   pVM             Pointer to the shared VM structure.
    184  * @param   pDevIns         The device instance.
    185  */
    186 VMMR3DECL(int) PDMR3AsyncCompletionTemplateDestroyDevice(PVM pVM, PPDMDEVINS pDevIns);
    187 
    188 /**
    189  * Destroys all the specified async completion templates for the given driver instance.
    190  *
    191  * @returns VBox status codes:
    192  * @retval  VINF_SUCCESS on success.
    193  * @retval  VERR_PDM_ASYNC_TEMPLATE_BUSY if one or more of the templates are still in use.
    194  *
    195  * @param   pVM             Pointer to the shared VM structure.
    196  * @param   pDrvIns         The driver instance.
    197  */
    198 VMMR3DECL(int) PDMR3AsyncCompletionTemplateDestroyDriver(PVM pVM, PPDMDRVINS pDrvIns);
    199 
    200 /**
    201  * Destroys all the specified async completion templates for the given USB device instance.
    202  *
    203  * @returns VBox status codes:
    204  * @retval  VINF_SUCCESS on success.
    205  * @retval  VERR_PDM_ASYNC_TEMPLATE_BUSY if one or more of the templates are still in use.
    206  *
    207  * @param   pVM             Pointer to the shared VM structure.
    208  * @param   pUsbIns         The USB device instance.
    209  */
    210 VMMR3DECL(int) PDMR3AsyncCompletionTemplateDestroyUsb(PVM pVM, PPDMUSBINS pUsbIns);
    211 
    212 
    213 /**
    214  * Opens a file as an async completion endpoint.
    215  *
    216  * @returns VBox status code.
    217  * @param   ppEndpoint      Where to store the opaque endpoint handle on success.
    218  * @param   pszFilename     Path to the file which is to be opened. (UTF-8)
    219  * @param   fFlags          Open flags, see grp_pdmacep_file_flags.
    220  * @param   pTemplate       Handle to the completion callback template to use
    221  *                          for this end point.
    222  */
    223109VMMR3DECL(int) PDMR3AsyncCompletionEpCreateForFile(PPPDMASYNCCOMPLETIONENDPOINT ppEndpoint,
    224110                                                   const char *pszFilename, uint32_t fFlags,
     
    239125/** @} */
    240126
    241 /**
    242  * Closes a endpoint waiting for any pending tasks to finish.
    243  *
    244  * @returns nothing.
    245  * @param   pEndpoint       Handle of the endpoint.
    246  */
    247127VMMR3DECL(void) PDMR3AsyncCompletionEpClose(PPDMASYNCCOMPLETIONENDPOINT pEndpoint);
    248 
    249 /**
    250  * Creates a read task on the given endpoint.
    251  *
    252  * @returns VBox status code.
    253  * @param   pEndpoint       The file endpoint to read from.
    254  * @param   off             Where to start reading from.
    255  * @param   paSegments      Scatter gather list to store the data in.
    256  * @param   cSegments       Number of segments in the list.
    257  * @param   cbRead          The overall number of bytes to read.
    258  * @param   pvUser          Opaque user data returned in the completion callback
    259  *                          upon completion of the task.
    260  * @param   ppTask          Where to store the task handle on success.
    261  */
    262128VMMR3DECL(int) PDMR3AsyncCompletionEpRead(PPDMASYNCCOMPLETIONENDPOINT pEndpoint, RTFOFF off,
    263129                                          PCRTSGSEG paSegments, unsigned cSegments,
    264130                                          size_t cbRead, void *pvUser,
    265131                                          PPPDMASYNCCOMPLETIONTASK ppTask);
    266 
    267 /**
    268  * Creates a write task on the given endpoint.
    269  *
    270  * @returns VBox status code.
    271  * @param   pEndpoint       The file endpoint to write to.
    272  * @param   off             Where to start writing at.
    273  * @param   paSegments      Scatter gather list of the data to write.
    274  * @param   cSegments       Number of segments in the list.
    275  * @param   cbWrite         The overall number of bytes to write.
    276  * @param   pvUser          Opaque user data returned in the completion callback
    277  *                          upon completion of the task.
    278  * @param   ppTask          Where to store the task handle on success.
    279  */
    280132VMMR3DECL(int) PDMR3AsyncCompletionEpWrite(PPDMASYNCCOMPLETIONENDPOINT pEndpoint, RTFOFF off,
    281133                                           PCRTSGSEG paSegments, unsigned cSegments,
    282134                                           size_t cbWrite, void *pvUser,
    283135                                           PPPDMASYNCCOMPLETIONTASK ppTask);
    284 
    285 /**
    286  * Creates a flush task on the given endpoint.
    287  *
    288  * Every read and write task initiated before the flush task is
    289  * finished upon completion of this task.
    290  *
    291  * @returns VBox status code.
    292  * @param   pEndpoint       The file endpoint to flush.
    293  * @param   pvUser          Opaque user data returned in the completion callback
    294  *                          upon completion of the task.
    295  * @param   ppTask          Where to store the task handle on success.
    296  */
    297 VMMR3DECL(int) PDMR3AsyncCompletionEpFlush(PPDMASYNCCOMPLETIONENDPOINT pEndpoint,
    298                                            void *pvUser,
    299                                            PPPDMASYNCCOMPLETIONTASK ppTask);
    300 
    301 /**
    302  * Queries the size of an endpoint.
    303  * Not that some endpoints may not support this and will return an error
    304  * (sockets for example).
    305  *
    306  * @returns VBox status code.
    307  * @retval  VERR_NOT_SUPPORTED if the endpoint does not support this operation.
    308  * @param   pEndpoint       The file endpoint.
    309  * @param   pcbSize         Where to store the size of the endpoint.
    310  */
    311 VMMR3DECL(int) PDMR3AsyncCompletionEpGetSize(PPDMASYNCCOMPLETIONENDPOINT pEndpoint,
    312                                              uint64_t *pcbSize);
    313 
    314 /**
    315  * Sets the size of an endpoint.
    316  * Not that some endpoints may not support this and will return an error
    317  * (sockets for example).
    318  *
    319  * @returns VBox status code.
    320  * @retval  VERR_NOT_SUPPORTED if the endpoint does not support this operation.
    321  * @param   pEndpoint       The file endpoint.
    322  * @param   cbSize          The size to set.
    323  *
    324  * @note PDMR3AsyncCompletionEpFlush should be called before this operation is executed.
    325  */
    326 VMMR3DECL(int) PDMR3AsyncCompletionEpSetSize(PPDMASYNCCOMPLETIONENDPOINT pEndpoint,
    327                                              uint64_t cbSize);
    328 
    329 /**
    330  * Assigns or removes a bandwidth control manager to/from the endpoint.
    331  *
    332  * @returns VBox status code.
    333  * @param   pEndpoint       The endpoint.
    334  * @param   pcszBwMgr       The identifer of the new bandwidth manager to assign
    335  *                          or NULL to remove the current one.
    336  */
    337 VMMR3DECL(int) PDMR3AsyncCompletionEpSetBwMgr(PPDMASYNCCOMPLETIONENDPOINT pEndpoint,
    338                                               const char *pcszBwMgr);
    339 
    340 /**
    341  * Cancels an async completion task.
    342  *
    343  * If you want to use this method, you have to take great create to make sure
    344  * you will never attempt cancel a task which has been completed. Since there is
    345  * no reference counting or anything on the task it self, you have to serialize
    346  * the cancelation and completion paths such that the aren't racing one another.
    347  *
    348  * @returns VBox status code
    349  * @param   pTask           The Task to cancel.
    350  */
     136VMMR3DECL(int) PDMR3AsyncCompletionEpFlush(PPDMASYNCCOMPLETIONENDPOINT pEndpoint, void *pvUser, PPPDMASYNCCOMPLETIONTASK ppTask);
     137VMMR3DECL(int) PDMR3AsyncCompletionEpGetSize(PPDMASYNCCOMPLETIONENDPOINT pEndpoint, uint64_t *pcbSize);
     138VMMR3DECL(int) PDMR3AsyncCompletionEpSetSize(PPDMASYNCCOMPLETIONENDPOINT pEndpoint, uint64_t cbSize);
     139VMMR3DECL(int) PDMR3AsyncCompletionEpSetBwMgr(PPDMASYNCCOMPLETIONENDPOINT pEndpoint, const char *pszBwMgr);
    351140VMMR3DECL(int) PDMR3AsyncCompletionTaskCancel(PPDMASYNCCOMPLETIONTASK pTask);
    352 
    353 /**
    354  * Changes the limit of a bandwidth manager for file endpoints to the given value.
    355  *
    356  * @returns VBox status code.
    357  * @param   pVM             Pointer to the shared VM structure.
    358  * @param   pcszBwMgr       The identifer of the bandwidth manager to change.
    359  * @param   cbMaxNew        The new maximum for the bandwidth manager in bytes/sec.
    360  */
    361 VMMR3DECL(int) PDMR3AsyncCompletionBwMgrSetMaxForFile(PVM pVM, const char *pcszBwMgr, uint32_t cbMaxNew);
     141VMMR3DECL(int) PDMR3AsyncCompletionBwMgrSetMaxForFile(PUVM pUVM, const char *pszBwMgr, uint32_t cbMaxNew);
    362142
    363143/** @} */
  • trunk/src/VBox/Devices/Storage/DrvVD.cpp

    r43923 r44358  
    55
    66/*
    7  * Copyright (C) 2006-2010 Oracle Corporation
     7 * Copyright (C) 2006-2013 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
  • trunk/src/VBox/Main/src-client/ConsoleImpl.cpp

    r44355 r44358  
    53445344                int vrc = VINF_SUCCESS;
    53455345                if (enmType == BandwidthGroupType_Disk)
    5346                     vrc = PDMR3AsyncCompletionBwMgrSetMaxForFile(ptrVM, Utf8Str(strName).c_str(), cMax);
     5346                    vrc = PDMR3AsyncCompletionBwMgrSetMaxForFile(ptrVM.rawUVM(), Utf8Str(strName).c_str(), cMax);
    53475347#ifdef VBOX_WITH_NETSHAPER
    53485348                else if (enmType == BandwidthGroupType_Network)
  • trunk/src/VBox/VMM/VMMR3/PDM.cpp

    r44351 r44358  
    55
    66/*
    7  * Copyright (C) 2006-2012 Oracle Corporation
     7 * Copyright (C) 2006-2013 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    664664        //PDMR3QueueDestroyDevice(pVM, pDevIns);
    665665        PGMR3PhysMMIO2Deregister(pVM, pDevIns, UINT32_MAX);
     666#ifdef VBOX_WITH_PDM_ASYNC_COMPLETION
     667        pdmR3AsyncCompletionTemplateDestroyDevice(pVM, pDevIns);
     668#endif
    666669    }
    667670
  • trunk/src/VBox/VMM/VMMR3/PDMAsyncCompletion.cpp

    r43599 r44358  
    55
    66/*
    7  * Copyright (C) 2006-2012 Oracle Corporation
     7 * Copyright (C) 2006-2013 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    195195}
    196196
     197
     198#ifdef SOME_UNUSED_FUNCTION
    197199/**
    198200 * Creates a async completion template for a device instance.
     
    207209 * @param   pszDesc         Description.
    208210 */
    209 VMMR3DECL(int) PDMR3AsyncCompletionTemplateCreateDevice(PVM pVM, PPDMDEVINS pDevIns, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate, PFNPDMASYNCCOMPLETEDEV pfnCompleted, const char *pszDesc)
     211int pdmR3AsyncCompletionTemplateCreateDevice(PVM pVM, PPDMDEVINS pDevIns, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate,
     212                                             PFNPDMASYNCCOMPLETEDEV pfnCompleted, const char *pszDesc)
    210213{
    211214    LogFlow(("%s: pDevIns=%p ppTemplate=%p pfnCompleted=%p pszDesc=%s\n",
     
    236239    return rc;
    237240}
     241#endif /* SOME_UNUSED_FUNCTION */
     242
    238243
    239244/**
     
    250255 * @param   pszDesc         Description.
    251256 */
    252 VMMR3DECL(int) PDMR3AsyncCompletionTemplateCreateDriver(PVM pVM, PPDMDRVINS pDrvIns, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate, PFNPDMASYNCCOMPLETEDRV pfnCompleted, void *pvTemplateUser, const char *pszDesc)
    253 {
    254     LogFlow(("%s: pDrvIns=%p ppTemplate=%p pfnCompleted=%p pszDesc=%s\n",
    255               __FUNCTION__, pDrvIns, ppTemplate, pfnCompleted, pszDesc));
     257int pdmR3AsyncCompletionTemplateCreateDriver(PVM pVM, PPDMDRVINS pDrvIns, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate,
     258                                             PFNPDMASYNCCOMPLETEDRV pfnCompleted, void *pvTemplateUser,
     259                                             const char *pszDesc)
     260{
     261    LogFlow(("PDMR3AsyncCompletionTemplateCreateDriver: pDrvIns=%p ppTemplate=%p pfnCompleted=%p pszDesc=%s\n", pDrvIns, ppTemplate, pfnCompleted, pszDesc));
    256262
    257263    /*
     
    280286}
    281287
     288
     289#ifdef SOME_UNUSED_FUNCTION
    282290/**
    283291 * Creates a async completion template for a USB device instance.
     
    292300 * @param   pszDesc         Description.
    293301 */
    294 VMMR3DECL(int) PDMR3AsyncCompletionTemplateCreateUsb(PVM pVM, PPDMUSBINS pUsbIns, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate, PFNPDMASYNCCOMPLETEUSB pfnCompleted, const char *pszDesc)
    295 {
    296     LogFlow(("%s: pUsbIns=%p ppTemplate=%p pfnCompleted=%p pszDesc=%s\n",
    297               __FUNCTION__, pUsbIns, ppTemplate, pfnCompleted, pszDesc));
     302int pdmR3AsyncCompletionTemplateCreateUsb(PVM pVM, PPDMUSBINS pUsbIns, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate,
     303                                          PFNPDMASYNCCOMPLETEUSB pfnCompleted, const char *pszDesc)
     304{
     305    LogFlow(("pdmR3AsyncCompletionTemplateCreateUsb: pUsbIns=%p ppTemplate=%p pfnCompleted=%p pszDesc=%s\n", pUsbIns, ppTemplate, pfnCompleted, pszDesc));
    298306
    299307    /*
     
    321329    return rc;
    322330}
     331#endif
     332
    323333
    324334/**
     
    333343 * @param   pvUser2         The 2nd user argument for the callback.
    334344 * @param   pszDesc         Description.
     345 * @internal
    335346 */
    336347VMMR3DECL(int) PDMR3AsyncCompletionTemplateCreateInternal(PVM pVM, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate, PFNPDMASYNCCOMPLETEINT pfnCompleted, void *pvUser2, const char *pszDesc)
     
    364375}
    365376
     377
    366378/**
    367379 * Destroys the specified async completion template.
     
    419431}
    420432
     433
    421434/**
    422435 * Destroys all the specified async completion templates for the given device instance.
     
    429442 * @param   pDevIns         The device instance.
    430443 */
    431 VMMR3DECL(int) PDMR3AsyncCompletionTemplateDestroyDevice(PVM pVM, PPDMDEVINS pDevIns)
    432 {
    433     LogFlow(("%s: pDevIns=%p\n", __FUNCTION__, pDevIns));
     444int pdmR3AsyncCompletionTemplateDestroyDevice(PVM pVM, PPDMDEVINS pDevIns)
     445{
     446    LogFlow(("pdmR3AsyncCompletionTemplateDestroyDevice: pDevIns=%p\n", pDevIns));
    434447
    435448    /*
     
    468481}
    469482
     483
    470484/**
    471485 * Destroys all the specified async completion templates for the given driver instance.
     
    478492 * @param   pDrvIns         The driver instance.
    479493 */
    480 VMMR3DECL(int) PDMR3AsyncCompletionTemplateDestroyDriver(PVM pVM, PPDMDRVINS pDrvIns)
    481 {
    482     LogFlow(("%s: pDevIns=%p\n", __FUNCTION__, pDrvIns));
     494int pdmR3AsyncCompletionTemplateDestroyDriver(PVM pVM, PPDMDRVINS pDrvIns)
     495{
     496    LogFlow(("pdmR3AsyncCompletionTemplateDestroyDriver: pDevIns=%p\n", pDrvIns));
    483497
    484498    /*
     
    517531}
    518532
     533
    519534/**
    520535 * Destroys all the specified async completion templates for the given USB device instance.
     
    527542 * @param   pUsbIns         The USB device instance.
    528543 */
    529 VMMR3DECL(int) PDMR3AsyncCompletionTemplateDestroyUsb(PVM pVM, PPDMUSBINS pUsbIns)
    530 {
    531     LogFlow(("%s: pUsbIns=%p\n", __FUNCTION__, pUsbIns));
     544int pdmR3AsyncCompletionTemplateDestroyUsb(PVM pVM, PPDMUSBINS pUsbIns)
     545{
     546    LogFlow(("pdmR3AsyncCompletionTemplateDestroyUsb: pUsbIns=%p\n", pUsbIns));
    532547
    533548    /*
     
    567582
    568583
    569 static PPDMACBWMGR pdmacBwMgrFindById(PPDMASYNCCOMPLETIONEPCLASS pEpClass, const char *pcszId)
     584/** Lazy coder. */
     585static PPDMACBWMGR pdmacBwMgrFindById(PPDMASYNCCOMPLETIONEPCLASS pEpClass, const char *pszId)
    570586{
    571587    PPDMACBWMGR pBwMgr = NULL;
    572588
    573     if (RT_VALID_PTR(pcszId))
     589    if (pszId)
    574590    {
    575591        int rc = RTCritSectEnter(&pEpClass->CritSect); AssertRC(rc);
     
    577593        pBwMgr = pEpClass->pBwMgrsHead;
    578594        while (   pBwMgr
    579                && RTStrCmp(pBwMgr->pszId, pcszId))
     595               && RTStrCmp(pBwMgr->pszId, pszId))
    580596            pBwMgr = pBwMgr->pNext;
    581597
     
    586602}
    587603
     604
     605/** Lazy coder. */
    588606static void pdmacBwMgrLink(PPDMACBWMGR pBwMgr)
    589607{
     
    597615}
    598616
     617
    599618#ifdef SOME_UNUSED_FUNCTION
     619/** Lazy coder. */
    600620static void pdmacBwMgrUnlink(PPDMACBWMGR pBwMgr)
    601621{
     
    620640#endif /* SOME_UNUSED_FUNCTION */
    621641
    622 static int pdmacAsyncCompletionBwMgrCreate(PPDMASYNCCOMPLETIONEPCLASS pEpClass, const char *pcszBwMgr, uint32_t cbTransferPerSecMax,
     642
     643/** Lazy coder. */
     644static int pdmacAsyncCompletionBwMgrCreate(PPDMASYNCCOMPLETIONEPCLASS pEpClass, const char *pszBwMgr, uint32_t cbTransferPerSecMax,
    623645                                           uint32_t cbTransferPerSecStart, uint32_t cbTransferPerSecStep)
    624646{
    625     LogFlowFunc(("pEpClass=%#p pcszBwMgr=%#p{%s} cbTransferPerSecMax=%u cbTransferPerSecStart=%u cbTransferPerSecStep=%u\n",
    626                  pEpClass, pcszBwMgr, cbTransferPerSecMax, cbTransferPerSecStart, cbTransferPerSecStep));
     647    LogFlowFunc(("pEpClass=%#p pszBwMgr=%#p{%s} cbTransferPerSecMax=%u cbTransferPerSecStart=%u cbTransferPerSecStep=%u\n",
     648                 pEpClass, pszBwMgr, cbTransferPerSecMax, cbTransferPerSecStart, cbTransferPerSecStep));
    627649
    628650    AssertPtrReturn(pEpClass, VERR_INVALID_POINTER);
    629     AssertPtrReturn(pcszBwMgr, VERR_INVALID_POINTER);
    630     AssertReturn(*pcszBwMgr != '\0', VERR_INVALID_PARAMETER);
     651    AssertPtrReturn(pszBwMgr, VERR_INVALID_POINTER);
     652    AssertReturn(*pszBwMgr != '\0', VERR_INVALID_PARAMETER);
    631653
    632654    int         rc;
    633     PPDMACBWMGR pBwMgr = pdmacBwMgrFindById(pEpClass, pcszBwMgr);
     655    PPDMACBWMGR pBwMgr = pdmacBwMgrFindById(pEpClass, pszBwMgr);
    634656    if (!pBwMgr)
    635657    {
     
    639661        if (RT_SUCCESS(rc))
    640662        {
    641             pBwMgr->pszId = RTStrDup(pcszBwMgr);
     663            pBwMgr->pszId = RTStrDup(pszBwMgr);
    642664            if (pBwMgr->pszId)
    643665            {
     
    670692}
    671693
    672 DECLINLINE(void) pdmacBwMgrRef(PPDMACBWMGR pBwMgr)
     694
     695/** Lazy coder. */
     696DECLINLINE(void) pdmacBwMgrRetain(PPDMACBWMGR pBwMgr)
    673697{
    674698    ASMAtomicIncU32(&pBwMgr->cRefs);
    675699}
    676700
    677 DECLINLINE(void) pdmacBwMgrUnref(PPDMACBWMGR pBwMgr)
     701
     702/** Lazy coder. */
     703DECLINLINE(void) pdmacBwMgrRelease(PPDMACBWMGR pBwMgr)
    678704{
    679705    Assert(pBwMgr->cRefs > 0);
     
    681707}
    682708
     709
     710/**
     711 * Checks if the endpoint is allowed to transfer the given amount of bytes.
     712 *
     713 * @returns true if the endpoint is allowed to transfer the data.
     714 *          false otherwise
     715 * @param   pEndpoint                 The endpoint.
     716 * @param   cbTransfer                The number of bytes to transfer.
     717 * @param   pmsWhenNext               Where to store the number of milliseconds
     718 *                                    until the bandwidth is refreshed.
     719 *                                    Only set if false is returned.
     720 */
    683721bool pdmacEpIsTransferAllowed(PPDMASYNCCOMPLETIONENDPOINT pEndpoint, uint32_t cbTransfer, RTMSINTERVAL *pmsWhenNext)
    684722{
     
    729767}
    730768
     769
     770/**
     771 * Called by the endpoint if a task has finished.
     772 *
     773 * @returns nothing
     774 * @param   pTask                     Pointer to the finished task.
     775 * @param   rc                        Status code of the completed request.
     776 * @param   fCallCompletionHandler    Flag whether the completion handler should be called to
     777 *                                    inform the owner of the task that it has completed.
     778 */
    731779void pdmR3AsyncCompletionCompleteTask(PPDMASYNCCOMPLETIONTASK pTask, int rc, bool fCallCompletionHandler)
    732780{
     
    763811}
    764812
     813
    765814/**
    766815 * Worker initializing a endpoint class.
     
    778827    AssertReturn(pEpClassOps->u32VersionEnd == PDMAC_EPCLASS_OPS_VERSION, VERR_VERSION_MISMATCH);
    779828
    780     LogFlowFunc((": pVM=%p pEpClassOps=%p{%s}\n", pVM, pEpClassOps, pEpClassOps->pcszName));
     829    LogFlow(("pdmR3AsyncCompletionEpClassInit: pVM=%p pEpClassOps=%p{%s}\n", pVM, pEpClassOps, pEpClassOps->pszName));
    781830
    782831    /* Allocate global class data. */
     
    795844        if (RT_SUCCESS(rc))
    796845        {
    797             PCFGMNODE pCfgNodeClass = CFGMR3GetChild(pCfgHandle, pEpClassOps->pcszName);
     846            PCFGMNODE pCfgNodeClass = CFGMR3GetChild(pCfgHandle, pEpClassOps->pszName);
    798847
    799848            /* Create task cache */
     
    855904
    856905                        pUVM->pdm.s.apAsyncCompletionEndpointClass[pEpClassOps->enmClassType] = pEndpointClass;
    857                         LogFlowFunc((": Initialized endpoint class \"%s\" rc=%Rrc\n", pEpClassOps->pcszName, rc));
     906                        LogFlowFunc((": Initialized endpoint class \"%s\" rc=%Rrc\n", pEpClassOps->pszName, rc));
    858907                        return VINF_SUCCESS;
    859908                    }
     
    871920}
    872921
     922
    873923/**
    874924 * Worker terminating all endpoint classes.
     
    906956    MMR3HeapFree(pEndpointClass);
    907957}
     958
    908959
    909960/**
     
    9491000}
    9501001
     1002
    9511003/**
    9521004 * Records the required processing time of a request.
     
    9831035}
    9841036
     1037
    9851038/**
    9861039 * Registers advanced statistics for the given endpoint.
     
    12221275    return rc;
    12231276}
     1277
    12241278
    12251279/**
     
    12641318}
    12651319
     1320
    12661321/**
    12671322 * Initialize the async completion manager.
     
    12841339}
    12851340
     1341
    12861342/**
    12871343 * Terminates the async completion manager.
     
    13011357    return VINF_SUCCESS;
    13021358}
     1359
    13031360
    13041361/**
     
    13591416        }
    13601417}
     1418
    13611419
    13621420/**
     
    13871445}
    13881446
     1447
    13891448/**
    13901449 * Puts a task in one of the caches.
     
    14081467}
    14091468
    1410 static PPDMASYNCCOMPLETIONENDPOINT pdmR3AsyncCompletionFindEndpointWithUri(PPDMASYNCCOMPLETIONEPCLASS pEndpointClass,
    1411                                                                            const char *pszUri)
     1469
     1470static PPDMASYNCCOMPLETIONENDPOINT
     1471pdmR3AsyncCompletionFindEndpointWithUri(PPDMASYNCCOMPLETIONEPCLASS pEndpointClass, const char *pszUri)
    14121472{
    14131473    PPDMASYNCCOMPLETIONENDPOINT pEndpoint = pEndpointClass->pEndpointsHead;
     
    14241484}
    14251485
     1486
     1487/**
     1488 * Opens a file as an async completion endpoint.
     1489 *
     1490 * @returns VBox status code.
     1491 * @param   ppEndpoint      Where to store the opaque endpoint handle on success.
     1492 * @param   pszFilename     Path to the file which is to be opened. (UTF-8)
     1493 * @param   fFlags          Open flags, see grp_pdmacep_file_flags.
     1494 * @param   pTemplate       Handle to the completion callback template to use
     1495 *                          for this end point.
     1496 */
    14261497VMMR3DECL(int) PDMR3AsyncCompletionEpCreateForFile(PPPDMASYNCCOMPLETIONENDPOINT ppEndpoint,
    14271498                                                   const char *pszFilename, uint32_t fFlags,
     
    15191590}
    15201591
     1592
     1593/**
     1594 * Closes a endpoint waiting for any pending tasks to finish.
     1595 *
     1596 * @returns nothing.
     1597 * @param   pEndpoint       Handle of the endpoint.
     1598 */
    15211599VMMR3DECL(void) PDMR3AsyncCompletionEpClose(PPDMASYNCCOMPLETIONENDPOINT pEndpoint)
    15221600{
     
    15661644}
    15671645
     1646
     1647/**
     1648 * Creates a read task on the given endpoint.
     1649 *
     1650 * @returns VBox status code.
     1651 * @param   pEndpoint       The file endpoint to read from.
     1652 * @param   off             Where to start reading from.
     1653 * @param   paSegments      Scatter gather list to store the data in.
     1654 * @param   cSegments       Number of segments in the list.
     1655 * @param   cbRead          The overall number of bytes to read.
     1656 * @param   pvUser          Opaque user data returned in the completion callback
     1657 *                          upon completion of the task.
     1658 * @param   ppTask          Where to store the task handle on success.
     1659 */
    15681660VMMR3DECL(int) PDMR3AsyncCompletionEpRead(PPDMASYNCCOMPLETIONENDPOINT pEndpoint, RTFOFF off,
    15691661                                          PCRTSGSEG paSegments, unsigned cSegments,
     
    15991691}
    16001692
     1693
     1694/**
     1695 * Creates a write task on the given endpoint.
     1696 *
     1697 * @returns VBox status code.
     1698 * @param   pEndpoint       The file endpoint to write to.
     1699 * @param   off             Where to start writing at.
     1700 * @param   paSegments      Scatter gather list of the data to write.
     1701 * @param   cSegments       Number of segments in the list.
     1702 * @param   cbWrite         The overall number of bytes to write.
     1703 * @param   pvUser          Opaque user data returned in the completion callback
     1704 *                          upon completion of the task.
     1705 * @param   ppTask          Where to store the task handle on success.
     1706 */
    16011707VMMR3DECL(int) PDMR3AsyncCompletionEpWrite(PPDMASYNCCOMPLETIONENDPOINT pEndpoint, RTFOFF off,
    16021708                                           PCRTSGSEG paSegments, unsigned cSegments,
     
    16321738}
    16331739
    1634 VMMR3DECL(int) PDMR3AsyncCompletionEpFlush(PPDMASYNCCOMPLETIONENDPOINT pEndpoint,
    1635                                            void *pvUser,
    1636                                            PPPDMASYNCCOMPLETIONTASK ppTask)
     1740
     1741/**
     1742 * Creates a flush task on the given endpoint.
     1743 *
     1744 * Every read and write task initiated before the flush task is
     1745 * finished upon completion of this task.
     1746 *
     1747 * @returns VBox status code.
     1748 * @param   pEndpoint       The file endpoint to flush.
     1749 * @param   pvUser          Opaque user data returned in the completion callback
     1750 *                          upon completion of the task.
     1751 * @param   ppTask          Where to store the task handle on success.
     1752 */
     1753VMMR3DECL(int) PDMR3AsyncCompletionEpFlush(PPDMASYNCCOMPLETIONENDPOINT pEndpoint, void *pvUser, PPPDMASYNCCOMPLETIONTASK ppTask)
    16371754{
    16381755    AssertPtrReturn(pEndpoint, VERR_INVALID_POINTER);
     
    16541771}
    16551772
     1773
     1774/**
     1775 * Queries the size of an endpoint.
     1776 *
     1777 * Not that some endpoints may not support this and will return an error
     1778 * (sockets for example).
     1779 *
     1780 * @returns VBox status code.
     1781 * @retval  VERR_NOT_SUPPORTED if the endpoint does not support this operation.
     1782 * @param   pEndpoint       The file endpoint.
     1783 * @param   pcbSize         Where to store the size of the endpoint.
     1784 */
    16561785VMMR3DECL(int) PDMR3AsyncCompletionEpGetSize(PPDMASYNCCOMPLETIONENDPOINT pEndpoint,
    16571786                                             uint64_t *pcbSize)
     
    16651794}
    16661795
    1667 VMMR3DECL(int) PDMR3AsyncCompletionEpSetSize(PPDMASYNCCOMPLETIONENDPOINT pEndpoint,
    1668                                              uint64_t cbSize)
     1796
     1797/**
     1798 * Sets the size of an endpoint.
     1799 *
     1800 * Not that some endpoints may not support this and will return an error
     1801 * (sockets for example).
     1802 *
     1803 * @returns VBox status code.
     1804 * @retval  VERR_NOT_SUPPORTED if the endpoint does not support this operation.
     1805 * @param   pEndpoint       The file endpoint.
     1806 * @param   cbSize          The size to set.
     1807 *
     1808 * @note PDMR3AsyncCompletionEpFlush should be called before this operation is executed.
     1809 */
     1810VMMR3DECL(int) PDMR3AsyncCompletionEpSetSize(PPDMASYNCCOMPLETIONENDPOINT pEndpoint, uint64_t cbSize)
    16691811{
    16701812    AssertPtrReturn(pEndpoint, VERR_INVALID_POINTER);
     
    16751817}
    16761818
    1677 VMMR3DECL(int) PDMR3AsyncCompletionEpSetBwMgr(PPDMASYNCCOMPLETIONENDPOINT pEndpoint,
    1678                                               const char *pcszBwMgr)
     1819
     1820/**
     1821 * Assigns or removes a bandwidth control manager to/from the endpoint.
     1822 *
     1823 * @returns VBox status code.
     1824 * @param   pEndpoint       The endpoint.
     1825 * @param   pszBwMgr        The identifer of the new bandwidth manager to assign
     1826 *                          or NULL to remove the current one.
     1827 */
     1828VMMR3DECL(int) PDMR3AsyncCompletionEpSetBwMgr(PPDMASYNCCOMPLETIONENDPOINT pEndpoint, const char *pszBwMgr)
    16791829{
    16801830    AssertPtrReturn(pEndpoint, VERR_INVALID_POINTER);
     
    16831833
    16841834    int rc = VINF_SUCCESS;
    1685     if (pcszBwMgr)
    1686     {
    1687         pBwMgrNew = pdmacBwMgrFindById(pEndpoint->pEpClass, pcszBwMgr);
     1835    if (pszBwMgr)
     1836    {
     1837        pBwMgrNew = pdmacBwMgrFindById(pEndpoint->pEpClass, pszBwMgr);
    16881838        if (pBwMgrNew)
    1689             pdmacBwMgrRef(pBwMgrNew);
     1839            pdmacBwMgrRetain(pBwMgrNew);
    16901840        else
    16911841            rc = VERR_NOT_FOUND;
     
    16961846        pBwMgrOld = ASMAtomicXchgPtrT(&pEndpoint->pBwMgr, pBwMgrNew, PPDMACBWMGR);
    16971847        if (pBwMgrOld)
    1698             pdmacBwMgrUnref(pBwMgrOld);
     1848            pdmacBwMgrRelease(pBwMgrOld);
    16991849    }
    17001850
     
    17021852}
    17031853
     1854
     1855/**
     1856 * Cancels an async completion task.
     1857 *
     1858 * If you want to use this method, you have to take great create to make sure
     1859 * you will never attempt cancel a task which has been completed. Since there is
     1860 * no reference counting or anything on the task it self, you have to serialize
     1861 * the cancelation and completion paths such that the aren't racing one another.
     1862 *
     1863 * @returns VBox status code
     1864 * @param   pTask           The Task to cancel.
     1865 */
    17041866VMMR3DECL(int) PDMR3AsyncCompletionTaskCancel(PPDMASYNCCOMPLETIONTASK pTask)
    17051867{
     
    17081870}
    17091871
    1710 VMMR3DECL(int) PDMR3AsyncCompletionBwMgrSetMaxForFile(PVM pVM, const char *pcszBwMgr, uint32_t cbMaxNew)
    1711 {
    1712     AssertPtrReturn(pVM, VERR_INVALID_POINTER);
    1713     AssertPtrReturn(pcszBwMgr, VERR_INVALID_POINTER);
     1872
     1873/**
     1874 * Changes the limit of a bandwidth manager for file endpoints to the given value.
     1875 *
     1876 * @returns VBox status code.
     1877 * @param   pUVM            The user mode VM handle.
     1878 * @param   pszBwMgr        The identifer of the bandwidth manager to change.
     1879 * @param   cbMaxNew        The new maximum for the bandwidth manager in bytes/sec.
     1880 */
     1881VMMR3DECL(int) PDMR3AsyncCompletionBwMgrSetMaxForFile(PUVM pUVM, const char *pszBwMgr, uint32_t cbMaxNew)
     1882{
     1883    UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
     1884    PVM pVM = pUVM->pVM;
     1885    VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
     1886    AssertPtrReturn(pszBwMgr, VERR_INVALID_POINTER);
    17141887
    17151888    int                         rc       = VINF_SUCCESS;
    17161889    PPDMASYNCCOMPLETIONEPCLASS  pEpClass = pVM->pUVM->pdm.s.apAsyncCompletionEndpointClass[PDMASYNCCOMPLETIONEPCLASSTYPE_FILE];
    1717     PPDMACBWMGR                 pBwMgr   = pdmacBwMgrFindById(pEpClass, pcszBwMgr);
     1890    PPDMACBWMGR                 pBwMgr   = pdmacBwMgrFindById(pEpClass, pszBwMgr);
    17181891    if (pBwMgr)
    17191892    {
  • trunk/src/VBox/VMM/VMMR3/PDMDriver.cpp

    r44355 r44358  
    55
    66/*
    7  * Copyright (C) 2006-2012 Oracle Corporation
     7 * Copyright (C) 2006-2013 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    968968        PDMR3BlkCacheReleaseDriver(pVM, pCur);
    969969
     970#ifdef VBOX_WITH_PDM_ASYNC_COMPLETION
     971        /* Completion templates.*/
     972        pdmR3AsyncCompletionTemplateDestroyDriver(pVM, pCur);
     973#endif
     974
    970975        /* Finally, the driver it self. */
    971976        bool fHyperHeap = pCur->Internal.s.fHyperHeap;
     
    15451550             pDrvIns->pReg->szName, pDrvIns->iInstance, ppTemplate, pfnCompleted, pszDesc, pszDesc));
    15461551
    1547     int rc = PDMR3AsyncCompletionTemplateCreateDriver(pDrvIns->Internal.s.pVMR3, pDrvIns, ppTemplate, pfnCompleted, pvTemplateUser, pszDesc);
     1552    int rc = pdmR3AsyncCompletionTemplateCreateDriver(pDrvIns->Internal.s.pVMR3, pDrvIns, ppTemplate, pfnCompleted, pvTemplateUser, pszDesc);
    15481553
    15491554    LogFlow(("pdmR3DrvHlp_AsyncCompletionTemplateCreate: caller='%s'/%d: returns %Rrc *ppThread=%p\n", pDrvIns->pReg->szName,
  • trunk/src/VBox/VMM/VMMR3/PDMUsb.cpp

    r44351 r44358  
    55
    66/*
    7  * Copyright (C) 2006-2007 Oracle Corporation
     7 * Copyright (C) 2006-2013 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    970970    //SSMR3DeregisterUsb(pVM, pUsbIns, NULL, 0);
    971971    pdmR3ThreadDestroyUsb(pVM, pUsbIns);
     972#ifdef VBOX_WITH_PDM_ASYNC_COMPLETION
     973    pdmR3AsyncCompletionTemplateDestroyUsb(pVM, pUsbIns);
     974#endif
    972975
    973976    /*
  • trunk/src/VBox/VMM/include/PDMAsyncCompletionInternal.h

    r43599 r44358  
    55
    66/*
    7  * Copyright (C) 2006-2010 Oracle Corporation
     7 * Copyright (C) 2006-2013 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3939    uint32_t                      u32Version;
    4040    /** Name of the endpoint class. */
    41     const char                   *pcszName;
     41    const char                   *pszName;
    4242    /** Class type. */
    4343    PDMASYNCCOMPLETIONEPCLASSTYPE enmClassType;
     
    267267} PDMASYNCCOMPLETIONTASK;
    268268
    269 /**
    270  * Called by the endpoint if a task has finished.
    271  *
    272  * @returns nothing
    273  * @param   pTask                     Pointer to the finished task.
    274  * @param   rc                        Status code of the completed request.
    275  * @param   fCallCompletionHandler    Flag whether the completion handler should be called to
    276  *                                    inform the owner of the task that it has completed.
    277  */
    278269void pdmR3AsyncCompletionCompleteTask(PPDMASYNCCOMPLETIONTASK pTask, int rc, bool fCallCompletionHandler);
    279 
    280 /**
    281  * Checks if the endpoint is allowed to transfer the given amount of bytes.
    282  *
    283  * @returns true if the endpoint is allowed to transfer the data.
    284  *          false otherwise
    285  * @param   pEndpoint                 The endpoint.
    286  * @param   cbTransfer                The number of bytes to transfer.
    287  * @param   pmsWhenNext               Where to store the number of milliseconds
    288  *                                    until the bandwidth is refreshed.
    289  *                                    Only set if false is returned.
    290  */
    291270bool pdmacEpIsTransferAllowed(PPDMASYNCCOMPLETIONENDPOINT pEndpoint, uint32_t cbTransfer, RTMSINTERVAL *pmsWhenNext);
    292271
  • trunk/src/VBox/VMM/include/PDMInternal.h

    r44355 r44358  
    2626#include <VBox/vmm/pdmasynccompletion.h>
    2727#ifdef VBOX_WITH_NETSHAPER
    28 #include <VBox/vmm/pdmnetshaper.h>
    29 #endif /* VBOX_WITH_NETSHAPER */
     28# include <VBox/vmm/pdmnetshaper.h>
     29#endif
     30#ifdef VBOX_WITH_PDM_ASYNC_COMPLETION
     31# include <VBox/vmm/pdmasynccompletion.h>
     32#endif
    3033#include <VBox/vmm/pdmblkcache.h>
    3134#include <VBox/vmm/pdmcommon.h>
     
    12081211int         pdmR3AsyncCompletionTerm(PVM pVM);
    12091212void        pdmR3AsyncCompletionResume(PVM pVM);
     1213int         pdmR3AsyncCompletionTemplateCreateDevice(PVM pVM, PPDMDEVINS pDevIns, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate, PFNPDMASYNCCOMPLETEDEV pfnCompleted, const char *pszDesc);
     1214int         pdmR3AsyncCompletionTemplateCreateDriver(PVM pVM, PPDMDRVINS pDrvIns, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate,
     1215                                                     PFNPDMASYNCCOMPLETEDRV pfnCompleted, void *pvTemplateUser, const char *pszDesc);
     1216int         pdmR3AsyncCompletionTemplateCreateUsb(PVM pVM, PPDMUSBINS pUsbIns, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate, PFNPDMASYNCCOMPLETEUSB pfnCompleted, const char *pszDesc);
     1217int         pdmR3AsyncCompletionTemplateDestroyDevice(PVM pVM, PPDMDEVINS pDevIns);
     1218int         pdmR3AsyncCompletionTemplateDestroyDriver(PVM pVM, PPDMDRVINS pDrvIns);
     1219int         pdmR3AsyncCompletionTemplateDestroyUsb(PVM pVM, PPDMUSBINS pUsbIns);
    12101220#endif
    12111221
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