- Timestamp:
- Dec 15, 2008 2:36:30 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 40984
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/sup.h
r15397 r15505 839 839 SUPR0DECL(void *) SUPR0ObjRegister(PSUPDRVSESSION pSession, SUPDRVOBJTYPE enmType, PFNSUPDRVDESTRUCTOR pfnDestructor, void *pvUser1, void *pvUser2); 840 840 SUPR0DECL(int) SUPR0ObjAddRef(void *pvObj, PSUPDRVSESSION pSession); 841 SUPR0DECL(int) SUPR0ObjAddRefEx(void *pvObj, PSUPDRVSESSION pSession, bool fNoBlocking); 841 842 SUPR0DECL(int) SUPR0ObjRelease(void *pvObj, PSUPDRVSESSION pSession); 842 843 SUPR0DECL(int) SUPR0ObjVerifyAccess(void *pvObj, PSUPDRVSESSION pSession, const char *pszObjName); -
trunk/src/VBox/Devices/Network/SrvIntNetR0.cpp
r14695 r15505 537 537 DECLINLINE(int) intnetR0IfRetain(PINTNETIF pIf, PSUPDRVSESSION pSession) 538 538 { 539 int rc = SUPR0ObjAddRef (pIf->pvObj, pSession);539 int rc = SUPR0ObjAddRefEx(pIf->pvObj, pSession, true /* fNoBlocking */); 540 540 AssertRCReturn(rc, rc); 541 541 return VINF_SUCCESS; … … 2001 2001 || cbPacket < cbIpHdr + RTNETUDP_MIN_LEN + RTNETBOOTP_DHCP_MIN_LEN) /* Min DHCP packet len */ 2002 2002 return; 2003 2003 2004 2004 size_t cbUdpPkt = cbPacket - cbIpHdr; 2005 2005 PCRTNETUDP pUdpHdr = (PCRTNETUDP)((uintptr_t)pIpHdr + cbIpHdr); -
trunk/src/VBox/Devices/Network/testcase/tstIntNetR0.cpp
r14831 r15505 130 130 } 131 131 132 INTNETR3DECL(int) SUPR0ObjAddRef (void *pvObj, PSUPDRVSESSION pSession)132 INTNETR3DECL(int) SUPR0ObjAddRefEx(void *pvObj, PSUPDRVSESSION pSession, bool fNoBlocking) 133 133 { 134 134 if (pSession != g_pSession) … … 141 141 ASMAtomicIncU32(&pRef->cRefs); 142 142 return VINF_SUCCESS; 143 } 144 145 INTNETR3DECL(int) SUPR0ObjAddRef(void *pvObj, PSUPDRVSESSION pSession) 146 { 147 return SUPR0ObjAddRefEx(pvObj, pSession, false); 143 148 } 144 149 -
trunk/src/VBox/HostDrivers/Support/SUPDrv.c
r15212 r15505 161 161 DECLASM(void *) UNWIND_WRAP(SUPR0ObjRegister)(PSUPDRVSESSION pSession, SUPDRVOBJTYPE enmType, PFNSUPDRVDESTRUCTOR pfnDestructor, void *pvUser1, void *pvUser2); 162 162 DECLASM(int) UNWIND_WRAP(SUPR0ObjAddRef)(void *pvObj, PSUPDRVSESSION pSession); 163 DECLASM(int) UNWIND_WRAP(SUPR0ObjAddRefEx)(void *pvObj, PSUPDRVSESSION pSession, bool fNoPreempt); 163 164 DECLASM(int) UNWIND_WRAP(SUPR0ObjRelease)(void *pvObj, PSUPDRVSESSION pSession); 164 165 DECLASM(int) UNWIND_WRAP(SUPR0ObjVerifyAccess)(void *pvObj, PSUPDRVSESSION pSession, const char *pszObjName); … … 296 297 { "SUPR0ObjRegister", (void *)UNWIND_WRAP(SUPR0ObjRegister) }, 297 298 { "SUPR0ObjAddRef", (void *)UNWIND_WRAP(SUPR0ObjAddRef) }, 299 { "SUPR0ObjAddRefEx", (void *)UNWIND_WRAP(SUPR0ObjAddRefEx) }, 298 300 { "SUPR0ObjRelease", (void *)UNWIND_WRAP(SUPR0ObjRelease) }, 299 301 { "SUPR0ObjVerifyAccess", (void *)UNWIND_WRAP(SUPR0ObjVerifyAccess) }, … … 1725 1727 /* 1726 1728 * Allocate the usage record. 1727 * (We keep freed usage records around to simplify SUPR0ObjAddRef ().)1729 * (We keep freed usage records around to simplify SUPR0ObjAddRefEx().) 1728 1730 */ 1729 1731 RTSpinlockAcquire(pDevExt->Spinlock, &SpinlockTmp); … … 1779 1781 SUPR0DECL(int) SUPR0ObjAddRef(void *pvObj, PSUPDRVSESSION pSession) 1780 1782 { 1783 return SUPR0ObjAddRefEx(pvObj, pSession, false /* fNoBlocking */); 1784 } 1785 1786 1787 /** 1788 * Increment the reference counter for the object associating the reference 1789 * with the specified session. 1790 * 1791 * @returns IPRT status code. 1792 * @retval VERR_TRY_AGAIN if fNoBlocking was set and a new usage record 1793 * couldn't be allocated. (If you see this you're not doing the right 1794 * thing and it won't ever work reliably.) 1795 * 1796 * @param pvObj The identifier returned by SUPR0ObjRegister(). 1797 * @param pSession The session which is referencing the object. 1798 * @param fNoBlocking Set if it's not OK to block. Never try to make the 1799 * first reference to an object in a session with this 1800 * argument set. 1801 * 1802 * @remarks The caller should not own any spinlocks and must carefully protect 1803 * itself against potential race with the destructor so freed memory 1804 * isn't accessed here. 1805 */ 1806 SUPR0DECL(int) SUPR0ObjAddRefEx(void *pvObj, PSUPDRVSESSION pSession, bool fNoBlocking) 1807 { 1781 1808 RTSPINLOCKTMP SpinlockTmp = RTSPINLOCKTMP_INITIALIZER; 1782 1809 PSUPDRVDEVEXT pDevExt = pSession->pDevExt; 1783 1810 PSUPDRVOBJ pObj = (PSUPDRVOBJ)pvObj; 1811 int rc = VINF_SUCCESS; 1784 1812 PSUPDRVUSAGE pUsagePre; 1785 1813 PSUPDRVUSAGE pUsage; … … 1807 1835 1808 1836 /* 1809 * Preallocate the usage record .1837 * Preallocate the usage record if we can. 1810 1838 */ 1811 1839 pUsagePre = pDevExt->pUsageFree; 1812 1840 if (pUsagePre) 1813 1841 pDevExt->pUsageFree = pUsagePre->pNext; 1814 else 1842 else if (!fNoBlocking) 1815 1843 { 1816 1844 RTSpinlockRelease(pDevExt->Spinlock, &SpinlockTmp); … … 1820 1848 1821 1849 RTSpinlockAcquire(pDevExt->Spinlock, &SpinlockTmp); 1850 if (RT_UNLIKELY(pObj->u32Magic != SUPDRVOBJ_MAGIC)) 1851 { 1852 RTSpinlockRelease(pDevExt->Spinlock, &SpinlockTmp); 1853 1854 AssertMsgFailed(("pvObj=%p magic=%#x\n", pvObj, pObj->u32Magic)); 1855 return VERR_WRONG_ORDER; 1856 } 1822 1857 } 1823 1858 … … 1838 1873 if (pUsage) 1839 1874 pUsage->cUsage++; 1840 else 1875 else if (pUsagePre) 1841 1876 { 1842 1877 /* create a new session record. */ … … 1849 1884 pUsagePre = NULL; 1850 1885 } 1886 else 1887 { 1888 pObj->cUsage--; 1889 rc = VERR_TRY_AGAIN; 1890 } 1851 1891 1852 1892 /* … … 1861 1901 RTSpinlockRelease(pDevExt->Spinlock, &SpinlockTmp); 1862 1902 1863 return VINF_SUCCESS;1903 return rc; 1864 1904 } 1865 1905 … … 1972 2012 } 1973 2013 2014 1974 2015 /** 1975 2016 * Verifies that the current process can access the specified object. -
trunk/src/VBox/HostDrivers/Support/SUPDrvIOC.h
r14901 r15505 188 188 * and renaming the related IOCtls too. 189 189 */ 190 #define SUPDRV_IOC_VERSION 0x000a000 7190 #define SUPDRV_IOC_VERSION 0x000a0008 191 191 192 192 /** SUP_IOCTL_COOKIE. */ -
trunk/src/VBox/HostDrivers/Support/SUPLib.cpp
r15351 r15505 261 261 CookieReq.u.In.u32ReqVersion = SUPDRV_IOC_VERSION; 262 262 const uint32_t MinVersion = (SUPDRV_IOC_VERSION & 0xffff0000) == 0x000a0000 263 ? 0x000a000 7263 ? 0x000a0008 264 264 : SUPDRV_IOC_VERSION & 0xffff0000; 265 265 CookieReq.u.In.u32MinVersion = MinVersion; … … 389 389 { "SUPR0ObjRegister", 0xefef0000 }, 390 390 { "SUPR0ObjAddRef", 0xefef0001 }, 391 { "SUPR0ObjAddRefEx", 0xefef0001 }, 391 392 { "SUPR0ObjRelease", 0xefef0002 }, 392 393 { "SUPR0ObjVerifyAccess", 0xefef0003 }, -
trunk/src/VBox/HostDrivers/Support/SUPR0.def
r14901 r15505 41 41 SUPR0ObjRegister 42 42 SUPR0ObjAddRef 43 SUPR0ObjAddRefEx 43 44 SUPR0ObjRelease 44 45 SUPR0ObjVerifyAccess -
trunk/src/VBox/HostDrivers/Support/win/SUPDrvA-win.asm
r14825 r15505 60 60 NtWrapDyn2DrvFunctionWith5Params supdrvNtWrap, SUPR0ObjRegister 61 61 NtWrapDyn2DrvFunctionWithAllRegParams supdrvNtWrap, SUPR0ObjAddRef 62 NtWrapDyn2DrvFunctionWithAllRegParams supdrvNtWrap, SUPR0ObjAddRefEx 62 63 NtWrapDyn2DrvFunctionWithAllRegParams supdrvNtWrap, SUPR0ObjRelease 63 64 NtWrapDyn2DrvFunctionWithAllRegParams supdrvNtWrap, SUPR0ObjVerifyAccess
Note:
See TracChangeset
for help on using the changeset viewer.