summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeenu Viswambharan <jeenu.viswambharan@arm.com>2017-01-19 14:23:36 +0000
committerKostya Porotchkin <kostap@marvell.com>2018-04-15 14:12:16 +0300
commit31af8ba0b5e1b04f31352a4a7051e64be39cc463 (patch)
treedea46870b6d9661958d1c91812f9139851518787
parent1eed2fc33ab121f2792c8829f5dd96796a4a0a7e (diff)
Allow spin locks to be defined from assembly
At present, spin locks can only defined from C files. Add some macros such that they can be defined from assembly files too. Change-Id: I64f0c214062f5c15b3c8b412c7f25c908e87d970 Signed-off-by: Jeenu Viswambharan <jeenu.viswambharan@arm.com> Reviewed-on: http://vgitil04.il.marvell.com:8080/52566 Tested-by: iSoC Platform CI <ykjenk@marvell.com> Reviewed-by: Kostya Porotchkin <kostap@marvell.com>
-rw-r--r--include/common/aarch32/asm_macros.S12
-rw-r--r--include/common/aarch64/asm_macros.S13
-rw-r--r--include/lib/spinlock.h16
3 files changed, 37 insertions, 4 deletions
diff --git a/include/common/aarch32/asm_macros.S b/include/common/aarch32/asm_macros.S
index 5f044991..d75aeb5f 100644
--- a/include/common/aarch32/asm_macros.S
+++ b/include/common/aarch32/asm_macros.S
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2016-2017, ARM Limited and Contributors. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -32,6 +32,7 @@
#include <arch.h>
#include <asm_macros_common.S>
+#include <spinlock.h>
#define WORD_SIZE 4
@@ -102,4 +103,13 @@
ldr r0, =(\_name + \_size)
.endm
+ /*
+ * Reserve space for a spin lock in assembly file.
+ */
+ .macro define_asm_spinlock _name:req
+ .align SPINLOCK_ASM_ALIGN
+ \_name:
+ .space SPINLOCK_ASM_SIZE
+ .endm
+
#endif /* __ASM_MACROS_S__ */
diff --git a/include/common/aarch64/asm_macros.S b/include/common/aarch64/asm_macros.S
index 737cd366..a9b3a01e 100644
--- a/include/common/aarch64/asm_macros.S
+++ b/include/common/aarch64/asm_macros.S
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2013-2017, ARM Limited and Contributors. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -32,6 +32,7 @@
#include <arch.h>
#include <asm_macros_common.S>
+#include <spinlock.h>
.macro func_prologue
@@ -172,4 +173,14 @@
.endif
.endm
+
+ /*
+ * Reserve space for a spin lock in assembly file.
+ */
+ .macro define_asm_spinlock _name:req
+ .align SPINLOCK_ASM_ALIGN
+ \_name:
+ .space SPINLOCK_ASM_SIZE
+ .endm
+
#endif /* __ASM_MACROS_S__ */
diff --git a/include/lib/spinlock.h b/include/lib/spinlock.h
index cb0bc3e5..8273c784 100644
--- a/include/lib/spinlock.h
+++ b/include/lib/spinlock.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2013-2017, ARM Limited and Contributors. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -31,11 +31,23 @@
#ifndef __SPINLOCK_H__
#define __SPINLOCK_H__
+#ifndef __ASSEMBLY__
+
+#include <types.h>
+
typedef struct spinlock {
- volatile unsigned int lock;
+ volatile uint32_t lock;
} spinlock_t;
void spin_lock(spinlock_t *lock);
void spin_unlock(spinlock_t *lock);
+#else
+
+/* Spin lock definitions for use in assembly */
+#define SPINLOCK_ASM_ALIGN 2
+#define SPINLOCK_ASM_SIZE 4
+
+#endif
+
#endif /* __SPINLOCK_H__ */