1/****************************************************************************
2**+-----------------------------------------------------------------------+**
3**|                                                                       |**
4**| Copyright(c) 1998 - 2008 Texas Instruments. All rights reserved.      |**
5**| All rights reserved.                                                  |**
6**|                                                                       |**
7**| Redistribution and use in source and binary forms, with or without    |**
8**| modification, are permitted provided that the following conditions    |**
9**| are met:                                                              |**
10**|                                                                       |**
11**|  * Redistributions of source code must retain the above copyright     |**
12**|    notice, this list of conditions and the following disclaimer.      |**
13**|  * Redistributions in binary form must reproduce the above copyright  |**
14**|    notice, this list of conditions and the following disclaimer in    |**
15**|    the documentation and/or other materials provided with the         |**
16**|    distribution.                                                      |**
17**|  * Neither the name Texas Instruments nor the names of its            |**
18**|    contributors may be used to endorse or promote products derived    |**
19**|    from this software without specific prior written permission.      |**
20**|                                                                       |**
21**| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS   |**
22**| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT     |**
23**| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |**
24**| A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  |**
25**| OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |**
26**| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT      |**
27**| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |**
28**| DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |**
29**| THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT   |**
30**| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |**
31**| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  |**
32**|                                                                       |**
33**+-----------------------------------------------------------------------+**
34****************************************************************************/
35
36/*--------------------------------------------------------------------------*/
37/* Module:      OSAPI.H*/
38/**/
39/* Purpose:     This module defines unified interface to the OS specific*/
40/*              sources and services.*/
41/**/
42/*--------------------------------------------------------------------------*/
43
44#ifndef __OS_API_H__
45#define __OS_API_H__
46
47
48#include "osTIType.h"
49#include "TI_IPC_Api.h"
50//TRS:MEB
51#ifdef _WINDOWS
52#endif
53
54//TRS end
55
56
57/****************************************************************************************
58						START OF OS API (Common to all GWSI LIB, Driver and TI Driver)
59*****************************************************************************************/
60
61
62#define OS_API_MEM_ADRR  0x0000000
63#define OS_API_REG_ADRR  0x300000
64
65
66/****************************************************************************************
67                        OS HW API NEEDED BY DRIVER
68*****************************************************************************************/
69
70
71#define OS_PAGE_SIZE 4096
72
73/*
74Clear the WLAN Ready Interrupt Line stored in the PIC Controller
75*/
76VOID os_clearWlanReady(void);
77
78/*
79Read the WLAN_IRQ line
80*/
81UINT32 os_senseIrqLine( TI_HANDLE OsContext );
82
83/* TRS: CDB Needed for osApi.C */
84#ifdef BSP_H5
85#define WLAN_GPIO_INTERRUPT_LINE		9
86#define WLAN_GPIO_POWER_ENABLET_LINE    10
87#else
88#define WLAN_GPIO_INTERRUPT_LINE    134
89#define WLAN_GPIO_POWER_ENABLET_LINE    71
90#endif
91
92
93VOID
94os_disableIrq(
95    TI_HANDLE OsContext
96    );
97
98VOID
99os_enableIrq(
100    TI_HANDLE OsContext
101    );
102
103/****************************************************************************************
104 *                        																*
105 *						OS Report API													*
106 *																						*
107 ****************************************************************************************/
108
109VOID
110os_setDebugMode(
111	BOOL enable
112	);
113
114VOID
115os_printf(
116	const char *format ,...);
117
118VOID os_setDebugOutputToTicon(BOOL value);
119
120#define os_report   os_printf
121#define osPrintf os_printf  //TRS::CDB
122
123/****************************************************************************************
124 *                        																*
125 *							OS DMA CALLBACK API											*
126 ****************************************************************************************
127 *	Callback directly called at an IRQ context from the SPI modue						*
128 *	This should triger a tasklet_schedule so that the End of DMA will be handled		*
129 *	in a tasklet  context and then be directed to the TNETWIF to call the Client 		*
130 *																						*
131 *																						*
132 ****************************************************************************************/
133
134VOID
135os_TNETWIF_BusTxn_Complete(
136	TI_HANDLE OsContext,
137	int status
138	);
139
140
141/****************************************************************************************
142 *                        																*
143 *						OS Memory API													*
144 *																						*
145 ****************************************************************************************/
146
147PVOID
148os_memoryAlloc(
149    TI_HANDLE OsContext,
150    UINT32 Size
151    );
152
153PVOID
154os_memoryPreAlloc(
155    TI_HANDLE OsContext,
156    int section,
157    UINT32 Size
158    );
159
160PVOID
161os_memoryCAlloc(
162    TI_HANDLE OsContext,
163    UINT32 Number,
164    UINT32 Size
165    );
166
167VOID
168os_memorySet(
169    TI_HANDLE OsContext,
170    PVOID pMemPtr,
171    INT32 Value,
172    UINT32 Length
173    );
174
175VOID
176os_memoryZero(
177    TI_HANDLE OsContext,
178    PVOID pMemPtr,
179    UINT32 Length
180   );
181
182VOID
183os_memoryCopy(
184    TI_HANDLE pOsContext,
185    PVOID pDestination,
186    PVOID pSource,
187    UINT32 Size
188   );
189
190VOID
191os_memoryMove(
192    TI_HANDLE pOsContext,
193    PVOID pDestination,
194    PVOID pSource,
195    UINT32 Size
196   );
197
198VOID
199os_memoryFree(
200    TI_HANDLE pOsContext,
201    PVOID pMemPtr,
202    UINT32 Size
203    );
204
205INT32
206os_memoryCompare(
207    TI_HANDLE OsContext,
208    PUINT8 Buf1,
209    PUINT8 Buf2,
210    INT32 Count
211    );
212
213PVOID
214os_memoryAlloc4HwDma(
215    TI_HANDLE pOsContext,
216    UINT32 Size
217    );
218
219VOID
220os_memory4HwDmaFree(
221    TI_HANDLE pOsContext,
222    PVOID pPMem_ptr,
223    UINT32 Size
224    );
225
226
227/****************************************************************************************
228 *                        																*
229 *							OS TIMER API												*
230 *																						*
231 ****************************************************************************************/
232typedef void (*PTIMER_FUNCTION)(TI_HANDLE Context);
233
234TI_HANDLE
235os_timerCreate(
236    TI_HANDLE OsContext,
237    PTIMER_FUNCTION pRoutine,
238    TI_HANDLE Context
239    );
240
241VOID
242os_timerDestroy(
243    TI_HANDLE OsContext,
244    TI_HANDLE TimerHandle
245    );
246
247VOID
248os_timerStart(
249    TI_HANDLE OsContext,
250    TI_HANDLE TimerHandle,
251    UINT32 DelayMs,
252    BOOL bPeriodic
253    );
254
255VOID
256os_timerStop(
257    TI_HANDLE OsContext,
258    TI_HANDLE TimerHandle
259    );
260
261VOID
262os_periodicIntrTimerStart(
263	TI_HANDLE OsContext
264	);
265
266UINT32
267os_timeStampMs(
268    TI_HANDLE OsContext
269    );
270
271UINT32
272os_timeStampUs(
273    TI_HANDLE OsContext
274    );
275
276VOID
277os_StalluSec(
278    TI_HANDLE OsContext,
279    UINT32 uSec
280    );
281
282void os_ToggleDebugGPIO(int count);
283
284
285/****************************************************************************************
286 *                        																*
287 *							Hardware access functions	API								*
288 *																						*
289 ****************************************************************************************/
290PVOID
291os_hwGetRegistersAddr(
292    TI_HANDLE OsContext
293    );
294
295
296PVOID
297os_hwGetMemoryAddr(
298    TI_HANDLE OsContext
299    );
300
301
302/****************************************************************************************
303 *                        																*
304 *							Protection services	API										*
305 *																						*
306 ****************************************************************************************
307 * OS protection is implemented as dummy functions because								*
308 * all driver code is executed in context of a single tasklet,							*
309 * except IOCTL handlers and xmition.													*
310 * Protection in IOCTL handlers and hard_start_xmit is done by different				*
311 * means.																				*
312 ****************************************************************************************/
313TI_HANDLE
314os_protectCreate(
315    TI_HANDLE OsContext
316    );
317
318VOID
319os_protectDestroy(
320    TI_HANDLE OsContext,
321    TI_HANDLE ProtectContext
322    );
323
324VOID
325os_protectLock(
326    TI_HANDLE OsContext,
327    TI_HANDLE ProtectContext
328    );
329
330VOID
331os_protectUnlock(
332    TI_HANDLE OsContext,
333    TI_HANDLE ProtectContext
334    );
335
336
337
338#ifdef DRIVER_PROFILING
339  void _os_profile (TI_HANDLE OsContext, UINT32 fn, UINT32 par);
340  #define os_profile(hos,fn,par) _os_profile (hos, fn, par)
341#else
342  #define os_profile(hos,fn,par)
343#endif
344
345
346/****************************************************************************************
347						START OF GWSI DRIVER API
348*****************************************************************************************/
349VOID
350os_Complete(
351	TI_HANDLE OsContext
352	);
353
354#ifndef GWSI_LIB
355
356VOID
357os_WaitComplete(
358	TI_HANDLE OsContext
359	);
360
361UINT32
362os_memoryGetPhysicalLow (OS_PHYSICAL_ADDRESS pAddr);
363UINT32
364os_memoryGetPhysicalHigh (OS_PHYSICAL_ADDRESS pAddr);
365
366/* MEB use native NDIS functions */
367#ifdef _WINDOWS
368#else
369
370  UINT32 os_memoryGetPhysicalLow(OS_PHYSICAL_ADDRESS pAddr);
371  UINT32 os_memoryGetPhysicalHigh(OS_PHYSICAL_ADDRESS pAddr);
372
373#endif
374
375  VOID os_hardResetTnetw(void);
376
377#endif
378
379
380/****************************************************************************************
381						START OF TI DRIVER API
382*****************************************************************************************/
383#if !defined(GWSI_DRIVER) && !defined(GWSI_LIB)
384
385typedef struct {
386    UINT32      Event;
387    UINT8*      Data;
388} TI_CONNECTION_STATUS, *PTI_CONNECTION_STATUS;
389
390
391
392PVOID
393os_memoryAlloc4HwCopy(
394    TI_HANDLE pOsContext,
395    UINT32 Size
396    );
397
398VOID
399os_memorySharedFree(
400    TI_HANDLE OsContext,
401    PVOID pVirtual,
402    UINT32 Size,
403    OS_PHYSICAL_ADDRESS pPhysical
404    );
405
406PVOID
407os_memorySharedAlloc(
408    TI_HANDLE OsContext,
409    UINT32 Size,
410    OS_PHYSICAL_ADDRESS *pPhysical
411    );
412
413VOID
414os_memoryMoveToHw(
415    TI_HANDLE OsContext,
416    PVOID pTarget,
417    PVOID pSource,
418    UINT32 Size
419    );
420
421VOID
422os_memoryMoveFromHw(
423    TI_HANDLE OsContext,
424    PVOID pTarget,
425    PVOID pSource,
426    UINT32 Size
427    );
428
429
430/**/
431/* Register access functions*/
432/**/
433VOID
434os_hwReadMemRegisterUINT32(
435    TI_HANDLE OsContext,
436    PUINT32 Register,
437    PUINT32 Data
438    );
439
440VOID
441os_hwWriteMemRegisterUINT32(
442    TI_HANDLE OsContext,
443    PUINT32 Register,
444    UINT32 Data
445    );
446
447VOID
448os_hwReadMemRegisterUINT16(
449    TI_HANDLE OsContext,
450    PUINT16 Register,
451    PUINT16 Data
452    );
453
454VOID
455os_hwWriteMemRegisterUINT16(
456    TI_HANDLE OsContext,
457    PUINT16 Register,
458    UINT16 Data
459    );
460
461VOID
462os_hwReadMemRegisterUINT8(
463    TI_HANDLE OsContext,
464    PUINT8 Register,
465    PUINT8 Data
466    );
467
468VOID
469os_hwWriteMemRegisterUINT8(
470    TI_HANDLE OsContext,
471    PUINT8 Register,
472    UINT8 Data
473    );
474
475int
476os_getFirmwareImage(
477    TI_HANDLE OsContext,
478    PUINT8 *pBuffer,
479    PUINT32 Length,
480    UINT8 RadioType
481    );
482
483int
484os_getRadioImage(
485    TI_HANDLE OsContext,
486    PUINT8 *pBuffer,
487    PUINT32 Length,
488    UINT8 RadioType
489    );
490
491VOID
492os_closeFirmwareImage( TI_HANDLE OsContext );
493
494VOID
495os_closeRadioImage( TI_HANDLE OsContext );
496
497BOOL
498os_receivePacket(
499    TI_HANDLE OsContext,
500    PVOID pPacket,
501    UINT16 Length
502    );
503
504INT32
505os_sendPacket(
506        TI_HANDLE OsContext,
507        PVOID pPacket,
508        UINT16 Length
509        );
510
511tiINT32
512os_IndicateEvent(
513    IPC_EV_DATA* pData
514    );
515
516VOID
517os_powerStateBusy(
518    TI_HANDLE OsContext
519    );
520
521VOID
522os_powerStateIdle(
523    TI_HANDLE OsContext
524    );
525
526VOID
527os_setWakeOnGpio(
528    TI_HANDLE OsContext
529    );
530
531VOID
532os_resetWakeOnGpio(
533    TI_HANDLE OsContext
534    );
535
536BOOL
537os_getEeepromImage(
538    TI_HANDLE OsContext,
539    PUINT8* pBuffer,
540    PUINT32 length
541    );
542
543// TRS:JCG missing in 4.03
544VOID
545os_setPowerOfTnetw(
546    BOOL bPowerOn
547    );
548
549#endif
550
551#endif
552