14ecca339SDan Handley /* 2*b38bc68bSJeenu Viswambharan * Copyright (c) 2013-2017, ARM Limited and Contributors. All rights reserved. 34ecca339SDan Handley * 44ecca339SDan Handley * Redistribution and use in source and binary forms, with or without 54ecca339SDan Handley * modification, are permitted provided that the following conditions are met: 64ecca339SDan Handley * 74ecca339SDan Handley * Redistributions of source code must retain the above copyright notice, this 84ecca339SDan Handley * list of conditions and the following disclaimer. 94ecca339SDan Handley * 104ecca339SDan Handley * Redistributions in binary form must reproduce the above copyright notice, 114ecca339SDan Handley * this list of conditions and the following disclaimer in the documentation 124ecca339SDan Handley * and/or other materials provided with the distribution. 134ecca339SDan Handley * 144ecca339SDan Handley * Neither the name of ARM nor the names of its contributors may be used 154ecca339SDan Handley * to endorse or promote products derived from this software without specific 164ecca339SDan Handley * prior written permission. 174ecca339SDan Handley * 184ecca339SDan Handley * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 194ecca339SDan Handley * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 204ecca339SDan Handley * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 214ecca339SDan Handley * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 224ecca339SDan Handley * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 234ecca339SDan Handley * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 244ecca339SDan Handley * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 254ecca339SDan Handley * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 264ecca339SDan Handley * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 274ecca339SDan Handley * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 284ecca339SDan Handley * POSSIBILITY OF SUCH DAMAGE. 294ecca339SDan Handley */ 304ecca339SDan Handley 314ecca339SDan Handley #ifndef __SPINLOCK_H__ 324ecca339SDan Handley #define __SPINLOCK_H__ 334ecca339SDan Handley 34*b38bc68bSJeenu Viswambharan #ifndef __ASSEMBLY__ 35*b38bc68bSJeenu Viswambharan 36*b38bc68bSJeenu Viswambharan #include <types.h> 37*b38bc68bSJeenu Viswambharan 38fb037bfbSDan Handley typedef struct spinlock { 39*b38bc68bSJeenu Viswambharan volatile uint32_t lock; 404ecca339SDan Handley } spinlock_t; 414ecca339SDan Handley 424ecca339SDan Handley void spin_lock(spinlock_t *lock); 434ecca339SDan Handley void spin_unlock(spinlock_t *lock); 444ecca339SDan Handley 45*b38bc68bSJeenu Viswambharan #else 46*b38bc68bSJeenu Viswambharan 47*b38bc68bSJeenu Viswambharan /* Spin lock definitions for use in assembly */ 48*b38bc68bSJeenu Viswambharan #define SPINLOCK_ASM_ALIGN 2 49*b38bc68bSJeenu Viswambharan #define SPINLOCK_ASM_SIZE 4 50*b38bc68bSJeenu Viswambharan 51*b38bc68bSJeenu Viswambharan #endif 52*b38bc68bSJeenu Viswambharan 534ecca339SDan Handley #endif /* __SPINLOCK_H__ */ 54