MLECO-2948: Minor refactoring for platform modules.

Reducing dependency on cmsis-device sources as these will
be removed under MLECO-2944. Also, starting to refactor
to allow HAL to drop NPU and TA init routines - this will
happen in future CRs.

Added platform driver for native, and subsequent patches
will attempt to get rid of the HAL "profile" specific
sources and allow platform stub implementations at a level
below HAL. This will allow platforms drivers to only
override the range of functions that they actually want to
implement and will fall back on stubs for the rest. In this
CR only "utils" have been removed.

Change-Id: I09b4a28e20847a07a956c818c6f47c74aab89063
diff --git a/source/hal/profiles/bare-metal/data_acquisition/data_acq.c b/source/hal/profiles/bare-metal/data_acquisition/data_acq.c
index 1e40b02..7113a24 100644
--- a/source/hal/profiles/bare-metal/data_acquisition/data_acq.c
+++ b/source/hal/profiles/bare-metal/data_acquisition/data_acq.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Arm Limited. All rights reserved.
+ * Copyright (c) 2021-2022 Arm Limited. All rights reserved.
  * SPDX-License-Identifier: Apache-2.0
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,6 +17,8 @@
 #include "data_acq.h"
 
 #include "bsp.h"
+#include "log_macros.h"
+#include "uart_stdout.h"
 
 #include <assert.h>
 #include <stdlib.h>
