1/* 2 * Copyright 2010 Tilera Corporation. All Rights Reserved. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation, version 2. 7 * 8 * This program is distributed in the hope that it will be useful, but 9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or 11 * NON INFRINGEMENT. See the GNU General Public License for 12 * more details. 13 */ 14 15#ifndef _ASM_TILE_SPINLOCK_TYPES_H 16#define _ASM_TILE_SPINLOCK_TYPES_H 17 18#ifndef __LINUX_SPINLOCK_TYPES_H 19# error "please don't include this file directly" 20#endif 21 22#ifdef __tilegx__ 23 24/* Low 15 bits are "next"; high 15 bits are "current". */ 25typedef struct arch_spinlock { 26 unsigned int lock; 27} arch_spinlock_t; 28 29#define __ARCH_SPIN_LOCK_UNLOCKED { 0 } 30 31/* High bit is "writer owns"; low 31 bits are a count of readers. */ 32typedef struct arch_rwlock { 33 unsigned int lock; 34} arch_rwlock_t; 35 36#define __ARCH_RW_LOCK_UNLOCKED { 0 } 37 38#else 39 40typedef struct arch_spinlock { 41 /* Next ticket number to hand out. */ 42 int next_ticket; 43 /* The ticket number that currently owns this lock. */ 44 int current_ticket; 45} arch_spinlock_t; 46 47#define __ARCH_SPIN_LOCK_UNLOCKED { 0, 0 } 48 49/* 50 * Byte 0 for tns (only the low bit is used), byte 1 for ticket-lock "next", 51 * byte 2 for ticket-lock "current", byte 3 for reader count. 52 */ 53typedef struct arch_rwlock { 54 unsigned int lock; 55} arch_rwlock_t; 56 57#define __ARCH_RW_LOCK_UNLOCKED { 0 } 58 59#endif 60#endif /* _ASM_TILE_SPINLOCK_TYPES_H */ 61