T398: Source cleanup for tool chain integration
This is a code cleanup to improve portability.
Specific issues addressed:
- Added type casts to (void *) here and there
- Changed non-standard \e escapes to \033
- Added cmake function to handle preinclude
- Changed a few Image$$ references to make use of the REGION_DECLARE
macro
- Reordered code slightly to avoid the need for a "void *rangeptr"
variable
- Changed compile time check typedef "err_msg" to avoid declaring
zero sized array, which is not standards compliant. It will now
either be -1 (error) or 1 (ok), not -1 and 0
- Reordered the *nfsptr_t typedef to make the cmse_nonsecure_call
standards compliant
- Added null tests to both secure and non_secure suites to avoid
defining zero length array. Also use this to find end of list
- Only define __stdout for ARMCLANG builds and conditionalize ns printf
output for ARMCLANG/GCC/IAR
- Cleaned up some enum type mismatches
- Changed non standard EINVAL error return to -1. The value was only
checked against 0 anyway
- Added type cast for conversion from float to int
Have tested with IAR, which starts and runs the idle thread. Changes
related to this is not included in this commit.
Author: Thomas Tornblom <thomas.tornblom@iar.com>
Signed-off-by: Thomas Tornblom <thomas.tornblom@iar.com>
Note: Sign off authority needs to adhere to the [DCO](./dco.txt)
rules.
Change-Id: I3e5229c0777623b128474af0311020ccacc1b797
diff --git a/app/main_ns.c b/app/main_ns.c
index 0205b1b..c648dfe 100644
--- a/app/main_ns.c
+++ b/app/main_ns.c
@@ -57,6 +57,7 @@
*/
};
+#if defined(__ARMCC_VERSION)
/* Struct FILE is implemented in stdio.h. Used to redirect printf to
* NS_DRIVER_STDIO
*/
@@ -68,6 +69,7 @@
/* Return character written */
return ch;
}
+#elif defined(__GNUC__)
/* redirects gcc printf to NS_DRIVER_STDIO */
int _write(int fd, char * str, int len)
{
@@ -75,6 +77,15 @@
return len;
}
+#elif defined(__ICCARM__)
+int putchar(int ch)
+{
+ /* Send byte to NS_DRIVER_STDIO */
+ (void)NS_DRIVER_STDIO.Send((const unsigned char *)&ch, 1);
+ /* Return character written */
+ return ch;
+}
+#endif
/**
* \brief List of RTOS thread attributes
diff --git a/app/os_wrapper_rtx.c b/app/os_wrapper_rtx.c
index 0952b2c..9a9a887 100644
--- a/app/os_wrapper_rtx.c
+++ b/app/os_wrapper_rtx.c
@@ -23,7 +23,7 @@
task_attribs.attr_bits = osThreadJoinable;
task_attribs.stack_size = stack_size;
task_attribs.name = name;
- task_attribs.priority = priority;
+ task_attribs.priority = (osPriority_t) priority;
thread_id = osThreadNew(func, arg, &task_attribs);
if (thread_id == NULL) {
diff --git a/app/tfm_integ_test.h b/app/tfm_integ_test.h
index a823ff1..1e419d2 100644
--- a/app/tfm_integ_test.h
+++ b/app/tfm_integ_test.h
@@ -50,10 +50,10 @@
#ifndef LOG_MSG_HANDLER_MODE_PRINTF_ENABLED
/* if IPSR is non-zero, exception is active. NOT banked S/NS */
if (!__get_IPSR()) {
- printf("\t\e[1;32m[Non-Sec] %s\e[0m\r\n", MSG);
+ printf("\t\033[1;32m[Non-Sec] %s\033[0m\r\n", MSG);
}
#else
- printf("\t\e[1;32m[Non-Sec] %s\e[0m\r\n", MSG);
+ printf("\t\033[1;32m[Non-Sec] %s\033[0m\r\n", MSG);
#endif
}