//! 2.2.6.1 Write Value to Register //! //! @param dnRegNumber //! @param drvValue //! USBDM_GDI_API DiReturnT DiRegisterWrite ( DiUInt32T dnRegNumber, DiRegisterValueT drvValue ) { LOGGING; U32c regValue(drvValue); DSC_Registers_t regNum = mapReg(dnRegNumber); USBDM_ErrorCode rc = BDM_RC_OK; Logging::print("DiRegisterWrite(0x%lX,%s) => %lX\n", (unsigned long)dnRegNumber, DSC_GetRegisterName(regNum), (unsigned long)regValue); CHECK_ERROR_STATE(); if ((regNum == DSC_RegPC) && !pcWritten) { pcWritten = true; pcResetValue = regValue; } if (regNum == DSC_UnknownReg) { // rc = BDM_RC_OK; rc = BDM_RC_ILLEGAL_PARAMS; } else { rc = DSC_WriteRegister(regNum, (uint32_t)regValue); } if (rc != BDM_RC_OK) { Logging::print("DiRegisterWrite(0x%X,%s) Failed, reason= %s\n", dnRegNumber, DSC_GetRegisterName(regNum), USBDM_GetErrorString(rc)); return setErrorState(DI_ERR_NONFATAL, rc); } return setErrorState(DI_OK); }
int8_t TMP102::io_op_callback(I2CBusOp* completed) { I2CDeviceWithRegisters::io_op_callback(completed); int i = 0; DeviceRegister *temp_reg = reg_defs.get(i++); while (temp_reg) { switch (temp_reg->addr) { case TMP102_REG_RESULT: { uint16_t temperature_read = regValue(TMP102_REG_RESULT); //temperature_read = ((msb * (0x01 << (4+(lsb & 0x01)))) + (lsb >> (4-(lsb & 0x01)))); // Handles EXTended mode. float celcius = ((int16_t) temperature_read) * 0.0625; // The scale of the TMP102. updateDatum(0, celcius); } break; case TMP102_REG_CONFIG: break; case TMP102_REG_ALRT_LO: break; case TMP102_REG_ALRT_HI: break; default: break; } temp_reg->unread = false; temp_reg = reg_defs.get(i++); } return 0; }
/** * Our purpose here is to verify that our test value comes back on a read. This is a * bus-integrity test that must be passed prior to entering INIT-3. * * @return true if the test passes. False otherwise. */ bool LSM9DSx_Common::integrity_check() { if (!present()) return false; // If we are ain a state where we are reading the init values back, look for our test // values, and fail the init if they are not found. if (io_test_val_0 == regValue(IDX_T0)) { if (io_test_val_1 == regValue(IDX_T1)) { // We will call this successful init. if (getVerbosity() > 5) { StringBuilder local_log; local_log.concat("Successful readback!"); integrator->deposit_log(&local_log); } // Rewrite valid values to those registers if necessary. //writeDirtyRegisters(); _alter_flags(true, IMU_COMMON_FLAG_HW_WRITABLE); return true; } else { if (getVerbosity() > 2) { StringBuilder local_log; local_log.concatf("%s failed integrity check (index 0x%02x). Found 0x%02x. Expected 0x%02x.\n", imu_type(), IDX_T1, regValue(IDX_T1), io_test_val_1); integrator->deposit_log(&local_log); } } } else { if (getVerbosity() > 2) { StringBuilder local_log; local_log.concatf("%s failed integrity check (index 0x%02x). Found 0x%02x. Expected 0x%02x.\n", imu_type(), IDX_T0, regValue(IDX_T0), io_test_val_0); integrator->deposit_log(&local_log); } } error_condition = IMU_ERROR_NOT_WRITABLE; return false; }
// 获取注册表的值 string TelnetReader::getRegValue() { string regValue(""); HKEY hkResult = 0; LONG lRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, //_T("Software\\Siteview"),// 键路径 (const WCHAR *)"Software\\Siteview",// 键路径 0, KEY_READ, &hkResult); if( ERROR_SUCCESS == lRet) {// 打开键成功 std::wstring strValue; DWORD dwType=REG_NONE; DWORD dwCount=0; //先查询键值的长度。 LONG lResult = RegQueryValueEx(hkResult, //_T("COMMONDIR"),//键名 (const WCHAR *)"COMMONDIR", NULL, &dwType, NULL, &dwCount); if (lResult == ERROR_SUCCESS) { strValue.resize(dwCount); lResult = RegQueryValueEx(hkResult,(const WCHAR*)"COMMONDIR", NULL, &dwType, (LPBYTE)strValue.data(), &dwCount); if(lResult == ERROR_SUCCESS) { path = ws2s(strValue); //added by zhangyan 2009-01-13 regValue = path + "\\ReadDeviceInfo.dll"; } } ::RegCloseKey( hkResult ); } return regValue; }
BOOLEAN KdpIsSpecialCall ( ULONG Pc, PCONTEXT ContextRecord ) /*++ Routine Description: Check to see if the instruction at pc is a call to one of the SpecialCall routines. Argument: Pc - program counter of instruction in question. --*/ { UCHAR opcode; UCHAR modRM; UCHAR sib; USHORT twoBytes; ULONG callAddr; ULONG addrAddr; LONG offset; ULONG i; char d8; KdpMoveMemory(( PCHAR)&opcode, (PCHAR)Pc, 1 ); if ( opcode == 0xe8 ) { // // Signed offset from pc // KdpMoveMemory( (PCHAR)&offset, (PCHAR)Pc+1, 4 ); callAddr = Pc + offset + 5; // +5 for instr len. } else if ( opcode == 0xff ) { KdpMoveMemory( (PCHAR)&modRM, (PCHAR)Pc+1, 1 ); if ( ((modRM & 0x30) == 0x00) || ((modRM & 0x30) == 0x30) ) { // not call or jump return FALSE; } if ( (modRM & 0x08) == 0x08 ) { // m16:16 or m16:32 -- we don't handle this return FALSE; } if ( (modRM & 0xc0) == 0xc0 ) { /* Direct register addressing */ callAddr = regValue( (UCHAR)(modRM&0x7), ContextRecord ); } else if ( (modRM & 0xc7) == 0x05 ) { // // ff15 or ff25 -- call or jump with disp32 // KdpMoveMemory( (PCHAR)&addrAddr, (PCHAR)Pc+2, 4 ); KdpMoveMemory( (PCHAR)&callAddr, (PCHAR)addrAddr, 4 ); } else if ( (modRM & 0x7) == 0x4 ) { LONG indexValue; /* sib byte present */ KdpMoveMemory( (PCHAR)&sib, (PCHAR)Pc+2, 1 ); indexValue = regValue( (UCHAR)((sib & 0x31) >> 3), ContextRecord ); switch ( sib&0xc0 ) { case 0x0: /* x1 */ break; case 0x40: indexValue *= 2; break; case 0x80: indexValue *= 4; break; case 0xc0: indexValue *= 8; break; } /* switch */ switch ( modRM & 0xc0 ) { case 0x0: /* no displacement */ if ( (sib & 0x7) == 0x5 ) { DPRINT(("funny call #1 at %x\n", Pc)); return FALSE; } callAddr = indexValue + regValue((UCHAR)(sib&0x7), ContextRecord ); break; case 0x40: if ( (sib & 0x6) == 0x4 ) { DPRINT(("Funny call #2\n")); /* calling into the stack */ return FALSE; } KdpMoveMemory( &d8, (PCHAR)Pc+3,1 ); callAddr = indexValue + d8 + regValue((UCHAR)(sib&0x7), ContextRecord ); break; case 0x80: if ( (sib & 0x6) == 0x4 ) { DPRINT(("Funny call #3\n")); /* calling into the stack */ return FALSE; } KdpMoveMemory( (PCHAR)&offset, (PCHAR)Pc+3, 4 ); callAddr = indexValue + offset + regValue((UCHAR)(sib&0x7), ContextRecord ); break; case 0xc0: ASSERT( FALSE ); break; } } else {