[U-Boot] [PATCH v3 4/7] ARMv8: add the sec_firmware header file

Zhiqiang Hou Zhiqiang.Hou at nxp.com
Wed Apr 27 15:39:24 CEST 2016


From: Hou Zhiqiang <Zhiqiang.Hou at nxp.com>

The sec_firmware.h is a common header file for secure monitor
firmware under ARMv8. The common API can be added to this file,
and added APIs for secure firmware validation and getting
supported PSCI version.

Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou at nxp.com>
---
V3:
 - new patch

 arch/arm/cpu/armv8/fsl-layerscape/ppa.c        | 27 +++++++++++++++++++++++++-
 arch/arm/cpu/armv8/fsl-layerscape/ppa_entry.S  | 11 +++++++++++
 arch/arm/include/asm/arch-fsl-layerscape/ppa.h |  1 +
 arch/arm/include/asm/armv8/sec_firmware.h      | 19 ++++++++++++++++++
 4 files changed, 57 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/include/asm/armv8/sec_firmware.h

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/ppa.c b/arch/arm/cpu/armv8/fsl-layerscape/ppa.c
index aa71212..3cd4d00 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/ppa.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/ppa.c
@@ -17,7 +17,7 @@
 #elif defined(CONFIG_FSL_LSCH2)
 #include <asm/arch/immap_lsch2.h>
 #endif
-#include <asm/arch/ppa.h>
+#include <asm/armv8/sec_firmware.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -161,6 +161,31 @@ static int ppa_copy_image(const char *title,
 	return 0;
 }
 
+int sec_firmware_validate(void)
+{
+	void *ppa_addr;
+
+#ifdef CONFIG_SYS_LS_PPA_FW_IN_NOR
+	ppa_addr = (void *)CONFIG_SYS_LS_PPA_FW_ADDR;
+#else
+#error "No CONFIG_SYS_LS_PPA_FW_IN_xxx defined"
+#endif
+
+	return ppa_firmware_validate(ppa_addr);
+}
+
+#ifdef CONFIG_ARMV8_PSCI
+unsigned int sec_firmware_support_psci_version(void)
+{
+	unsigned int psci_ver = 0;
+
+	if (!sec_firmware_validate())
+		psci_ver = ppa_support_psci_version();
+
+	return psci_ver;
+}
+#endif
+
 int ppa_init_pre(u64 *entry)
 {
 	u64 ppa_ram_addr;
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/ppa_entry.S b/arch/arm/cpu/armv8/fsl-layerscape/ppa_entry.S
index 3a3bb64..1f5577b 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/ppa_entry.S
+++ b/arch/arm/cpu/armv8/fsl-layerscape/ppa_entry.S
@@ -40,3 +40,14 @@ ENTRY(ppa_init)
         mov	x0, #0
         ret
 ENDPROC(ppa_init)
+
+#ifdef CONFIG_ARMV8_PSCI
+ENTRY(ppa_support_psci_version)
+	mov	x0, 0x84000000
+	mov	x1, 0x0
+	mov	x2, 0x0
+	mov	x3, 0x0
+	smc	#0
+	ret
+ENDPROC(ppa_support_psci_version)
+#endif
diff --git a/arch/arm/include/asm/arch-fsl-layerscape/ppa.h b/arch/arm/include/asm/arch-fsl-layerscape/ppa.h
index f0f0d10..7b13d56 100644
--- a/arch/arm/include/asm/arch-fsl-layerscape/ppa.h
+++ b/arch/arm/include/asm/arch-fsl-layerscape/ppa.h
@@ -11,5 +11,6 @@ int ppa_init_pre(u64 *);
 int ppa_init_entry(void *);
 int ppa_init(void *, u32*, u32*);
 unsigned long ppa_get_dram_block_size(void);
+unsigned int ppa_support_psci_version(void);
 
 #endif
diff --git a/arch/arm/include/asm/armv8/sec_firmware.h b/arch/arm/include/asm/armv8/sec_firmware.h
new file mode 100644
index 0000000..a54a599
--- /dev/null
+++ b/arch/arm/include/asm/armv8/sec_firmware.h
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2015 Freescale Semiconductor, Inc.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef __SEC_FIRMWARE_H_
+#define __SEC_FIRMWARE_H_
+
+#ifdef CONFIG_FSL_LS_PPA
+#include <asm/arch/ppa.h>
+#endif
+
+#ifdef CONFIG_ARMV8_PSCI
+unsigned int sec_firmware_support_psci_version(void);
+#endif
+int sec_firmware_validate(void);
+
+#endif /* __SEC_FIRMWARE_H_ */
-- 
2.1.0.27.g96db324



More information about the U-Boot mailing list