aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Bellows <greg.bellows@linaro.org>2014-09-12 16:45:59 -0500
committerGreg Bellows <greg.bellows@linaro.org>2014-09-12 16:45:59 -0500
commitf6102cd929db41eb11471506eb03a567e1a63e02 (patch)
treeb245f60e4ec53cd9ab0d85d82546e9baac0cf1f0
parent551f7f74f2b9743cf671375c45f8cc7aa80cedc9 (diff)
Cleanup header names and inclusion
Signed-off-by: Greg Bellows <greg.bellows@linaro.org>
-rw-r--r--arm/Makefile.tztest4
-rw-r--r--arm/common_defs.h (renamed from arm/tztest_asm.h)0
-rw-r--r--arm/common_mmu.c (renamed from arm/tztest_mmu.c)5
-rw-r--r--arm/common_mmu.h (renamed from arm/tztest_mmu.h)0
-rw-r--r--arm/common_svc.c (renamed from arm/tztest_common.c)5
-rw-r--r--arm/common_svc.h71
-rw-r--r--arm/monitor.c3
-rw-r--r--arm/monitor_asm.S2
-rw-r--r--arm/nonsecure_init.S2
-rw-r--r--arm/nonsecure_loader.h18
-rw-r--r--arm/nonsecure_svc.c37
-rw-r--r--arm/secure_asm.S2
-rw-r--r--arm/secure_init.S2
-rw-r--r--arm/secure_loader.h21
-rw-r--r--arm/secure_svc.c44
-rw-r--r--arm/tztest.c2
-rw-r--r--arm/tztest.h71
17 files changed, 159 insertions, 130 deletions
diff --git a/arm/Makefile.tztest b/arm/Makefile.tztest
index c2dbd4d..fbedd7a 100644
--- a/arm/Makefile.tztest
+++ b/arm/Makefile.tztest
@@ -16,8 +16,8 @@ TZSECOBJS = $(ARCH)/secure_init.o \
TZNSECOBJS = $(ARCH)/nonsecure_init.o \
$(ARCH)/nonsecure_svc.o \
$(ARCH)/tztest.o
-TZOBJS = $(ARCH)/tztest_mmu.o \
- $(ARCH)/tztest_common.o
+TZOBJS = $(ARCH)/common_mmu.o \
+ $(ARCH)/common_svc.o
LIBCFLAT_OBJS += $(LIBCFLAT_objdir)/devicetree.o \
$(LIBCFLAT_objdir)/virtio.o \
$(LIBCFLAT_objdir)/virtio-testdev.o \
diff --git a/arm/tztest_asm.h b/arm/common_defs.h
index de46a6b..de46a6b 100644
--- a/arm/tztest_asm.h
+++ b/arm/common_defs.h
diff --git a/arm/tztest_mmu.c b/arm/common_mmu.c
index 3e11277..cf9fc15 100644
--- a/arm/tztest_mmu.c
+++ b/arm/common_mmu.c
@@ -1,5 +1,6 @@
-#include "tztest.h"
-#include "tztest_mmu.h"
+#include "common_svc.h"
+#include "common_mmu.h"
+#include "common_defs.h"
void pagetable_add_section_entries(uint32_t *ttbr, pagetable_map_entry_t *pe)
{
diff --git a/arm/tztest_mmu.h b/arm/common_mmu.h
index 43da031..43da031 100644
--- a/arm/tztest_mmu.h
+++ b/arm/common_mmu.h
diff --git a/arm/tztest_common.c b/arm/common_svc.c
index c211afe..3d8ceb5 100644
--- a/arm/tztest_common.c
+++ b/arm/common_svc.c
@@ -1,4 +1,7 @@
-#include "tztest.h"
+#include "common_svc.h"
+#include "common_mmu.h"
+#include "common_defs.h"
+#include "sm.h"
extern uint32_t _shared_memory_heap_base;
diff --git a/arm/common_svc.h b/arm/common_svc.h
new file mode 100644
index 0000000..a9f19d5
--- /dev/null
+++ b/arm/common_svc.h
@@ -0,0 +1,71 @@
+#ifndef _COMMON_SVC_H
+#define _COMMON_SVC_H
+
+#include "tztest_builtins.h"
+#include "sm.h"
+#include "libcflat.h"
+
+typedef struct {
+ uint32_t (*func)(uint32_t);
+ uint32_t arg;
+ uint32_t ret;
+} tztest_dispatch_t;
+
+typedef struct {
+ union {
+ tztest_dispatch_t dispatch;
+ struct {
+ uint32_t reg;
+ uint32_t val;
+ } reg_read;
+ struct {
+ uint32_t state;
+ } secure_state;
+ };
+} tztest_svc_desc_t;
+
+#define CLEAR_SVC_DESC(_desc) memset(&(_desc), sizeof(tztest_svc_desc_t), 0)
+
+typedef struct {
+ union {
+ tztest_dispatch_t dispatch;
+ };
+} tztest_smc_desc_t;
+
+#ifdef DEBUG
+#define DEBUG_MSG(_str, ...) \
+ printf("\n[DEBUG] %s: " _str, __FUNCTION__, ##__VA_ARGS__)
+#define DEBUG_ARG
+#else
+#define DEBUG_MSG(_str, ...)
+#define DEBUG_ARG __attribute__ ((unused))
+#endif
+
+#define MODE_STR(_mode) \
+ ((_mode == MON) ? "MON" : \
+ (_mode == SVC) ? "SVC" : \
+ (_mode == SYS) ? "SYS" : \
+ (_mode == USR) ? "USR" : "Unknown")
+
+
+#define FAULT_STR(_s) \
+ ((0x01 == (_s)) ? "Alignment fault" : \
+ (0x02 == (_s)) ? "Debug event" : \
+ (0x03 == (_s)) ? "Access flag fault" : \
+ (0x04 == (_s)) ? "Instruction cache maintenance" : \
+ (0x05 == (_s)) ? "Translation fault" : \
+ (0x06 == (_s)) ? "Access flag fault" : \
+ (0x07 == (_s)) ? "Translation fault" : \
+ (0x08 == (_s)) ? "Synchronous external abort" : \
+ (0x09 == (_s)) ? "Domain fault" : \
+ (0x0b == (_s)) ? "Domain fault" : \
+ (0x0c == (_s)) ? "External abort on table walk" : \
+ (0x0d == (_s)) ? "Permisison fault" : \
+ (0x0e == (_s)) ? "Synchronous external abort" : \
+ (0x0f == (_s)) ? "Permisison fault" : \
+ (0x10 == (_s)) ? "TLB conflict abort" : \
+ (0x1c == (_s)) ? "External parity err on table walk" : \
+ (0x1e == (_s)) ? "External parity err on table walk" : \
+ "Unknown")
+
+#endif
diff --git a/arm/monitor.c b/arm/monitor.c
index a188c0d..32675a8 100644
--- a/arm/monitor.c
+++ b/arm/monitor.c
@@ -1,5 +1,6 @@
-#include "tztest.h"
+#include "common_svc.h"
+#include "common_defs.h"
void monitor_init_ns_entry(uint32_t entry_point)
{
diff --git a/arm/monitor_asm.S b/arm/monitor_asm.S
index ed17fc9..9105a68 100644
--- a/arm/monitor_asm.S
+++ b/arm/monitor_asm.S
@@ -1,5 +1,5 @@
-#include "tztest_asm.h"
+#include "common_defs.h"
.align 5
.global monitor_vectors
diff --git a/arm/nonsecure_init.S b/arm/nonsecure_init.S
index 54e33ae..656454e 100644
--- a/arm/nonsecure_init.S
+++ b/arm/nonsecure_init.S
@@ -1,4 +1,4 @@
-#include "tztest_asm.h"
+#include "common_defs.h"
/* The nonsecure image load code must be placed at the beginning of the image
* as this is the starting point for the boot code to load. The loader code
diff --git a/arm/nonsecure_loader.h b/arm/nonsecure_loader.h
new file mode 100644
index 0000000..f19b12f
--- /dev/null
+++ b/arm/nonsecure_loader.h
@@ -0,0 +1,18 @@
+#ifndef _NONSECURE_LOADER_H
+#define _NONSECURE_LOADER_H
+#include "sm.h"
+
+extern uint32_t _nsec_l1_page_table;
+extern uint32_t _ram_nsectext_start;
+extern uint32_t _ram_nsecdata_start;
+extern uint32_t _nsecstack_start;
+extern uint32_t _nsectext_size;
+extern uint32_t _nsecdata_size;
+extern uint32_t _nsecstack_size;
+extern uint32_t _shared_memory_heap_base;
+extern uint32_t _common_memory_heap_base;
+extern volatile int _tztest_exception;
+extern volatile int _tztest_exception_status;
+extern volatile int _tztest_exception_addr;
+
+#endif
diff --git a/arm/nonsecure_svc.c b/arm/nonsecure_svc.c
index 0e34498..332dc51 100644
--- a/arm/nonsecure_svc.c
+++ b/arm/nonsecure_svc.c
@@ -1,20 +1,11 @@
-#include "tztest.h"
+#include "nonsecure_loader.h"
+#include "common_svc.h"
+#include "common_mmu.h"
+#include "common_defs.h"
-uint32_t nonsecure_dispatch_secure_usr_function(uint32_t (*)(uint32_t), uint32_t);
-uint32_t nonsecure_dispatch_secure_svc_function(uint32_t (*)(uint32_t), uint32_t);
-extern uint32_t _nsec_l1_page_table;
+uint32_t nonsecure_dispatch_sec_usr_function(uint32_t (*)(uint32_t), uint32_t);
+uint32_t nonsecure_dispatch_sec_svc_function(uint32_t (*)(uint32_t), uint32_t);
uint32_t *nsec_l1_page_table = &_nsec_l1_page_table;
-extern uint32_t _ram_nsectext_start;
-extern uint32_t _ram_nsecdata_start;
-extern uint32_t _nsecstack_start;
-extern uint32_t _nsectext_size;
-extern uint32_t _nsecdata_size;
-extern uint32_t _nsecstack_size;
-extern uint32_t _shared_memory_heap_base;
-extern uint32_t _common_memory_heap_base;
-extern volatile int _tztest_exception;
-extern volatile int _tztest_exception_status;
-extern volatile int _tztest_exception_addr;
volatile int *tztest_exception = &_tztest_exception;
volatile int *tztest_exception_addr = &_tztest_exception_addr;
volatile int *tztest_exception_status = &_tztest_exception_status;
@@ -38,16 +29,16 @@ void nonsecure_svc_handler(volatile uint32_t op,
case SVC_DISPATCH_SECURE_USR:
DEBUG_MSG("Dispatching secure usr function\n");
desc->dispatch.ret =
- nonsecure_dispatch_secure_usr_function(desc->dispatch.func,
- desc->dispatch.arg);
+ nonsecure_dispatch_sec_usr_function(desc->dispatch.func,
+ desc->dispatch.arg);
DEBUG_MSG("Returning from secure usr function, ret = 0x%x\n",
desc->dispatch.ret);
break;
case SVC_DISPATCH_SECURE_SVC:
DEBUG_MSG("Dispatching secure svc function\n");
desc->dispatch.ret =
- nonsecure_dispatch_secure_svc_function(desc->dispatch.func,
- desc->dispatch.arg);
+ nonsecure_dispatch_sec_svc_function(desc->dispatch.func,
+ desc->dispatch.arg);
DEBUG_MSG("Returning from secure svc function, ret = 0x%x\n",
desc->dispatch.ret);
break;
@@ -91,8 +82,8 @@ void nonsecure_dabort_handler(int status, DEBUG_ARG int addr) {
*tztest_exception_status = status & 0x1f;
}
-uint32_t nonsecure_dispatch_secure_usr_function(uint32_t (*func)(uint32_t),
- uint32_t arg)
+uint32_t nonsecure_dispatch_sec_usr_function(uint32_t (*func)(uint32_t),
+ uint32_t arg)
{
volatile int r0 = SMC_DISPATCH_SECURE_USR;
tztest_smc_desc_t *desc_p = &smc_desc;
@@ -105,8 +96,8 @@ uint32_t nonsecure_dispatch_secure_usr_function(uint32_t (*func)(uint32_t),
return smc_desc.dispatch.ret;
}
-uint32_t nonsecure_dispatch_secure_svc_function(uint32_t (*func)(uint32_t),
- uint32_t arg)
+uint32_t nonsecure_dispatch_sec_svc_function(uint32_t (*func)(uint32_t),
+ uint32_t arg)
{
volatile int op = SMC_DISPATCH_SECURE_SVC;
tztest_smc_desc_t desc, *desc_p = &desc;
diff --git a/arm/secure_asm.S b/arm/secure_asm.S
index 083f53a..9761a6c 100644
--- a/arm/secure_asm.S
+++ b/arm/secure_asm.S
@@ -1,5 +1,5 @@
-#include "tztest_asm.h"
+#include "common_defs.h"
.global secure_dispatch_usr
secure_dispatch_usr:
diff --git a/arm/secure_init.S b/arm/secure_init.S
index 9ad4846..c09499b 100644
--- a/arm/secure_init.S
+++ b/arm/secure_init.S
@@ -1,4 +1,4 @@
-#include "tztest_asm.h"
+#include "common_defs.h"
.arch_extension sec
diff --git a/arm/secure_loader.h b/arm/secure_loader.h
new file mode 100644
index 0000000..577d6e5
--- /dev/null
+++ b/arm/secure_loader.h
@@ -0,0 +1,21 @@
+#ifndef _SECURE_LOADER_H
+#define _SECURE_LOADER_H
+#include "sm.h"
+
+extern int _ram_nsec_base;
+extern uint32_t _sec_l1_page_table;
+extern uint32_t _ram_secvecs_start;
+extern uint32_t _ram_sectext_start;
+extern uint32_t _ram_secdata_start;
+extern uint32_t _secstack_start;
+extern uint32_t _secvecs_size;
+extern uint32_t _sectext_size;
+extern uint32_t _secdata_size;
+extern uint32_t _secstack_size;
+extern uint32_t _shared_memory_heap_base;
+extern uint32_t _common_memory_heap_base;
+extern volatile uint32_t _tztest_exception;
+extern volatile uint32_t _tztest_exception_addr;
+extern volatile uint32_t _tztest_exception_status;
+
+#endif
diff --git a/arm/secure_svc.c b/arm/secure_svc.c
index d34f180..c8a723e 100644
--- a/arm/secure_svc.c
+++ b/arm/secure_svc.c
@@ -1,32 +1,20 @@
-#include "tztest.h"
+#include "secure_loader.h"
+#include "common_svc.h"
+#include "common_mmu.h"
+#include "common_defs.h"
/* Make the below globals volatile as found that the compiler uses the
* register value ratherh than the memory value making it look like the writes
* actually happened.
*/
-extern int _ram_nsec_base;
int secure_dispatch_usr(int, int);
void secure_svc_loop(int initial_r0, int initial_r1);
-void *sec_allocate_secure_memory(int);
-extern uint32_t _sec_l1_page_table;
+
+volatile uint32_t *exception = &_tztest_exception;
+volatile uint32_t *exception_addr = &_tztest_exception_addr;
+volatile uint32_t *exception_status = &_tztest_exception_status;
uint32_t *sec_l1_page_table = &_sec_l1_page_table;
-extern uint32_t _ram_secvecs_start;
-extern uint32_t _ram_sectext_start;
-extern uint32_t _ram_secdata_start;
-extern uint32_t _secstack_start;
-extern uint32_t _secvecs_size;
-extern uint32_t _sectext_size;
-extern uint32_t _secdata_size;
-extern uint32_t _secstack_size;
-extern uint32_t _shared_memory_heap_base;
-extern uint32_t _common_memory_heap_base;
-extern volatile int _tztest_exception;
-extern volatile int _tztest_exception_addr;
-extern volatile int _tztest_exception_status;
-volatile int *tztest_exception = &_tztest_exception;
-volatile int *tztest_exception_addr = &_tztest_exception_addr;
-volatile int *tztest_exception_status = &_tztest_exception_status;
uint32_t ram_secvecs_start = (uint32_t)&_ram_secvecs_start;
uint32_t ram_sectext_start = (uint32_t)&_ram_sectext_start;
uint32_t ram_secdata_start = (uint32_t)&_ram_secdata_start;
@@ -72,24 +60,24 @@ void secure_svc_handler(volatile uint32_t op, volatile tztest_svc_desc_t *desc)
void secure_undef_handler() {
DEBUG_MSG("Undefined exception taken\n");
- *tztest_exception = CPSR_MODE_UND;
- *tztest_exception_status = 0;
+ *exception = CPSR_MODE_UND;
+ *exception_status = 0;
}
void secure_pabort_handler(int status, int addr) {
DEBUG_MSG("status = 0x%x\taddress = 0x%x\n", status, addr);
- *tztest_exception = CPSR_MODE_ABT;
- *tztest_exception_addr = addr;
- *tztest_exception_status = status & 0x1f;
+ *exception = CPSR_MODE_ABT;
+ *exception_addr = addr;
+ *exception_status = status & 0x1f;
}
void secure_dabort_handler(int status, int addr) {
DEBUG_MSG("Data Abort: %s\n", FAULT_STR(status & 0x1f));
DEBUG_MSG("status = 0x%x\taddress = 0x%x\n",
status & 0x1f, addr);
- *tztest_exception = CPSR_MODE_ABT;
- *tztest_exception_addr = addr;
- *tztest_exception_status = status & 0x1f;
+ *exception = CPSR_MODE_ABT;
+ *exception_addr = addr;
+ *exception_status = status & 0x1f;
}
void secure_check_init()
diff --git a/arm/tztest.c b/arm/tztest.c
index 945181b..5a539d8 100644
--- a/arm/tztest.c
+++ b/arm/tztest.c
@@ -1,7 +1,5 @@
#include "tztest.h"
-extern volatile int _tztest_fail_count;
-extern volatile int _tztest_test_count;
volatile int *tztest_fail_count = &_tztest_fail_count;
volatile int *tztest_test_count = &_tztest_test_count;
diff --git a/arm/tztest.h b/arm/tztest.h
index 1d06336..34ced86 100644
--- a/arm/tztest.h
+++ b/arm/tztest.h
@@ -1,74 +1,11 @@
#ifndef _TZTEST_H
#define _TZTEST_H
-#include "tztest_asm.h"
-#include "tztest_builtins.h"
-#include "tztest_mmu.h"
-#include "sm.h"
-#include "libcflat.h"
-
-typedef struct {
- uint32_t (*func)(uint32_t);
- uint32_t arg;
- uint32_t ret;
-} tztest_dispatch_t;
-
-typedef struct {
- union {
- tztest_dispatch_t dispatch;
- struct {
- uint32_t reg;
- uint32_t val;
- } reg_read;
- struct {
- uint32_t state;
- } secure_state;
- };
-} tztest_svc_desc_t;
-
-#define CLEAR_SVC_DESC(_desc) memset(&(_desc), sizeof(tztest_svc_desc_t), 0)
-
-typedef struct {
- union {
- tztest_dispatch_t dispatch;
- };
-} tztest_smc_desc_t;
-
-#ifdef DEBUG
-#define DEBUG_MSG(_str, ...) \
- printf("\n[DEBUG] %s: " _str, __FUNCTION__, ##__VA_ARGS__)
-#define DEBUG_ARG
-#else
-#define DEBUG_MSG(_str, ...)
-#define DEBUG_ARG __attribute__ ((unused))
-#endif
+#include "common_defs.h"
+#include "common_svc.h"
-#define MODE_STR(_mode) \
- ((_mode == MON) ? "MON" : \
- (_mode == SVC) ? "SVC" : \
- (_mode == SYS) ? "SYS" : \
- (_mode == USR) ? "USR" : "Unknown")
-
-
-#define FAULT_STR(_s) \
- ((0x01 == (_s)) ? "Alignment fault" : \
- (0x02 == (_s)) ? "Debug event" : \
- (0x03 == (_s)) ? "Access flag fault" : \
- (0x04 == (_s)) ? "Instruction cache maintenance" : \
- (0x05 == (_s)) ? "Translation fault" : \
- (0x06 == (_s)) ? "Access flag fault" : \
- (0x07 == (_s)) ? "Translation fault" : \
- (0x08 == (_s)) ? "Synchronous external abort" : \
- (0x09 == (_s)) ? "Domain fault" : \
- (0x0b == (_s)) ? "Domain fault" : \
- (0x0c == (_s)) ? "External abort on table walk" : \
- (0x0d == (_s)) ? "Permisison fault" : \
- (0x0e == (_s)) ? "Synchronous external abort" : \
- (0x0f == (_s)) ? "Permisison fault" : \
- (0x10 == (_s)) ? "TLB conflict abort" : \
- (0x1c == (_s)) ? "External parity err on table walk" : \
- (0x1e == (_s)) ? "External parity err on table walk" : \
- "Unknown")
+extern volatile int _tztest_fail_count;
+extern volatile int _tztest_test_count;
#define CALL(_f) __svc(0, _f)
#define RETURN(_r) __svc(0,(_r))