aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike J. Chen <mjchen@google.com>2012-03-01 10:31:03 -0800
committerMike J. Chen <mjchen@google.com>2012-03-07 10:01:13 -0800
commitb93c6cbffaf30afbb47c59b710e70e2735a33108 (patch)
tree002fc04df0ec8905a4e002d1daa8d51576549bb7
parentc097ba3e8df2382e051a409fdc85f55d792decec (diff)
downloaduboot-b93c6cbffaf30afbb47c59b710e70e2735a33108.tar.gz
ARMV7: omap4: Add Public to Secure entry API to call PPA HAL services
Introduced abstraction API using Public ROM Code's PUBLIC_API_SEC_ENTRY API to call PPA HAL services. Change-Id: Iced8d3dc083d6a35bbab7f4680764395f47b9b2a Signed-off-by: Carlos Leija <cileija@ti.com> Signed-off-by: Mike J. Chen <mjchen@google.com>
-rw-r--r--arch/arm/cpu/armv7/omap4/Makefile2
-rw-r--r--arch/arm/cpu/armv7/omap4/hal_services.c103
-rw-r--r--arch/arm/include/asm/arch-omap4/omap4_hal.h68
3 files changed, 173 insertions, 0 deletions
diff --git a/arch/arm/cpu/armv7/omap4/Makefile b/arch/arm/cpu/armv7/omap4/Makefile
index e7ee0b8c0..567596bb0 100644
--- a/arch/arm/cpu/armv7/omap4/Makefile
+++ b/arch/arm/cpu/armv7/omap4/Makefile
@@ -35,6 +35,8 @@ COBJS += sdram_elpida.o
ifndef CONFIG_SPL_BUILD
COBJS += mem.o
COBJS += sys_info.o
+COBJS-$(CONFIG_OMAP_SECURE_HAL) += hal_services.o
+COBJS += $(COBJS-y)
endif
SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
diff --git a/arch/arm/cpu/armv7/omap4/hal_services.c b/arch/arm/cpu/armv7/omap4/hal_services.c
new file mode 100644
index 000000000..cb2739875
--- /dev/null
+++ b/arch/arm/cpu/armv7/omap4/hal_services.c
@@ -0,0 +1,103 @@
+/*
+ * (C) Copyright 2012
+ * Texas Instruments, <www.ti.com>
+ * Carlos Leija <cileija@ti.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+#include <asm/arch/omap4_hal.h>
+#include <common.h>
+
+/*
+ * Abstraction API to format arguments to pass to
+ * PUBLIC_API_SEC_ENTRY
+ */
+U32 SEC_ENTRY_Std_Ppa_Call (U32 appl_id, U32 inNbArg, ...)
+{
+ U32 result = 0;
+ U32 Param[4];
+ va_list ap;
+
+ va_start(ap, inNbArg);
+
+ /* we must disable cache because the ROM dispatcher will
+ marshal arguments onto a stack structure before passing
+ it to secure mode and secure mode has a different mapping
+ of the memory and won't be able to see what was put on
+ the stack from our mapping.
+ */
+ flush_dcache_all();
+ dcache_disable();
+ switch (inNbArg)
+ {
+ case 0:
+ result = PUBLIC_SEC_ENTRY_Pub2SecDispatcher(
+ appl_id,
+ 0,
+ FLAG_START_CRITICAL,
+ inNbArg);
+ break;
+
+ case 1:
+ Param[0] = va_arg(ap, U32);
+ result = PUBLIC_SEC_ENTRY_Pub2SecDispatcher(
+ appl_id,
+ 0,
+ FLAG_START_CRITICAL,
+ inNbArg, Param[0]);
+ break;
+
+ case 2:
+ Param[0] = va_arg(ap, U32);
+ Param[1] = va_arg(ap, U32);
+ result = PUBLIC_SEC_ENTRY_Pub2SecDispatcher(
+ appl_id,
+ 0,
+ FLAG_START_CRITICAL,
+ inNbArg, Param[0], Param[1]);
+ break;
+
+ case 3:
+ Param[0] = va_arg(ap, U32);
+ Param[1] = va_arg(ap, U32);
+ Param[2] = va_arg(ap, U32);
+ result = PUBLIC_SEC_ENTRY_Pub2SecDispatcher(
+ appl_id,
+ 0,
+ FLAG_START_CRITICAL,
+ inNbArg, Param[0], Param[1], Param[2]);
+ break;
+ case 4:
+ Param[0] = va_arg(ap, U32);
+ Param[1] = va_arg(ap, U32);
+ Param[2] = va_arg(ap, U32);
+ Param[3] = va_arg(ap, U32);
+ result = PUBLIC_SEC_ENTRY_Pub2SecDispatcher(
+ appl_id,
+ 0,
+ FLAG_START_CRITICAL,
+ inNbArg, Param[0], Param[1], Param[2], Param[3]);
+ break;
+ default:
+ printf("[ERROR] [SEC_ENTRY] Number of arguments not supported \n");
+ dcache_enable();
+ return 1;
+ }
+ dcache_enable();
+ va_end(ap);
+ if (result != 0)
+ printf("[ERROR] [SEC_ENTRY] Call to Secure HAL failed!\n");
+ return result;
+}
diff --git a/arch/arm/include/asm/arch-omap4/omap4_hal.h b/arch/arm/include/asm/arch-omap4/omap4_hal.h
new file mode 100644
index 000000000..8248a1197
--- /dev/null
+++ b/arch/arm/include/asm/arch-omap4/omap4_hal.h
@@ -0,0 +1,68 @@
+/*
+ * (C) Copyright 2012
+ * Texas Instruments, <www.ti.com>
+ * Carlos Leija <cileija@ti.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef _OMAP4_HAL_H
+#define _OMAP4_HAL_H_
+
+#include <asm/sizes.h>
+
+/*
+ * Constants
+ */
+
+#define FLAG_START_CRITICAL 0x7
+#define PUBLIC_API_SEC_ENTRY 0x0
+
+/* Find base address based on OMAP revision */
+#define PUBLIC_API_BASE ( \
+ ((*((volatile unsigned int *)(0x4A002204))>>12) & 0x00F0)== 0x0040 ? \
+ 0x00030400 : 0x00028400 )
+
+/*
+ * Type definitions
+ */
+typedef unsigned char U8;
+typedef unsigned short U16;
+typedef unsigned int U32;
+typedef volatile unsigned int VU32;
+
+typedef U32 (** const PUBLIC_SEC_ENTRY_Pub2SecDispatcher_pt) \
+ (U32 appl_id, U32 proc_ID, U32 flag, ...);
+
+
+/*
+ * Function declaration
+ */
+
+/* Pointer to Public ROM Pub2SecDispatcher */
+#define PUBLIC_SEC_ENTRY_Pub2SecDispatcher \
+ (*(PUBLIC_SEC_ENTRY_Pub2SecDispatcher_pt) \
+ (PUBLIC_API_BASE+PUBLIC_API_SEC_ENTRY))
+
+U32 SEC_ENTRY_Std_Ppa_Call (U32 appl_id, U32 inNbArg, ...);
+
+U32 bch_enc(U8 index, U32 in_v[]);
+U32 cpfrom_byte_reverse32(U32 value);
+U32 hexStringtoInteger(const char* hexString, U32* result);
+
+#endif