diff --git a/include/common/aarch32/asm_macros.S b/include/common/aarch32/asm_macros.S index 23122f34a6f6d9eb5ccae6eb429d4dedc4bdaf1e..45023a0bbac5eb766731e9a311df88745fdaa7be 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 #include +#include #define WORD_SIZE 4 @@ -124,4 +125,13 @@ #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/common/aarch64/asm_macros.S b/include/common/aarch64/asm_macros.S index 88e8d9c68d274f8341ec0459e857f7a589603aed..b0f3a0dbba3190d0f4a7bc839e3e78bd23c87420 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 #include +#include .macro func_prologue @@ -200,4 +201,13 @@ #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 cb0bc3e5d9b43e1d0f308422157b337968e5660c..8273c78410459ea47c0611777809bc08d62f8e81 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 + 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__ */