Changeset 28263 in vbox
- Timestamp:
- Apr 13, 2010 3:55:36 PM (15 years ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/PDMAsyncCompletion.cpp
r28262 r28263 151 151 * Add template to the global VM template list. 152 152 */ 153 RTCritSectEnter(&pUVM->pdm.s.ListCritSect); 153 154 pTemplate->pNext = pUVM->pdm.s.pAsyncCompletionTemplates; 154 155 if (pUVM->pdm.s.pAsyncCompletionTemplates) 155 156 pUVM->pdm.s.pAsyncCompletionTemplates->pPrev = pTemplate; 156 157 pUVM->pdm.s.pAsyncCompletionTemplates = pTemplate; 158 RTCritSectLeave(&pUVM->pdm.s.ListCritSect); 157 159 158 160 *ppTemplate = pTemplate; … … 398 400 */ 399 401 PUVM pUVM = pTemplate->pVM->pUVM; 402 RTCritSectEnter(&pUVM->pdm.s.ListCritSect); 403 400 404 PPDMASYNCCOMPLETIONTEMPLATE pPrev = pTemplate->pPrev; 401 405 PPDMASYNCCOMPLETIONTEMPLATE pNext = pTemplate->pNext; … … 409 413 pNext->pPrev = pPrev; 410 414 415 RTCritSectLeave(&pUVM->pdm.s.ListCritSect); 416 411 417 /* 412 418 * Free the template. … … 441 447 * Unlink it. 442 448 */ 443 PPDMASYNCCOMPLETIONTEMPLATE pTemplate = pVM->pUVM->pdm.s.pAsyncCompletionTemplates; 449 PUVM pUVM = pVM->pUVM; 450 RTCritSectEnter(&pUVM->pdm.s.ListCritSect); 451 PPDMASYNCCOMPLETIONTEMPLATE pTemplate = pUVM->pdm.s.pAsyncCompletionTemplates; 444 452 while (pTemplate) 445 453 { … … 451 459 int rc = PDMR3AsyncCompletionTemplateDestroy(pTemplateDestroy); 452 460 if (RT_FAILURE(rc)) 461 { 462 RTCritSectLeave(&pUVM->pdm.s.ListCritSect); 453 463 return rc; 464 } 454 465 } 455 466 else … … 457 468 } 458 469 470 RTCritSectLeave(&pUVM->pdm.s.ListCritSect); 459 471 return VINF_SUCCESS; 460 472 } … … 484 496 * Unlink it. 485 497 */ 486 PPDMASYNCCOMPLETIONTEMPLATE pTemplate = pVM->pUVM->pdm.s.pAsyncCompletionTemplates; 498 PUVM pUVM = pVM->pUVM; 499 RTCritSectEnter(&pUVM->pdm.s.ListCritSect); 500 PPDMASYNCCOMPLETIONTEMPLATE pTemplate = pUVM->pdm.s.pAsyncCompletionTemplates; 487 501 while (pTemplate) 488 502 { … … 494 508 int rc = PDMR3AsyncCompletionTemplateDestroy(pTemplateDestroy); 495 509 if (RT_FAILURE(rc)) 510 { 511 RTCritSectLeave(&pUVM->pdm.s.ListCritSect); 496 512 return rc; 513 } 497 514 } 498 515 else … … 500 517 } 501 518 519 RTCritSectLeave(&pUVM->pdm.s.ListCritSect); 502 520 return VINF_SUCCESS; 503 521 } … … 527 545 * Unlink it. 528 546 */ 529 PPDMASYNCCOMPLETIONTEMPLATE pTemplate = pVM->pUVM->pdm.s.pAsyncCompletionTemplates; 547 PUVM pUVM = pVM->pUVM; 548 RTCritSectEnter(&pUVM->pdm.s.ListCritSect); 549 PPDMASYNCCOMPLETIONTEMPLATE pTemplate = pUVM->pdm.s.pAsyncCompletionTemplates; 530 550 while (pTemplate) 531 551 { … … 537 557 int rc = PDMR3AsyncCompletionTemplateDestroy(pTemplateDestroy); 538 558 if (RT_FAILURE(rc)) 559 { 560 RTCritSectLeave(&pUVM->pdm.s.ListCritSect); 539 561 return rc; 562 } 540 563 } 541 564 else … … 543 566 } 544 567 568 RTCritSectLeave(&pUVM->pdm.s.ListCritSect); 545 569 return VINF_SUCCESS; 546 570 } … … 631 655 { 632 656 PUVM pUVM = pVM->pUVM; 633 AssertMsg(!pUVM->pdm.s. papAsyncCompletionEndpointClass[pEpClassOps->enmClassType],657 AssertMsg(!pUVM->pdm.s.apAsyncCompletionEndpointClass[pEpClassOps->enmClassType], 634 658 ("Endpoint class was already initialized\n")); 635 659 636 pUVM->pdm.s. papAsyncCompletionEndpointClass[pEpClassOps->enmClassType] = pEndpointClass;660 pUVM->pdm.s.apAsyncCompletionEndpointClass[pEpClassOps->enmClassType] = pEndpointClass; 637 661 LogFlowFunc((": Initialized endpoint class \"%s\" rc=%Rrc\n", pEpClassOps->pcszName, rc)); 638 662 return VINF_SUCCESS; … … 674 698 675 699 /* Free the memory of the class finally and clear the entry in the class array. */ 676 pVM->pUVM->pdm.s. papAsyncCompletionEndpointClass[pEndpointClass->pEndpointOps->enmClassType] = NULL;700 pVM->pUVM->pdm.s.apAsyncCompletionEndpointClass[pEndpointClass->pEndpointOps->enmClassType] = NULL; 677 701 MMR3HeapFree(pEndpointClass); 678 702 } … … 693 717 VM_ASSERT_EMT(pVM); 694 718 695 do 696 { 697 /* Allocate array for global class data. */ 698 rc = MMR3HeapAllocZEx(pVM, MM_TAG_PDM_ASYNC_COMPLETION, 699 sizeof(PPDMASYNCCOMPLETIONEPCLASS) * PDMASYNCCOMPLETIONEPCLASSTYPE_MAX, 700 (void **)&pUVM->pdm.s.papAsyncCompletionEndpointClass); 701 if (RT_FAILURE(rc)) 702 break; 703 704 PCFGMNODE pCfgRoot = CFGMR3GetRoot(pVM); 705 PCFGMNODE pCfgAsyncCompletion = CFGMR3GetChild(CFGMR3GetChild(pCfgRoot, "PDM"), "AsyncCompletion"); 706 707 rc = pdmR3AsyncCompletionEpClassInit(pVM, &g_PDMAsyncCompletionEndpointClassFile, pCfgAsyncCompletion); 708 if (RT_FAILURE(rc)) 709 break; 710 711 /* Put other classes here. */ 712 } while (0); 719 PCFGMNODE pCfgRoot = CFGMR3GetRoot(pVM); 720 PCFGMNODE pCfgAsyncCompletion = CFGMR3GetChild(CFGMR3GetChild(pCfgRoot, "PDM"), "AsyncCompletion"); 721 722 rc = pdmR3AsyncCompletionEpClassInit(pVM, &g_PDMAsyncCompletionEndpointClassFile, pCfgAsyncCompletion); 713 723 714 724 LogFlowFunc((": pVM=%p rc=%Rrc\n", pVM, rc)); … … 728 738 PUVM pUVM = pVM->pUVM; 729 739 730 if (pUVM->pdm.s.papAsyncCompletionEndpointClass) 731 { 732 pdmR3AsyncCompletionEpClassTerminate(pUVM->pdm.s.papAsyncCompletionEndpointClass[PDMASYNCCOMPLETIONEPCLASSTYPE_FILE]); 733 MMR3HeapFree(pUVM->pdm.s.papAsyncCompletionEndpointClass); 734 } 740 for (size_t i = 0; i < RT_ELEMENTS(pUVM->pdm.s.apAsyncCompletionEndpointClass); i++) 741 if (pUVM->pdm.s.apAsyncCompletionEndpointClass[i]) 742 pdmR3AsyncCompletionEpClassTerminate(pUVM->pdm.s.apAsyncCompletionEndpointClass[i]); 743 735 744 return VINF_SUCCESS; 736 745 } … … 880 889 PVM pVM = pTemplate->pVM; 881 890 PUVM pUVM = pVM->pUVM; 882 PPDMASYNCCOMPLETIONEPCLASS pEndpointClass = pUVM->pdm.s. papAsyncCompletionEndpointClass[PDMASYNCCOMPLETIONEPCLASSTYPE_FILE];891 PPDMASYNCCOMPLETIONEPCLASS pEndpointClass = pUVM->pdm.s.apAsyncCompletionEndpointClass[PDMASYNCCOMPLETIONEPCLASSTYPE_FILE]; 883 892 PPDMASYNCCOMPLETIONENDPOINT pEndpoint = NULL; 884 893 -
trunk/src/VBox/VMM/PDMAsyncCompletionInternal.h
r28065 r28263 5 5 6 6 /* 7 * Copyright (C) 2006-20 08Sun Microsystems, Inc.7 * Copyright (C) 2006-2010 Sun Microsystems, Inc. 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 19 19 * additional information or have any questions. 20 20 */ 21 #ifndef __PDMAsyncCompletionInternal_h 22 #define __PDMAsyncCompletionInternal_h 23 24 #include "PDMInternal.h" 25 #include <iprt/cdefs.h> 21 22 #ifndef ___PDMAsyncCompletionInternal_h 23 #define ___PDMAsyncCompletionInternal_h 24 26 25 #include <iprt/critsect.h> 27 26 #include <iprt/memcache.h> … … 31 30 #include <VBox/stam.h> 32 31 #include <VBox/pdmasynccompletion.h> 32 #include "PDMInternal.h" 33 33 34 34 RT_C_DECLS_BEGIN 35 35 36 /**37 * Supported endpoint classes.38 */39 typedef enum PDMASYNCCOMPLETIONEPCLASSTYPE40 {41 /** File class. */42 PDMASYNCCOMPLETIONEPCLASSTYPE_FILE = 0,43 /** Number of supported classes. */44 PDMASYNCCOMPLETIONEPCLASSTYPE_MAX,45 /** 32bit hack. */46 PDMASYNCCOMPLETIONEPCLASSTYPE_32BIT_HACK = 0x7fffffff47 } PDMASYNCCOMPLETIONEPCLASSTYPE;48 36 49 37 /** … … 274 262 extern const PDMASYNCCOMPLETIONEPCLASSOPS g_PDMAsyncCompletionEndpointClassFile; 275 263 276 #endif /* __PDMAsyncCompletionInternal_h */ 264 #endif /* !___PDMAsyncCompletionInternal_h */ 265 -
trunk/src/VBox/VMM/PDMInternal.h
r28262 r28263 91 91 /** Pointer to an USB HUB registration record. */ 92 92 typedef struct PDMUSBHUB *PPDMUSBHUB; 93 94 /** 95 * Supported asynchronous completion endpoint classes. 96 */ 97 typedef enum PDMASYNCCOMPLETIONEPCLASSTYPE 98 { 99 /** File class. */ 100 PDMASYNCCOMPLETIONEPCLASSTYPE_FILE = 0, 101 /** Number of supported classes. */ 102 PDMASYNCCOMPLETIONEPCLASSTYPE_MAX, 103 /** 32bit hack. */ 104 PDMASYNCCOMPLETIONEPCLASSTYPE_32BIT_HACK = 0x7fffffff 105 } PDMASYNCCOMPLETIONEPCLASSTYPE; 93 106 94 107 /** … … 1000 1013 1001 1014 1015 1002 1016 /** 1003 1017 * PDM data kept in the UVM. … … 1016 1030 /** Tail of the PDM Thread list. (singly linked) */ 1017 1031 R3PTRTYPE(PPDMTHREAD) pThreadsTail; 1018 1019 /** @name PDM Async Completion1020 * @{ */1021 /** Pointer to the array of supported endpoint classes. */1022 R3PTRTYPE(PPDMASYNCCOMPLETIONEPCLASS *) papAsyncCompletionEndpointClass;1023 /** Head of the templates. (singly linked) */1024 R3PTRTYPE(PPDMASYNCCOMPLETIONTEMPLATE) pAsyncCompletionTemplates;1025 /** @} */1026 1032 1027 1033 /** Lock protecting the lists below it. */ … … 1031 1037 /** List of initialized critical sections. (LIFO) */ 1032 1038 R3PTRTYPE(PPDMCRITSECTINT) pCritSects; 1039 1040 /** @name PDM Async Completion 1041 * @{ */ 1042 /** Pointer to the array of supported endpoint classes. */ 1043 PPDMASYNCCOMPLETIONEPCLASS apAsyncCompletionEndpointClass[PDMASYNCCOMPLETIONEPCLASSTYPE_MAX]; 1044 /** Head of the templates. Singly linked, protected by ListCritSect. */ 1045 R3PTRTYPE(PPDMASYNCCOMPLETIONTEMPLATE) pAsyncCompletionTemplates; 1046 /** @} */ 1033 1047 1034 1048 } PDMUSERPERVM;
Note:
See TracChangeset
for help on using the changeset viewer.