PageRenderTime 48ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/drivers/net/wireless/tiwlan1251/CUDK/Inc/TI_OAL.h

http://github.com/CyanogenMod/cm-kernel
C Header | 149 lines | 74 code | 21 blank | 54 comment | 3 complexity | 3372106cc9366be7b8990ebb52ebbe33 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0, LGPL-2.0
  1. /*******************************************************************************
  2. **+--------------------------------------------------------------------------+**
  3. **| |**
  4. **| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/ |**
  5. **| |**
  6. **| Licensed under the Apache License, Version 2.0 (the "License"); |**
  7. **| you may not use this file except in compliance with the License. |**
  8. **| You may obtain a copy of the License at |**
  9. **| |**
  10. **| http://www.apache.org/licenses/LICENSE-2.0 |**
  11. **| |**
  12. **| Unless required by applicable law or agreed to in writing, software |**
  13. **| distributed under the License is distributed on an "AS IS" BASIS, |**
  14. **| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
  15. **| See the License for the specific language governing permissions and |**
  16. **| limitations under the License. |**
  17. **| |**
  18. **+--------------------------------------------------------------------------+**
  19. *******************************************************************************/
  20. /*--------------------------------------------------------------------------*/
  21. /* Module: TI_OAL.h*/
  22. /**/
  23. /* Purpose: This file contains a interface for the TI_OAL class.*/
  24. /**/
  25. /*////////////////////////////////////////////////////////////////////*/
  26. #if !defined(AFX_TIUNILIB_H__F79CA4B8_8596_4F36_B541_2B2FCCF70197__INCLUDED_)
  27. #define AFX_TIUNILIB_H__F79CA4B8_8596_4F36_B541_2B2FCCF70197__INCLUDED_
  28. #if _MSC_VER > 1000
  29. #pragma once
  30. #endif /* _MSC_VER > 1000*/
  31. #include "osTIType.h"
  32. #include "TI_Results.h"
  33. #ifdef _UNICODE
  34. #define tisprintf swprintf
  35. #define tistrncpy wcsncpy
  36. #else
  37. #define tisprintf sprintf
  38. #define tistrncpy strncpy
  39. #endif
  40. class TI_OSWrapCriticalSection
  41. {
  42. protected:
  43. tiVOID* m_pCS;
  44. public:
  45. static TI_OSWrapCriticalSection* CreateObject();
  46. static tiVOID DeleteObject(TI_OSWrapCriticalSection* pObj);
  47. TI_OSWrapCriticalSection() {}
  48. virtual ~TI_OSWrapCriticalSection() {}
  49. virtual tiVOID Enter () = 0;
  50. virtual tiVOID Leave () = 0;
  51. };
  52. class TI_OSCriticalSection
  53. {
  54. TI_OSWrapCriticalSection* m_pWrapCS;
  55. public:
  56. TI_OSCriticalSection();
  57. ~TI_OSCriticalSection();
  58. tiVOID Enter ();
  59. tiVOID Leave ();
  60. };
  61. /*
  62. class TI_OSWrapEvent
  63. {
  64. protected:
  65. tiVOID* m_pEvent;
  66. public:
  67. static TI_OSWrapEvent* CreateObject();
  68. TI_OSWrapEvent() {}
  69. ~TI_OSWrapEvent() {}
  70. virtual tiUINT32 Wait ( tiUINT32 uTime ) = 0;
  71. virtual tiVOID Set () = 0;
  72. virtual tiVOID Reset () = 0;
  73. };
  74. class TI_OSEvent
  75. {
  76. TI_OSWrapEvent* m_pWrapEvent;
  77. public:
  78. TI_OSEvent();
  79. ~TI_OSEvent();
  80. tiUINT32 Wait ( tiUINT32 uTime );
  81. tiVOID Set ();
  82. tiVOID Reset ();
  83. };
  84. */
  85. typedef tiUINT32 (* tiPTHREAD_START_ROUTINE)( tiVOID* pThreadParameter );
  86. class TI_OAL
  87. {
  88. protected:
  89. TI_OAL ();
  90. virtual ~TI_OAL ();
  91. static TI_OAL* _instance;
  92. static tiUINT32 m_uReferenceCount;
  93. public:
  94. static TI_OAL* GetInstance (); /* static function for create TI_OSlib object*/
  95. static tiVOID FreeInstance (); /* static function for release TI_OAL object*/
  96. /* list of functions that will call from Utility Adapter and Utility GUI modules */
  97. virtual tiVOID TIOutputDebugString (tiCHAR* lpOutputString) = 0;
  98. virtual tiBOOL TIIsBadWritePtr (tiVOID* lp, tiUINT32 ucb ) = 0;
  99. /* list of functions that will call from Windows Utility module */
  100. virtual tiUINT32 TILoadLibrary (tiCHAR* pLibFileName) = 0;
  101. virtual tiBOOL TIFreeLibrary (tiUINT32 hLibModule) = 0;
  102. virtual tiUINT32 TIGetProcAddress (tiUINT32 hModule, tiCHAR* lpProcName ) = 0;
  103. virtual tiUINT32 TIRegisterWindowMessage (tiCHAR* pszMsgName ) = 0;
  104. virtual tiBOOL TIPostMessage (tiUINT32 hWnd, tiUINT32 Msg, tiUINT32 wParam, tiUINT32 lParam) = 0;
  105. virtual tiVOID TIPrintLastError (tiCHAR* psz) = 0;
  106. virtual tiUINT32 TIGetCurrentThreadId () = 0;
  107. virtual tiUINT32 TICreateThread (tiPTHREAD_START_ROUTINE pStartAddress, tiVOID* pParameter ) = 0;
  108. virtual tiVOID TISleep (tiUINT32 msec) = 0;
  109. };
  110. #define TIOALib_OBJECT_CREATOR_IMP( ClassApi, ClassBase ) \
  111. ClassBase* ClassBase::CreateObject(){ return (ClassBase*) new ClassApi;} \
  112. tiVOID ClassBase::DeleteObject(ClassBase* pObj){ClassApi* pRealObj = (ClassApi*)pObj; \
  113. if(pRealObj)delete pRealObj; }
  114. #define TIOALib_SINGLETON_CLASS_IMP( ClassApi ) \
  115. TI_OAL* TI_OAL::GetInstance() \
  116. { return (TI_OAL*) ClassApi::GetInstance(); } \
  117. TI_OAL* ClassApi::GetInstance() \
  118. {if( _instance == 0){_instance = new ClassApi();} \
  119. m_uReferenceCount++; return _instance;} \
  120. tiVOID TI_OAL::FreeInstance() \
  121. { ClassApi::FreeInstance(); } \
  122. tiVOID ClassApi::FreeInstance() \
  123. { m_uReferenceCount--;if(!m_uReferenceCount && _instance ) \
  124. {delete (ClassApi*)_instance;_instance = NULL;}}
  125. #endif /* !defined(AFX_TIUNILIB_H__F79CA4B8_8596_4F36_B541_2B2FCCF70197__INCLUDED_)*/