コード例 #1
0
//! (HCS12) Reads contents of core registers
//!
//! @param  registers   pointer to structure to receive the register values
//!
//! @return 0 => Success,\n !=0 => Fail
//!
TBDML_API unsigned char _tbdml_read_regs(registers_t *registers) {
   uint8_t rc;
   unsigned long value;

   rc = USBDM_ReadReg(HCS12_RegPC, &value);
   if (rc != BDM_RC_OK)
      return rc;
   registers->hc12.pc  = (uint16_t)value;
   rc = USBDM_ReadReg(HCS12_RegSP, &value);
   if (rc != BDM_RC_OK)
      return rc;
   registers->hc12.sp  = (uint16_t)value;
   rc = USBDM_ReadReg(HCS12_RegX, &value);
   if (rc != BDM_RC_OK)
      return rc;
   registers->hc12.ix  = (uint16_t)value;
   rc = USBDM_ReadReg(HCS12_RegY, &value);
   if (rc != BDM_RC_OK)
      return rc;
   registers->hc12.iy  = (uint16_t)value;
   rc = USBDM_ReadReg(HCS12_RegD, &value);
   if (rc != BDM_RC_OK)
      return rc;
   registers->hc12.d   = (uint16_t)value;
   rc = USBDM_ReadDReg(0xFF06,&value);
   if (rc != BDM_RC_OK)
      return rc;
	registers->hc12.ccr = (uint8_t)value;

   return BDM_RC_OK;
}
コード例 #2
0
//! 2.2.6.2 Read Value from Register
//!
//! @param dnRegNumber
//! @param drvValue
//!
USBDM_GDI_API
DiReturnT DiRegisterRead ( DiUInt32T         dnRegNumber,
                           pDiRegisterValueT drvValue ) {
unsigned long dataValue = 0xDEADBEEF;
USBDM_ErrorCode rc = BDM_RC_OK;

   Logging::print("DiRegisterRead(0x%X(%d))\n", dnRegNumber, dnRegNumber);

   CHECK_ERROR_STATE();

   if (dnRegNumber>=cfv234regID_FIRST_DEBUG_REG) {
      dnRegNumber -= cfv234regID_FIRST_DEBUG_REG;
      rc = USBDM_ReadDReg(dnRegNumber,&dataValue);
      Logging::print("DiRegisterRead(0x%X(%s) => 0x%08X)\n", dnRegNumber, getCFVxDebugRegName(dnRegNumber), (uint32_t)dataValue);
   }
   else if (dnRegNumber >= cfv234regID_FIRST_CONTROL_REG) {
      dnRegNumber -= cfv234regID_FIRST_CONTROL_REG;
      rc = USBDM_ReadCReg(dnRegNumber,&dataValue);
      Logging::print("DiRegisterRead(0x%X(%s) => 0x%08X)\n", dnRegNumber, getCFVxControlRegName(dnRegNumber), (uint32_t)dataValue);
   }
   else {
      switch (dnRegNumber) {
         case cfv234regID_pc :
            rc = USBDM_ReadCReg(CFVx_CRegPC,&dataValue);
            Logging::print("DiRegisterRead(0x%X(%s) => 0x%08X)\n", CFVx_CRegPC, getCFVxControlRegName(CFVx_CRegPC), (uint32_t)dataValue);
            break;
         case cfv234regID_sr :
            rc = USBDM_ReadCReg(CFVx_CRegSR,&dataValue);
            Logging::print("DiRegisterRead(0x%X(%s) => 0x%08X)\n", CFVx_CRegSR, getCFVxControlRegName(CFVx_CRegSR), (uint32_t)dataValue);
            break;
         default : // D0-7, A0-7
            if (dnRegNumber<=cfv234regID_a7) {
               rc = USBDM_ReadReg(dnRegNumber,&dataValue);
               Logging::print("DiRegisterRead(0x%X(%s) => 0x%08X)\n", dnRegNumber, getCFVxRegName(dnRegNumber), (uint32_t)dataValue);
            }
            else {
               Logging::print("DiRegisterRead(Illegal reg# = 0x%X (%d)\n", dnRegNumber, dnRegNumber);
               rc = BDM_RC_ILLEGAL_PARAMS;
            }
            break;
      }
   }
   if (rc != BDM_RC_OK) {
      Logging::print("DiRegisterRead(0x%X) => error\n", dnRegNumber);
      return setErrorState(DI_ERR_NONFATAL, rc);
   }
   *drvValue = (U32c)dataValue;
   Logging::print("0x%X(%d) => 0x%08X\n", dnRegNumber, dnRegNumber, dataValue);
   return setErrorState(DI_OK);
}
コード例 #3
0
//! (HCS12) Reads one byte from the BDM address space
//!
//! @param address 16-bit memory address
//! @return 8-bit data value
//!
//! @note Access to BDMSTS register address is mapped to USBDM_ReadStatusReg()
//!
TBDML_API unsigned char _tbdml_read_bd(unsigned int address) {
uint8_t rc;
unsigned long value;

   if (address == HC12_BDMSTS)
      rc = USBDM_ReadStatusReg(&value);
   else
      rc = USBDM_ReadDReg(address, &value);

   print("_tbdml_read_bd(%4.4X) => %2.2X\n", address, value);

   if (rc != BDM_RC_OK)
      return 0;

	return (uint8_t)value;
}
コード例 #4
0
//! 2.2.6.2 Read Value from Register
//!
//! @param dnRegNumber
//! @param drvValue
//!
USBDM_GDI_DECLSPEC
DiReturnT DiRegisterRead ( DiUInt32T         dnRegNumber,
                           pDiRegisterValueT drvValue ) {
   LOGGING;
   log.print("0x%X(%d)\n", dnRegNumber, dnRegNumber);

   unsigned long     dataValue = 0xDEADBEEF;
   USBDM_ErrorCode   rc        = BDM_RC_OK;
   log.print("0x%X(%d)\n", dnRegNumber, dnRegNumber);

   if (forceMassErase) {
      // Dummy register reads until device in unsecured
      *drvValue = (U32c)dataValue;
      return setErrorState(DI_OK);
   }
   CHECK_ERROR_STATE();

   if (dnRegNumber>cfv1regID_FIRST_DEBUG_regID_BYTE)
      switch (dnRegNumber) {
         case cfv1regID_xcsr_byte :
            rc = USBDM_ReadStatusReg(&dataValue);
            break;
         case cfv1regID_csr2_byte :
            rc = USBDM_ReadDReg(CFV1_DRegCSR2byte,&dataValue);
            break;
         case cfv1regID_csr3_byte :
            rc = USBDM_ReadDReg(CFV1_DRegCSR3byte,&dataValue);
            break;
         default                  :
            log.print("DiRegisterRead(Illegal Reg# 0x%X(%d)\n", dnRegNumber, dnRegNumber);
            rc = BDM_RC_ILLEGAL_PARAMS;
            break;
      }
   else if (dnRegNumber>cfv1regID_FIRST_DEBUG_REG)
      rc = USBDM_ReadDReg(dnRegNumber-cfv1regID_FIRST_DEBUG_REG,&dataValue);
   else if (dnRegNumber > cfv1regID_FIRST_CONTROL_REG)
      rc = USBDM_ReadCReg(dnRegNumber-cfv1regID_FIRST_CONTROL_REG,&dataValue);
   else {
      switch (dnRegNumber) {
         case cfv1regID_pc :
            rc = USBDM_ReadCReg(CFV1_CRegPC,&dataValue);
            break;
         case cfv1regID_sr :
            rc = USBDM_ReadCReg(CFV1_CRegSR,&dataValue);
            break;
         default : // D0-7, A0-7
            if (dnRegNumber>15) {
               log.print("DiRegisterRead(Illegal Reg# 0x%X(%d)\n", dnRegNumber, dnRegNumber);
               rc = BDM_RC_ILLEGAL_PARAMS;
            }
            else
               rc = USBDM_ReadReg(dnRegNumber,&dataValue);
            break;
      }
   }
   if (rc != BDM_RC_OK) {
      log.print("DiRegisterRead(0x%X) => error\n", dnRegNumber);
      return setErrorState(DI_ERR_NONFATAL, rc);
   }
   *drvValue = (U32c)dataValue;
   log.print("0x%lX(%ld) => 0x%08lX\n", (unsigned long)dnRegNumber, (unsigned long)dnRegNumber, (unsigned long)dataValue);
   return setErrorState(DI_OK);
}
コード例 #5
0
//! (CFv1) Read Debug register
//!
//! @param regNo  Register #
//!
//! @return 32-bit number
//!
OSBDM_API unsigned int  _opensourcebdm_read_dreg(unsigned char regNo) {
unsigned long value;

   USBDM_ReadDReg(regNo, &value);
   return value;
}
コード例 #6
0
//! (CFv1) Read CSR3.msb
//!
//! @return value 8-bit number
//!
OSBDM_API unsigned int  _opensourcebdm_read_csr3_byte(void) {
unsigned long regValue;

   USBDM_ReadDReg(CFV1_DRegCSR3byte, &regValue);
   return regValue;
}
コード例 #7
0
//! (HCS08 & RS08) Read from Breakpoint Register
//!
//! @return 16-bit value
//!
OSBDM_API unsigned int _opensourcebdm_read_bkpt(void){
unsigned long value;

   USBDM_ReadDReg(0, &value);
   return value;
}