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