RK3368 GPU: Rogue N Init.
[firefly-linux-kernel-4.4.55.git] / drivers / staging / imgtec / rogue / lock_types.h
1 /*************************************************************************/ /*!
2 @File           lock_types.h
3 @Title          Locking types
4 @Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description    Locking specific enums, defines and structures
6 @License        Dual MIT/GPLv2
7
8 The contents of this file are subject to the MIT license as set out below.
9
10 Permission is hereby granted, free of charge, to any person obtaining a copy
11 of this software and associated documentation files (the "Software"), to deal
12 in the Software without restriction, including without limitation the rights
13 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 copies of the Software, and to permit persons to whom the Software is
15 furnished to do so, subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 Alternatively, the contents of this file may be used under the terms of
21 the GNU General Public License Version 2 ("GPL") in which case the provisions
22 of GPL are applicable instead of those above.
23
24 If you wish to allow use of your version of this file only under the terms of
25 GPL, and not to allow others to use your version of this file under the terms
26 of the MIT license, indicate your decision by deleting the provisions above
27 and replace them with the notice and other provisions required by GPL as set
28 out in the file called "GPL-COPYING" included in this distribution. If you do
29 not delete the provisions above, a recipient may use your version of this file
30 under the terms of either the MIT license or GPL.
31
32 This License is also included in this distribution in the file called
33 "MIT-COPYING".
34
35 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
36 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
37 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
38 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
39 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
40 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
41 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
42 */ /**************************************************************************/
43
44 #ifndef _LOCK_TYPES_H_
45 #define _LOCK_TYPES_H_
46
47 /* In Linux kernel mode we are using the kernel mutex implementation directly
48  * with macros. This allows us to use the kernel lockdep feature for lock
49  * debugging. */
50 #if defined(LINUX) && defined(__KERNEL__)
51
52 #include <linux/types.h>
53 #include <linux/mutex.h>
54 /* The mutex is defined as a pointer to be compatible with the other code. This
55  * isn't ideal and usually you wouldn't do that in kernel code. */
56 typedef struct mutex *POS_LOCK;
57 typedef atomic_t ATOMIC_T;
58
59 #else /* defined(LINUX) && defined(__KERNEL__) */
60 #include "img_types.h" /* needed for IMG_INT */
61 typedef struct _OS_LOCK_ *POS_LOCK;
62 #if defined(LINUX)
63         typedef struct _OS_ATOMIC {IMG_INT counter;} ATOMIC_T;
64 #elif defined(__QNXNTO__)
65         typedef struct _OS_ATOMIC {IMG_INT counter;} ATOMIC_T;
66 #elif defined(_WIN32)
67         /*
68          * Dummy definition. WDDM doesn't use Services, but some headers
69          * still have to be shared. This is one such case.
70          */
71         typedef struct _OS_ATOMIC {IMG_INT counter;} ATOMIC_T;
72 #elif defined(INTEGRITY_OS)
73         /*Fixed size data type to hold the largest value*/
74         typedef struct _OS_ATOMIC {IMG_UINT64 counter;} ATOMIC_T;
75 #else
76         #error "Please type-define an atomic lock for this environment"
77 #endif
78
79 #endif /* defined(LINUX) && defined(__KERNEL__) */
80
81 typedef enum
82 {
83         LOCK_TYPE_NONE                  = 0x00,
84
85         LOCK_TYPE_MASK                  = 0x0F,
86         LOCK_TYPE_PASSIVE               = 0x01,         /* Passive level lock e.g. mutex, system may promote to dispatch */
87         LOCK_TYPE_DISPATCH              = 0x02,         /* Dispatch level lock e.g. spin lock, may be used in ISR/MISR */
88
89         LOCK_TYPE_INSIST_FLAG   = 0x80,         /* When set caller can guarantee lock not used in ISR/MISR */
90         LOCK_TYPE_PASSIVE_ONLY  = LOCK_TYPE_INSIST_FLAG | LOCK_TYPE_PASSIVE
91
92 } LOCK_TYPE;
93 #endif  /* _LOCK_TYPES_H_ */