From 17beaf58026f194da42ef1123915f2384e76d36a Mon Sep 17 00:00:00 2001 From: Frank Voorburg Date: Thu, 26 Jul 2018 10:46:20 +0000 Subject: [PATCH] Refs #579. Added CpuMemSet function to all ports and used it in XCP memory reads when the programming resource is locked. git-svn-id: https://svn.code.sf.net/p/openblt/code/trunk@549 5dc33758-31d5-4daf-9ae8-b24bf3d40d73 --- Target/Source/ARM7_LPC2000/cpu.c | 26 ++++++++++++++++++++++++++ Target/Source/ARMCM0_STM32F0/cpu.c | 26 ++++++++++++++++++++++++++ Target/Source/ARMCM0_XMC1/cpu.c | 26 ++++++++++++++++++++++++++ Target/Source/ARMCM3_EFM32/cpu.c | 26 ++++++++++++++++++++++++++ Target/Source/ARMCM3_LM3S/cpu.c | 26 ++++++++++++++++++++++++++ Target/Source/ARMCM3_STM32F1/cpu.c | 26 ++++++++++++++++++++++++++ Target/Source/ARMCM3_STM32F2/cpu.c | 26 ++++++++++++++++++++++++++ Target/Source/ARMCM4_STM32F3/cpu.c | 26 ++++++++++++++++++++++++++ Target/Source/ARMCM4_STM32F4/cpu.c | 26 ++++++++++++++++++++++++++ Target/Source/ARMCM4_STM32L4/cpu.c | 26 ++++++++++++++++++++++++++ Target/Source/ARMCM4_TM4C/cpu.c | 26 ++++++++++++++++++++++++++ Target/Source/ARMCM4_XMC4/cpu.c | 26 ++++++++++++++++++++++++++ Target/Source/HCS12/cpu.c | 26 ++++++++++++++++++++++++++ Target/Source/TRICORE_TC1798/cpu.c | 26 ++++++++++++++++++++++++++ Target/Source/cpu.h | 1 + Target/Source/xcp.c | 22 ++-------------------- 16 files changed, 367 insertions(+), 20 deletions(-) diff --git a/Target/Source/ARM7_LPC2000/cpu.c b/Target/Source/ARM7_LPC2000/cpu.c index 4a972963..ebbb7add 100644 --- a/Target/Source/ARM7_LPC2000/cpu.c +++ b/Target/Source/ARM7_LPC2000/cpu.c @@ -145,4 +145,30 @@ void CpuMemCopy(blt_addr dest, blt_addr src, blt_int16u len) } /*** end of CpuMemCopy ***/ +/************************************************************************************//** +** \brief Sets the bytes at the destination address to the specified value. +** \param dest Destination address for the data. +** \param value Value to write. +** \param len Number of bytes to write. +** \return none. +** +****************************************************************************************/ +void CpuMemSet(blt_addr dest, blt_int8u value, blt_int16u len) +{ + blt_int8u *to; + + /* set casted pointer */ + to = (blt_int8u *)dest; + + /* set all bytes at the destination address to the specified value */ + while (len-- > 0) + { + /* set byte value */ + *to++ = value; + /* keep the watchdog happy */ + CopService(); + } +} /*** end of CpuMemSet ***/ + + /*********************************** end of cpu.c **************************************/ diff --git a/Target/Source/ARMCM0_STM32F0/cpu.c b/Target/Source/ARMCM0_STM32F0/cpu.c index 6df6afa3..2618b0e9 100644 --- a/Target/Source/ARMCM0_STM32F0/cpu.c +++ b/Target/Source/ARMCM0_STM32F0/cpu.c @@ -156,4 +156,30 @@ void CpuMemCopy(blt_addr dest, blt_addr src, blt_int16u len) } /*** end of CpuMemCopy ***/ +/************************************************************************************//** +** \brief Sets the bytes at the destination address to the specified value. +** \param dest Destination address for the data. +** \param value Value to write. +** \param len Number of bytes to write. +** \return none. +** +****************************************************************************************/ +void CpuMemSet(blt_addr dest, blt_int8u value, blt_int16u len) +{ + blt_int8u *to; + + /* set casted pointer */ + to = (blt_int8u *)dest; + + /* set all bytes at the destination address to the specified value */ + while (len-- > 0) + { + /* set byte value */ + *to++ = value; + /* keep the watchdog happy */ + CopService(); + } +} /*** end of CpuMemSet ***/ + + /*********************************** end of cpu.c **************************************/ diff --git a/Target/Source/ARMCM0_XMC1/cpu.c b/Target/Source/ARMCM0_XMC1/cpu.c index f6c65c91..e200ddf1 100644 --- a/Target/Source/ARMCM0_XMC1/cpu.c +++ b/Target/Source/ARMCM0_XMC1/cpu.c @@ -136,4 +136,30 @@ void CpuMemCopy(blt_addr dest, blt_addr src, blt_int16u len) } /*** end of CpuMemCopy ***/ +/************************************************************************************//** +** \brief Sets the bytes at the destination address to the specified value. +** \param dest Destination address for the data. +** \param value Value to write. +** \param len Number of bytes to write. +** \return none. +** +****************************************************************************************/ +void CpuMemSet(blt_addr dest, blt_int8u value, blt_int16u len) +{ + blt_int8u *to; + + /* set casted pointer */ + to = (blt_int8u *)dest; + + /* set all bytes at the destination address to the specified value */ + while (len-- > 0) + { + /* set byte value */ + *to++ = value; + /* keep the watchdog happy */ + CopService(); + } +} /*** end of CpuMemSet ***/ + + /*********************************** end of cpu.c **************************************/ diff --git a/Target/Source/ARMCM3_EFM32/cpu.c b/Target/Source/ARMCM3_EFM32/cpu.c index 1b99c6bb..09c9c70f 100644 --- a/Target/Source/ARMCM3_EFM32/cpu.c +++ b/Target/Source/ARMCM3_EFM32/cpu.c @@ -145,4 +145,30 @@ void CpuMemCopy(blt_addr dest, blt_addr src, blt_int16u len) } /*** end of CpuMemCopy ***/ +/************************************************************************************//** +** \brief Sets the bytes at the destination address to the specified value. +** \param dest Destination address for the data. +** \param value Value to write. +** \param len Number of bytes to write. +** \return none. +** +****************************************************************************************/ +void CpuMemSet(blt_addr dest, blt_int8u value, blt_int16u len) +{ + blt_int8u *to; + + /* set casted pointer */ + to = (blt_int8u *)dest; + + /* set all bytes at the destination address to the specified value */ + while (len-- > 0) + { + /* set byte value */ + *to++ = value; + /* keep the watchdog happy */ + CopService(); + } +} /*** end of CpuMemSet ***/ + + /*********************************** end of cpu.c **************************************/ diff --git a/Target/Source/ARMCM3_LM3S/cpu.c b/Target/Source/ARMCM3_LM3S/cpu.c index 571c3a8c..dfc70b1f 100644 --- a/Target/Source/ARMCM3_LM3S/cpu.c +++ b/Target/Source/ARMCM3_LM3S/cpu.c @@ -145,4 +145,30 @@ void CpuMemCopy(blt_addr dest, blt_addr src, blt_int16u len) } /*** end of CpuMemCopy ***/ +/************************************************************************************//** +** \brief Sets the bytes at the destination address to the specified value. +** \param dest Destination address for the data. +** \param value Value to write. +** \param len Number of bytes to write. +** \return none. +** +****************************************************************************************/ +void CpuMemSet(blt_addr dest, blt_int8u value, blt_int16u len) +{ + blt_int8u *to; + + /* set casted pointer */ + to = (blt_int8u *)dest; + + /* set all bytes at the destination address to the specified value */ + while (len-- > 0) + { + /* set byte value */ + *to++ = value; + /* keep the watchdog happy */ + CopService(); + } +} /*** end of CpuMemSet ***/ + + /*********************************** end of cpu.c **************************************/ diff --git a/Target/Source/ARMCM3_STM32F1/cpu.c b/Target/Source/ARMCM3_STM32F1/cpu.c index 952907e9..eadafa07 100644 --- a/Target/Source/ARMCM3_STM32F1/cpu.c +++ b/Target/Source/ARMCM3_STM32F1/cpu.c @@ -145,4 +145,30 @@ void CpuMemCopy(blt_addr dest, blt_addr src, blt_int16u len) } /*** end of CpuMemCopy ***/ +/************************************************************************************//** +** \brief Sets the bytes at the destination address to the specified value. +** \param dest Destination address for the data. +** \param value Value to write. +** \param len Number of bytes to write. +** \return none. +** +****************************************************************************************/ +void CpuMemSet(blt_addr dest, blt_int8u value, blt_int16u len) +{ + blt_int8u *to; + + /* set casted pointer */ + to = (blt_int8u *)dest; + + /* set all bytes at the destination address to the specified value */ + while (len-- > 0) + { + /* set byte value */ + *to++ = value; + /* keep the watchdog happy */ + CopService(); + } +} /*** end of CpuMemSet ***/ + + /*********************************** end of cpu.c **************************************/ diff --git a/Target/Source/ARMCM3_STM32F2/cpu.c b/Target/Source/ARMCM3_STM32F2/cpu.c index d24913d9..71dba751 100644 --- a/Target/Source/ARMCM3_STM32F2/cpu.c +++ b/Target/Source/ARMCM3_STM32F2/cpu.c @@ -141,4 +141,30 @@ void CpuMemCopy(blt_addr dest, blt_addr src, blt_int16u len) } /*** end of CpuMemCopy ***/ +/************************************************************************************//** +** \brief Sets the bytes at the destination address to the specified value. +** \param dest Destination address for the data. +** \param value Value to write. +** \param len Number of bytes to write. +** \return none. +** +****************************************************************************************/ +void CpuMemSet(blt_addr dest, blt_int8u value, blt_int16u len) +{ + blt_int8u *to; + + /* set casted pointer */ + to = (blt_int8u *)dest; + + /* set all bytes at the destination address to the specified value */ + while (len-- > 0) + { + /* set byte value */ + *to++ = value; + /* keep the watchdog happy */ + CopService(); + } +} /*** end of CpuMemSet ***/ + + /*********************************** end of cpu.c **************************************/ diff --git a/Target/Source/ARMCM4_STM32F3/cpu.c b/Target/Source/ARMCM4_STM32F3/cpu.c index e1e5c243..72576301 100644 --- a/Target/Source/ARMCM4_STM32F3/cpu.c +++ b/Target/Source/ARMCM4_STM32F3/cpu.c @@ -141,4 +141,30 @@ void CpuMemCopy(blt_addr dest, blt_addr src, blt_int16u len) } /*** end of CpuMemCopy ***/ +/************************************************************************************//** +** \brief Sets the bytes at the destination address to the specified value. +** \param dest Destination address for the data. +** \param value Value to write. +** \param len Number of bytes to write. +** \return none. +** +****************************************************************************************/ +void CpuMemSet(blt_addr dest, blt_int8u value, blt_int16u len) +{ + blt_int8u *to; + + /* set casted pointer */ + to = (blt_int8u *)dest; + + /* set all bytes at the destination address to the specified value */ + while (len-- > 0) + { + /* set byte value */ + *to++ = value; + /* keep the watchdog happy */ + CopService(); + } +} /*** end of CpuMemSet ***/ + + /*********************************** end of cpu.c **************************************/ diff --git a/Target/Source/ARMCM4_STM32F4/cpu.c b/Target/Source/ARMCM4_STM32F4/cpu.c index 2c7354af..9d59fbdd 100644 --- a/Target/Source/ARMCM4_STM32F4/cpu.c +++ b/Target/Source/ARMCM4_STM32F4/cpu.c @@ -145,4 +145,30 @@ void CpuMemCopy(blt_addr dest, blt_addr src, blt_int16u len) } /*** end of CpuMemCopy ***/ +/************************************************************************************//** +** \brief Sets the bytes at the destination address to the specified value. +** \param dest Destination address for the data. +** \param value Value to write. +** \param len Number of bytes to write. +** \return none. +** +****************************************************************************************/ +void CpuMemSet(blt_addr dest, blt_int8u value, blt_int16u len) +{ + blt_int8u *to; + + /* set casted pointer */ + to = (blt_int8u *)dest; + + /* set all bytes at the destination address to the specified value */ + while (len-- > 0) + { + /* set byte value */ + *to++ = value; + /* keep the watchdog happy */ + CopService(); + } +} /*** end of CpuMemSet ***/ + + /*********************************** end of cpu.c **************************************/ diff --git a/Target/Source/ARMCM4_STM32L4/cpu.c b/Target/Source/ARMCM4_STM32L4/cpu.c index 3695f061..ed6e4522 100644 --- a/Target/Source/ARMCM4_STM32L4/cpu.c +++ b/Target/Source/ARMCM4_STM32L4/cpu.c @@ -141,4 +141,30 @@ void CpuMemCopy(blt_addr dest, blt_addr src, blt_int16u len) } /*** end of CpuMemCopy ***/ +/************************************************************************************//** +** \brief Sets the bytes at the destination address to the specified value. +** \param dest Destination address for the data. +** \param value Value to write. +** \param len Number of bytes to write. +** \return none. +** +****************************************************************************************/ +void CpuMemSet(blt_addr dest, blt_int8u value, blt_int16u len) +{ + blt_int8u *to; + + /* set casted pointer */ + to = (blt_int8u *)dest; + + /* set all bytes at the destination address to the specified value */ + while (len-- > 0) + { + /* set byte value */ + *to++ = value; + /* keep the watchdog happy */ + CopService(); + } +} /*** end of CpuMemSet ***/ + + /*********************************** end of cpu.c **************************************/ diff --git a/Target/Source/ARMCM4_TM4C/cpu.c b/Target/Source/ARMCM4_TM4C/cpu.c index 9ec474ab..44f8e662 100644 --- a/Target/Source/ARMCM4_TM4C/cpu.c +++ b/Target/Source/ARMCM4_TM4C/cpu.c @@ -145,4 +145,30 @@ void CpuMemCopy(blt_addr dest, blt_addr src, blt_int16u len) } /*** end of CpuMemCopy ***/ +/************************************************************************************//** +** \brief Sets the bytes at the destination address to the specified value. +** \param dest Destination address for the data. +** \param value Value to write. +** \param len Number of bytes to write. +** \return none. +** +****************************************************************************************/ +void CpuMemSet(blt_addr dest, blt_int8u value, blt_int16u len) +{ + blt_int8u *to; + + /* set casted pointer */ + to = (blt_int8u *)dest; + + /* set all bytes at the destination address to the specified value */ + while (len-- > 0) + { + /* set byte value */ + *to++ = value; + /* keep the watchdog happy */ + CopService(); + } +} /*** end of CpuMemSet ***/ + + /*********************************** end of cpu.c **************************************/ diff --git a/Target/Source/ARMCM4_XMC4/cpu.c b/Target/Source/ARMCM4_XMC4/cpu.c index 95b6d0b0..8cfe8855 100644 --- a/Target/Source/ARMCM4_XMC4/cpu.c +++ b/Target/Source/ARMCM4_XMC4/cpu.c @@ -145,4 +145,30 @@ void CpuMemCopy(blt_addr dest, blt_addr src, blt_int16u len) } /*** end of CpuMemCopy ***/ +/************************************************************************************//** +** \brief Sets the bytes at the destination address to the specified value. +** \param dest Destination address for the data. +** \param value Value to write. +** \param len Number of bytes to write. +** \return none. +** +****************************************************************************************/ +void CpuMemSet(blt_addr dest, blt_int8u value, blt_int16u len) +{ + blt_int8u *to; + + /* set casted pointer */ + to = (blt_int8u *)dest; + + /* set all bytes at the destination address to the specified value */ + while (len-- > 0) + { + /* set byte value */ + *to++ = value; + /* keep the watchdog happy */ + CopService(); + } +} /*** end of CpuMemSet ***/ + + /*********************************** end of cpu.c **************************************/ diff --git a/Target/Source/HCS12/cpu.c b/Target/Source/HCS12/cpu.c index e314c8c2..395e4e4f 100644 --- a/Target/Source/HCS12/cpu.c +++ b/Target/Source/HCS12/cpu.c @@ -133,4 +133,30 @@ void CpuMemCopy(blt_addr dest, blt_addr src, blt_int16u len) } /*** end of CpuMemCopy ***/ +/************************************************************************************//** +** \brief Sets the bytes at the destination address to the specified value. +** \param dest Destination address for the data. +** \param value Value to write. +** \param len Number of bytes to write. +** \return none. +** +****************************************************************************************/ +void CpuMemSet(blt_addr dest, blt_int8u value, blt_int16u len) +{ + blt_int8u *to; + + /* set casted pointer */ + to = (blt_int8u *)dest; + + /* set all bytes at the destination address to the specified value */ + while (len-- > 0) + { + /* set byte value */ + *to++ = value; + /* keep the watchdog happy */ + CopService(); + } +} /*** end of CpuMemSet ***/ + + /*********************************** end of cpu.c **************************************/ diff --git a/Target/Source/TRICORE_TC1798/cpu.c b/Target/Source/TRICORE_TC1798/cpu.c index 40095887..57594ff2 100644 --- a/Target/Source/TRICORE_TC1798/cpu.c +++ b/Target/Source/TRICORE_TC1798/cpu.c @@ -129,4 +129,30 @@ void CpuMemCopy(blt_addr dest, blt_addr src, blt_int16u len) } /*** end of CpuMemCopy ***/ +/************************************************************************************//** +** \brief Sets the bytes at the destination address to the specified value. +** \param dest Destination address for the data. +** \param value Value to write. +** \param len Number of bytes to write. +** \return none. +** +****************************************************************************************/ +void CpuMemSet(blt_addr dest, blt_int8u value, blt_int16u len) +{ + blt_int8u *to; + + /* set casted pointer */ + to = (blt_int8u *)dest; + + /* set all bytes at the destination address to the specified value */ + while (len-- > 0) + { + /* set byte value */ + *to++ = value; + /* keep the watchdog happy */ + CopService(); + } +} /*** end of CpuMemSet ***/ + + /*********************************** end of cpu.c **************************************/ diff --git a/Target/Source/cpu.h b/Target/Source/cpu.h index cfdde23f..8714d9ca 100644 --- a/Target/Source/cpu.h +++ b/Target/Source/cpu.h @@ -35,6 +35,7 @@ void CpuInit(void); void CpuStartUserProgram(void); void CpuMemCopy(blt_addr dest, blt_addr src, blt_int16u len); +void CpuMemSet(blt_addr dest, blt_int8u value, blt_int16u len); void CpuIrqDisable(void); void CpuIrqEnable(void); diff --git a/Target/Source/xcp.c b/Target/Source/xcp.c index 60c0ba39..7c16c667 100644 --- a/Target/Source/xcp.c +++ b/Target/Source/xcp.c @@ -707,16 +707,7 @@ static void XcpCmdUpload(blt_int8u *data) /* resource is locked so memory read access is denied. zero values are returned * instead. */ - while (len > 0) - { - /* write a zero value */ - *destPtr = 0; - /* update write pointer and loop counter */ - destPtr++; - len--; - /* keep the watchdog happy */ - CopService(); - } + CpuMemSet((blt_addr)destPtr, 0, len); } else { @@ -779,16 +770,7 @@ static void XcpCmdShortUpload(blt_int8u *data) /* resource is locked so memory read access is denied. zero values are returned * instead. */ - while (len > 0) - { - /* write a zero value */ - *destPtr = 0; - /* update write pointer and loop counter */ - destPtr++; - len--; - /* keep the watchdog happy */ - CopService(); - } + CpuMemSet((blt_addr)destPtr, 0, len); } else {