xref: /OK3568_Linux_fs/external/rkwifibt/drivers/bcmdhd/include/linux_osl.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * Linux OS Independent Layer
3*4882a593Smuzhiyun  *
4*4882a593Smuzhiyun  * Copyright (C) 2020, Broadcom.
5*4882a593Smuzhiyun  *
6*4882a593Smuzhiyun  *      Unless you and Broadcom execute a separate written software license
7*4882a593Smuzhiyun  * agreement governing use of this software, this software is licensed to you
8*4882a593Smuzhiyun  * under the terms of the GNU General Public License version 2 (the "GPL"),
9*4882a593Smuzhiyun  * available at http://www.broadcom.com/licenses/GPLv2.php, with the
10*4882a593Smuzhiyun  * following added to such license:
11*4882a593Smuzhiyun  *
12*4882a593Smuzhiyun  *      As a special exception, the copyright holders of this software give you
13*4882a593Smuzhiyun  * permission to link this software with independent modules, and to copy and
14*4882a593Smuzhiyun  * distribute the resulting executable under terms of your choice, provided that
15*4882a593Smuzhiyun  * you also meet, for each linked independent module, the terms and conditions of
16*4882a593Smuzhiyun  * the license of that module.  An independent module is a module which is not
17*4882a593Smuzhiyun  * derived from this software.  The special exception does not apply to any
18*4882a593Smuzhiyun  * modifications of the software.
19*4882a593Smuzhiyun  *
20*4882a593Smuzhiyun  *
21*4882a593Smuzhiyun  * <<Broadcom-WL-IPTag/Dual:>>
22*4882a593Smuzhiyun  */
23*4882a593Smuzhiyun 
24*4882a593Smuzhiyun #ifndef _linux_osl_h_
25*4882a593Smuzhiyun #define _linux_osl_h_
26*4882a593Smuzhiyun 
27*4882a593Smuzhiyun #include <typedefs.h>
28*4882a593Smuzhiyun #define DECLSPEC_ALIGN(x)	__attribute__ ((aligned(x)))
29*4882a593Smuzhiyun 
30*4882a593Smuzhiyun /* Linux Kernel: File Operations: start */
osl_os_open_image(char * filename)31*4882a593Smuzhiyun static INLINE void * osl_os_open_image(char * filename)
32*4882a593Smuzhiyun 	{ return NULL; }
osl_os_close_image(void * image)33*4882a593Smuzhiyun static INLINE void osl_os_close_image(void * image)
34*4882a593Smuzhiyun 	{ return; }
osl_os_get_image_block(char * buf,int len,void * image)35*4882a593Smuzhiyun static INLINE int osl_os_get_image_block(char * buf, int len, void * image)
36*4882a593Smuzhiyun 	{ return 0; }
osl_os_image_size(void * image)37*4882a593Smuzhiyun static INLINE int osl_os_image_size(void *image)
38*4882a593Smuzhiyun 	{ return 0; }
39*4882a593Smuzhiyun /* Linux Kernel: File Operations: end */
40*4882a593Smuzhiyun 
41*4882a593Smuzhiyun #ifdef BCMDRIVER
42*4882a593Smuzhiyun 
43*4882a593Smuzhiyun /* OSL initialization */
44*4882a593Smuzhiyun #ifdef SHARED_OSL_CMN
45*4882a593Smuzhiyun extern osl_t *osl_attach(void *pdev, uint bustype, bool pkttag, void **osh_cmn);
46*4882a593Smuzhiyun #else
47*4882a593Smuzhiyun extern osl_t *osl_attach(void *pdev, uint bustype, bool pkttag);
48*4882a593Smuzhiyun #endif /* SHARED_OSL_CMN */
49*4882a593Smuzhiyun 
50*4882a593Smuzhiyun extern void osl_detach(osl_t *osh);
51*4882a593Smuzhiyun extern int osl_static_mem_init(osl_t *osh, void *adapter);
52*4882a593Smuzhiyun extern int osl_static_mem_deinit(osl_t *osh, void *adapter);
53*4882a593Smuzhiyun extern void osl_set_bus_handle(osl_t *osh, void *bus_handle);
54*4882a593Smuzhiyun extern void* osl_get_bus_handle(osl_t *osh);
55*4882a593Smuzhiyun #ifdef DHD_MAP_LOGGING
56*4882a593Smuzhiyun extern void osl_dma_map_dump(osl_t *osh);
57*4882a593Smuzhiyun #define OSL_DMA_MAP_DUMP(osh)	osl_dma_map_dump(osh)
58*4882a593Smuzhiyun #else
59*4882a593Smuzhiyun #define OSL_DMA_MAP_DUMP(osh)	do {} while (0)
60*4882a593Smuzhiyun #endif /* DHD_MAP_LOGGING */
61*4882a593Smuzhiyun 
62*4882a593Smuzhiyun /* Global ASSERT type */
63*4882a593Smuzhiyun extern uint32 g_assert_type;
64*4882a593Smuzhiyun 
65*4882a593Smuzhiyun #ifdef CONFIG_PHYS_ADDR_T_64BIT
66*4882a593Smuzhiyun #define PRI_FMT_x       "llx"
67*4882a593Smuzhiyun #define PRI_FMT_X       "llX"
68*4882a593Smuzhiyun #define PRI_FMT_o       "llo"
69*4882a593Smuzhiyun #define PRI_FMT_d       "lld"
70*4882a593Smuzhiyun #else
71*4882a593Smuzhiyun #define PRI_FMT_x       "x"
72*4882a593Smuzhiyun #define PRI_FMT_X       "X"
73*4882a593Smuzhiyun #define PRI_FMT_o       "o"
74*4882a593Smuzhiyun #define PRI_FMT_d       "d"
75*4882a593Smuzhiyun #endif /* CONFIG_PHYS_ADDR_T_64BIT */
76*4882a593Smuzhiyun /* ASSERT */
77*4882a593Smuzhiyun #ifndef ASSERT
78*4882a593Smuzhiyun #if (defined(BCMDBG_ASSERT) || defined(BCMASSERT_LOG)) && !defined(BINCMP)
79*4882a593Smuzhiyun 	#define ASSERT(exp) \
80*4882a593Smuzhiyun 		do { if (!(exp)) osl_assert(#exp, __FILE__, __LINE__); } while (0)
81*4882a593Smuzhiyun extern void osl_assert(const char *exp, const char *file, int line);
82*4882a593Smuzhiyun #else
83*4882a593Smuzhiyun #ifdef __GNUC__
84*4882a593Smuzhiyun 	#define GCC_VERSION \
85*4882a593Smuzhiyun 		(__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
86*4882a593Smuzhiyun #if GCC_VERSION > 30100
87*4882a593Smuzhiyun 	#define ASSERT(exp)	do {} while (0)
88*4882a593Smuzhiyun #else
89*4882a593Smuzhiyun 	/* ASSERT could cause segmentation fault on GCC3.1, use empty instead */
90*4882a593Smuzhiyun 	#define ASSERT(exp)
91*4882a593Smuzhiyun #endif /* GCC_VERSION > 30100 */
92*4882a593Smuzhiyun #endif /* __GNUC__ */
93*4882a593Smuzhiyun #endif /* (BCMDBG_ASSERT || BCMASSERT_LOG) && !BINCMP */
94*4882a593Smuzhiyun #endif /* ASSERT */
95*4882a593Smuzhiyun 
96*4882a593Smuzhiyun #define ASSERT_FP(exp) ASSERT(exp)
97*4882a593Smuzhiyun 
98*4882a593Smuzhiyun /* microsecond delay */
99*4882a593Smuzhiyun #define	OSL_DELAY(usec)		osl_delay(usec)
100*4882a593Smuzhiyun extern void osl_delay(uint usec);
101*4882a593Smuzhiyun 
102*4882a593Smuzhiyun #define OSL_SLEEP(ms)			osl_sleep(ms)
103*4882a593Smuzhiyun extern void osl_sleep(uint ms);
104*4882a593Smuzhiyun 
105*4882a593Smuzhiyun /* PCI configuration space access macros */
106*4882a593Smuzhiyun #define	OSL_PCI_READ_CONFIG(osh, offset, size) \
107*4882a593Smuzhiyun 	osl_pci_read_config((osh), (offset), (size))
108*4882a593Smuzhiyun #define	OSL_PCI_WRITE_CONFIG(osh, offset, size, val) \
109*4882a593Smuzhiyun 	osl_pci_write_config((osh), (offset), (size), (val))
110*4882a593Smuzhiyun extern uint32 osl_pci_read_config(osl_t *osh, uint offset, uint size);
111*4882a593Smuzhiyun extern void osl_pci_write_config(osl_t *osh, uint offset, uint size, uint val);
112*4882a593Smuzhiyun 
113*4882a593Smuzhiyun #ifdef BCMPCIE
114*4882a593Smuzhiyun /* PCI device bus # and slot # */
115*4882a593Smuzhiyun #define OSL_PCI_BUS(osh)	osl_pci_bus(osh)
116*4882a593Smuzhiyun #define OSL_PCI_SLOT(osh)	osl_pci_slot(osh)
117*4882a593Smuzhiyun #define OSL_PCIE_DOMAIN(osh)	osl_pcie_domain(osh)
118*4882a593Smuzhiyun #define OSL_PCIE_BUS(osh)	osl_pcie_bus(osh)
119*4882a593Smuzhiyun extern uint osl_pci_bus(osl_t *osh);
120*4882a593Smuzhiyun extern uint osl_pci_slot(osl_t *osh);
121*4882a593Smuzhiyun extern uint osl_pcie_domain(osl_t *osh);
122*4882a593Smuzhiyun extern uint osl_pcie_bus(osl_t *osh);
123*4882a593Smuzhiyun extern struct pci_dev *osl_pci_device(osl_t *osh);
124*4882a593Smuzhiyun #endif
125*4882a593Smuzhiyun 
126*4882a593Smuzhiyun /* precommit failed when this is removed */
127*4882a593Smuzhiyun /* BLAZAR_BRANCH_101_10_DHD_003/build/dhd/linux-fc30/brix-brcm */
128*4882a593Smuzhiyun /* TBD: Revisit later */
129*4882a593Smuzhiyun #if defined(BCMINTERNAL)
130*4882a593Smuzhiyun /* Flags that can be used to handle OSL specifcs */
131*4882a593Smuzhiyun #define OSL_PHYS_MEM_LESS_THAN_16MB	(1<<0L)
132*4882a593Smuzhiyun #endif /* BCMINTERNAL */
133*4882a593Smuzhiyun 
134*4882a593Smuzhiyun #define OSL_ACP_COHERENCE		(1<<1L)
135*4882a593Smuzhiyun #define OSL_FWDERBUF			(1<<2L)
136*4882a593Smuzhiyun 
137*4882a593Smuzhiyun /* Pkttag flag should be part of public information */
138*4882a593Smuzhiyun typedef struct {
139*4882a593Smuzhiyun 	bool pkttag;
140*4882a593Smuzhiyun 	bool mmbus;		/**< Bus supports memory-mapped register accesses */
141*4882a593Smuzhiyun 	pktfree_cb_fn_t tx_fn;  /**< Callback function for PKTFREE */
142*4882a593Smuzhiyun 	void *tx_ctx;		/**< Context to the callback function */
143*4882a593Smuzhiyun #ifdef OSLREGOPS
144*4882a593Smuzhiyun 	osl_rreg_fn_t rreg_fn;	/**< Read Register function */
145*4882a593Smuzhiyun 	osl_wreg_fn_t wreg_fn;	/**< Write Register function */
146*4882a593Smuzhiyun 	void *reg_ctx;		/**< Context to the reg callback functions */
147*4882a593Smuzhiyun #else
148*4882a593Smuzhiyun 	void	*unused[3];	/**< temp fix for USBAP cftpool handle currption */
149*4882a593Smuzhiyun #endif
150*4882a593Smuzhiyun 	void (*rx_fn)(void *rx_ctx, void *p);
151*4882a593Smuzhiyun 	void *rx_ctx;
152*4882a593Smuzhiyun } osl_pubinfo_t;
153*4882a593Smuzhiyun 
154*4882a593Smuzhiyun extern void osl_flag_set(osl_t *osh, uint32 mask);
155*4882a593Smuzhiyun extern void osl_flag_clr(osl_t *osh, uint32 mask);
156*4882a593Smuzhiyun extern bool osl_is_flag_set(osl_t *osh, uint32 mask);
157*4882a593Smuzhiyun 
158*4882a593Smuzhiyun #define PKTFREESETCB(osh, _tx_fn, _tx_ctx)		\
159*4882a593Smuzhiyun 	do {						\
160*4882a593Smuzhiyun 	   ((osl_pubinfo_t*)osh)->tx_fn = _tx_fn;	\
161*4882a593Smuzhiyun 	   ((osl_pubinfo_t*)osh)->tx_ctx = _tx_ctx;	\
162*4882a593Smuzhiyun 	} while (0)
163*4882a593Smuzhiyun 
164*4882a593Smuzhiyun #define PKTFREESETRXCB(osh, _rx_fn, _rx_ctx)		\
165*4882a593Smuzhiyun 	do {						\
166*4882a593Smuzhiyun 	   ((osl_pubinfo_t*)osh)->rx_fn = _rx_fn;	\
167*4882a593Smuzhiyun 	   ((osl_pubinfo_t*)osh)->rx_ctx = _rx_ctx;	\
168*4882a593Smuzhiyun 	} while (0)
169*4882a593Smuzhiyun 
170*4882a593Smuzhiyun #ifdef OSLREGOPS
171*4882a593Smuzhiyun #define REGOPSSET(osh, rreg, wreg, ctx)			\
172*4882a593Smuzhiyun 	do {						\
173*4882a593Smuzhiyun 	   ((osl_pubinfo_t*)osh)->rreg_fn = rreg;	\
174*4882a593Smuzhiyun 	   ((osl_pubinfo_t*)osh)->wreg_fn = wreg;	\
175*4882a593Smuzhiyun 	   ((osl_pubinfo_t*)osh)->reg_ctx = ctx;	\
176*4882a593Smuzhiyun 	} while (0)
177*4882a593Smuzhiyun #endif /* OSLREGOPS */
178*4882a593Smuzhiyun 
179*4882a593Smuzhiyun /* host/bus architecture-specific byte swap */
180*4882a593Smuzhiyun #define BUS_SWAP32(v)		(v)
181*4882a593Smuzhiyun 
182*4882a593Smuzhiyun #if defined(BCMDBG_MEM) && !defined(BINCMP)
183*4882a593Smuzhiyun 	#define MALLOC(osh, size)	osl_debug_malloc((osh), (size), __LINE__, __FILE__)
184*4882a593Smuzhiyun 	#define MALLOCZ(osh, size)	osl_debug_mallocz((osh), (size), __LINE__, __FILE__)
185*4882a593Smuzhiyun 	#define MFREE(osh, addr, size)	\
186*4882a593Smuzhiyun 	({osl_debug_mfree((osh), ((void *)addr), (size), __LINE__, __FILE__);(addr) = NULL;})
187*4882a593Smuzhiyun 	#define VMALLOC(osh, size)	osl_debug_vmalloc((osh), (size), __LINE__, __FILE__)
188*4882a593Smuzhiyun 	#define VMALLOCZ(osh, size)	osl_debug_vmallocz((osh), (size), __LINE__, __FILE__)
189*4882a593Smuzhiyun 	#define VMFREE(osh, addr, size)	osl_debug_vmfree((osh), (addr), (size), __LINE__, __FILE__)
190*4882a593Smuzhiyun 	#define MALLOCED(osh)		osl_malloced((osh))
191*4882a593Smuzhiyun 	#define MEMORY_LEFTOVER(osh) osl_check_memleak(osh)
192*4882a593Smuzhiyun 	#define MALLOC_DUMP(osh, b)	osl_debug_memdump((osh), (b))
193*4882a593Smuzhiyun 	extern void *osl_debug_malloc(osl_t *osh, uint size, int line, const char* file);
194*4882a593Smuzhiyun 	extern void *osl_debug_mallocz(osl_t *osh, uint size, int line, const char* file);
195*4882a593Smuzhiyun 	extern void osl_debug_mfree(osl_t *osh, void *addr, uint size, int line, const char* file);
196*4882a593Smuzhiyun 	extern void *osl_debug_vmalloc(osl_t *osh, uint size, int line, const char* file);
197*4882a593Smuzhiyun 	extern void *osl_debug_vmallocz(osl_t *osh, uint size, int line, const char* file);
198*4882a593Smuzhiyun 	extern void osl_debug_vmfree(osl_t *osh, void *addr, uint size, int line, const char* file);
199*4882a593Smuzhiyun 	extern uint osl_malloced(osl_t *osh);
200*4882a593Smuzhiyun 	struct bcmstrbuf;
201*4882a593Smuzhiyun 	extern int osl_debug_memdump(osl_t *osh, struct bcmstrbuf *b);
202*4882a593Smuzhiyun 	extern uint osl_check_memleak(osl_t *osh);
203*4882a593Smuzhiyun #else /* BCMDBG_MEM && !BINCMP */
204*4882a593Smuzhiyun 	#define MALLOC(osh, size)	osl_malloc((osh), (size))
205*4882a593Smuzhiyun 	#define MALLOCZ(osh, size)	osl_mallocz((osh), (size))
206*4882a593Smuzhiyun 	#define MALLOC_RA(osh, size, callsite)	osl_mallocz((osh), (size))
207*4882a593Smuzhiyun 	#define MFREE(osh, addr, size) ({osl_mfree((osh), ((void *)addr), (size));(addr) = NULL;})
208*4882a593Smuzhiyun 	#define VMALLOC(osh, size)	osl_vmalloc((osh), (size))
209*4882a593Smuzhiyun 	#define VMALLOCZ(osh, size)	osl_vmallocz((osh), (size))
210*4882a593Smuzhiyun 	#define VMFREE(osh, addr, size)	osl_vmfree((osh), (addr), (size))
211*4882a593Smuzhiyun 	#define MALLOCED(osh)		osl_malloced((osh))
212*4882a593Smuzhiyun 	#define MEMORY_LEFTOVER(osh) osl_check_memleak(osh)
213*4882a593Smuzhiyun 	extern void *osl_malloc(osl_t *osh, uint size);
214*4882a593Smuzhiyun 	extern void *osl_mallocz(osl_t *osh, uint size);
215*4882a593Smuzhiyun 	extern void osl_mfree(osl_t *osh, void *addr, uint size);
216*4882a593Smuzhiyun 	extern void *osl_vmalloc(osl_t *osh, uint size);
217*4882a593Smuzhiyun 	extern void *osl_vmallocz(osl_t *osh, uint size);
218*4882a593Smuzhiyun 	extern void osl_vmfree(osl_t *osh, void *addr, uint size);
219*4882a593Smuzhiyun 	extern uint osl_malloced(osl_t *osh);
220*4882a593Smuzhiyun 	extern uint osl_check_memleak(osl_t *osh);
221*4882a593Smuzhiyun #endif /* BCMDBG_MEM && !BINCMP */
222*4882a593Smuzhiyun 
223*4882a593Smuzhiyun extern int memcpy_s(void *dest, size_t destsz, const void *src, size_t n);
224*4882a593Smuzhiyun extern int memset_s(void *dest, size_t destsz, int c, size_t n);
225*4882a593Smuzhiyun #define	MALLOC_FAILED(osh)	osl_malloc_failed((osh))
226*4882a593Smuzhiyun extern uint osl_malloc_failed(osl_t *osh);
227*4882a593Smuzhiyun 
228*4882a593Smuzhiyun /* allocate/free shared (dma-able) consistent memory */
229*4882a593Smuzhiyun #define	DMA_CONSISTENT_ALIGN	osl_dma_consistent_align()
230*4882a593Smuzhiyun #define	DMA_ALLOC_CONSISTENT(osh, size, align, tot, pap, dmah) \
231*4882a593Smuzhiyun 	osl_dma_alloc_consistent((osh), (size), (align), (tot), (pap))
232*4882a593Smuzhiyun #define	DMA_FREE_CONSISTENT(osh, va, size, pa, dmah) \
233*4882a593Smuzhiyun 	osl_dma_free_consistent((osh), (void*)(va), (size), (pa))
234*4882a593Smuzhiyun 
235*4882a593Smuzhiyun #define	DMA_ALLOC_CONSISTENT_FORCE32(osh, size, align, tot, pap, dmah) \
236*4882a593Smuzhiyun 	osl_dma_alloc_consistent((osh), (size), (align), (tot), (pap))
237*4882a593Smuzhiyun #define	DMA_FREE_CONSISTENT_FORCE32(osh, va, size, pa, dmah) \
238*4882a593Smuzhiyun 	osl_dma_free_consistent((osh), (void*)(va), (size), (pa))
239*4882a593Smuzhiyun 
240*4882a593Smuzhiyun extern uint osl_dma_consistent_align(void);
241*4882a593Smuzhiyun extern void *osl_dma_alloc_consistent(osl_t *osh, uint size, uint16 align,
242*4882a593Smuzhiyun 	uint *tot, dmaaddr_t *pap);
243*4882a593Smuzhiyun extern void osl_dma_free_consistent(osl_t *osh, void *va, uint size, dmaaddr_t pa);
244*4882a593Smuzhiyun 
245*4882a593Smuzhiyun /* map/unmap direction */
246*4882a593Smuzhiyun #define DMA_NO	0	/* Used to skip cache op */
247*4882a593Smuzhiyun #define	DMA_TX	1	/* TX direction for DMA */
248*4882a593Smuzhiyun #define	DMA_RX	2	/* RX direction for DMA */
249*4882a593Smuzhiyun 
250*4882a593Smuzhiyun /* map/unmap shared (dma-able) memory */
251*4882a593Smuzhiyun #define	DMA_UNMAP(osh, pa, size, direction, p, dmah) \
252*4882a593Smuzhiyun 	osl_dma_unmap((osh), (pa), (size), (direction))
253*4882a593Smuzhiyun extern void osl_dma_flush(osl_t *osh, void *va, uint size, int direction, void *p,
254*4882a593Smuzhiyun 	hnddma_seg_map_t *txp_dmah);
255*4882a593Smuzhiyun extern dmaaddr_t osl_dma_map(osl_t *osh, void *va, uint size, int direction, void *p,
256*4882a593Smuzhiyun 	hnddma_seg_map_t *txp_dmah);
257*4882a593Smuzhiyun extern void osl_dma_unmap(osl_t *osh, dmaaddr_t pa, uint size, int direction);
258*4882a593Smuzhiyun 
259*4882a593Smuzhiyun #ifndef PHYS_TO_VIRT
260*4882a593Smuzhiyun #define	PHYS_TO_VIRT(pa)	osl_phys_to_virt(pa)
261*4882a593Smuzhiyun #endif
262*4882a593Smuzhiyun #ifndef VIRT_TO_PHYS
263*4882a593Smuzhiyun #define	VIRT_TO_PHYS(va)	osl_virt_to_phys(va)
264*4882a593Smuzhiyun #endif
265*4882a593Smuzhiyun extern void * osl_phys_to_virt(void * pa);
266*4882a593Smuzhiyun extern void * osl_virt_to_phys(void * va);
267*4882a593Smuzhiyun 
268*4882a593Smuzhiyun /* API for DMA addressing capability */
269*4882a593Smuzhiyun #define OSL_DMADDRWIDTH(osh, addrwidth) ({BCM_REFERENCE(osh); BCM_REFERENCE(addrwidth);})
270*4882a593Smuzhiyun 
271*4882a593Smuzhiyun #define OSL_SMP_WMB()	smp_wmb()
272*4882a593Smuzhiyun 
273*4882a593Smuzhiyun /* API for CPU relax */
274*4882a593Smuzhiyun extern void osl_cpu_relax(void);
275*4882a593Smuzhiyun #define OSL_CPU_RELAX() osl_cpu_relax()
276*4882a593Smuzhiyun 
277*4882a593Smuzhiyun extern void osl_preempt_disable(osl_t *osh);
278*4882a593Smuzhiyun extern void osl_preempt_enable(osl_t *osh);
279*4882a593Smuzhiyun #define OSL_DISABLE_PREEMPTION(osh)	osl_preempt_disable(osh)
280*4882a593Smuzhiyun #define OSL_ENABLE_PREEMPTION(osh)	osl_preempt_enable(osh)
281*4882a593Smuzhiyun 
282*4882a593Smuzhiyun #if (defined(BCMPCIE) && !defined(DHD_USE_COHERENT_MEM_FOR_RING) && defined(__ARM_ARCH_7A__))
283*4882a593Smuzhiyun 
284*4882a593Smuzhiyun 	extern void osl_cache_flush(void *va, uint size);
285*4882a593Smuzhiyun 	extern void osl_cache_inv(void *va, uint size);
286*4882a593Smuzhiyun 	extern void osl_prefetch(const void *ptr);
287*4882a593Smuzhiyun 	#define OSL_CACHE_FLUSH(va, len)	osl_cache_flush((void *)(va), len)
288*4882a593Smuzhiyun 	#define OSL_CACHE_INV(va, len)		osl_cache_inv((void *)(va), len)
289*4882a593Smuzhiyun 	#define OSL_PREFETCH(ptr)			osl_prefetch(ptr)
290*4882a593Smuzhiyun #else  /* !__ARM_ARCH_7A__ */
291*4882a593Smuzhiyun 	#define OSL_CACHE_FLUSH(va, len)	BCM_REFERENCE(va)
292*4882a593Smuzhiyun 	#define OSL_CACHE_INV(va, len)		BCM_REFERENCE(va)
293*4882a593Smuzhiyun 	#define OSL_PREFETCH(ptr)		BCM_REFERENCE(ptr)
294*4882a593Smuzhiyun #endif /* !__ARM_ARCH_7A__ */
295*4882a593Smuzhiyun 
296*4882a593Smuzhiyun #ifdef AXI_TIMEOUTS_NIC
297*4882a593Smuzhiyun extern void osl_set_bpt_cb(osl_t *osh, void *bpt_cb, void *bpt_ctx);
298*4882a593Smuzhiyun extern void osl_bpt_rreg(osl_t *osh, ulong addr, volatile void *v, uint size);
299*4882a593Smuzhiyun #endif /* AXI_TIMEOUTS_NIC */
300*4882a593Smuzhiyun 
301*4882a593Smuzhiyun /* register access macros */
302*4882a593Smuzhiyun #if defined(BCMSDIO)
303*4882a593Smuzhiyun 	#include <bcmsdh.h>
304*4882a593Smuzhiyun 	#define OSL_WRITE_REG(osh, r, v) (bcmsdh_reg_write(osl_get_bus_handle(osh), \
305*4882a593Smuzhiyun 		(uintptr)(r), sizeof(*(r)), (v)))
306*4882a593Smuzhiyun 	#define OSL_READ_REG(osh, r) (bcmsdh_reg_read(osl_get_bus_handle(osh), \
307*4882a593Smuzhiyun 		(uintptr)(r), sizeof(*(r))))
308*4882a593Smuzhiyun #elif defined(AXI_TIMEOUTS_NIC)
309*4882a593Smuzhiyun #define OSL_READ_REG(osh, r) \
310*4882a593Smuzhiyun 	({\
311*4882a593Smuzhiyun 		__typeof(*(r)) __osl_v; \
312*4882a593Smuzhiyun 		osl_bpt_rreg(osh, (uintptr)(r), &__osl_v, sizeof(*(r))); \
313*4882a593Smuzhiyun 		__osl_v; \
314*4882a593Smuzhiyun 	})
315*4882a593Smuzhiyun #endif
316*4882a593Smuzhiyun 
317*4882a593Smuzhiyun #if defined(AXI_TIMEOUTS_NIC)
318*4882a593Smuzhiyun 	#define SELECT_BUS_WRITE(osh, mmap_op, bus_op) ({BCM_REFERENCE(osh); mmap_op;})
319*4882a593Smuzhiyun 	#define SELECT_BUS_READ(osh, mmap_op, bus_op) ({BCM_REFERENCE(osh); bus_op;})
320*4882a593Smuzhiyun #else /* !AXI_TIMEOUTS_NIC */
321*4882a593Smuzhiyun #if defined(BCMSDIO)
322*4882a593Smuzhiyun 	#define SELECT_BUS_WRITE(osh, mmap_op, bus_op) if (((osl_pubinfo_t*)(osh))->mmbus) \
323*4882a593Smuzhiyun 		mmap_op else bus_op
324*4882a593Smuzhiyun 	#define SELECT_BUS_READ(osh, mmap_op, bus_op) (((osl_pubinfo_t*)(osh))->mmbus) ? \
325*4882a593Smuzhiyun 		mmap_op : bus_op
326*4882a593Smuzhiyun #else
327*4882a593Smuzhiyun 	#define SELECT_BUS_WRITE(osh, mmap_op, bus_op) ({BCM_REFERENCE(osh); mmap_op;})
328*4882a593Smuzhiyun 	#define SELECT_BUS_READ(osh, mmap_op, bus_op) ({BCM_REFERENCE(osh); mmap_op;})
329*4882a593Smuzhiyun #endif /* defined(BCMSDIO) */
330*4882a593Smuzhiyun #endif /* AXI_TIMEOUTS_NIC */
331*4882a593Smuzhiyun 
332*4882a593Smuzhiyun #define OSL_ERROR(bcmerror)	osl_error(bcmerror)
333*4882a593Smuzhiyun extern int osl_error(int bcmerror);
334*4882a593Smuzhiyun 
335*4882a593Smuzhiyun /* the largest reasonable packet buffer driver uses for ethernet MTU in bytes */
336*4882a593Smuzhiyun #define	PKTBUFSZ	2048   /* largest reasonable packet buffer, driver uses for ethernet MTU */
337*4882a593Smuzhiyun 
338*4882a593Smuzhiyun #define OSH_NULL   NULL
339*4882a593Smuzhiyun 
340*4882a593Smuzhiyun /*
341*4882a593Smuzhiyun  * BINOSL selects the slightly slower function-call-based binary compatible osl.
342*4882a593Smuzhiyun  * Macros expand to calls to functions defined in linux_osl.c .
343*4882a593Smuzhiyun  */
344*4882a593Smuzhiyun #ifndef BINOSL
345*4882a593Smuzhiyun #include <linuxver.h>           /* use current 2.4.x calling conventions */
346*4882a593Smuzhiyun #include <linux/kernel.h>       /* for vsn/printf's */
347*4882a593Smuzhiyun #include <linux/string.h>       /* for mem*, str* */
348*4882a593Smuzhiyun extern uint64 osl_sysuptime_us(void);
349*4882a593Smuzhiyun #define OSL_SYSUPTIME()		((uint32)jiffies_to_msecs(jiffies))
350*4882a593Smuzhiyun #define OSL_SYSUPTIME_US()	osl_sysuptime_us()
351*4882a593Smuzhiyun extern uint64 osl_localtime_ns(void);
352*4882a593Smuzhiyun extern void osl_get_localtime(uint64 *sec, uint64 *usec);
353*4882a593Smuzhiyun extern uint64 osl_systztime_us(void);
354*4882a593Smuzhiyun #define OSL_LOCALTIME_NS()	osl_localtime_ns()
355*4882a593Smuzhiyun #define OSL_GET_LOCALTIME(sec, usec)	osl_get_localtime((sec), (usec))
356*4882a593Smuzhiyun #define OSL_SYSTZTIME_US()	osl_systztime_us()
357*4882a593Smuzhiyun #define	printf(fmt, args...)	printk(PERCENT_S DHD_LOG_PREFIXS fmt, PRINTF_SYSTEM_TIME, ## args)
358*4882a593Smuzhiyun #include <linux/kernel.h>	/* for vsn/printf's */
359*4882a593Smuzhiyun #include <linux/string.h>	/* for mem*, str* */
360*4882a593Smuzhiyun /* bcopy's: Linux kernel doesn't provide these (anymore) */
361*4882a593Smuzhiyun #define	bcopy_hw(src, dst, len)		memcpy((dst), (src), (len))
362*4882a593Smuzhiyun #define	bcopy_hw_async(src, dst, len)	memcpy((dst), (src), (len))
363*4882a593Smuzhiyun #define	bcopy_hw_poll_for_completion()
364*4882a593Smuzhiyun #define	bcopy(src, dst, len)	memcpy((dst), (src), (len))
365*4882a593Smuzhiyun #define	bcmp(b1, b2, len)	memcmp((b1), (b2), (len))
366*4882a593Smuzhiyun #define	bzero(b, len)		memset((b), '\0', (len))
367*4882a593Smuzhiyun 
368*4882a593Smuzhiyun #if defined(CONFIG_SOC_EXYNOS9810) || defined(CONFIG_SOC_EXYNOS9820) || \
369*4882a593Smuzhiyun 	defined(CONFIG_SOC_EXYNOS9830) || defined(CONFIG_SOC_GS101)
370*4882a593Smuzhiyun extern int pcie_ch_num;
371*4882a593Smuzhiyun extern int exynos_pcie_l1_exit(int ch_num);
372*4882a593Smuzhiyun #endif /* CONFIG_SOC_EXYNOS9810 || CONFIG_SOC_EXYNOS9820
373*4882a593Smuzhiyun 	* CONFIG_SOC_EXYNOS9830 || CONFIG_SOC_GS101
374*4882a593Smuzhiyun 	*/
375*4882a593Smuzhiyun 
376*4882a593Smuzhiyun /* register access macros */
377*4882a593Smuzhiyun #if defined(OSLREGOPS)
378*4882a593Smuzhiyun #define R_REG(osh, r) (\
379*4882a593Smuzhiyun 	sizeof(*(r)) == sizeof(uint8) ? osl_readb((osh), (volatile uint8*)(r)) : \
380*4882a593Smuzhiyun 	sizeof(*(r)) == sizeof(uint16) ? osl_readw((osh), (volatile uint16*)(r)) : \
381*4882a593Smuzhiyun 	sizeof(*(r)) == sizeof(uint32) ? osl_readl((osh), (volatile uint32*)(r)) : \
382*4882a593Smuzhiyun 	osl_readq((osh), (volatile uint64*)(r)) \
383*4882a593Smuzhiyun )
384*4882a593Smuzhiyun 
385*4882a593Smuzhiyun #define W_REG(osh, r, v) do { \
386*4882a593Smuzhiyun 	switch (sizeof(*(r))) { \
387*4882a593Smuzhiyun 	case sizeof(uint8):	osl_writeb((osh), (volatile uint8*)(r), (uint8)(v)); break; \
388*4882a593Smuzhiyun 	case sizeof(uint16):	osl_writew((osh), (volatile uint16*)(r), (uint16)(v)); break; \
389*4882a593Smuzhiyun 	case sizeof(uint32):	osl_writel((osh), (volatile uint32*)(r), (uint32)(v)); break; \
390*4882a593Smuzhiyun 	case sizeof(uint64):	osl_writeq((osh), (volatile uint64*)(r), (uint64)(v)); break; \
391*4882a593Smuzhiyun 	} \
392*4882a593Smuzhiyun } while (0)
393*4882a593Smuzhiyun 
394*4882a593Smuzhiyun extern uint8 osl_readb(osl_t *osh, volatile uint8 *r);
395*4882a593Smuzhiyun extern uint16 osl_readw(osl_t *osh, volatile uint16 *r);
396*4882a593Smuzhiyun extern uint32 osl_readl(osl_t *osh, volatile uint32 *r);
397*4882a593Smuzhiyun extern uint32 osl_readq(osl_t *osh, volatile uint64 *r);
398*4882a593Smuzhiyun extern void osl_writeb(osl_t *osh, volatile uint8 *r, uint8 v);
399*4882a593Smuzhiyun extern void osl_writew(osl_t *osh, volatile uint16 *r, uint16 v);
400*4882a593Smuzhiyun extern void osl_writel(osl_t *osh, volatile uint32 *r, uint32 v);
401*4882a593Smuzhiyun extern void osl_writeq(osl_t *osh, volatile uint64 *r, uint64 v);
402*4882a593Smuzhiyun 
403*4882a593Smuzhiyun #else /* OSLREGOPS */
404*4882a593Smuzhiyun 
405*4882a593Smuzhiyun #ifndef IL_BIGENDIAN
406*4882a593Smuzhiyun #ifdef CONFIG_64BIT
407*4882a593Smuzhiyun /* readq is defined only for 64 bit platform */
408*4882a593Smuzhiyun #if defined(CONFIG_SOC_EXYNOS9810) || defined(CONFIG_SOC_EXYNOS9820) || \
409*4882a593Smuzhiyun 	defined(CONFIG_SOC_EXYNOS9830) || defined(CONFIG_SOC_GS101)
410*4882a593Smuzhiyun #define R_REG(osh, r) (\
411*4882a593Smuzhiyun 	SELECT_BUS_READ(osh, \
412*4882a593Smuzhiyun 		({ \
413*4882a593Smuzhiyun 			__typeof(*(r)) __osl_v = 0; \
414*4882a593Smuzhiyun 			exynos_pcie_l1_exit(pcie_ch_num); \
415*4882a593Smuzhiyun 			BCM_REFERENCE(osh);	\
416*4882a593Smuzhiyun 			switch (sizeof(*(r))) { \
417*4882a593Smuzhiyun 				case sizeof(uint8):	__osl_v = \
418*4882a593Smuzhiyun 					readb((volatile uint8*)(r)); break; \
419*4882a593Smuzhiyun 				case sizeof(uint16):	__osl_v = \
420*4882a593Smuzhiyun 					readw((volatile uint16*)(r)); break; \
421*4882a593Smuzhiyun 				case sizeof(uint32):	__osl_v = \
422*4882a593Smuzhiyun 					readl((volatile uint32*)(r)); break; \
423*4882a593Smuzhiyun 				case sizeof(uint64):	__osl_v = \
424*4882a593Smuzhiyun 					readq((volatile uint64*)(r)); break; \
425*4882a593Smuzhiyun 			} \
426*4882a593Smuzhiyun 			__osl_v; \
427*4882a593Smuzhiyun 		}), \
428*4882a593Smuzhiyun 		OSL_READ_REG(osh, r)) \
429*4882a593Smuzhiyun )
430*4882a593Smuzhiyun #else
431*4882a593Smuzhiyun #define R_REG(osh, r) (\
432*4882a593Smuzhiyun 	SELECT_BUS_READ(osh, \
433*4882a593Smuzhiyun 		({ \
434*4882a593Smuzhiyun 			__typeof(*(r)) __osl_v = 0; \
435*4882a593Smuzhiyun 			BCM_REFERENCE(osh);	\
436*4882a593Smuzhiyun 			switch (sizeof(*(r))) { \
437*4882a593Smuzhiyun 				case sizeof(uint8):	__osl_v = \
438*4882a593Smuzhiyun 					readb((volatile uint8*)(r)); break; \
439*4882a593Smuzhiyun 				case sizeof(uint16):	__osl_v = \
440*4882a593Smuzhiyun 					readw((volatile uint16*)(r)); break; \
441*4882a593Smuzhiyun 				case sizeof(uint32):	__osl_v = \
442*4882a593Smuzhiyun 					readl((volatile uint32*)(r)); break; \
443*4882a593Smuzhiyun 				case sizeof(uint64):	__osl_v = \
444*4882a593Smuzhiyun 					readq((volatile uint64*)(r)); break; \
445*4882a593Smuzhiyun 			} \
446*4882a593Smuzhiyun 			__osl_v; \
447*4882a593Smuzhiyun 		}), \
448*4882a593Smuzhiyun 		OSL_READ_REG(osh, r)) \
449*4882a593Smuzhiyun )
450*4882a593Smuzhiyun #endif /* CONFIG_SOC_EXYNOS9810 || CONFIG_SOC_EXYNOS9820
451*4882a593Smuzhiyun 	* CONFIG_SOC_EXYNOS9830 || CONFIG_SOC_GS101
452*4882a593Smuzhiyun 	*/
453*4882a593Smuzhiyun #else /* !CONFIG_64BIT */
454*4882a593Smuzhiyun #define R_REG(osh, r) (\
455*4882a593Smuzhiyun 	SELECT_BUS_READ(osh, \
456*4882a593Smuzhiyun 		({ \
457*4882a593Smuzhiyun 			__typeof(*(r)) __osl_v = 0; \
458*4882a593Smuzhiyun 			switch (sizeof(*(r))) { \
459*4882a593Smuzhiyun 				case sizeof(uint8):	__osl_v = \
460*4882a593Smuzhiyun 					readb((volatile uint8*)(r)); break; \
461*4882a593Smuzhiyun 				case sizeof(uint16):	__osl_v = \
462*4882a593Smuzhiyun 					readw((volatile uint16*)(r)); break; \
463*4882a593Smuzhiyun 				case sizeof(uint32):	__osl_v = \
464*4882a593Smuzhiyun 					readl((volatile uint32*)(r)); break; \
465*4882a593Smuzhiyun 			} \
466*4882a593Smuzhiyun 			__osl_v; \
467*4882a593Smuzhiyun 		}), \
468*4882a593Smuzhiyun 		OSL_READ_REG(osh, r)) \
469*4882a593Smuzhiyun )
470*4882a593Smuzhiyun #endif /* CONFIG_64BIT */
471*4882a593Smuzhiyun 
472*4882a593Smuzhiyun #ifdef CONFIG_64BIT
473*4882a593Smuzhiyun /* writeq is defined only for 64 bit platform */
474*4882a593Smuzhiyun #if defined(CONFIG_SOC_EXYNOS9810) || defined(CONFIG_SOC_EXYNOS9820) || \
475*4882a593Smuzhiyun 	defined(CONFIG_SOC_EXYNOS9830) || defined(CONFIG_SOC_GS101)
476*4882a593Smuzhiyun #define W_REG(osh, r, v) do { \
477*4882a593Smuzhiyun 	SELECT_BUS_WRITE(osh, \
478*4882a593Smuzhiyun 		({ \
479*4882a593Smuzhiyun 			exynos_pcie_l1_exit(pcie_ch_num); \
480*4882a593Smuzhiyun 			switch (sizeof(*(r))) { \
481*4882a593Smuzhiyun 				case sizeof(uint8):	writeb((uint8)(v), \
482*4882a593Smuzhiyun 						(volatile uint8*)(r)); break; \
483*4882a593Smuzhiyun 				case sizeof(uint16):	writew((uint16)(v), \
484*4882a593Smuzhiyun 						(volatile uint16*)(r)); break; \
485*4882a593Smuzhiyun 				case sizeof(uint32):	writel((uint32)(v), \
486*4882a593Smuzhiyun 						(volatile uint32*)(r)); break; \
487*4882a593Smuzhiyun 				case sizeof(uint64):	writeq((uint64)(v), \
488*4882a593Smuzhiyun 						(volatile uint64*)(r)); break; \
489*4882a593Smuzhiyun 			} \
490*4882a593Smuzhiyun 		 }), \
491*4882a593Smuzhiyun 		(OSL_WRITE_REG(osh, r, v))); \
492*4882a593Smuzhiyun 	} while (0)
493*4882a593Smuzhiyun #else
494*4882a593Smuzhiyun #define W_REG(osh, r, v) do { \
495*4882a593Smuzhiyun 	SELECT_BUS_WRITE(osh, \
496*4882a593Smuzhiyun 		switch (sizeof(*(r))) { \
497*4882a593Smuzhiyun 			case sizeof(uint8):	writeb((uint8)(v), (volatile uint8*)(r)); break; \
498*4882a593Smuzhiyun 			case sizeof(uint16):	writew((uint16)(v), (volatile uint16*)(r)); break; \
499*4882a593Smuzhiyun 			case sizeof(uint32):	writel((uint32)(v), (volatile uint32*)(r)); break; \
500*4882a593Smuzhiyun 			case sizeof(uint64):	writeq((uint64)(v), (volatile uint64*)(r)); break; \
501*4882a593Smuzhiyun 		}, \
502*4882a593Smuzhiyun 		(OSL_WRITE_REG(osh, r, v))); \
503*4882a593Smuzhiyun 	} while (0)
504*4882a593Smuzhiyun #endif /* CONFIG_SOC_EXYNOS9810 || CONFIG_SOC_EXYNOS9820
505*4882a593Smuzhiyun 	* CONFIG_SOC_EXYNOS9830 || CONFIG_SOC_GS101
506*4882a593Smuzhiyun 	*/
507*4882a593Smuzhiyun #else /* !CONFIG_64BIT */
508*4882a593Smuzhiyun #define W_REG(osh, r, v) do { \
509*4882a593Smuzhiyun 	SELECT_BUS_WRITE(osh, \
510*4882a593Smuzhiyun 		switch (sizeof(*(r))) { \
511*4882a593Smuzhiyun 			case sizeof(uint8):	writeb((uint8)(v), (volatile uint8*)(r)); break; \
512*4882a593Smuzhiyun 			case sizeof(uint16):	writew((uint16)(v), (volatile uint16*)(r)); break; \
513*4882a593Smuzhiyun 			case sizeof(uint32):	writel((uint32)(v), (volatile uint32*)(r)); break; \
514*4882a593Smuzhiyun 		}, \
515*4882a593Smuzhiyun 		(OSL_WRITE_REG(osh, r, v))); \
516*4882a593Smuzhiyun 	} while (0)
517*4882a593Smuzhiyun #endif /* CONFIG_64BIT */
518*4882a593Smuzhiyun 
519*4882a593Smuzhiyun #else	/* IL_BIGENDIAN */
520*4882a593Smuzhiyun 
521*4882a593Smuzhiyun #ifdef CONFIG_64BIT
522*4882a593Smuzhiyun /* readq and writeq is defined only for 64 bit platform */
523*4882a593Smuzhiyun #define R_REG(osh, r) (\
524*4882a593Smuzhiyun 	SELECT_BUS_READ(osh, \
525*4882a593Smuzhiyun 		({ \
526*4882a593Smuzhiyun 			__typeof(*(r)) __osl_v = 0; \
527*4882a593Smuzhiyun 			switch (sizeof(*(r))) { \
528*4882a593Smuzhiyun 				case sizeof(uint8):	__osl_v = \
529*4882a593Smuzhiyun 					readb((volatile uint8*)((uintptr)(r)^3)); break; \
530*4882a593Smuzhiyun 				case sizeof(uint16):	__osl_v = \
531*4882a593Smuzhiyun 					readw((volatile uint16*)((uintptr)(r)^2)); break; \
532*4882a593Smuzhiyun 				case sizeof(uint32):	__osl_v = \
533*4882a593Smuzhiyun 					readl((volatile uint32*)(r)); break; \
534*4882a593Smuzhiyun 				case sizeof(uint64):    __osl_v = \
535*4882a593Smuzhiyun 					readq((volatile uint64*)(r)); break; \
536*4882a593Smuzhiyun 			} \
537*4882a593Smuzhiyun 			__osl_v; \
538*4882a593Smuzhiyun 		}), \
539*4882a593Smuzhiyun 		OSL_READ_REG(osh, r)) \
540*4882a593Smuzhiyun )
541*4882a593Smuzhiyun #define W_REG(osh, r, v) do { \
542*4882a593Smuzhiyun 	SELECT_BUS_WRITE(osh, \
543*4882a593Smuzhiyun 		switch (sizeof(*(r))) { \
544*4882a593Smuzhiyun 			case sizeof(uint8):	writeb((uint8)(v), \
545*4882a593Smuzhiyun 					(volatile uint8*)((uintptr)(r)^3)); break; \
546*4882a593Smuzhiyun 			case sizeof(uint16):	writew((uint16)(v), \
547*4882a593Smuzhiyun 					(volatile uint16*)((uintptr)(r)^2)); break; \
548*4882a593Smuzhiyun 			case sizeof(uint32):	writel((uint32)(v), \
549*4882a593Smuzhiyun 					(volatile uint32*)(r)); break; \
550*4882a593Smuzhiyun 			case sizeof(uint64):	writeq((uint64)(v), \
551*4882a593Smuzhiyun 					(volatile uint64*)(r)); break; \
552*4882a593Smuzhiyun 		}, \
553*4882a593Smuzhiyun 		(OSL_WRITE_REG(osh, r, v))); \
554*4882a593Smuzhiyun 	} while (0)
555*4882a593Smuzhiyun 
556*4882a593Smuzhiyun #else /* !CONFIG_64BIT */
557*4882a593Smuzhiyun #define R_REG(osh, r) (\
558*4882a593Smuzhiyun 	SELECT_BUS_READ(osh, \
559*4882a593Smuzhiyun 		({ \
560*4882a593Smuzhiyun 			__typeof(*(r)) __osl_v = 0; \
561*4882a593Smuzhiyun 			switch (sizeof(*(r))) { \
562*4882a593Smuzhiyun 				case sizeof(uint8):	__osl_v = \
563*4882a593Smuzhiyun 					readb((volatile uint8*)((uintptr)(r)^3)); break; \
564*4882a593Smuzhiyun 				case sizeof(uint16):	__osl_v = \
565*4882a593Smuzhiyun 					readw((volatile uint16*)((uintptr)(r)^2)); break; \
566*4882a593Smuzhiyun 				case sizeof(uint32):	__osl_v = \
567*4882a593Smuzhiyun 					readl((volatile uint32*)(r)); break; \
568*4882a593Smuzhiyun 			} \
569*4882a593Smuzhiyun 			__osl_v; \
570*4882a593Smuzhiyun 		}), \
571*4882a593Smuzhiyun 		OSL_READ_REG(osh, r)) \
572*4882a593Smuzhiyun )
573*4882a593Smuzhiyun #define W_REG(osh, r, v) do { \
574*4882a593Smuzhiyun 	SELECT_BUS_WRITE(osh, \
575*4882a593Smuzhiyun 		switch (sizeof(*(r))) { \
576*4882a593Smuzhiyun 			case sizeof(uint8):	writeb((uint8)(v), \
577*4882a593Smuzhiyun 					(volatile uint8*)((uintptr)(r)^3)); break; \
578*4882a593Smuzhiyun 			case sizeof(uint16):	writew((uint16)(v), \
579*4882a593Smuzhiyun 					(volatile uint16*)((uintptr)(r)^2)); break; \
580*4882a593Smuzhiyun 			case sizeof(uint32):	writel((uint32)(v), \
581*4882a593Smuzhiyun 					(volatile uint32*)(r)); break; \
582*4882a593Smuzhiyun 		}, \
583*4882a593Smuzhiyun 		(OSL_WRITE_REG(osh, r, v))); \
584*4882a593Smuzhiyun 	} while (0)
585*4882a593Smuzhiyun #endif /* CONFIG_64BIT */
586*4882a593Smuzhiyun #endif /* IL_BIGENDIAN */
587*4882a593Smuzhiyun 
588*4882a593Smuzhiyun #endif /* OSLREGOPS */
589*4882a593Smuzhiyun 
590*4882a593Smuzhiyun #define	AND_REG(osh, r, v)		W_REG(osh, (r), R_REG(osh, r) & (v))
591*4882a593Smuzhiyun #define	OR_REG(osh, r, v)		W_REG(osh, (r), R_REG(osh, r) | (v))
592*4882a593Smuzhiyun 
593*4882a593Smuzhiyun /* bcopy, bcmp, and bzero functions */
594*4882a593Smuzhiyun #define	bcopy(src, dst, len)	memcpy((dst), (src), (len))
595*4882a593Smuzhiyun #define	bcmp(b1, b2, len)	memcmp((b1), (b2), (len))
596*4882a593Smuzhiyun #define	bzero(b, len)		memset((b), '\0', (len))
597*4882a593Smuzhiyun 
598*4882a593Smuzhiyun /* uncached/cached virtual address */
599*4882a593Smuzhiyun #define OSL_UNCACHED(va)	((void *)va)
600*4882a593Smuzhiyun #define OSL_CACHED(va)		((void *)va)
601*4882a593Smuzhiyun 
602*4882a593Smuzhiyun #define OSL_PREF_RANGE_LD(va, sz) BCM_REFERENCE(va)
603*4882a593Smuzhiyun #define OSL_PREF_RANGE_ST(va, sz) BCM_REFERENCE(va)
604*4882a593Smuzhiyun 
605*4882a593Smuzhiyun /* get processor cycle count */
606*4882a593Smuzhiyun #if defined(__i386__)
607*4882a593Smuzhiyun #define	OSL_GETCYCLES(x)	rdtscl((x))
608*4882a593Smuzhiyun #else
609*4882a593Smuzhiyun #define OSL_GETCYCLES(x)	((x) = 0)
610*4882a593Smuzhiyun #endif /* __i386__ */
611*4882a593Smuzhiyun 
612*4882a593Smuzhiyun /* dereference an address that may cause a bus exception */
613*4882a593Smuzhiyun #define	BUSPROBE(val, addr)	({ (val) = R_REG(NULL, (addr)); 0; })
614*4882a593Smuzhiyun 
615*4882a593Smuzhiyun /* map/unmap physical to virtual I/O */
616*4882a593Smuzhiyun #if !defined(CONFIG_MMC_MSM7X00A)
617*4882a593Smuzhiyun #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0))
618*4882a593Smuzhiyun #define	REG_MAP(pa, size)	ioremap((unsigned long)(pa), (unsigned long)(size))
619*4882a593Smuzhiyun #else
620*4882a593Smuzhiyun #define	REG_MAP(pa, size)	ioremap_nocache((unsigned long)(pa), (unsigned long)(size))
621*4882a593Smuzhiyun #endif
622*4882a593Smuzhiyun #else
623*4882a593Smuzhiyun #define REG_MAP(pa, size)       (void *)(0)
624*4882a593Smuzhiyun #endif /* !defined(CONFIG_MMC_MSM7X00A */
625*4882a593Smuzhiyun #define	REG_UNMAP(va)		iounmap((va))
626*4882a593Smuzhiyun 
627*4882a593Smuzhiyun /* shared (dma-able) memory access macros */
628*4882a593Smuzhiyun #define	R_SM(r)			*(r)
629*4882a593Smuzhiyun #define	W_SM(r, v)		(*(r) = (v))
630*4882a593Smuzhiyun #define	OR_SM(r, v)		(*(r) |= (v))
631*4882a593Smuzhiyun #define	BZERO_SM(r, len)	memset((r), '\0', (len))
632*4882a593Smuzhiyun 
633*4882a593Smuzhiyun /* Because the non BINOSL implemenation of the PKT OSL routines are macros (for
634*4882a593Smuzhiyun  * performance reasons),  we need the Linux headers.
635*4882a593Smuzhiyun  */
636*4882a593Smuzhiyun #include <linuxver.h>		/* use current 2.4.x calling conventions */
637*4882a593Smuzhiyun 
638*4882a593Smuzhiyun #else	/* BINOSL */
639*4882a593Smuzhiyun 
640*4882a593Smuzhiyun /* Where to get the declarations for mem, str, printf, bcopy's? Two basic approaches.
641*4882a593Smuzhiyun  *
642*4882a593Smuzhiyun  * First, use the Linux header files and the C standard library replacmenent versions
643*4882a593Smuzhiyun  * built-in to the kernel.  Use this approach when compiling non hybrid code or compling
644*4882a593Smuzhiyun  * the OS port files.  The second approach is to use our own defines/prototypes and
645*4882a593Smuzhiyun  * functions we have provided in the Linux OSL, i.e. linux_osl.c.  Use this approach when
646*4882a593Smuzhiyun  * compiling the files that make up the hybrid binary.  We are ensuring we
647*4882a593Smuzhiyun  * don't directly link to the kernel replacement routines from the hybrid binary.
648*4882a593Smuzhiyun  *
649*4882a593Smuzhiyun  * NOTE: The issue we are trying to avoid is any questioning of whether the
650*4882a593Smuzhiyun  * hybrid binary is derived from Linux.  The wireless common code (wlc) is designed
651*4882a593Smuzhiyun  * to be OS independent through the use of the OSL API and thus the hybrid binary doesn't
652*4882a593Smuzhiyun  * derive from the Linux kernel at all.  But since we defined our OSL API to include
653*4882a593Smuzhiyun  * a small collection of standard C library routines and these routines are provided in
654*4882a593Smuzhiyun  * the kernel we want to avoid even the appearance of deriving at all even though clearly
655*4882a593Smuzhiyun  * usage of a C standard library API doesn't represent a derivation from Linux.  Lastly
656*4882a593Smuzhiyun  * note at the time of this checkin 4 references to memcpy/memset could not be eliminated
657*4882a593Smuzhiyun  * from the binary because they are created internally by GCC as part of things like
658*4882a593Smuzhiyun  * structure assignment.  I don't think the compiler should be doing this but there is
659*4882a593Smuzhiyun  * no options to disable it on Intel architectures (there is for MIPS so somebody must
660*4882a593Smuzhiyun  * agree with me).  I may be able to even remove these references eventually with
661*4882a593Smuzhiyun  * a GNU binutil such as objcopy via a symbol rename (i.e. memcpy to osl_memcpy).
662*4882a593Smuzhiyun  */
663*4882a593Smuzhiyun 	#define	printf(fmt, args...)	printk(fmt , ## args)
664*4882a593Smuzhiyun 	#include <linux/kernel.h>	/* for vsn/printf's */
665*4882a593Smuzhiyun 	#include <linux/string.h>	/* for mem*, str* */
666*4882a593Smuzhiyun 	/* bcopy's: Linux kernel doesn't provide these (anymore) */
667*4882a593Smuzhiyun 	#define	bcopy(src, dst, len)	memcpy((dst), (src), (len))
668*4882a593Smuzhiyun 	#define	bcmp(b1, b2, len)	memcmp((b1), (b2), (len))
669*4882a593Smuzhiyun 	#define	bzero(b, len)		memset((b), '\0', (len))
670*4882a593Smuzhiyun 
671*4882a593Smuzhiyun 	/* These are provided only because when compiling linux_osl.c there
672*4882a593Smuzhiyun 	 * must be an explicit prototype (separate from the definition) because
673*4882a593Smuzhiyun 	 * we are compiling with GCC option -Wstrict-prototypes.  Conversely
674*4882a593Smuzhiyun 	 * these could be placed directly in linux_osl.c.
675*4882a593Smuzhiyun 	 */
676*4882a593Smuzhiyun 	extern int osl_printf(const char *format, ...);
677*4882a593Smuzhiyun 	extern int osl_sprintf(char *buf, const char *format, ...);
678*4882a593Smuzhiyun 	extern int osl_snprintf(char *buf, size_t n, const char *format, ...);
679*4882a593Smuzhiyun 	extern int osl_vsprintf(char *buf, const char *format, va_list ap);
680*4882a593Smuzhiyun 	extern int osl_vsnprintf(char *buf, size_t n, const char *format, va_list ap);
681*4882a593Smuzhiyun 	extern int osl_strcmp(const char *s1, const char *s2);
682*4882a593Smuzhiyun 	extern int osl_strncmp(const char *s1, const char *s2, uint n);
683*4882a593Smuzhiyun 	extern int osl_strlen(const char *s);
684*4882a593Smuzhiyun 	extern char* osl_strcpy(char *d, const char *s);
685*4882a593Smuzhiyun 	extern char* osl_strncpy(char *d, const char *s, uint n);
686*4882a593Smuzhiyun 	extern char* osl_strchr(const char *s, int c);
687*4882a593Smuzhiyun 	extern char* osl_strrchr(const char *s, int c);
688*4882a593Smuzhiyun 	extern void *osl_memset(void *d, int c, size_t n);
689*4882a593Smuzhiyun 	extern void *osl_memcpy(void *d, const void *s, size_t n);
690*4882a593Smuzhiyun 	extern void *osl_memmove(void *d, const void *s, size_t n);
691*4882a593Smuzhiyun 	extern int osl_memcmp(const void *s1, const void *s2, size_t n);
692*4882a593Smuzhiyun 
693*4882a593Smuzhiyun /* register access macros */
694*4882a593Smuzhiyun #if !defined(BCMSDIO)
695*4882a593Smuzhiyun #define R_REG(osh, r) \
696*4882a593Smuzhiyun 	({ \
697*4882a593Smuzhiyun 	 BCM_REFERENCE(osh); \
698*4882a593Smuzhiyun 	 sizeof(*(r)) == sizeof(uint8) ? osl_readb((volatile uint8*)(r)) : \
699*4882a593Smuzhiyun 	 sizeof(*(r)) == sizeof(uint16) ? osl_readw((volatile uint16*)(r)) : \
700*4882a593Smuzhiyun 	 sizeof(*(r)) == sizeof(uint32) ? osl_readl((volatile uint32*)(r)) : \
701*4882a593Smuzhiyun 	 osl_readq((volatile uint64*)(r)); \
702*4882a593Smuzhiyun 	 })
703*4882a593Smuzhiyun #define W_REG(osh, r, v) do { \
704*4882a593Smuzhiyun 	BCM_REFERENCE(osh); \
705*4882a593Smuzhiyun 	switch (sizeof(*(r))) { \
706*4882a593Smuzhiyun 	case sizeof(uint8):	osl_writeb((uint8)(v), (volatile uint8*)(r)); break; \
707*4882a593Smuzhiyun 	case sizeof(uint16):	osl_writew((uint16)(v), (volatile uint16*)(r)); break; \
708*4882a593Smuzhiyun 	case sizeof(uint32):	osl_writel((uint32)(v), (volatile uint32*)(r)); break; \
709*4882a593Smuzhiyun 	case sizeof(uint64):	osl_writeq((uint64)(v), (volatile uint64*)(r)); break; \
710*4882a593Smuzhiyun 	} \
711*4882a593Smuzhiyun } while (0)
712*4882a593Smuzhiyun 
713*4882a593Smuzhiyun #else
714*4882a593Smuzhiyun #define R_REG(osh, r) OSL_READ_REG(osh, r)
715*4882a593Smuzhiyun #define W_REG(osh, r, v) do { OSL_WRITE_REG(osh, r, v); } while (0)
716*4882a593Smuzhiyun #endif /* !defined(BCMSDIO) */
717*4882a593Smuzhiyun 
718*4882a593Smuzhiyun #define	AND_REG(osh, r, v)		W_REG(osh, (r), R_REG(osh, r) & (v))
719*4882a593Smuzhiyun #define	OR_REG(osh, r, v)		W_REG(osh, (r), R_REG(osh, r) | (v))
720*4882a593Smuzhiyun extern uint8 osl_readb(volatile uint8 *r);
721*4882a593Smuzhiyun extern uint16 osl_readw(volatile uint16 *r);
722*4882a593Smuzhiyun extern uint32 osl_readl(volatile uint32 *r);
723*4882a593Smuzhiyun extern uint64 osl_readq(volatile uint64 *r);
724*4882a593Smuzhiyun extern void osl_writeb(uint8 v, volatile uint8 *r);
725*4882a593Smuzhiyun extern void osl_writew(uint16 v, volatile uint16 *r);
726*4882a593Smuzhiyun extern void osl_writel(uint32 v, volatile uint32 *r);
727*4882a593Smuzhiyun extern void osl_writeq(uint64 v, volatile uint64 *r);
728*4882a593Smuzhiyun 
729*4882a593Smuzhiyun /* system up time in ms */
730*4882a593Smuzhiyun #define OSL_SYSUPTIME()		osl_sysuptime()
731*4882a593Smuzhiyun extern uint32 osl_sysuptime(void);
732*4882a593Smuzhiyun 
733*4882a593Smuzhiyun /* uncached/cached virtual address */
734*4882a593Smuzhiyun #define OSL_UNCACHED(va)	osl_uncached((va))
735*4882a593Smuzhiyun extern void *osl_uncached(void *va);
736*4882a593Smuzhiyun #define OSL_CACHED(va)		osl_cached((va))
737*4882a593Smuzhiyun extern void *osl_cached(void *va);
738*4882a593Smuzhiyun 
739*4882a593Smuzhiyun #define OSL_PREF_RANGE_LD(va, sz)
740*4882a593Smuzhiyun #define OSL_PREF_RANGE_ST(va, sz)
741*4882a593Smuzhiyun 
742*4882a593Smuzhiyun /* get processor cycle count */
743*4882a593Smuzhiyun #define OSL_GETCYCLES(x)	((x) = osl_getcycles())
744*4882a593Smuzhiyun extern uint osl_getcycles(void);
745*4882a593Smuzhiyun 
746*4882a593Smuzhiyun /* dereference an address that may target abort */
747*4882a593Smuzhiyun #define	BUSPROBE(val, addr)	osl_busprobe(&(val), (addr))
748*4882a593Smuzhiyun extern int osl_busprobe(uint32 *val, uint32 addr);
749*4882a593Smuzhiyun 
750*4882a593Smuzhiyun /* map/unmap physical to virtual */
751*4882a593Smuzhiyun #define	REG_MAP(pa, size)	osl_reg_map((pa), (size))
752*4882a593Smuzhiyun #define	REG_UNMAP(va)		osl_reg_unmap((va))
753*4882a593Smuzhiyun extern void *osl_reg_map(uint32 pa, uint size);
754*4882a593Smuzhiyun extern void osl_reg_unmap(void *va);
755*4882a593Smuzhiyun 
756*4882a593Smuzhiyun /* shared (dma-able) memory access macros */
757*4882a593Smuzhiyun #define	R_SM(r)			*(r)
758*4882a593Smuzhiyun #define	W_SM(r, v)		(*(r) = (v))
759*4882a593Smuzhiyun #define	OR_SM(r, v)		(*(r) |= (v))
760*4882a593Smuzhiyun #define	BZERO_SM(r, len)	bzero((r), (len))
761*4882a593Smuzhiyun 
762*4882a593Smuzhiyun #endif	/* BINOSL */
763*4882a593Smuzhiyun 
764*4882a593Smuzhiyun #define OSL_RAND()		osl_rand()
765*4882a593Smuzhiyun extern uint32 osl_rand(void);
766*4882a593Smuzhiyun 
767*4882a593Smuzhiyun #define	DMA_FLUSH(osh, va, size, direction, p, dmah) \
768*4882a593Smuzhiyun 	osl_dma_flush((osh), (va), (size), (direction), (p), (dmah))
769*4882a593Smuzhiyun #define	DMA_MAP(osh, va, size, direction, p, dmah) \
770*4882a593Smuzhiyun 	osl_dma_map((osh), (va), (size), (direction), (p), (dmah))
771*4882a593Smuzhiyun 
772*4882a593Smuzhiyun #else /* ! BCMDRIVER */
773*4882a593Smuzhiyun 
774*4882a593Smuzhiyun /* ASSERT */
775*4882a593Smuzhiyun #ifdef BCMDBG_ASSERT
776*4882a593Smuzhiyun 	#include <assert.h>
777*4882a593Smuzhiyun 	#define ASSERT assert
778*4882a593Smuzhiyun #else /* BCMDBG_ASSERT */
779*4882a593Smuzhiyun 	#define ASSERT(exp)	do {} while (0)
780*4882a593Smuzhiyun #endif /* BCMDBG_ASSERT */
781*4882a593Smuzhiyun 
782*4882a593Smuzhiyun #define ASSERT_FP(exp) ASSERT(exp)
783*4882a593Smuzhiyun 
784*4882a593Smuzhiyun /* MALLOC and MFREE */
785*4882a593Smuzhiyun #define MALLOC(o, l) malloc(l)
786*4882a593Smuzhiyun #define MFREE(o, p, l) free(p)
787*4882a593Smuzhiyun #include <stdlib.h>
788*4882a593Smuzhiyun 
789*4882a593Smuzhiyun /* str* and mem* functions */
790*4882a593Smuzhiyun #include <string.h>
791*4882a593Smuzhiyun 
792*4882a593Smuzhiyun /* *printf functions */
793*4882a593Smuzhiyun #include <stdio.h>
794*4882a593Smuzhiyun 
795*4882a593Smuzhiyun /* bcopy, bcmp, and bzero */
796*4882a593Smuzhiyun extern void bcopy(const void *src, void *dst, size_t len);
797*4882a593Smuzhiyun extern int bcmp(const void *b1, const void *b2, size_t len);
798*4882a593Smuzhiyun extern void bzero(void *b, size_t len);
799*4882a593Smuzhiyun #endif /* ! BCMDRIVER */
800*4882a593Smuzhiyun 
801*4882a593Smuzhiyun typedef struct sk_buff_head PKT_LIST;
802*4882a593Smuzhiyun #define PKTLIST_INIT(x)		skb_queue_head_init((x))
803*4882a593Smuzhiyun #define PKTLIST_ENQ(x, y)	skb_queue_head((struct sk_buff_head *)(x), (struct sk_buff *)(y))
804*4882a593Smuzhiyun #define PKTLIST_DEQ(x)		skb_dequeue((struct sk_buff_head *)(x))
805*4882a593Smuzhiyun #define PKTLIST_UNLINK(x, y)	skb_unlink((struct sk_buff *)(y), (struct sk_buff_head *)(x))
806*4882a593Smuzhiyun #define PKTLIST_FINI(x)		skb_queue_purge((struct sk_buff_head *)(x))
807*4882a593Smuzhiyun 
808*4882a593Smuzhiyun #ifndef _linuxver_h_
809*4882a593Smuzhiyun typedef struct timer_list_compat timer_list_compat_t;
810*4882a593Smuzhiyun #endif /* _linuxver_h_ */
811*4882a593Smuzhiyun typedef struct osl_timer {
812*4882a593Smuzhiyun 	timer_list_compat_t *timer;
813*4882a593Smuzhiyun 	bool   set;
814*4882a593Smuzhiyun #ifdef BCMDBG
815*4882a593Smuzhiyun 	char    *name;          /* Desription of the timer */
816*4882a593Smuzhiyun #endif
817*4882a593Smuzhiyun } osl_timer_t;
818*4882a593Smuzhiyun 
819*4882a593Smuzhiyun typedef void (*linux_timer_fn)(ulong arg);
820*4882a593Smuzhiyun 
821*4882a593Smuzhiyun extern osl_timer_t * osl_timer_init(osl_t *osh, const char *name, void (*fn)(void *arg), void *arg);
822*4882a593Smuzhiyun extern void osl_timer_add(osl_t *osh, osl_timer_t *t, uint32 ms, bool periodic);
823*4882a593Smuzhiyun extern void osl_timer_update(osl_t *osh, osl_timer_t *t, uint32 ms, bool periodic);
824*4882a593Smuzhiyun extern bool osl_timer_del(osl_t *osh, osl_timer_t *t);
825*4882a593Smuzhiyun 
826*4882a593Smuzhiyun #ifdef BCMDRIVER
827*4882a593Smuzhiyun typedef atomic_t osl_atomic_t;
828*4882a593Smuzhiyun #define OSL_ATOMIC_SET(osh, v, x)	atomic_set(v, x)
829*4882a593Smuzhiyun #define OSL_ATOMIC_INIT(osh, v)		atomic_set(v, 0)
830*4882a593Smuzhiyun #define OSL_ATOMIC_INC(osh, v)		atomic_inc(v)
831*4882a593Smuzhiyun #define OSL_ATOMIC_INC_RETURN(osh, v)	atomic_inc_return(v)
832*4882a593Smuzhiyun #define OSL_ATOMIC_DEC(osh, v)		atomic_dec(v)
833*4882a593Smuzhiyun #define OSL_ATOMIC_DEC_RETURN(osh, v)	atomic_dec_return(v)
834*4882a593Smuzhiyun #define OSL_ATOMIC_READ(osh, v)		atomic_read(v)
835*4882a593Smuzhiyun #define OSL_ATOMIC_ADD(osh, v, x)	atomic_add(v, x)
836*4882a593Smuzhiyun 
837*4882a593Smuzhiyun #ifndef atomic_set_mask
838*4882a593Smuzhiyun #define OSL_ATOMIC_OR(osh, v, x)	atomic_or(x, v)
839*4882a593Smuzhiyun #define OSL_ATOMIC_AND(osh, v, x)	atomic_and(x, v)
840*4882a593Smuzhiyun #else
841*4882a593Smuzhiyun #define OSL_ATOMIC_OR(osh, v, x)	atomic_set_mask(x, v)
842*4882a593Smuzhiyun #define OSL_ATOMIC_AND(osh, v, x)	atomic_clear_mask(~x, v)
843*4882a593Smuzhiyun #endif
844*4882a593Smuzhiyun #endif /* BCMDRIVER */
845*4882a593Smuzhiyun 
846*4882a593Smuzhiyun extern void *osl_spin_lock_init(osl_t *osh);
847*4882a593Smuzhiyun extern void osl_spin_lock_deinit(osl_t *osh, void *lock);
848*4882a593Smuzhiyun extern unsigned long osl_spin_lock(void *lock);
849*4882a593Smuzhiyun extern void osl_spin_unlock(void *lock, unsigned long flags);
850*4882a593Smuzhiyun extern unsigned long osl_spin_lock_irq(void *lock);
851*4882a593Smuzhiyun extern void osl_spin_unlock_irq(void *lock, unsigned long flags);
852*4882a593Smuzhiyun extern unsigned long osl_spin_lock_bh(void *lock);
853*4882a593Smuzhiyun extern void osl_spin_unlock_bh(void *lock, unsigned long flags);
854*4882a593Smuzhiyun 
855*4882a593Smuzhiyun extern void *osl_mutex_lock_init(osl_t *osh);
856*4882a593Smuzhiyun extern void osl_mutex_lock_deinit(osl_t *osh, void *lock);
857*4882a593Smuzhiyun extern unsigned long osl_mutex_lock(void *lock);
858*4882a593Smuzhiyun void osl_mutex_unlock(void *lock, unsigned long flags);
859*4882a593Smuzhiyun 
860*4882a593Smuzhiyun typedef struct osl_timespec {
861*4882a593Smuzhiyun #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0))
862*4882a593Smuzhiyun 	__kernel_old_time_t	tv_sec;			/* seconds */
863*4882a593Smuzhiyun #else
864*4882a593Smuzhiyun 	__kernel_time_t	tv_sec;			/* seconds */
865*4882a593Smuzhiyun #endif
866*4882a593Smuzhiyun 	__kernel_suseconds_t	tv_usec;	/* microseconds */
867*4882a593Smuzhiyun 	long		tv_nsec;		/* nanoseconds */
868*4882a593Smuzhiyun } osl_timespec_t;
869*4882a593Smuzhiyun extern void osl_do_gettimeofday(struct osl_timespec *ts);
870*4882a593Smuzhiyun extern void osl_get_monotonic_boottime(struct osl_timespec *ts);
871*4882a593Smuzhiyun extern uint32 osl_do_gettimediff(struct osl_timespec *cur_ts, struct osl_timespec *old_ts);
872*4882a593Smuzhiyun #endif	/* _linux_osl_h_ */
873