1
2
3
4
5#ifndef _INC_SBECOM_INLNX_H_
6#define _INC_SBECOM_INLNX_H_
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46#include <linux/types.h>
47#include <linux/module.h>
48#include <linux/kernel.h>
49#include <linux/skbuff.h>
50#include <linux/netdevice.h>
51#include <asm/byteorder.h>
52
53
54u_int32_t pci_read_32 (u_int32_t *p);
55void pci_write_32 (u_int32_t *p, u_int32_t v);
56
57
58
59
60
61
62
63
64
65
66static inline void *
67OS_kmalloc (size_t size)
68{
69 char *ptr = kmalloc (size, GFP_KERNEL | GFP_DMA);
70
71 if (ptr)
72 memset (ptr, 0, size);
73 return ptr;
74}
75
76static inline void
77OS_kfree (void *x)
78{
79 kfree (x);
80}
81
82
83
84
85
86
87static inline void *
88OS_mem_token_alloc (size_t size)
89{
90 struct sk_buff *skb;
91
92 skb = dev_alloc_skb (size);
93 if (!skb)
94 {
95
96 return 0;
97 }
98 return skb;
99}
100
101
102static inline void
103OS_mem_token_free (void *token)
104{
105 dev_kfree_skb_any (token);
106}
107
108
109static inline void
110OS_mem_token_free_irq (void *token)
111{
112 dev_kfree_skb_irq (token);
113}
114
115
116static inline void *
117OS_mem_token_data (void *token)
118{
119 return ((struct sk_buff *) token)->data;
120}
121
122
123static inline void *
124OS_mem_token_next (void *token)
125{
126 return 0;
127}
128
129
130static inline int
131OS_mem_token_len (void *token)
132{
133 return ((struct sk_buff *) token)->len;
134}
135
136
137static inline int
138OS_mem_token_tlen (void *token)
139{
140 return ((struct sk_buff *) token)->len;
141}
142
143
144
145
146
147
148static inline u_long
149OS_phystov (void *addr)
150{
151 return (u_long) __va (addr);
152}
153
154
155static inline u_long
156OS_vtophys (void *addr)
157{
158 return __pa (addr);
159}
160
161
162
163
164
165
166void OS_sem_init (void *, int);
167
168
169static inline void
170OS_sem_free (void *sem)
171{
172
173
174
175
176}
177
178#define SD_SEM_TAKE(sem,desc) down(sem)
179#define SD_SEM_GIVE(sem) up(sem)
180#define SEM_AVAILABLE 1
181#define SEM_TAKEN 0
182
183
184
185
186
187
188struct watchdog
189{
190 struct timer_list h;
191 struct work_struct work;
192 void *softc;
193 void (*func) (void *softc);
194 int ticks;
195 int init_tq;
196};
197
198
199static inline int
200OS_start_watchdog (struct watchdog * wd)
201{
202 wd->h.expires = jiffies + wd->ticks;
203 add_timer (&wd->h);
204 return 0;
205}
206
207
208static inline int
209OS_stop_watchdog (struct watchdog * wd)
210{
211 del_timer_sync (&wd->h);
212 return 0;
213}
214
215
216static inline int
217OS_free_watchdog (struct watchdog * wd)
218{
219 OS_stop_watchdog (wd);
220 OS_kfree (wd);
221 return 0;
222}
223
224
225
226void OS_uwait (int usec, char *description);
227void OS_uwait_dummy (void);
228
229
230
231int OS_init_watchdog(struct watchdog *wdp, void (*f) (void *), void *ci, int usec);
232
233
234#endif
235