Commit b38bc68b authored by Jeenu Viswambharan's avatar Jeenu Viswambharan
Browse files

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: default avatarJeenu Viswambharan <jeenu.viswambharan@arm.com>
parent d7aa7b44
/* /*
* 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <arch.h> #include <arch.h>
#include <asm_macros_common.S> #include <asm_macros_common.S>
#include <spinlock.h>
#define WORD_SIZE 4 #define WORD_SIZE 4
...@@ -124,4 +125,13 @@ ...@@ -124,4 +125,13 @@
#endif #endif
.endm .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__ */ #endif /* __ASM_MACROS_S__ */
/* /*
* 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <arch.h> #include <arch.h>
#include <asm_macros_common.S> #include <asm_macros_common.S>
#include <spinlock.h>
.macro func_prologue .macro func_prologue
...@@ -200,4 +201,13 @@ ...@@ -200,4 +201,13 @@
#endif #endif
.endm .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__ */ #endif /* __ASM_MACROS_S__ */
/* /*
* 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
...@@ -31,11 +31,23 @@ ...@@ -31,11 +31,23 @@
#ifndef __SPINLOCK_H__ #ifndef __SPINLOCK_H__
#define __SPINLOCK_H__ #define __SPINLOCK_H__
#ifndef __ASSEMBLY__
#include <types.h>
typedef struct spinlock { typedef struct spinlock {
volatile unsigned int lock; volatile uint32_t lock;
} spinlock_t; } spinlock_t;
void spin_lock(spinlock_t *lock); void spin_lock(spinlock_t *lock);
void spin_unlock(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__ */ #endif /* __SPINLOCK_H__ */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment