From e8f23f0aa56b7e02c2dfe5aa5d13d0f7b8e10f9f Mon Sep 17 00:00:00 2001 From: Naga Sureshkumar Relli Date: Tue, 21 Jul 2015 14:10:21 +0530 Subject: [PATCH] uartlite: Removed received data updation outside critical region. This patch modifies the XUartLite_ReceiveBuffer function to update the received data in critical region. Earlier the data updation is outside the critical region. Signed-off-by: Naga Sureshkumar Relli Reviewed-by: Anirudha Sarangi --- .../drivers/uartlite/data/uartlite.mdd | 2 +- .../drivers/uartlite/src/xuartlite.c | 24 +++++++++++-------- .../drivers/uartlite/src/xuartlite.h | 3 +++ 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/XilinxProcessorIPLib/drivers/uartlite/data/uartlite.mdd b/XilinxProcessorIPLib/drivers/uartlite/data/uartlite.mdd index 6035ae38..baff7aeb 100755 --- a/XilinxProcessorIPLib/drivers/uartlite/data/uartlite.mdd +++ b/XilinxProcessorIPLib/drivers/uartlite/data/uartlite.mdd @@ -54,7 +54,7 @@ BEGIN driver uartlite OPTION supported_peripherals = (mdm axi_uartlite); OPTION driver_state = ACTIVE; OPTION copyfiles = all; - OPTION VERSION = 3.0; + OPTION VERSION = 3.1; OPTION NAME = uartlite; BEGIN INTERFACE stdin diff --git a/XilinxProcessorIPLib/drivers/uartlite/src/xuartlite.c b/XilinxProcessorIPLib/drivers/uartlite/src/xuartlite.c index dd686dda..71e3533f 100644 --- a/XilinxProcessorIPLib/drivers/uartlite/src/xuartlite.c +++ b/XilinxProcessorIPLib/drivers/uartlite/src/xuartlite.c @@ -69,6 +69,10 @@ * 2.01a adk 18/04/13 Updated the code to avoid unused variable * warnings when compiling with the -Wextra -Wall flags * In the file xuartlite.c. CR:704999. +* 3.1 nsk 21/07/15 Updated XUartLite_ReceiveBuffer function to update the +* receive data into user buffer in critical region. +* CR#865787. +* * * *****************************************************************************/ @@ -576,8 +580,16 @@ unsigned int XUartLite_SendBuffer(XUartLite *InstancePtr) unsigned int XUartLite_ReceiveBuffer(XUartLite *InstancePtr) { u8 StatusRegister; + u8 StatusRegisterVal; unsigned int ReceivedCount = 0; + /* + * Enter a critical region by disabling all the UART interrupts to allow + * this call to stop a previous operation that may be interrupt driven + */ + StatusRegisterVal = XUartLite_GetStatusReg(InstancePtr->RegBaseAddress); + XUartLite_WriteReg(InstancePtr->RegBaseAddress, + XUL_CONTROL_REG_OFFSET, 0); /* * Loop until there is not more data buffered by the UART or the * specified number of bytes is received @@ -613,14 +625,6 @@ unsigned int XUartLite_ReceiveBuffer(XUartLite *InstancePtr) } } - /* - * Enter a critical region by disabling all the UART interrupts to allow - * this call to stop a previous operation that may be interrupt driven - */ - StatusRegister = XUartLite_GetStatusReg(InstancePtr->RegBaseAddress); - XUartLite_WriteReg(InstancePtr->RegBaseAddress, - XUL_CONTROL_REG_OFFSET, 0); - /* * Update the receive buffer to reflect the number of bytes that was * received @@ -637,9 +641,9 @@ unsigned int XUartLite_ReceiveBuffer(XUartLite *InstancePtr) * Restore the interrupt enable register to it's previous value such * that the critical region is exited */ - StatusRegister &= XUL_CR_ENABLE_INTR; + StatusRegisterVal &= XUL_CR_ENABLE_INTR; XUartLite_WriteReg(InstancePtr->RegBaseAddress, - XUL_CONTROL_REG_OFFSET, StatusRegister); + XUL_CONTROL_REG_OFFSET, StatusRegisterVal); return ReceivedCount; } diff --git a/XilinxProcessorIPLib/drivers/uartlite/src/xuartlite.h b/XilinxProcessorIPLib/drivers/uartlite/src/xuartlite.h index cd867fe9..d6036b8f 100644 --- a/XilinxProcessorIPLib/drivers/uartlite/src/xuartlite.h +++ b/XilinxProcessorIPLib/drivers/uartlite/src/xuartlite.h @@ -134,6 +134,9 @@ * 3.0 adk 17/12/13 Fixed CR:741186,761863 Changes are made in the file * xuartlite_selftest.c * 3.0 adk 19/12/13 Update the driver as per new TCL API's +* 3.1 nsk 21/07/15 Updated XUartLite_ReceiveBuffer function in xuartlite.c +* to update the receive data into user buffer in critical +* region.CR#865787. * * *