@@ -31,7 +33,6 @@
 static int get_uart_user_input(char* user_input, int size)
 {
     if (true != GetLine(user_input, size - 1)) {
-        printf_err("invalid input\n");
         return 1;
     }
     return 0;
diff --git a/source/hal/profiles/bare-metal/data_presentation/lcd/lcd_img.c b/source/hal/profiles/bare-metal/data_presentation/lcd/lcd_img.c
index 7064396..bb950c3 100644
--- a/source/hal/profiles/bare-metal/data_presentation/lcd/lcd_img.c
+++ b/source/hal/profiles/bare-metal/data_presentation/lcd/lcd_img.c
@@ -17,6 +17,7 @@
 #include "lcd_img.h"
 
 #include "bsp.h"
+#include "log_macros.h"
 
 #include <string.h>
 #include <assert.h>
diff --git a/source/hal/profiles/bare-metal/timer/platform_timer.c b/source/hal/profiles/bare-metal/timer/platform_timer.c
index c8e7252..11ccf8b 100644
--- a/source/hal/profiles/bare-metal/timer/platform_timer.c
+++ b/source/hal/profiles/bare-metal/timer/platform_timer.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Arm Limited. All rights reserved.
+ * Copyright (c) 2021-2022 Arm Limited. All rights reserved.
  * SPDX-License-Identifier: Apache-2.0
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,6 +16,7 @@
  */
 #include "bsp.h"
 #include "timer.h"
+#include "log_macros.h"
 
 #include <assert.h>
 #include <string.h>
diff --git a/source/hal/profiles/bare-metal/utils/include/system_init.h b/source/hal/profiles/bare-metal/utils/include/system_init.h
deleted file mode 100644
index 84e0305..0000000
--- a/source/hal/profiles/bare-metal/utils/include/system_init.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2021 Arm Limited. All rights reserved.
- * SPDX-License-Identifier: Apache-2.0
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef BAREMETAL_SYSTEM_INIT_H
-#define BAREMETAL_SYSTEM_INIT_H
-
-#include "bsp.h"
-
-/**
- * @brief   Initialises the platform (MPS3 FPGA board or Fixed Virtual Platform)
- *          Updates the system core clock and initialises the UART. It also
- *          verifies that the Cortex-M CPU variant being used matches the expected
- *          value if running on MPS3.
- * @return  0 if successful, error code otherwise.
-*/
-int system_init(void);
-
-/**
- * @brief  Releases the platform (MPS3 FPGA board or Fixed Virtual Platform).
- **/
-void system_release(void);
-
-/**
- * @brief  Return the name the platform (MPS3 FPGA board or Fixed Virtual Platform).
- * @param[out]   name Platform name string.
- * @param[in]    size Name string length.
- **/
-void system_name(char* name, size_t size);
-
-#endif /* BAREMETAL_SYSTEM_INIT_H */
diff --git a/source/hal/profiles/bare-metal/utils/system_init.c b/source/hal/profiles/bare-metal/utils/system_init.c
deleted file mode 100644
index 23af14f..0000000
--- a/source/hal/profiles/bare-metal/utils/system_init.c
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (c) 2021 Arm Limited. All rights reserved.
- * SPDX-License-Identifier: Apache-2.0
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "system_init.h"
-
-#include <string.h>
-#include <inttypes.h>
-
-#if defined(MPS3_PLATFORM)
-#define CREATE_MASK(msb, lsb)           (int)(((1U << ((msb) - (lsb) + 1)) - 1) << (lsb))
-#define MASK_BITS(arg, msb, lsb)        (int)((arg) & CREATE_MASK(msb, lsb))
-#define EXTRACT_BITS(arg, msb, lsb)     (int)(MASK_BITS(arg, msb, lsb) >> (lsb))
-#endif /* MPS3_PLATFORM */
-
-int system_init(void)
-{
-#if defined(MPS3_PLATFORM)
-    uint32_t id = 0;
-    uint32_t fpgaid = 0;
-    uint32_t apnote = 0;
-    uint32_t rev = 0;
-    uint32_t aid = 0;
-    uint32_t fpga_clk = 0;
-    const uint32_t ascii_A = (uint32_t)('A');
-
-    /* Initialise the LEDs as the switches are */
-    MPS3_FPGAIO->LED = MPS3_FPGAIO->SWITCHES & 0xFF;
-#endif
-
-    /* UART init - will enable valid use of printf (stdout
-     * re-directed at this UART (UART0) */
-    UartStdOutInit();
-    info("Processor internal clock: %" PRIu32 "Hz\n", GetSystemCoreClock());
-
-#if defined(MPS3_PLATFORM)
-    /* Get revision information from various registers */
-    rev = MPS3_SCC->CFG_REG4;
-    fpgaid = MPS3_SCC->SCC_ID;
-    aid = MPS3_SCC->SCC_AID;
-    apnote = EXTRACT_BITS(fpgaid, 15, 4);
-    fpga_clk = GetMPS3CoreClock();
-
-    info("V2M-MPS3 revision %c\n\n", (char)(rev + ascii_A));
-    info("Application Note AN%" PRIx32 ", Revision %c\n", apnote,
-        (char)(EXTRACT_BITS(aid, 23, 20) + ascii_A));
-    info("MPS3 build %d\n", EXTRACT_BITS(aid, 31, 24));
-    info("MPS3 core clock has been set to: %" PRIu32 "Hz\n", fpga_clk);
-
-    /* Display CPU ID */
-    id = SCB->CPUID;
-    info("CPU ID: 0x%08" PRIx32 "\n", id);
-
-    if(EXTRACT_BITS(id, 15, 8) == 0xD2) {
-        if (EXTRACT_BITS(id, 7, 4) == 2) {
-            info ("CPU: Cortex-M55 r%dp%d\n\n",
-                EXTRACT_BITS(id, 23, 20),EXTRACT_BITS(id, 3, 0));
-#if defined (CPU_CORTEX_M55)
-            /* CPU ID should be "0x_41_0f_d2_20" for Cortex-M55 */
-            return 0;
-#endif /* CPU_CORTEX_M55 */
-        } else if (EXTRACT_BITS(id, 7, 4) == 1) {
-            info ("CPU: Cortex-M33 r%dp%d\n\n",
-                EXTRACT_BITS(id, 23, 20),EXTRACT_BITS(id, 3, 0));
-#if defined (CPU_CORTEX_M33)
-            return 0;
-#endif /* CPU_CORTEX_M33 */
-        } else if (EXTRACT_BITS(id, 7, 4) == 0) {
-            info ("CPU: Cortex-M23 r%dp%d\n\n",
-                EXTRACT_BITS(id, 23, 20),EXTRACT_BITS(id, 3, 0));
-        } else {
-            info ("CPU: Cortex-M processor family");
-        }
-    } else if (EXTRACT_BITS(id, 15, 8) == 0xC6) {
-        info ("CPU: Cortex-M%d+ r%dp%d\n\n",
-            EXTRACT_BITS(id, 7, 4), EXTRACT_BITS(id, 23, 20),
-            EXTRACT_BITS(id, 3, 0));
-    } else {
-        info ("CPU: Cortex-M%d r%dp%d\n\n",
-            EXTRACT_BITS(id, 7, 4), EXTRACT_BITS(id, 23, 20),
-            EXTRACT_BITS(id, 3, 0));
-    }
-#else /* MPS3_PLATFORM */
-
-    info("%s: complete\n", __FUNCTION__);
-    return 0;
-#endif /* MPS3_PLATFORM */
-
-    /* If the CPU is anything other than M33 or M55, we return 1 */
-    printf_err("CPU mismatch!\n");
-    return 1;
-}
-
-void system_release(void)
-{
-    __disable_irq();
-}
-
-void system_name(char* name, size_t size)
-{
-    strncpy(name, DESIGN_NAME, size);
-}
\ No newline at end of file
diff --git a/source/hal/profiles/native/utils/include/system_init.h b/source/hal/profiles/native/utils/include/system_init.h
deleted file mode 100644
index 5d3fcd0..0000000
--- a/source/hal/profiles/native/utils/include/system_init.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2021 Arm Limited. All rights reserved.
- * SPDX-License-Identifier: Apache-2.0
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef NATIVE_SYSTEM_INIT_H
-#define NATIVE_SYSTEM_INIT_H
-
-#include <stddef.h>
-/**
- * @brief  Platform initialisation for native platform.
- **/
-int system_init(void);
-
-/**
- * @brief  Platform release for native platform.
- **/
-void system_release(void);
-
-/**
- * @brief       Returns the name of the platform.
- * @param[out]  name Platform name string.
- * @param[in]   size Name string length.
- */
-void system_name(char* name, size_t size);
-
-#endif /* NATIVE_SYSTEM_INIT_H */
diff --git a/source/hal/profiles/native/utils/system_init.c b/source/hal/profiles/native/utils/system_init.c
deleted file mode 100644
index 8e0b768..0000000
--- a/source/hal/profiles/native/utils/system_init.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2021 Arm Limited. All rights reserved.
- * SPDX-License-Identifier: Apache-2.0
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "system_init.h"
-
-#include <string.h>
-
-int system_init(void)
-{
-    return 0;
-}
-
-void system_release(void)
-{}
-
-void system_name(char* name, size_t size)
-{
-    strncpy(name, "native", size);
-}
\ No newline at end of file