Platform: Add BL2 platform-specific hw initialization
Adding boot_platform_init() function.
Contrarily to SystemInit() intended for a high priority hw
initialization (for example clock and power subsystems), and
called on a very early boot stage from startup code, this
function is called from C code, hence variables and other drivers
data are protected from being cleared up by the C library init.
This function can be used for initializing platform-specific hw
resources (e.g. IPC, UART) thus freeing up application main()
function from the platform details.
Implemented as a "weak" function, it can be overwritten by a platform
specific implementation.
Signed-off-by: Andrei Narkevitch <ainh@cypress.com>
Change-Id: Id48c1443862fd52a4c11ac5071bbba8352c718b7
diff --git a/platform/ext/Mps2AN519.cmake b/platform/ext/Mps2AN519.cmake
index 7ae3e9e..616b2fe 100644
--- a/platform/ext/Mps2AN519.cmake
+++ b/platform/ext/Mps2AN519.cmake
@@ -1,5 +1,5 @@
#-------------------------------------------------------------------------------
-# Copyright (c) 2018-2019, Arm Limited. All rights reserved.
+# Copyright (c) 2018-2020, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -144,6 +144,7 @@
if (NOT DEFINED BUILD_BOOT_HAL)
message(FATAL_ERROR "Configuration variable BUILD_BOOT_HAL (true|false) is undefined!")
elseif(BUILD_BOOT_HAL)
+ list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/boot_hal.c")
list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an519/boot_hal.c")
endif()
diff --git a/platform/ext/Mps2AN521.cmake b/platform/ext/Mps2AN521.cmake
index aa008e4..13ffa4e 100644
--- a/platform/ext/Mps2AN521.cmake
+++ b/platform/ext/Mps2AN521.cmake
@@ -1,5 +1,5 @@
#-------------------------------------------------------------------------------
-# Copyright (c) 2018-2019, Arm Limited. All rights reserved.
+# Copyright (c) 2018-2020, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -145,6 +145,7 @@
if (NOT DEFINED BUILD_BOOT_HAL)
message(FATAL_ERROR "Configuration variable BUILD_BOOT_HAL (true|false) is undefined!")
elseif(BUILD_BOOT_HAL)
+ list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/boot_hal.c")
list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an521/boot_hal.c")
endif()
diff --git a/platform/ext/Mps2AN539.cmake b/platform/ext/Mps2AN539.cmake
index c2c5cf9..363630a 100644
--- a/platform/ext/Mps2AN539.cmake
+++ b/platform/ext/Mps2AN539.cmake
@@ -1,5 +1,5 @@
#-------------------------------------------------------------------------------
-# Copyright (c) 2019, Arm Limited. All rights reserved.
+# Copyright (c) 2019-2020, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -179,6 +179,7 @@
if (NOT DEFINED BUILD_BOOT_HAL)
message(FATAL_ERROR "Configuration variable BUILD_BOOT_HAL (true|false) is undefined!")
elseif(BUILD_BOOT_HAL)
+ list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/boot_hal.c")
list(APPEND ALL_SRC_C "${AN539_DIR}/boot_hal.c")
endif()
diff --git a/platform/ext/Mps3AN524.cmake b/platform/ext/Mps3AN524.cmake
index f546bba..26a55a7 100644
--- a/platform/ext/Mps3AN524.cmake
+++ b/platform/ext/Mps3AN524.cmake
@@ -1,5 +1,5 @@
#-------------------------------------------------------------------------------
-# Copyright (c) 2019, Arm Limited. All rights reserved.
+# Copyright (c) 2019-2020, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -151,6 +151,7 @@
if (NOT DEFINED BUILD_BOOT_HAL)
message(FATAL_ERROR "Configuration variable BUILD_BOOT_HAL (true|false) is undefined!")
elseif(BUILD_BOOT_HAL)
+ list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/boot_hal.c")
list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps3/an524/boot_hal.c")
endif()
diff --git a/platform/ext/SSE-200_AWS.cmake b/platform/ext/SSE-200_AWS.cmake
index fa44101..32c0847 100644
--- a/platform/ext/SSE-200_AWS.cmake
+++ b/platform/ext/SSE-200_AWS.cmake
@@ -1,5 +1,5 @@
#-------------------------------------------------------------------------------
-# Copyright (c) 2018-2019, Arm Limited. All rights reserved.
+# Copyright (c) 2018-2020, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -145,6 +145,7 @@
if (NOT DEFINED BUILD_BOOT_HAL)
message(FATAL_ERROR "Configuration variable BUILD_BOOT_HAL (true|false) is undefined!")
elseif(BUILD_BOOT_HAL)
+ list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/boot_hal.c")
list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/sse-200_aws/boot_hal.c")
endif()
diff --git a/platform/ext/common/boot_hal.c b/platform/ext/common/boot_hal.c
new file mode 100644
index 0000000..16b0aa7
--- /dev/null
+++ b/platform/ext/common/boot_hal.c
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#include "target_cfg.h"
+#include "cmsis.h"
+#include "Driver_Flash.h"
+#include "flash_layout.h"
+
+/* Flash device name must be specified by target */
+extern ARM_DRIVER_FLASH FLASH_DEV_NAME;
+
+/* bootloader platform-specific hw initialization */
+__WEAK int32_t boot_platform_init(void)
+{
+ int32_t result;
+
+ result = FLASH_DEV_NAME.Initialize(NULL);
+ if (result == ARM_DRIVER_OK) {
+ return 0;
+ }
+
+ return 1;
+}
diff --git a/platform/ext/musca_a.cmake b/platform/ext/musca_a.cmake
index c9161d4..d8422c5 100644
--- a/platform/ext/musca_a.cmake
+++ b/platform/ext/musca_a.cmake
@@ -1,5 +1,5 @@
#-------------------------------------------------------------------------------
-# Copyright (c) 2018-2019, Arm Limited. All rights reserved.
+# Copyright (c) 2018-2020, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -140,6 +140,7 @@
if (NOT DEFINED BUILD_BOOT_HAL)
message(FATAL_ERROR "Configuration variable BUILD_BOOT_HAL (true|false) is undefined!")
elseif(BUILD_BOOT_HAL)
+ list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/boot_hal.c")
list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_a/boot_hal.c")
endif()
diff --git a/platform/ext/musca_b1.cmake b/platform/ext/musca_b1.cmake
index c739870..c6e1418 100644
--- a/platform/ext/musca_b1.cmake
+++ b/platform/ext/musca_b1.cmake
@@ -1,5 +1,5 @@
#-------------------------------------------------------------------------------
-# Copyright (c) 2018-2019, Arm Limited. All rights reserved.
+# Copyright (c) 2018-2020, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -153,6 +153,7 @@
if (NOT DEFINED BUILD_BOOT_HAL)
message(FATAL_ERROR "Configuration variable BUILD_BOOT_HAL (true|false) is undefined!")
elseif(BUILD_BOOT_HAL)
+ list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/boot_hal.c")
list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_b1/boot_hal.c")
endif()
diff --git a/platform/ext/musca_s1.cmake b/platform/ext/musca_s1.cmake
index c3e4bc2..68ec513 100644
--- a/platform/ext/musca_s1.cmake
+++ b/platform/ext/musca_s1.cmake
@@ -1,5 +1,5 @@
#-------------------------------------------------------------------------------
-# Copyright (c) 2018-2019, Arm Limited. All rights reserved.
+# Copyright (c) 2018-2020, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -145,6 +145,7 @@
if (NOT DEFINED BUILD_BOOT_HAL)
message(FATAL_ERROR "Configuration variable BUILD_BOOT_HAL (true|false) is undefined!")
elseif(BUILD_BOOT_HAL)
+ list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/boot_hal.c")
list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_s1/boot_hal.c")
endif()