Changeset 60375 in vbox for trunk/src/VBox/ValidationKit
- Timestamp:
- Apr 7, 2016 2:42:20 PM (9 years ago)
- Location:
- trunk/src/VBox/ValidationKit/utils/usb
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/utils/usb/Makefile.kmk
r60324 r60375 46 46 UsbTestServiceCfg.cpp \ 47 47 UsbTestServiceGadgetCfg.cpp \ 48 UsbTestServiceGadgetClassTest.cpp \ 48 49 UsbTestServiceGadgetHost.cpp \ 49 50 UsbTestServiceGadgetHostUsbIp.cpp \ -
trunk/src/VBox/ValidationKit/utils/usb/UsbTestServiceGadget.cpp
r60326 r60375 21 21 *********************************************************************************************************************************/ 22 22 23 #include <iprt/asm.h> 23 24 #include <iprt/cdefs.h> 24 25 #include <iprt/ctype.h> … … 27 28 #include <iprt/types.h> 28 29 29 #include "UsbTestServiceGadget.h" 30 30 #include "UsbTestServiceGadgetInternal.h" 31 31 32 32 /********************************************************************************************************************************* … … 34 34 *********************************************************************************************************************************/ 35 35 36 /** 37 * Internal UTS gadget host instance data. 38 */ 39 typedef struct UTSGADGETINT 40 { 41 /** Reference counter. */ 42 volatile uint32_t cRefs; 43 /** Pointer to the gadget class callback table. */ 44 PCUTSGADGETCLASSIF pClassIf; 45 /** The gadget host handle. */ 46 UTSGADGETHOST hGadgetHost; 47 /** Class specific instance data - variable in size. */ 48 uint8_t abClassInst[1]; 49 } UTSGADGETINT; 50 /** Pointer to the internal gadget host instance data. */ 51 typedef UTSGADGETINT *PUTSGADGETINT; 52 53 54 /********************************************************************************************************************************* 55 * Global variables * 56 *********************************************************************************************************************************/ 57 58 /** Known gadget host interfaces. */ 59 static const PCUTSGADGETCLASSIF g_apUtsGadgetClass[] = 60 { 61 &g_UtsGadgetClassTest 62 }; 63 36 64 37 65 /********************************************************************************************************************************* 38 66 * Internal Functions * 39 67 *********************************************************************************************************************************/ 68 69 70 /** 71 * Destroys a gadget instance. 72 * 73 * @returns nothing. 74 * @param pThis The gadget instance. 75 */ 76 static void utsGadgetDestroy(PUTSGADGETINT pThis) 77 { 78 pThis->pClassIf->pfnTerm((PUTSGADGETCLASSINT)&pThis->abClassInst[0]); 79 RTMemFree(pThis); 80 } 81 82 83 DECLHIDDEN(int) utsGadgetCreate(UTSGADGETHOST hGadgetHost, UTSGADGETCLASS enmClass, 84 PCUTSGADGETCFGITEM paCfg, PUTSGADET phGadget) 85 { 86 int rc = VINF_SUCCESS; 87 PCUTSGADGETCLASSIF pClassIf = NULL; 88 89 /* Get the interface. */ 90 for (unsigned i = 0; i < RT_ELEMENTS(g_apUtsGadgetClass); i++) 91 { 92 if (g_apUtsGadgetClass[i]->enmClass == enmClass) 93 { 94 pClassIf = g_apUtsGadgetClass[i]; 95 break; 96 } 97 } 98 99 if (RT_LIKELY(pClassIf)) 100 { 101 PUTSGADGETINT pThis = (PUTSGADGETINT)RTMemAllocZ(RT_OFFSETOF(UTSGADGETINT, abClassInst[pClassIf->cbClass])); 102 if (RT_LIKELY(pThis)) 103 { 104 pThis->cRefs = 1; 105 pThis->hGadgetHost = hGadgetHost; 106 pThis->pClassIf = pClassIf; 107 rc = pClassIf->pfnInit((PUTSGADGETCLASSINT)&pThis->abClassInst[0], paCfg); 108 if (RT_SUCCESS(rc)) 109 *phGadget = pThis; 110 else 111 RTMemFree(pThis); 112 } 113 else 114 rc = VERR_NO_MEMORY; 115 } 116 else 117 rc = VERR_INVALID_PARAMETER; 118 119 return rc; 120 } 121 122 123 DECLHIDDEN(uint32_t) utsGadgetRetain(UTSGADGET hGadget) 124 { 125 PUTSGADGETINT pThis = hGadget; 126 127 AssertPtrReturn(pThis, 0); 128 129 return ASMAtomicIncU32(&pThis->cRefs); 130 } 131 132 133 DECLHIDDEN(uint32_t) utsGadgetRelease(UTSGADGET hGadget) 134 { 135 PUTSGADGETINT pThis = hGadget; 136 137 AssertPtrReturn(pThis, 0); 138 139 uint32_t cRefs = ASMAtomicDecU32(&pThis->cRefs); 140 if (!cRefs) 141 utsGadgetDestroy(pThis); 142 143 return cRefs; 144 } 145 -
trunk/src/VBox/ValidationKit/utils/usb/UsbTestServiceGadgetHost.cpp
r60324 r60375 141 141 return cRefs; 142 142 } 143 -
trunk/src/VBox/ValidationKit/utils/usb/UsbTestServiceGadgetHostUsbIp.cpp
r60325 r60375 158 158 { 159 159 /* Nothing to do so far. */ 160 return VINF_SUCCESS; 160 return VINF_SUCCESS; 161 161 } 162 162 … … 167 167 static DECLCALLBACK(int) utsGadgetHostUsbIpGadgetConnect(PUTSGADGETHOSTTYPEINT pIf, UTSGADGET hGadget) 168 168 { 169 return VINF_SUCCESS; 169 return VINF_SUCCESS; 170 170 } 171 171
Note:
See TracChangeset
for help on using the changeset viewer.