Debian Codegraph @

test/dapltest/mdep/linux/dapl_mdep_kernel.h

raw
1 /*
2 * Copyright (c) 2002-2005, Network Appliance, Inc. All rights reserved.
3 *
4 * This Software is licensed under one of the following licenses:
5 *
6 * 1) under the terms of the "Common Public License 1.0" a copy of which is
7 * in the file LICENSE.txt in the root directory. The license is also
8 * available from the Open Source Initiative, see
9 * http://www.opensource.org/licenses/cpl.php.
10 *
11 * 2) under the terms of the "The BSD License" a copy of which is in the file
12 * LICENSE2.txt in the root directory. The license is also available from
13 * the Open Source Initiative, see
14 * http://www.opensource.org/licenses/bsd-license.php.
15 *
16 * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
17 * copy of which is in the file LICENSE3.txt in the root directory. The
18 * license is also available from the Open Source Initiative, see
19 * http://www.opensource.org/licenses/gpl-license.php.
20 *
21 * Licensee has the right to choose one of the above licenses.
22 *
23 * Redistributions of source code must retain the above copyright
24 * notice and one of the license notices.
25 *
26 * Redistributions in binary form must reproduce both the above copyright
27 * notice, one of the license notices in the documentation
28 * and/or other materials provided with the distribution.
29 */
30
31 #ifndef __DAPL_KERNEL_MDEP_H__
32 #define __DAPL_KERNEL_MDEP_H__
33
34 /* include files */
35
36 # include <linux/errno.h>
37 # include <linux/types.h>
38 # include <linux/kernel.h>
39 # include <linux/string.h>
40 # include <asm/atomic.h>
41 # include <linux/delay.h>
42 # include <linux/wait.h>
43 # include <dat2/kdat.h>
44 # include "kdapl_ioctl.h"
45 #ifndef UPCALL_FROM_IRQ
46 #include <linux/interrupt.h> /* for spin_lock_bh */
47 #endif /* UPCALL_FROM_IRQ */
48
49 /* Default Device Name */
50 #define DT_MdepDeviceName "ia0a"
51
52 /* Boolean */
53 typedef int bool;
54
55 #define true (1)
56 #define false (0)
57
58 #ifndef __BASE_FILE__
59 #define __BASE_FILE__ __FILE__
60 #endif
61
62 #ifndef _INLINE_
63 #define _INLINE_ __inline__
64 #endif
65
66 /*
67 * Locks
68 */
69
70 typedef spinlock_t DT_Mdep_LockType;
71
72 /*
73 * If UPCALL_FROM_IRQ is defined, the provider will invoke upcalls
74 * directly from IRQ. Most providers invoke upcalls from the Linux
75 * BH handler, the default here.
76 *
77 * Locks must be adapted to match the actual upcall context!
78 */
79 #ifdef UPCALL_FROM_IRQ
80 #define SPINLOCK(lp) spin_lock_irq (lp);
81 #define SPINUNLOCK(lp) spin_unlock_irq (lp);
82 #else
83 #define SPINLOCK(lp) spin_lock_bh (lp);
84 #define SPINUNLOCK(lp) spin_unlock_bh (lp);
85 #endif
86
87
88 /* Wait object used for inter thread communication */
89
90 typedef wait_queue_head_t DT_WAIT_OBJECT;
91
92 /*
93 * Thread types
94 */
95 typedef int DT_Mdep_ThreadHandleType;
96 typedef void (*DT_Mdep_ThreadFunction) (void *param);
97 typedef void * DT_Mdep_Thread_Start_Routine_Return_Type;
98 #define DT_MDEP_DEFAULT_STACK_SIZE 65536
99
100 typedef struct
101 {
102 void (*function) (void *);
103 void *param;
104 DT_Mdep_ThreadHandleType thread_handle;
105 unsigned int stacksize;
106 } Thread;
107
108 /*
109 * System information
110 *
111 */
112
113 typedef struct
114 {
115 unsigned long int system;
116 unsigned long int user;
117 unsigned long int idle;
118 } DT_CpuStat;
119
120 /*
121 * Timing
122 */
123
124 typedef unsigned long long int DT_Mdep_TimeStamp;
125
126 static _INLINE_ DT_Mdep_TimeStamp
127 DT_Mdep_GetTimeStamp ( void )
128 {
129 #if defined(__GNUC__) && defined(__PENTIUM__)
130 DT_Mdep_TimeStamp x;
131 __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x));
132 return x;
133 #else
134
135 #ifdef __ia64__
136 unsigned long x;
137
138 x = get_cycles ();
139 return x;
140 #else
141 #error "Non-Pentium Linux - unimplemented"
142 #endif
143 #endif
144
145 }
146
147 #ifndef __ia64__
148 typedef int * intptr_t;
149 typedef unsigned long uintptr_t;
150 #endif
151
152 #define bzero(x, y) memset(x, 0, y)
153
154 /*
155 * Define long format types to be used in *printf format strings. We
156 * use the C string constant concatenation ability to define 64 bit
157 * formats, which unfortunatly are non standard in the C compiler
158 * world. E.g. %llx for gcc, %I64x for Windows
159 */
160 #ifdef __x86_64__
161 #define F64d "%ld"
162 #define F64u "%lu"
163 #define F64x "%lx"
164 #define F64X "%lX"
165 #else
166 #define F64d "%lld"
167 #define F64u "%llu"
168 #define F64x "%llx"
169 #define F64X "%llX"
170 #endif
171
172 /*
173 * Define notion of a LONG LONG 0
174 */
175 #define LZERO 0ULL
176
177 /* Mdep function defines */
178
179 #define DT_Mdep_flush()
180 #endif