/** @interface_method_impl{PDMPCIHLPR0,pfnIoApicSetIrq} */ static DECLCALLBACK(void) pdmR0PciHlp_IoApicSetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel, uint32_t uTagSrc) { PDMDEV_ASSERT_DEVINS(pDevIns); Log4(("pdmR0PciHlp_IoApicSetIrq: iIrq=%d iLevel=%d uTagSrc=%#x\n", iIrq, iLevel, uTagSrc)); PVM pVM = pDevIns->Internal.s.pVMR0; if (pVM->pdm.s.IoApic.pDevInsR0) { pdmLock(pVM); pVM->pdm.s.IoApic.pfnSetIrqR0(pVM->pdm.s.IoApic.pDevInsR0, iIrq, iLevel, uTagSrc); pdmUnlock(pVM); } else if (pVM->pdm.s.IoApic.pDevInsR3) { /* queue for ring-3 execution. */ PPDMDEVHLPTASK pTask = (PPDMDEVHLPTASK)PDMQueueAlloc(pVM->pdm.s.pDevHlpQueueR0); if (pTask) { pTask->enmOp = PDMDEVHLPTASKOP_IOAPIC_SET_IRQ; pTask->pDevInsR3 = NIL_RTR3PTR; /* not required */ pTask->u.SetIRQ.iIrq = iIrq; pTask->u.SetIRQ.iLevel = iLevel; pTask->u.SetIRQ.uTagSrc = uTagSrc; PDMQueueInsertEx(pVM->pdm.s.pDevHlpQueueR0, &pTask->Core, 0); } else AssertMsgFailed(("We're out of devhlp queue items!!!\n")); } }
/** @interface_method_impl{PDMPCIHLPR3,pfnIsaSetIrq} */ static DECLCALLBACK(void) pdmR3PciHlp_IsaSetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel, uint32_t uTagSrc) { PDMDEV_ASSERT_DEVINS(pDevIns); Log4(("pdmR3PciHlp_IsaSetIrq: iIrq=%d iLevel=%d uTagSrc=%#x\n", iIrq, iLevel, uTagSrc)); PVM pVM = pDevIns->Internal.s.pVMR3; PDMIsaSetIrq(pDevIns->Internal.s.pVMR3, iIrq, iLevel, uTagSrc); }
/* * Unmap a range of virtual memory. Note that the size asked for here * is literally what the upper level has asked for. We need to do any * rounding, etc. here. If unmapping fails return 0, otherwise return * the address of the base of the unmapped memory. */ void * sysUnmapMem(void *requestedAddr, size_t requestedSize, size_t *unmappedSize) { void *unmappedAddr; int ret; *unmappedSize = roundUpToGrain(requestedSize); #ifdef USE_MALLOC sysFree(requestedAddr); ret = 1; #else ret = unmapChunk(requestedAddr, *unmappedSize); #endif /* USE_MALLOC */ if (ret) { unmappedAddr = requestedAddr; Log4(2, "sysUnmapMem: 0x%x bytes at 0x%x (request: 0x%x bytes at 0x%x)\n", *unmappedSize, unmappedAddr, requestedSize, requestedAddr); } else { unmappedAddr = 0; Log2(2, "sysUnmapMem failed: (request: 0x%x bytes at 0x%x)\n", requestedSize, requestedAddr); } return unmappedAddr; }
/* * Return the address of the base of the newly committed memory, or 0 * if committing failed. */ void * sysCommitMem(void *requestedAddr, size_t requestedSize, size_t *committedSize) { void *committedAddr; char *ret; *committedSize = roundUpToGrain(requestedSize); committedAddr = (void *) roundDownToGrain((long) requestedAddr); #ifdef USE_MALLOC #ifdef __linux__ ret = committedAddr; #else ret = requestedAddr; #endif #else ret = mapChunkReserve(committedAddr, *committedSize); #endif if (ret) { committedAddr = ret; Log4(2, "sysCommitMem: 0x%x bytes at 0x%x (request: 0x%x bytes at 0x%x)\n", *committedSize, committedAddr, requestedSize, requestedAddr); } else { committedAddr = 0; Log2(2, "sysCommitMem failed: (request: 0x%x bytes at 0x%x)\n", requestedSize, requestedAddr); } return committedAddr; }
/** @interface_method_impl{PDMPCIHLPR3,pfnIsMMIOExBase} */ static DECLCALLBACK(bool) pdmR3PciHlp_IsMMIO2Base(PPDMDEVINS pDevIns, PPDMDEVINS pOwner, RTGCPHYS GCPhys) { PDMDEV_ASSERT_DEVINS(pDevIns); VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3); bool fRc = PGMR3PhysMMIOExIsBase(pDevIns->Internal.s.pVMR3, pOwner, GCPhys); Log4(("pdmR3PciHlp_IsMMIOExBase: pOwner=%p GCPhys=%RGp -> %RTbool\n", pOwner, GCPhys, fRc)); return fRc; }
static int trace_response( Operation *op, SlapReply *rs ) { char *op_str = NULL; (void)trace_op2str( op, &op_str ); switch ( op->o_tag ) { case LDAP_REQ_EXTENDED: Log5( LDAP_DEBUG_ANY, LDAP_LEVEL_INFO, "%s trace op=EXTENDED RESPONSE dn=\"%s\" reqoid=%s rspoid=%s err=%d\n", op->o_log_prefix, BER_BVISNULL( &op->o_req_ndn ) ? "(null)" : op->o_req_ndn.bv_val, BER_BVISNULL( &op->ore_reqoid ) ? "" : op->ore_reqoid.bv_val, rs->sr_rspoid == NULL ? "" : rs->sr_rspoid, rs->sr_err ); break; case LDAP_REQ_SEARCH: switch ( rs->sr_type ) { case REP_SEARCH: Log2( LDAP_DEBUG_ANY, LDAP_LEVEL_INFO, "%s trace op=SEARCH ENTRY dn=\"%s\"\n", op->o_log_prefix, rs->sr_entry->e_name.bv_val ); goto done; case REP_SEARCHREF: Log2( LDAP_DEBUG_ANY, LDAP_LEVEL_INFO, "%s trace op=SEARCH REFERENCE ref=\"%s\"\n", op->o_log_prefix, rs->sr_ref[ 0 ].bv_val ); goto done; case REP_RESULT: break; default: assert( 0 ); } /* fallthru */ default: Log4( LDAP_DEBUG_ANY, LDAP_LEVEL_INFO, "%s trace op=%s RESPONSE dn=\"%s\" err=%d\n", op->o_log_prefix, op_str, BER_BVISNULL( &op->o_req_ndn ) ? "(null)" : op->o_req_ndn.bv_val, rs->sr_err ); break; } done: ; return SLAP_CB_CONTINUE; }
/*@null@*/ static struct _driverTracker *get_driver(struct udev_device *dev, const char *devpath, struct _driverTracker **classdriver) { int i; unsigned int idVendor, idProduct; static struct _driverTracker *driver; const char *str; str = udev_device_get_sysattr_value(dev, "idVendor"); if (!str) { Log1(PCSC_LOG_ERROR, "udev_device_get_sysattr_value() failed"); return NULL; } sscanf(str, "%X", &idVendor); str = udev_device_get_sysattr_value(dev, "idProduct"); if (!str) { Log1(PCSC_LOG_ERROR, "udev_device_get_sysattr_value() failed"); return NULL; } sscanf(str, "%X", &idProduct); Log4(PCSC_LOG_DEBUG, "Looking for a driver for VID: 0x%04X, PID: 0x%04X, path: %s", idVendor, idProduct, devpath); *classdriver = NULL; driver = NULL; /* check if the device is supported by one driver */ for (i=0; i<driverSize; i++) { if (driverTracker[i].libraryPath != NULL && idVendor == driverTracker[i].manuID && idProduct == driverTracker[i].productID) { if ((driverTracker[i].CFBundleName != NULL) && (0 == strcmp(driverTracker[i].CFBundleName, "CCIDCLASSDRIVER"))) *classdriver = &driverTracker[i]; else /* it is not a CCID Class driver */ driver = &driverTracker[i]; } } /* if we found a specific driver */ if (driver) return driver; /* else return the Class driver (if any) */ return *classdriver; }
/** @interface_method_impl{PDMPCIHLPR0,pfnIoApicSendMsi} */ static DECLCALLBACK(void) pdmR0PciHlp_IoApicSendMsi(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t uValue, uint32_t uTagSrc) { PDMDEV_ASSERT_DEVINS(pDevIns); Log4(("pdmR0PciHlp_IoApicSendMsi: GCPhys=%p uValue=%d uTagSrc=%#x\n", GCPhys, uValue, uTagSrc)); PVM pVM = pDevIns->Internal.s.pVMR0; if (pVM->pdm.s.IoApic.pDevInsR0) { pdmLock(pVM); pVM->pdm.s.IoApic.pfnSendMsiR0(pVM->pdm.s.IoApic.pDevInsR0, GCPhys, uValue, uTagSrc); pdmUnlock(pVM); } else { AssertFatalMsgFailed(("Lazy bastards!")); } }
static LONG MSGAddHandle(SCARDCONTEXT hContext, SCARDHANDLE hCard, SCONTEXT * threadContext) { LONG retval = SCARD_E_INVALID_VALUE; if (threadContext->hContext == hContext) { /* * Find an empty spot to put the hCard value */ int listLength; (void)pthread_mutex_lock(&threadContext->cardsList_lock); listLength = list_size(&threadContext->cardsList); if (listLength >= contextMaxCardHandles) { Log4(PCSC_LOG_DEBUG, "Too many card handles for thread context @%p: %d (max is %d)" "Restart pcscd with --max-card-handle-per-thread value", threadContext, listLength, contextMaxCardHandles); retval = SCARD_E_NO_MEMORY; } else { int lrv; lrv = list_append(&threadContext->cardsList, &hCard); if (lrv < 0) { Log2(PCSC_LOG_CRITICAL, "list_append failed with return value: %d", lrv); retval = SCARD_E_NO_MEMORY; } else retval = SCARD_S_SUCCESS; } (void)pthread_mutex_unlock(&threadContext->cardsList_lock); } return retval; }
/* * Return the address of the base of the newly decommitted memory, or 0 * if decommitting failed. */ void * sysDecommitMem(void *requestedAddr, size_t requestedSize, size_t *decommittedSize) { void *decommittedAddr; char *ret; *decommittedSize = roundDownToGrain(requestedSize); decommittedAddr = (void *) roundUpToGrain((long) requestedAddr); #ifdef USE_MALLOC ret = 0; #else ret = mapChunkNoreserve(decommittedAddr, *decommittedSize); #endif Log4(2, "sysDecommitMem: 0x%x bytes at 0x%x (request: 0x%x bytes at 0x%x)\n", *decommittedSize, decommittedAddr, requestedSize, requestedAddr); return ret; }
static void hpetProgramTimer(HpetTimer *pHpetTimer) { /* no wrapping on new timers */ pHpetTimer->u8Wrap = 0; uint64_t u64Ticks = hpetGetTicks(pHpetTimer->CTX_SUFF(pHpet)); hpetAdjustComparator(pHpetTimer, u64Ticks); uint64_t u64Diff = hpetComputeDiff(pHpetTimer, u64Ticks); /* * HPET spec says in one-shot 32-bit mode, generate an interrupt when * counter wraps in addition to an interrupt with comparator match. */ if ( hpet32bitTimer(pHpetTimer) && !(pHpetTimer->u64Config & HPET_TN_PERIODIC)) { uint32_t u32TillWrap = 0xffffffff - (uint32_t)u64Ticks + 1; if (u32TillWrap < (uint32_t)u64Diff) { Log(("wrap on timer %d: till=%u ticks=%lld diff64=%lld\n", pHpetTimer->idxTimer, u32TillWrap, u64Ticks, u64Diff)); u64Diff = u32TillWrap; pHpetTimer->u8Wrap = 1; } } /* * HACK ALERT! Avoid killing VM with interrupts. */ #if 1 /** @todo: HACK, rethink, may have negative impact on the guest */ if (u64Diff == 0) u64Diff = 100000; /* 1 millisecond */ #endif Log4(("HPET: next IRQ in %lld ticks (%lld ns)\n", u64Diff, hpetTicksToNs(pHpetTimer->CTX_SUFF(pHpet), u64Diff))); TMTimerSetNano(pHpetTimer->CTX_SUFF(pTimer), hpetTicksToNs(pHpetTimer->CTX_SUFF(pHpet), u64Diff)); hpetTimerSetFrequencyHint(pHpetTimer->CTX_SUFF(pHpet), pHpetTimer); }
/* * Finds USB devices currently registered in the system that match any of * the drivers detected in the driver bundle vector. */ static int HPDriversMatchUSBDevices(HPDriverVector driverBundle, HPDeviceList * readerList) { CFDictionaryRef usbMatch = IOServiceMatching("IOUSBDevice"); if (0 == usbMatch) { Log1(PCSC_LOG_ERROR, "error getting USB match from IOServiceMatching()"); return 1; } io_iterator_t usbIter; kern_return_t kret = IOServiceGetMatchingServices(kIOMasterPortDefault, usbMatch, &usbIter); if (kret != 0) { Log1(PCSC_LOG_ERROR, "error getting iterator from IOServiceGetMatchingServices()"); return 1; } IOIteratorReset(usbIter); io_object_t usbDevice = 0; while ((usbDevice = IOIteratorNext(usbIter))) { char namebuf[1024]; kret = IORegistryEntryGetName(usbDevice, namebuf); if (kret != 0) { Log1(PCSC_LOG_ERROR, "error getting device name from IORegistryEntryGetName()"); return 1; } IOCFPlugInInterface **iodev; SInt32 score; kret = IOCreatePlugInInterfaceForService(usbDevice, kIOUSBDeviceUserClientTypeID, kIOCFPlugInInterfaceID, &iodev, &score); if (kret != 0) { Log1(PCSC_LOG_ERROR, "error getting plugin interface from IOCreatePlugInInterfaceForService()"); return 1; } IOObjectRelease(usbDevice); IOUSBDeviceInterface **usbdev; HRESULT hres = (*iodev)->QueryInterface(iodev, CFUUIDGetUUIDBytes(kIOUSBDeviceInterfaceID), (LPVOID *) & usbdev); (*iodev)->Release(iodev); if (hres) { Log1(PCSC_LOG_ERROR, "error querying interface in QueryInterface()"); return 1; } UInt16 vendorId = 0; UInt16 productId = 0; UInt32 usbAddress = 0; kret = (*usbdev)->GetDeviceVendor(usbdev, &vendorId); kret = (*usbdev)->GetDeviceProduct(usbdev, &productId); kret = (*usbdev)->GetLocationID(usbdev, &usbAddress); (*usbdev)->Release(usbdev); #ifdef DEBUG_HOTPLUG Log4(PCSC_LOG_DEBUG, "Found USB device 0x%04X:0x%04X at 0x%X", vendorId, productId, usbAddress); #endif HPDriver *driver; for (driver = driverBundle; driver->m_vendorId; ++driver) { if ((driver->m_vendorId == vendorId) && (driver->m_productId == productId)) { #ifdef DEBUG_HOTPLUG Log4(PCSC_LOG_DEBUG, "Adding USB device %04X:%04X at 0x%X", vendorId, productId, usbAddress); #endif *readerList = HPDeviceListInsert(*readerList, driver, usbAddress); } } } IOObjectRelease(usbIter); return 0; }
/** * @brief parse an ATR * * @param[out] psExtension * @param[in] pucAtr ATR * @param[in] dwLength ATR length * @return */ short ATRDecodeAtr(PSMARTCARD_EXTENSION psExtension, const unsigned char *pucAtr, DWORD dwLength) { USHORT p; UCHAR K, TCK; /* MSN of T0/Check Sum */ UCHAR Y1i, T; /* MSN/LSN of TDi */ int i = 1; /* value of the index in TAi, TBi, etc. */ /* * Zero out everything */ p = K = TCK = Y1i = T = 0; #ifdef ATR_DEBUG if (dwLength > 0) LogXxd(PCSC_LOG_DEBUG, "ATR: ", pucAtr, dwLength); #endif if (dwLength < 2) return 0; /** @retval 0 Atr must have TS and T0 */ /* * Zero out the bitmasks */ psExtension->CardCapabilities.AvailableProtocols = SCARD_PROTOCOL_UNDEFINED; psExtension->CardCapabilities.CurrentProtocol = SCARD_PROTOCOL_UNDEFINED; /* * Decode the TS byte */ if (pucAtr[0] == 0x3F) { /* Inverse convention used */ psExtension->CardCapabilities.Convention = SCARD_CONVENTION_INVERSE; } else if (pucAtr[0] == 0x3B) { /* Direct convention used */ psExtension->CardCapabilities.Convention = SCARD_CONVENTION_DIRECT; } else { memset(psExtension, 0x00, sizeof(SMARTCARD_EXTENSION)); return 0; /** @retval 0 Unable to decode TS byte */ } /* * Here comes the platform dependant stuff */ /* * Decode the T0 byte */ Y1i = pucAtr[1] >> 4; /* Get the MSN in Y1 */ K = pucAtr[1] & 0x0F; /* Get the LSN in K */ p = 2; #ifdef ATR_DEBUG Log4(PCSC_LOG_DEBUG, "Conv: %02X, Y1: %02X, K: %02X", psExtension->CardCapabilities.Convention, Y1i, K); #endif /* * Examine Y1 */ do { short TAi, TBi, TCi, TDi; /* Interface characters */ TAi = (Y1i & 0x01) ? pucAtr[p++] : -1; TBi = (Y1i & 0x02) ? pucAtr[p++] : -1; TCi = (Y1i & 0x04) ? pucAtr[p++] : -1; TDi = (Y1i & 0x08) ? pucAtr[p++] : -1; #ifdef ATR_DEBUG Log9(PCSC_LOG_DEBUG, "TA%d: %02X, TB%d: %02X, TC%d: %02X, TD%d: %02X", i, TAi, i, TBi, i, TCi, i, TDi); #endif /* * Examine TDi to determine protocol and more */ if (TDi >= 0) { Y1i = TDi >> 4; /* Get the MSN in Y1 */ T = TDi & 0x0F; /* Get the LSN in K */ /* * Set the current protocol TD1 (first TD only) */ if (psExtension->CardCapabilities.CurrentProtocol == SCARD_PROTOCOL_UNDEFINED) { switch (T) { case 0: psExtension->CardCapabilities.CurrentProtocol = SCARD_PROTOCOL_T0; break; case 1: psExtension->CardCapabilities.CurrentProtocol = SCARD_PROTOCOL_T1; break; default: return 0; /** @retval 0 Unable to decode LNS */ } } #ifdef ATR_DEBUG Log2(PCSC_LOG_DEBUG, "T=%d Protocol Found", T); #endif if (0 == T) { psExtension->CardCapabilities.AvailableProtocols |= SCARD_PROTOCOL_T0; } else if (1 == T) { psExtension->CardCapabilities.AvailableProtocols |= SCARD_PROTOCOL_T1; } else if (15 == T) { psExtension->CardCapabilities.AvailableProtocols |= SCARD_PROTOCOL_T15; } else { /* * Do nothing for now since other protocols are not * supported at this time */ } } else Y1i = 0; /* test presence of TA2 */ if ((2 == i) && (TAi >= 0)) { T = TAi & 0x0F; #ifdef ATR_DEBUG Log2(PCSC_LOG_DEBUG, "Specific mode: T=%d", T); #endif switch (T) { case 0: psExtension->CardCapabilities.CurrentProtocol = psExtension->CardCapabilities.AvailableProtocols = SCARD_PROTOCOL_T0; break; case 1: psExtension->CardCapabilities.CurrentProtocol = psExtension->CardCapabilities.AvailableProtocols = SCARD_PROTOCOL_T1; break; default: return 0; /** @retval 0 Unable do decode T protocol */ } } if (p > MAX_ATR_SIZE) { memset(psExtension, 0x00, sizeof(SMARTCARD_EXTENSION)); return 0; /** @retval 0 Maximum attribute size */ } /* next interface characters index */ i++; }
/** @interface_method_impl{PDMPCIHLPRC,pfnIoApicSetIrq} */ static DECLCALLBACK(void) pdmRCPciHlp_IoApicSetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel) { PDMDEV_ASSERT_DEVINS(pDevIns); Log4(("pdmRCPciHlp_IoApicSetIrq: iIrq=%d iLevel=%d\n", iIrq, iLevel)); pdmRCIoApicSetIrq(pDevIns->Internal.s.pVMRC, iIrq, iLevel); }
/** @interface_method_impl{PDMPCIHLPRC,pfnIoApicSendMsi} */ static DECLCALLBACK(void) pdmRCPciHlp_IoApicSendMsi(PPDMDEVINS pDevIns, RTGCPHYS GCAddr, uint32_t uValue) { PDMDEV_ASSERT_DEVINS(pDevIns); Log4(("pdmRCPciHlp_IoApicSendMsi: Address=%p Value=%d\n", GCAddr, uValue)); pdmRCIoApicSendMsi(pDevIns->Internal.s.pVMRC, GCAddr, uValue); }
/** * Implements the SVGA_3D_CMD_SURFACE_DMA command (fifo). * * @returns VBox status code (currently ignored). * @param pThis The VGA device instance data. * @param guest . * @param host . * @param transfer . * @param cCopyBoxes . * @param paBoxes . */ int vmsvga3dSurfaceDMA(PVGASTATE pThis, SVGA3dGuestImage guest, SVGA3dSurfaceImageId host, SVGA3dTransferType transfer, uint32_t cCopyBoxes, SVGA3dCopyBox *paBoxes) { int rc = VINF_SUCCESS; PVMSVGA3DSTATE pState = pThis->svga.p3dState; AssertReturn(pState, VERR_NO_MEMORY); uint32_t sid = host.sid; Assert(sid < SVGA3D_MAX_SURFACE_IDS); AssertReturn(sid < pState->cSurfaces, VERR_INVALID_PARAMETER); PVMSVGA3DSURFACE pSurface = pState->papSurfaces[sid]; AssertReturn(pSurface && pSurface->id == sid, VERR_INVALID_PARAMETER); if (pSurface->flags & SVGA3D_SURFACE_HINT_TEXTURE) Log(("vmsvga3dSurfaceDMA TEXTURE guestptr gmr=%x offset=%x pitch=%x host sid=%x face=%d mipmap=%d transfer=%s cCopyBoxes=%d\n", guest.ptr.gmrId, guest.ptr.offset, guest.pitch, host.sid, host.face, host.mipmap, (transfer == SVGA3D_WRITE_HOST_VRAM) ? "READ" : "WRITE", cCopyBoxes)); else Log(("vmsvga3dSurfaceDMA guestptr gmr=%x offset=%x pitch=%x host sid=%x face=%d mipmap=%d transfer=%s cCopyBoxes=%d\n", guest.ptr.gmrId, guest.ptr.offset, guest.pitch, host.sid, host.face, host.mipmap, (transfer == SVGA3D_WRITE_HOST_VRAM) ? "READ" : "WRITE", cCopyBoxes)); AssertMsg(host.face == 0, ("host.face=%#x\n", host.face)); AssertMsgReturn(pSurface->faces[0].numMipLevels > host.mipmap, ("numMipLevels %d, host.mipmap %d", pSurface->faces[0].numMipLevels, host.mipmap), VERR_INVALID_PARAMETER); PVMSVGA3DMIPMAPLEVEL pMipLevel = &pSurface->pMipmapLevels[host.mipmap]; if (!VMSVGA3DSURFACE_HAS_HW_SURFACE(pSurface)) { /* * Not realized in host hardware/library yet, we have to work with * the copy of the data we've got in VMSVGA3DMIMAPLEVEL::pvSurfaceData. */ AssertReturn(pSurface->pMipmapLevels[host.mipmap].pSurfaceData, VERR_INTERNAL_ERROR); for (unsigned i = 0; i < cCopyBoxes; i++) { unsigned uDestOffset; unsigned cbSrcPitch; uint8_t *pBufferStart; Log(("Copy box %d (%d,%d,%d)(%d,%d,%d) dest (%d,%d)\n", i, paBoxes[i].srcx, paBoxes[i].srcy, paBoxes[i].srcz, paBoxes[i].w, paBoxes[i].h, paBoxes[i].d, paBoxes[i].x, paBoxes[i].y)); /* Apparently we're supposed to clip it (gmr test sample) */ if (paBoxes[i].x + paBoxes[i].w > pMipLevel->size.width) paBoxes[i].w = pMipLevel->size.width - paBoxes[i].x; if (paBoxes[i].y + paBoxes[i].h > pMipLevel->size.height) paBoxes[i].h = pMipLevel->size.height - paBoxes[i].y; if (paBoxes[i].z + paBoxes[i].d > pMipLevel->size.depth) paBoxes[i].d = pMipLevel->size.depth - paBoxes[i].z; if ( !paBoxes[i].w || !paBoxes[i].h || !paBoxes[i].d || paBoxes[i].x > pMipLevel->size.width || paBoxes[i].y > pMipLevel->size.height || paBoxes[i].z > pMipLevel->size.depth) { Log(("Empty box; skip\n")); continue; } uDestOffset = paBoxes[i].x * pSurface->cbBlock + paBoxes[i].y * pMipLevel->cbSurfacePitch + paBoxes[i].z * pMipLevel->size.height * pMipLevel->cbSurfacePitch; AssertReturn(uDestOffset + paBoxes[i].w * pSurface->cbBlock * paBoxes[i].h * paBoxes[i].d <= pMipLevel->cbSurface, VERR_INTERNAL_ERROR); cbSrcPitch = (guest.pitch == 0) ? paBoxes[i].w * pSurface->cbBlock : guest.pitch; #ifdef MANUAL_FLIP_SURFACE_DATA pBufferStart = (uint8_t *)pMipLevel->pSurfaceData + paBoxes[i].x * pSurface->cbBlock + pMipLevel->cbSurface - paBoxes[i].y * pMipLevel->cbSurfacePitch - pMipLevel->cbSurfacePitch; /* flip image during copy */ #else pBufferStart = (uint8_t *)pMipLevel->pSurfaceData + uDestOffset; #endif rc = vmsvgaGMRTransfer(pThis, transfer, pBufferStart, #ifdef MANUAL_FLIP_SURFACE_DATA -(int32_t)pMipLevel->cbSurfacePitch, #else (int32_t)pMipLevel->cbSurfacePitch, #endif guest.ptr, paBoxes[i].srcx * pSurface->cbBlock + (paBoxes[i].srcy + paBoxes[i].srcz * paBoxes[i].h) * cbSrcPitch, cbSrcPitch, paBoxes[i].w * pSurface->cbBlock, paBoxes[i].d * paBoxes[i].h); Log4(("first line:\n%.*Rhxd\n", pMipLevel->cbSurfacePitch, pMipLevel->pSurfaceData)); AssertRC(rc); } pSurface->pMipmapLevels[host.mipmap].fDirty = true; pSurface->fDirty = true; } else { /* * Because of the clipping below, we're doing a little more * here before calling the backend specific code. */ #ifdef VMSVGA3D_DIRECT3D /* Flush the drawing pipeline for this surface as it could be used in a shared context. */ vmsvga3dSurfaceFlush(pThis, pSurface); PVMSVGA3DCONTEXT pContext = NULL; #else /* VMSVGA3D_OPENGL */ PVMSVGA3DCONTEXT pContext = &pState->SharedCtx; VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); #endif for (unsigned i = 0; i < cCopyBoxes; i++) { /* Apparently we're supposed to clip it (gmr test sample) */ if (paBoxes[i].x + paBoxes[i].w > pMipLevel->size.width) paBoxes[i].w = pMipLevel->size.width - paBoxes[i].x; if (paBoxes[i].y + paBoxes[i].h > pMipLevel->size.height) paBoxes[i].h = pMipLevel->size.height - paBoxes[i].y; if (paBoxes[i].z + paBoxes[i].d > pMipLevel->size.depth) paBoxes[i].d = pMipLevel->size.depth - paBoxes[i].z; Assert((paBoxes[i].d == 1 || paBoxes[i].d == 0) && paBoxes[i].z == 0); if ( !paBoxes[i].w || !paBoxes[i].h || paBoxes[i].x > pMipLevel->size.width || paBoxes[i].y > pMipLevel->size.height) { Log(("Empty box; skip\n")); continue; } Log(("Copy box %d (%d,%d,%d)(%d,%d,%d) dest (%d,%d)\n", i, paBoxes[i].srcx, paBoxes[i].srcy, paBoxes[i].srcz, paBoxes[i].w, paBoxes[i].h, paBoxes[i].d, paBoxes[i].x, paBoxes[i].y)); uint32_t cbSrcPitch = (guest.pitch == 0) ? paBoxes[i].w * pSurface->cbBlock : guest.pitch; rc = vmsvga3dBackSurfaceDMACopyBox(pThis, pState, pSurface, host.mipmap, guest.ptr, cbSrcPitch, transfer, &paBoxes[i], pContext, rc, i); } } return rc; }
int ValidateWorldLinks( INDEX iWorld ) { GETWORLD(iWorld); int status = TRUE; int nLines; PFLATLAND_MYLINESEG *pLines; int nWalls; PWALL *pWalls; int nSectors; PSECTOR *pSectors; int nNames; PNAME *pNames; pSectors = GetLinearSectorArray( world->sectors, &nSectors ); pWalls = GetLinearWallArray( world->walls, &nWalls ); pLines = GetLinearLineArray( world->lines, &nLines ); pNames = GetLinearNameArray( world->names, &nNames ); { int n, m, refcount; for( n = 0; n < nLines; n++ ) { refcount = 0; for( m = 0; m < nWalls; m++ ) { if( GetLine( pWalls[m]->iLine ) == pLines[n] ) { if( pWalls[m]->iWallInto != INVALID_INDEX ) { refcount++; if( refcount == 2 ) { //pLines[n] = NULL; break; } } } else { //pLines[n] = NULL; break; } } if( m == nWalls ) { status = FALSE; Log1( "Line %08x is unreferenced... deleting now.", pLines[n] ); DeleteLine( world->lines, pLines[n] ); pLines[n] = NULL; } } for( n = 0; n < nWalls; n++ ) { if( !pWalls[n] ) continue; for( m = 0; m < nLines; m++ ) { if( GetLine( pWalls[n]->iLine ) == pLines[m] ) { // if this line is shared - remove the other reference to it. /* if( pWalls[n]->wall_into ) { int i; for( i = 0; i < nWalls; i++ ) { if( pWalls[i] == pWalls[n]->wall_into ) pWalls[i] = NULL; } } pLines[m] = NULL; // clear line reference... */ break; } } if( m == nLines ) { status = FALSE; Log3( "Wall %08x in Sector %d referenced line %08x that does not exist", pWalls[n], GetSector( pWalls[n]->iSector )->iName, pWalls[n]->iLine ); } } for( n = 0; n < nLines; n++ ) { int count = 0; if( !pLines[n]->refcount ) Log( "Line exists with no reference count" ); for( m = 0; m < nWalls; m++ ) { if( GetLine( pWalls[m]->iLine ) == pLines[n] ) { count++; } } if( count != pLines[n]->refcount ) { Log2( "Line reference count of %d does not match actual %d" , pLines[n]->refcount , count ); } } for( n = 0; n < nSectors; n++ ) { PWALL pStart, pCur; int priorend = TRUE; if( pSectors[n]->iName != INVALID_INDEX ) { int i; for( i = 0; i < nNames; i++ ) { if( GetName( pSectors[n]->iName ) == pNames[i] ) break; } if( i == nNames ) { Log2( "Name %08x referenced by Sector %d does not exist", pSectors[n]->iName, n ); } } pCur = pStart = GetWall( pSectors[n]->iWall ); do { if( pCur->iLine == INVALID_INDEX ) { Log1( "Wall in sector %d has an invalid line def", pSectors[n]->iName ); } for( m = 0; m < nWalls; m++ ) { if( pWalls[m] == pCur ) break; } if( m == nWalls ) { status = FALSE; Log4( "Sector %*.*s referenced wall %08x that does not exist", GetName( pSectors[n]->iName )->name[0].length, GetName( pSectors[n]->iName )->name[0].length, GetName( pSectors[n]->iName )->name[0].name, pCur ); } // code goes here.... if( priorend ) { priorend = pCur->flags.wall_start_end; pCur = GetWall( pCur->iWallStart ); } else { priorend = pCur->flags.wall_end_end; pCur = GetWall( pCur->iWallEnd ); } }while( pCur != pStart ); } } Release( pLines ); Release( pWalls ); Release( pSectors ); Release( pNames ); return status; }
static void HPRescanUsbBus(struct udev *udev) { int i, j; struct udev_enumerate *enumerate; struct udev_list_entry *devices, *dev_list_entry; /* all reader are marked absent */ for (i=0; i < PCSCLITE_MAX_READERS_CONTEXTS; i++) readerTracker[i].status = READER_ABSENT; /* Create a list of the devices in the 'usb' subsystem. */ enumerate = udev_enumerate_new(udev); udev_enumerate_add_match_subsystem(enumerate, "usb"); udev_enumerate_scan_devices(enumerate); devices = udev_enumerate_get_list_entry(enumerate); /* For each item enumerated */ udev_list_entry_foreach(dev_list_entry, devices) { const char *devpath; struct udev_device *dev, *parent; struct _driverTracker *driver, *classdriver; int newreader; int bInterfaceNumber; const char *interface; /* Get the filename of the /sys entry for the device and create a udev_device object (dev) representing it */ devpath = udev_list_entry_get_name(dev_list_entry); dev = udev_device_new_from_syspath(udev, devpath); /* The device pointed to by dev contains information about the interface. In order to get information about the USB device, get the parent device with the subsystem/devtype pair of "usb"/"usb_device". This will be several levels up the tree, but the function will find it.*/ parent = udev_device_get_parent_with_subsystem_devtype(dev, "usb", "usb_device"); if (!parent) continue; devpath = udev_device_get_devnode(parent); if (!devpath) { /* the device disapeared? */ Log1(PCSC_LOG_ERROR, "udev_device_get_devnode() failed"); continue; } driver = get_driver(parent, devpath, &classdriver); if (NULL == driver) /* no driver known for this device */ continue; #ifdef DEBUG_HOTPLUG Log2(PCSC_LOG_DEBUG, "Found matching USB device: %s", devpath); #endif newreader = TRUE; bInterfaceNumber = 0; interface = udev_device_get_sysattr_value(dev, "bInterfaceNumber"); if (interface) bInterfaceNumber = atoi(interface); /* Check if the reader is a new one */ for (j=0; j<PCSCLITE_MAX_READERS_CONTEXTS; j++) { if (readerTracker[j].devpath && (strcmp(readerTracker[j].devpath, devpath) == 0) && (bInterfaceNumber == readerTracker[j].bInterfaceNumber)) { /* The reader is already known */ readerTracker[j].status = READER_PRESENT; newreader = FALSE; #ifdef DEBUG_HOTPLUG Log2(PCSC_LOG_DEBUG, "Refresh USB device: %s", devpath); #endif break; } } /* New reader found */ if (newreader) HPAddDevice(dev, parent, devpath); /* free device */ udev_device_unref(dev); } /* Free the enumerator object */ udev_enumerate_unref(enumerate); pthread_mutex_lock(&usbNotifierMutex); /* check if all the previously found readers are still present */ for (i=0; i<PCSCLITE_MAX_READERS_CONTEXTS; i++) { if ((READER_ABSENT == readerTracker[i].status) && (readerTracker[i].fullName != NULL)) { Log4(PCSC_LOG_INFO, "Removing USB device[%d]: %s at %s", i, readerTracker[i].fullName, readerTracker[i].devpath); RFRemoveReader(readerTracker[i].fullName, PCSCLITE_HP_BASE_PORT + i); readerTracker[i].status = READER_ABSENT; free(readerTracker[i].devpath); readerTracker[i].devpath = NULL; free(readerTracker[i].fullName); readerTracker[i].fullName = NULL; } } pthread_mutex_unlock(&usbNotifierMutex); }
/** @interface_method_impl{PDMPCIHLPR3,pfnIoApicSendMsi} */ static DECLCALLBACK(void) pdmR3PciHlp_IoApicSendMsi(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t uValue, uint32_t uTagSrc) { PDMDEV_ASSERT_DEVINS(pDevIns); Log4(("pdmR3PciHlp_IoApicSendMsi: address=%p value=%x uTagSrc=%#x\n", GCPhys, uValue, uTagSrc)); PDMIoApicSendMsi(pDevIns->Internal.s.pVMR3, GCPhys, uValue, uTagSrc); }