main_app.h 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. /*****************************************************************************
  2. ** File: main_app.h
  3. **
  4. ** Description:
  5. **
  6. ** Copyright(c) 2008 Sunmedia Technologies - All Rights Reserved
  7. **
  8. ** Author : qin.he
  9. **
  10. ** $Id: $
  11. *****************************************************************************/
  12. #ifndef MAIN_APP_H_
  13. #define MAIN_APP_H_
  14. /*header file*/
  15. #include <stdio.h>
  16. #include <string.h>
  17. #include <ctype.h>
  18. #include <types.h>
  19. #include <sys/types.h>
  20. #include <sys/stat.h>
  21. #include <fcntl.h>
  22. #include "gl_types.h"
  23. #include "gobj_datastruct.h"
  24. #include "sysapp_if.h"
  25. /*macro define*/
  26. #define MAIN_APP_STACK_SIZE 4096
  27. /*Return Message definition*/
  28. #define MAIN_APP_OPERATION_FAILED (-4)
  29. #define MAIN_APP_INSTANCE_NOT_INITIALIZED (-3)
  30. #define MAIN_APP_OBJECT_CREATE_FAILED (-2)
  31. #define MAIN_APP_INVALID_SYSTEM_APP (-1)
  32. #define MAIN_APP_SUCCESS 0
  33. #define MAIN_APP_INSTANCE_ALREADY_EXIST 1
  34. #define MAIN_APP_NO_ACTIVE_SYSTEM_APP 2
  35. #define MAIN_APP_INDEX_ERROR 3
  36. #define MAIN_APP_TERMINATE_CURRENT_APP_FIRST 4
  37. #define MAIN_APP_SYSTEM_APP_ALREADY_RUNNING 5
  38. #define MAIN_APP_ACTIVATE_FAILED 6
  39. #define MAIN_APP_TERMAINATE_FAILED 7
  40. #define MAIN_APP_IN_TRANSITION 8
  41. /*Internal use definition.*/
  42. #define MAIN_APP_SYSTEM_APP_NOT_SELECTED (-1)
  43. /*Main App state*/
  44. #define MAIN_APP_SYSTEM_APP_ON_TRANSITION (1)
  45. #define MAIN_APP_NORMAL (2)
  46. #define MAIN_APP_INITIALIZING (3)
  47. #define MAIN_APP_RISC_ALIVE_STANDBY (4)
  48. /*data structure define*/
  49. extern GL_Queue_t MainAppQueueHandle;
  50. /*Function pointer declearation.*/
  51. typedef int (*MainAppFunc) (void);
  52. typedef int (*MainAppMsgHandler) (UINT32 dMessage, UINT32 dParam);
  53. typedef struct MainApp_InitCfg_t_
  54. {
  55. ifunc6 pfInitFlow;
  56. GUI_Object_Definition_t ** pGUIObjectTable;
  57. MainAppFunc pfOnTimerUpdate;
  58. MainAppMsgHandler pfOnEvent;
  59. } MainApp_InitCfg_t;
  60. typedef enum{
  61. MAINAPP_AWAKE = 0,
  62. MAINAPP_STANDBY = 1
  63. }StandByMode;
  64. /*****************************************************************************
  65. ** FUNCTION : MAINAPP_Initialize
  66. **
  67. ** DESCRIPTION :
  68. ** Initialize main app
  69. **
  70. ** PARAMETERS :
  71. ** pstMainAppInit: main app init config parameter
  72. **
  73. ** RETURN VALUES:
  74. ** MAIN_APP_INSTANCE_NOT_INITIALIZED: main app already initialized
  75. ** MAIN_APP_OBJECT_CREATE_FAILED: main app initialize failed
  76. ** MAIN_APP_SUCCESS: main app initialize success
  77. *****************************************************************************/
  78. int MAINAPP_Initialize(MainApp_InitCfg_t *pstMainAppInit);
  79. /*****************************************************************************
  80. ** FUNCTION : MAINAPP_Finalize
  81. **
  82. ** DESCRIPTION :
  83. ** Finalize main app
  84. **
  85. ** PARAMETERS :
  86. ** None
  87. **
  88. ** RETURN VALUES:
  89. ** MAIN_APP_INSTANCE_NOT_INITIALIZED: main app not initialized
  90. ** MAIN_APP_SUCCESS: main app finalize success
  91. *****************************************************************************/
  92. int MAINAPP_Finalize(void);
  93. /*****************************************************************************
  94. ** FUNCTION : MAINAPP_SendGlobalEvent
  95. **
  96. ** DESCRIPTION :
  97. ** Send globle event to main app
  98. **
  99. ** PARAMETERS :
  100. ** dMessage: globle event
  101. ** dParam: event's paramter
  102. **
  103. ** RETURN VALUES:
  104. ** MAIN_APP_INSTANCE_NOT_INITIALIZED: main app not is initialize
  105. ** SYSTEM_APP_QUEUE_ERROR: send message failed
  106. ** MAIN_APP_SUCCESS: send message success
  107. *****************************************************************************/
  108. int MAINAPP_SendGlobalEvent(UINT32 dMessage, UINT32 dParam);
  109. /*****************************************************************************
  110. ** FUNCTION : MAINAPP_GetMainAppState
  111. **
  112. ** DESCRIPTION :
  113. ** Get main app state
  114. **
  115. ** PARAMETERS :
  116. ** dState: main app state value
  117. **
  118. ** RETURN VALUES:
  119. ** MAIN_APP_INSTANCE_NOT_INITIALIZED: main app not is initialize
  120. ** MAIN_APP_SUCCESS: get main app state success
  121. *****************************************************************************/
  122. int MAINAPP_GetMainAppState(UINT32 * dState);
  123. /*****************************************************************************
  124. ** FUNCTION : MAINAPP_GetActiveSystemAppIndex
  125. **
  126. ** DESCRIPTION :
  127. ** Get active system app index
  128. **
  129. ** PARAMETERS :
  130. ** dIndex: active system app index
  131. **
  132. ** RETURN VALUES:
  133. ** MAIN_APP_INSTANCE_NOT_INITIALIZED: main app not is initialize
  134. ** MAIN_APP_IN_TRANSITION: main app in transition state
  135. ** MAIN_APP_NO_ACTIVE_SYSTEM_APP: not active system app
  136. ** MAIN_APP_SUCCESS: get actvie system app success
  137. *****************************************************************************/
  138. int MAINAPP_GetActiveSystemAppIndex(UINT32 * dIndex);
  139. /*****************************************************************************
  140. ** FUNCTION : MAINAPP_ActivateSystemApp
  141. **
  142. ** DESCRIPTION :
  143. ** Main app active system app
  144. **
  145. ** PARAMETERS :
  146. ** dSystemIndex: system app index
  147. ** dParam: system app on run paramter
  148. **
  149. ** RETURN VALUES:
  150. ** MAIN_APP_INSTANCE_NOT_INITIALIZED: main app not is initialize
  151. ** MAIN_APP_SYSTEM_APP_ALREADY_RUNNING: system app already running
  152. ** MAIN_APP_IN_TRANSITION: main app in transition state
  153. ** MAIN_APP_INDEX_ERROR: system app index error
  154. ** MAIN_APP_SUCCESS: active system app success
  155. *****************************************************************************/
  156. int MAINAPP_ActivateSystemApp(UINT32 dSystemIndex, UINT32 dParam);
  157. /*****************************************************************************
  158. ** FUNCTION : MAINAPP_TerminateSystemApp
  159. **
  160. ** DESCRIPTION :
  161. ** Main app terminate system app
  162. **
  163. ** PARAMETERS :
  164. ** dSystemIndex: system app index
  165. ** dParam: system app on terminate paramter
  166. **
  167. ** RETURN VALUES:
  168. ** MAIN_APP_INSTANCE_NOT_INITIALIZED: main app not is initialize
  169. ** MAIN_APP_SYSTEM_APP_ALREADY_RUNNING: system app already running
  170. ** MAIN_APP_IN_TRANSITION: main app in transition state
  171. ** MAIN_APP_INDEX_ERROR: system app index error
  172. ** MAIN_APP_SUCCESS: terminate system app success
  173. *****************************************************************************/
  174. int MAINAPP_TerminateSystemApp(UINT32 dSystemIndex, UINT32 dParam);
  175. /*****************************************************************************
  176. ** FUNCTION : MAINAPP_SwitchSystemApp
  177. **
  178. ** DESCRIPTION :
  179. ** Main app switch system app
  180. **
  181. ** PARAMETERS :
  182. ** dSystemIndex: system app index
  183. ** dParam1: system app on terminate paramter
  184. ** dParam2: system app on run paramter
  185. **
  186. ** RETURN VALUES:
  187. ** MAIN_APP_INSTANCE_NOT_INITIALIZED: main app not is initialize
  188. ** MAIN_APP_SYSTEM_APP_ALREADY_RUNNING: system app already running
  189. ** MAIN_APP_IN_TRANSITION: main app in transition state
  190. ** MAIN_APP_INDEX_ERROR: system app index error
  191. ** MAIN_APP_SUCCESS: Switch system app success
  192. *****************************************************************************/
  193. int MAINAPP_SwitchSystemApp(UINT32 dSystemIndex, UINT32 dParam1, UINT32 dParam2);
  194. /*****************************************************************************
  195. ** FUNCTION : MAINAPP_FinalizeSystemApp
  196. **
  197. ** DESCRIPTION :
  198. ** Main app finalize system app
  199. **
  200. ** PARAMETERS :
  201. ** dSystemIndex: system app index
  202. ** dParam: system app on terminate paramter
  203. **
  204. ** RETURN VALUES:
  205. ** MAIN_APP_INSTANCE_NOT_INITIALIZED: main app not is initialize
  206. ** MAIN_APP_SYSTEM_APP_ALREADY_RUNNING: system app already running
  207. ** MAIN_APP_IN_TRANSITION: main app in transition state
  208. ** MAIN_APP_INDEX_ERROR: system app index error
  209. ** MAIN_APP_SUCCESS: finalize system app success
  210. *****************************************************************************/
  211. int MAINAPP_FinalizeSystemApp(UINT32 dSystemIndex);
  212. /*****************************************************************************
  213. ** FUNCTION : MAINAPP_IsEnteringStandby
  214. **
  215. ** DESCRIPTION :
  216. ** get system standby mode
  217. **
  218. ** PARAMETERS :
  219. ** StandyMode: standby mode value
  220. **
  221. ** RETURN VALUES:
  222. ** MAIN_APP_INSTANCE_NOT_INITIALIZED: main app not is initialize
  223. ** MAIN_APP_SUCCESS: get system standby mode success
  224. *****************************************************************************/
  225. int MAINAPP_IsEnteringStandby(StandByMode* StandyMode);
  226. /*****************************************************************************
  227. ** FUNCTION : MAINAPP_GetRuningState
  228. **
  229. ** DESCRIPTION :
  230. ** Get main app is running state
  231. **
  232. ** PARAMETERS :
  233. ** None
  234. **
  235. ** RETURN VALUES:
  236. ** bMainAppRunning: main app running state value
  237. *****************************************************************************/
  238. UINT8 MAINAPP_GetRuningState(void);
  239. /*****************************************************************************
  240. ** FUNCTION : MAINAPP_RegisterFunc
  241. **
  242. ** DESCRIPTION :
  243. ** Register function
  244. **
  245. ** PARAMETERS :
  246. ** APP_MessageDisposeStart: Message dispose function start
  247. ** APP_MessageDisposeEnd: Message dispose function end
  248. **
  249. ** RETURN VALUES:
  250. ** None
  251. *****************************************************************************/
  252. void MAINAPP_RegisterFunc(ifunc10 APP_MessageDisposeStart, ifunc10 APP_MessageDisposeEnd);
  253. /*****************************************************************************
  254. ** FUNCTION : MAINAPP_MessageDisposeStart
  255. **
  256. ** DESCRIPTION :
  257. ** main app and system app message dispose start function
  258. **
  259. ** PARAMETERS :
  260. ** pdMessage: message
  261. ** pdParam: message param
  262. **
  263. ** RETURN VALUES:
  264. ** None
  265. *****************************************************************************/
  266. void MAINAPP_MessageDisposeStart(UINT32* pdMessage, UINT32* pdParam);
  267. /*****************************************************************************
  268. ** FUNCTION : MAINAPP_MessageDisposeEnd
  269. **
  270. ** DESCRIPTION :
  271. ** main app and system app message dispose end function
  272. **
  273. ** PARAMETERS :
  274. ** pdMessage: message
  275. ** pdParam: message param
  276. **
  277. ** RETURN VALUES:
  278. ** None
  279. *****************************************************************************/
  280. void MAINAPP_MessageDisposeEnd(UINT32* pdMessage, UINT32* pdParam);
  281. #endif