1 #ifndef _INC_SBECOM_INLNX_H_
2 #define _INC_SBECOM_INLNX_H_
4 /*-----------------------------------------------------------------------------
5 * sbecom_inline_linux.h - SBE common Linux inlined routines
7 * Copyright (C) 2007 One Stop Systems, Inc.
8 * Copyright (C) 2005 SBE, Inc.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * For further information, contact via email: support@onestopsystems.com
21 * One Stop Systems, Inc. Escondido, California U.S.A.
22 *-----------------------------------------------------------------------------
26 #include <linux/types.h>
27 #include <linux/module.h>
28 #include <linux/kernel.h> /* resolves kmalloc references */
29 #include <linux/skbuff.h> /* resolves skb references */
30 #include <linux/netdevice.h> /* resolves dev_kree_skb_any */
31 #include <asm/byteorder.h> /* resolves cpu_to_le32 */
33 /* forward reference */
34 u_int32_t pci_read_32 (u_int32_t *p);
35 void pci_write_32 (u_int32_t *p, u_int32_t v);
39 * system dependent callbacks
47 OS_kmalloc (size_t size)
49 char *ptr = kmalloc (size, GFP_KERNEL | GFP_DMA);
52 memset (ptr, 0, size);
68 OS_mem_token_alloc (size_t size)
72 skb = dev_alloc_skb (size);
75 //pr_warning("no mem in OS_mem_token_alloc !\n");
83 OS_mem_token_free (void *token)
85 dev_kfree_skb_any (token);
90 OS_mem_token_free_irq (void *token)
92 dev_kfree_skb_irq (token);
97 OS_mem_token_data (void *token)
99 return ((struct sk_buff *) token)->data;
104 OS_mem_token_next (void *token)
111 OS_mem_token_len (void *token)
113 return ((struct sk_buff *) token)->len;
118 OS_mem_token_tlen (void *token)
120 return ((struct sk_buff *) token)->len;
124 /***************************************/
125 /* virtual to physical addr conversion */
126 /***************************************/
129 OS_phystov (void *addr)
131 return (u_long) __va (addr);
136 OS_vtophys (void *addr)
146 void OS_sem_init (void *, int);
150 OS_sem_free (void *sem)
153 * NOOP - since semaphores structures predeclared w/in structures, no
158 #define SD_SEM_TAKE(sem,desc) down(sem)
159 #define SD_SEM_GIVE(sem) up(sem)
160 #define SEM_AVAILABLE 1
164 /**********************/
165 /* watchdog functions */
166 /**********************/
171 struct work_struct work;
173 void (*func) (void *softc);
180 OS_start_watchdog (struct watchdog * wd)
182 wd->h.expires = jiffies + wd->ticks;
189 OS_stop_watchdog (struct watchdog * wd)
191 del_timer_sync (&wd->h);
197 OS_free_watchdog (struct watchdog * wd)
199 OS_stop_watchdog (wd);
205 /* sleep in microseconds */
206 void OS_uwait (int usec, char *description);
207 void OS_uwait_dummy (void);
210 /* watchdog functions */
211 int OS_init_watchdog(struct watchdog *wdp, void (*f) (void *), void *ci, int usec);
214 #endif /*** _INC_SBECOM_INLNX_H_ ***/