Platform: Unify NS and secure UART STDOUT implementation
The uart_stdout implementations are actually identical for
Non-secure and Secure. The only difference is the actual
underlying stdio driver.
This patch unifies the implementations to one file, using
Macro to distinguish different drivers.
The patch also removes the unused enum uart_channel.
Change-Id: Ice89127cc98bd185947ce8de7af5190bd5bd69dc
Signed-off-by: Kevin Peng <kevin.peng@arm.com>
diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt
index d8fe183..eadbb54 100644
--- a/app/CMakeLists.txt
+++ b/app/CMakeLists.txt
@@ -167,7 +167,7 @@
set(BUILD_TARGET_HARDWARE_KEYS Off)
set(BUILD_TARGET_NV_COUNTERS Off)
set(BUILD_CMSIS_DRIVERS On)
-set(BUILD_UART_STDOUT Off)
+set(BUILD_UART_STDOUT On)
set(BUILD_FLASH Off)
if(CORE_TEST_POSITIVE)
set(BUILD_PLAT_TEST On)
diff --git a/app/main_ns.c b/app/main_ns.c
index 0c95a38..65a5242 100644
--- a/app/main_ns.c
+++ b/app/main_ns.c
@@ -26,6 +26,7 @@
#endif
#include "log/tfm_assert.h"
#include "log/tfm_log.h"
+#include "uart_stdout.h"
/**
* \brief Modified table template for user defined SVC functions
@@ -106,24 +107,6 @@
}
#endif
-/* For UART the CMSIS driver is used */
-extern ARM_DRIVER_USART NS_DRIVER_STDIO;
-
-int stdio_output_string(const unsigned char *str, uint32_t len)
-{
- int32_t ret;
-
- ret = NS_DRIVER_STDIO.Send(str, len);
- if (ret != ARM_DRIVER_OK) {
- return 0;
- }
- /* Add a busy wait after sending. */
- while (NS_DRIVER_STDIO.GetStatus().tx_busy)
- ;
-
- return NS_DRIVER_STDIO.GetTxCount();
-}
-
/**
* \brief Platform peripherals and devices initialization.
* Can be overridden for platform specific initialization.
@@ -132,19 +115,7 @@
*/
__WEAK int32_t tfm_ns_platform_init(void)
{
- int32_t ret;
-
- ret = NS_DRIVER_STDIO.Initialize(NULL);
- TFM_ASSERT(ret == ARM_DRIVER_OK);
-
- ret = NS_DRIVER_STDIO.PowerControl(ARM_POWER_FULL);
- TFM_ASSERT(ret == ARM_DRIVER_OK);
-
- ret = NS_DRIVER_STDIO.Control(ARM_USART_MODE_ASYNCHRONOUS,
- DEFAULT_UART_BAUDRATE);
- TFM_ASSERT(ret == ARM_DRIVER_OK);
-
- (void)NS_DRIVER_STDIO.Control(ARM_USART_CONTROL_TX, 1);
+ stdio_init();
return ARM_DRIVER_OK;
}
@@ -157,12 +128,7 @@
*/
__WEAK int32_t tfm_ns_platform_uninit(void)
{
- int32_t ret;
-
- (void)NS_DRIVER_STDIO.PowerControl(ARM_POWER_OFF);
-
- ret = NS_DRIVER_STDIO.Uninitialize();
- TFM_ASSERT(ret == ARM_DRIVER_OK);
+ stdio_uninit();
return ARM_DRIVER_OK;
}
diff --git a/app/uart_stdout.h b/app/uart_stdout.h
deleted file mode 100644
index 7c69c71..0000000
--- a/app/uart_stdout.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Copyright (c) 2019, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- *
- */
-
-#ifndef __UART_STDOUT_H__
-#define __UART_STDOUT_H__
-
-#include <stdint.h>
-
-/**
- * \brief Output buffer by STDIO.
- */
-int stdio_output_string(const unsigned char *str, uint32_t len);
-
-#endif /* __UART_STDOUT_H__ */