vos.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  1. /************** Begin of vos.h *******************************************/
  2. /**********************************************************
  3. * 版权所有 (C)2002, 深圳市中兴通讯股份有限公司。
  4. *
  5. * 文件名称: vos.h
  6. * 文件标识:
  7. * 内容摘要: 操作系统封装层头文件(主要是所包含头文件、数据结构、接口等)
  8. * 其它说明: 无
  9. * 当前版本: V1.0
  10. * 作 者: 王泽民
  11. * 完成日期: 2003/08/10
  12. *
  13. * 修改记录1:
  14. * 修改日期:
  15. * 版 本 号:
  16. * 修 改 人:
  17. * 修改内容:
  18. **********************************************************/
  19. #ifndef _VOS_H_
  20. #define _VOS_H_
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. #include "voscfg.h"
  25. /**********************************************************
  26. * 宏定义 *
  27. **********************************************************/
  28. #define VOS_NULL 0x0
  29. #define VOS_TRUE 1
  30. #define VOS_FALSE 0
  31. #define VOS_SUCCESS 0 /* PSOS返回值 */
  32. #define VOS_PCBINDEXNO 0 /* 保存pcbindex的便条寄存器号 */
  33. #define VOS_TASKPRINO 1 /* 保存任务优先级的便条寄存器号 */
  34. #define VOS_TICKNUM 1 /* 中断的tick数 */
  35. #define TIMER_SCAN_EVENT (WORD32)(1<<15)
  36. #define MEMLEAK_SCAN_EVENT (WORD32)(1<<16)
  37. #define MAX_LENGTH_BUF 512
  38. #define VOS_NO_WAIT 0x0
  39. #define VOS_WAIT_FOREVER -1
  40. #define VOS_SEM_DELETE_SAFE 0x04
  41. #define VOS_SEM_INVERSION_SAFE 0x08
  42. #define VOS_VM_STATE_MASK_VALID 0x03
  43. #define VOS_VM_STATE_MASK_WRITABLE 0x0c
  44. #define VOS_VM_STATE_MASK_CACHEABLE 0x30
  45. #define VOS_VM_STATE_MASK_WBACK 0x40
  46. #define VOS_VM_STATE_MASK_GLOBAL 0x80
  47. #define VOS_VM_STATE_MASK_GUARDED 0x80
  48. #define VOS_VM_STATE_VALID 0x01
  49. #define VOS_VM_STATE_VALID_NOT 0x00
  50. #define VOS_VM_STATE_WRITABLE 0x04
  51. #define VOS_VM_STATE_WRITABLE_NOT 0x00
  52. #define VOS_VM_STATE_CACHEABLE 0x10
  53. #define VOS_VM_STATE_CACHEABLE_NOT 0x00
  54. #define VOS_VM_STATE_WBACK 0x40
  55. #define VOS_VM_STATE_WBACK_NOT 0x00
  56. #define VOS_VM_STATE_GLOBAL 0x80
  57. #define VOS_VM_STATE_GLOBAL_NOT 0x00
  58. #define VOS_VM_STATE_GUARDED 0x80
  59. #define VOS_VM_STATE_GUARDED_NOT 0x00
  60. #define MAXCOUNTSEM 10000
  61. #define VOS_MAX_PATH_LEN 50
  62. #define VOS_MAX_FILENAME_LEN 60
  63. #define VOS_MAX_EXP_FILENAME_LEN 8
  64. #if OS_TYPE == OS_VXWORKS
  65. #define NULL_TASKID ERROR
  66. #define NULL_SEMID NULL
  67. #define NULL_MSGQID NULL
  68. #define NULL_MSGGET 0
  69. #define DIR_CODE 0x2f /* 定义符号 "/" */
  70. #define DIR_CONCATE_CODE "/"
  71. #endif
  72. #if OS_TYPE == OS_WINNT
  73. #define NULL_TASKID NULL
  74. #define NULL_SEMID NULL
  75. #define NULL_MSGQID NULL
  76. #define NULL_MSGGET 0
  77. #define DIR_CODE 0x5c /* 定义符号" \" */
  78. #define DIR_CONCATE_CODE "\\"
  79. #define RDONLY 0
  80. #define WRONLY 1
  81. #define RDWR 2
  82. #define WINNT_ERROR -1
  83. #endif
  84. #if OS_TYPE == OS_PSOS
  85. #define NULL_TASKID 0xffffffff
  86. #define NULL_SEMID 0xffffffff
  87. #define NULL_MSGQID 0xffffffff
  88. #define NULL_MSGGET 0xffffffff
  89. #define MSG_Q_FIFO 0x00
  90. #define MSG_Q_PRIORITY 0x01
  91. #define MSG_PRI_NORMAL 0x00
  92. #define MSG_PRI_URGENT 0x01
  93. #define RAM_BLOCKS 2*360 /* RAM disk块大小 */
  94. #define RAM_PATH_LENGTH 80
  95. #define MIN_EXPAN_BLOCKS 10
  96. #endif
  97. #if OS_TYPE == OS_LINUX
  98. #ifdef VXWORKS_TO_LINUX
  99. #define NULL_TASKID ERROR
  100. #define NULL_SEMID NULL
  101. #define NULL_MSGQID NULL
  102. #else
  103. #define NULL_TASKID 0xffffffff
  104. #define NULL_SEMID 0xffffffff
  105. #define NULL_MSGQID 0xffffffff
  106. #endif
  107. #define NULL_MSGGET 0
  108. #define DIR_CODE 0x2f /* 定义符号 "/" */
  109. #endif
  110. #if OS_TYPE == OS_KLINUX
  111. #define NULL_TASKID ERROR
  112. #define NULL_SEMID NULL
  113. #define NULL_MSGQID NULL
  114. #define TRUE 1
  115. #define FALSE 0
  116. #define DIR_CONCATE_CODE "/"
  117. #define DIR_CODE 0x2f
  118. #define VOS_ISDIR(mode) ((mode & S_IFMT) == S_IFDIR) /* 判断是否是目录 */
  119. // #define malloc(size) __vmalloc(size,GFP_KERNEL |__GFP_HIGHMEM, PAGE_KERNEL)
  120. //#define free(buf) vfree(buf)
  121. #define printf printk
  122. #endif
  123. /************** SOCKET & TCP ***************/
  124. #define NELEMENTS(array) (sizeof (array) / sizeof ((array) [0]))
  125. #ifndef HASMAX
  126. #ifndef max
  127. #define max(a,b) ((a)>(b)?(a):(b))
  128. #endif
  129. #endif
  130. #ifndef HASMIN
  131. #ifndef min
  132. #define min(a,b) ((a)<(b)?(a):(b))
  133. #endif
  134. #endif
  135. #if (OS_TYPE == OS_VXWORKS)
  136. #define SOCKET_ERROR ERROR
  137. #define SOMAXCONN 5
  138. #define VOS_EWOULDBLOCK EWOULDBLOCK
  139. #define VOS_ECONNRESET ECONNRESET
  140. #endif
  141. #if (OS_TYPE == OS_WINNT)
  142. /* 数组中元素个数 */
  143. ///(pclint检测注释掉该行)#define NELEMENTS(array) (sizeof (array) / sizeof ((array) [0]))
  144. #define CloseSocket closesocket
  145. #define bcopy(src,dst,size) memcpy(dst,src,size)
  146. #define errnoGet WSAGetLastError
  147. typedef long int STATUS ;
  148. #define VOS_EWOULDBLOCK WSAEWOULDBLOCK
  149. #define VOS_ECONNRESET WSAECONNRESET
  150. #endif
  151. #if ((OS_TYPE == OS_LINUX) ||(OS_TYPE == OS_KLINUX))
  152. typedef unsigned long ULONG;
  153. #define errnoGet() errno
  154. #define SOCKET_ERROR ERROR
  155. #define SOMAXCONN 128
  156. #define VOS_EWOULDBLOCK EWOULDBLOCK
  157. #define VOS_ECONNRESET ECONNRESET
  158. #endif
  159. #if ((OS_TYPE == OS_VXWORKS) || (OS_TYPE == OS_LINUX)||(OS_TYPE == OS_KLINUX))
  160. typedef int SOCKET;
  161. #endif
  162. /**************** VOS TIMER *******************/
  163. /* 时钟中断精度10ms */
  164. #define TIMER_RESOLUTION 10
  165. #if (OS_TYPE == OS_WINNT)
  166. #ifndef WIN32_LEAN_AND_MEAN
  167. #define WIN32_LEAN_AND_MEAN
  168. #endif
  169. #include <windows.h>
  170. #include <mmsystem.h>
  171. #define VOS_TIMERCALLBACK LPTIMECALLBACK
  172. #define VOS_TIMER_ID WORD32
  173. #define INVALID_VOS_TIMERID 0
  174. #endif
  175. #if (OS_TYPE == OS_VXWORKS)
  176. #define VOS_TIMERCALLBACK FUNCPTR
  177. #define VOS_TIMER_ID WDOG_ID
  178. #define INVALID_VOS_TIMERID NULL
  179. #define TIMER_ONESHOT 0
  180. #define TIMER_PERIODIC 1
  181. #endif
  182. #if (OS_TYPE == OS_PSOS)
  183. #define VOS_TIMERCALLBACK LPVOID
  184. #define VOS_TIMER_ID WORD32
  185. #define INVALID_VOS_TIMERID 0xffffffff
  186. #endif
  187. #if (OS_TYPE == OS_LINUX)
  188. typedef void(*VOS_TIMERCALLBACK)(int);
  189. #define VOS_TIMER_ID WORD32
  190. #define INVALID_VOS_TIMERID 0
  191. #endif
  192. #if (OS_TYPE == OS_KLINUX)
  193. #ifndef HZ
  194. #define HZ 100
  195. #endif
  196. extern unsigned long volatile jiffies;
  197. typedef void(*VOS_TIMERCALLBACK)(WORD32);
  198. typedef struct timer_list *VOS_TIMER_ID;
  199. #define INVALID_VOS_TIMERID NULL
  200. #endif
  201. /**************** VOS VOLUME *******************/
  202. #define VOLNAME_LENGTH 10
  203. /**********************************************************
  204. * 类型定义 *
  205. **********************************************************/
  206. #if OS_TYPE == OS_VXWORKS
  207. #define VOS_ISDIR(mode) ((mode & S_IFMT) == S_IFDIR) /* 判断是否是目录 */
  208. #define VOS_ISCHR(mode) ((mode & S_IFMT) == S_IFCHR) /* 是否 是特殊字符 */
  209. #define VOS_ISBLK(mode) ((mode & S_IFMT) == S_IFBLK) /* 判断是否是特殊块 */
  210. #define VOS_ISREG(mode) ((mode & S_IFMT) == S_IFREG) /* 判断是否正规块 */
  211. #define VOS_ISFIFO(mode) ((mode & S_IFMT) == S_IFIFO) /* 判断是否fifo */
  212. #elif OS_TYPE== OS_WINNT
  213. #define VOS_ISDIR(mode) ((mode & _S_IFMT) == _S_IFDIR) /* 判断是否是目录 */
  214. #define VOS_ISCHR(mode) ((mode & _S_IFMT) == _S_IFCHR) /* 是否 是特殊字符 */
  215. #define VOS_ISBLK(mode) ((mode & _S_IFMT) == _S_IFBLK) /* 判断是否是特殊块 */
  216. #define VOS_ISREG(mode) ((mode & _S_IFMT) == _S_IFREG) /* 判断是否正规块 */
  217. #define VOS_ISFIFO(mode) ((mode & _S_IFMT) == _S_IFIFO) /* 判断是否fifo */
  218. #endif
  219. /* ID类型定义 */
  220. #if OS_TYPE == OS_VXWORKS
  221. typedef SWORD32 TASK_ID;
  222. typedef PART_ID MEMPART_ID;
  223. typedef FUNCPTR VOS_FUNCPTR;
  224. typedef WIND_TCB TASK_TCB;
  225. #endif
  226. #if OS_TYPE == OS_PSOS
  227. typedef WORD32 TASK_ID;
  228. typedef VOS_VOIDFUNCPTR VOS_FUNCPTR;
  229. typedef WORD32 SEM_ID;
  230. typedef WORD32 MSG_Q_ID;
  231. typedef WORD32 MEMPART_ID;
  232. #endif
  233. #if OS_TYPE == OS_WINNT
  234. typedef HANDLE TASK_ID;
  235. typedef HANDLE SEM_ID;
  236. typedef HANDLE MEMPART_ID;
  237. typedef HANDLE MSG_Q_ID;
  238. typedef LPTHREAD_START_ROUTINE VOS_FUNCPTR;
  239. #endif
  240. #if OS_TYPE == OS_LINUX
  241. typedef void VOID;
  242. typedef pthread_t TASK_ID;
  243. typedef sem_t * SEM_ID;
  244. #ifndef PART_ID
  245. #define PART_ID int
  246. #endif /*wenhm,050826*/
  247. typedef PART_ID MEMPART_ID;
  248. typedef void* VOS_FUNCPTR;
  249. ///typedef void (*AutoRunHandler)(void);
  250. typedef WORD32 MSG_RECEIVE;/*yangyp*/
  251. typedef WORD32 MSG_Q_ID;
  252. ///typedef FUNCPTR VOS_FUNCPTR;
  253. ///typedef WIND_TCB TASK_TCB;
  254. ///typedef WORD16 VOS_TIMER_ID;/*yangyp*/
  255. ///typedef WORD32 SEM_ID;
  256. ///typedef SWORD32 TASK_ID;
  257. #endif
  258. #if OS_TYPE == OS_KLINUX
  259. typedef void VOID;
  260. typedef pthread_t TASK_ID;
  261. typedef sem_t* SEM_ID;
  262. /*typedef PART_ID MEMPART_ID;
  263. typedef FUNCPTR VOS_FUNCPTR;
  264. typedef WIND_TCB TASK_TCB;*/
  265. typedef WORD32 MEMPART_ID;
  266. typedef void* VOS_FUNCPTR;
  267. typedef WORD32 MSG_RECEIVE;/*yangyp*/
  268. typedef WORD16 VOS_TIMER_ID;/*yangyp*/
  269. typedef WORD32 MSG_Q_ID;
  270. #endif
  271. /* VOS_STATUS: VOS层函数返回值 */
  272. typedef enum
  273. {
  274. VOS_ERROR = -1,
  275. VOS_OK = 0,
  276. }VOS_STATUS;
  277. /* VOS_SEM_STATE 二进制信号量初始状态 */
  278. typedef enum
  279. {
  280. VOS_SEM_EMPTY,
  281. VOS_SEM_FULL
  282. }VOS_SEM_STATE;
  283. /* 信号量队列类型:先进先出或优先级 */
  284. typedef enum
  285. {
  286. VOS_SEM_Q_FIFO,
  287. VOS_SEM_Q_PRIORITY
  288. }VOS_SEM_QUEUE_TYPE;
  289. /* 消息优先级 */
  290. typedef enum
  291. {
  292. VOS_MSG_PRI_NORMAL,
  293. VOS_MSG_PRI_URGENT
  294. }VOS_MSG_TYPE;
  295. /* 消息排队类型:先进先出或优先级 */
  296. typedef enum
  297. {
  298. VOS_MSG_Q_FIFO,
  299. VOS_MSG_Q_PRIORITY
  300. }VOS_MSGQUE_TYPE;
  301. /* 任务状态 */
  302. typedef enum
  303. {
  304. VOS_TASK_STATUS_NULL,
  305. VOS_TASK_STATUS_RUNNING,
  306. VOS_TASK_STATUS_READY,
  307. VOS_TASK_STATUS_PEND,
  308. VOS_TASK_STATUS_SUSPEND,
  309. VOS_TASK_STATUS_DEBUG,
  310. VOS_TASK_STATUS_DEAD
  311. }VOS_TASK_STATUS;
  312. /* 参数和返回值为VOID的函数定义 */
  313. typedef VOID(*VOS_VOIDFUNCPTR)(VOID);
  314. /**********************************************************
  315. * 数据结构定义 *
  316. **********************************************************/
  317. /* 系统时钟 */
  318. typedef struct tagSYS_CLOCK
  319. {
  320. WORD16 wSysYear;
  321. WORD16 wSysMon;
  322. WORD16 wSysDay;
  323. WORD16 wSysHour;
  324. WORD16 wSysMin;
  325. WORD16 wSysSec;
  326. WORD16 wSysWeek;
  327. WORD16 wMilliSec;
  328. }T_SYS_CLOCK;
  329. #undef st_atime
  330. #undef st_mtime
  331. #undef st_ctime
  332. /* 文件状态描述 */
  333. typedef struct tagFileStat
  334. {
  335. WORD32 st_dev;
  336. WORD32 st_ino;
  337. WORD16 st_mode;
  338. SWORD16 st_nlink;
  339. SWORD16 st_uid;
  340. SWORD16 st_gid;
  341. WORD32 st_rdev;
  342. SWORD32 st_size;
  343. SWORD32 st_atime;
  344. SWORD32 st_mtime;
  345. SWORD32 st_ctime;
  346. }T_FileStat;
  347. /* added by 温辉敏,文件的访问属性*/
  348. enum Permissions {
  349. /// File has world execute permission
  350. WorldExecute = 1,
  351. /// File has world write permission
  352. WorldWrite = 2,
  353. /// File has world read permission
  354. WorldRead = 4,
  355. /// File has group execute permission
  356. GroupExecute = 8,
  357. /// File has group write permission
  358. GroupWrite = 16,
  359. /// File has group read permission
  360. GroupRead = 32,
  361. /// File has owner execute permission
  362. UserExecute = 64,
  363. /// File has owner write permission
  364. UserWrite = 128,
  365. /// File has owner read permission
  366. UserRead = 256,
  367. /// All possible permissions.
  368. AllPermissions = 0x1ff,
  369. /// Owner read & write plus group and world read permissions.
  370. DefaultPerms = UserRead|UserWrite|GroupRead|WorldRead,
  371. /// Owner read & write & execute plus group and world read & exectute permissions.
  372. DefaultDirPerms = DefaultPerms|UserExecute|GroupExecute|WorldExecute
  373. };
  374. #if OS_TYPE == OS_WINNT
  375. /**
  376. 下面结构当和MINIAce一起使用时,
  377. os_dirent.h中相应的结构产生的冲突,而os_dirent.h结构中采用了ACE_LACKS_STRUCT_DIR才会生效,
  378. 因此可以设定vos.h中不采用ACE_LACKS_STRUCT_DIR宏定义时它的结构dirent才生效.
  379. added by wenhm in 2007.05.16
  380. */
  381. #ifndef ACE_LACKS_STRUCT_DIR
  382. /* 路径入口 */
  383. struct dirent
  384. {
  385. unsigned short d_ino;
  386. unsigned short d_off;
  387. unsigned short d_reclen;
  388. CHAR d_name [VOS_MAX_FILENAME_LEN + 1];
  389. };
  390. #endif
  391. /* 目录项的定义 */
  392. typedef struct
  393. {
  394. SWORD32 dd_fd; /* 打开目录的文件描述 */
  395. SWORD32 dd_cookie; /* 目录中的文件特定标示filesys-specific marker within dir */
  396. struct dirent dd_dirent; /* 路径入口 */
  397. }DIR;
  398. #endif
  399. /**********************************************************
  400. * 函数原型 *
  401. **********************************************************/
  402. /****************** 任务管理模块 ************************/
  403. TASK_ID VOS_CreateTask(CHAR *pTaskName, SWORD32 priority,
  404. SWORD32 options, SWORD32 stackSize,
  405. VOS_FUNCPTR pTaskEntry, SWORD32 arg1,
  406. SWORD32 arg2, SWORD32 arg3, SWORD32 arg4,
  407. SWORD32 arg5, SWORD32 arg6, SWORD32 arg7,
  408. SWORD32 arg8, SWORD32 arg9, SWORD32 arg10);
  409. VOS_STATUS VOS_DeleteTask(TASK_ID taskId);
  410. VOS_STATUS VOS_SuspendTask(TASK_ID taskId);
  411. VOS_STATUS VOS_ResumeTask(TASK_ID taskId);
  412. VOS_STATUS VOS_SetPriority(TASK_ID TaskId, SWORD32 newPriority);
  413. SWORD32 VOS_GetPriority(TASK_ID TaskId);
  414. VOS_STATUS VOS_DelayTask(SWORD32 delayTime);
  415. TASK_ID VOS_GetSelfTaskID(VOID);
  416. VOS_STATUS VOS_SuspendSelf(VOID);
  417. VOS_TASK_STATUS VOS_GetTaskStatus(TASK_ID taskId);
  418. VOID VOS_CheckStack(TASK_ID taskId);
  419. /************** 二进制信号量与计数信号量 *****************/
  420. SEM_ID VOS_CreateBSem(SWORD32 options, VOS_SEM_STATE initialState);
  421. SEM_ID VOS_CreateCSem(SWORD32 options, SWORD32 initialState);
  422. SEM_ID VOS_CreateMSem(SWORD32 options);
  423. VOS_STATUS VOS_DeleteSem(SEM_ID semId);
  424. VOS_STATUS VOS_TakeSem(SEM_ID semId, SWORD32 timeout);
  425. VOS_STATUS VOS_GiveSem(SEM_ID semId);
  426. /**************** 内存管理模块 ***************************/
  427. MEMPART_ID VOS_CreateMemPart(CHAR *pPool, WORD32 poolSize);
  428. VOID *VOS_AllocMemPart(MEMPART_ID memPartId, WORD32 size);
  429. VOS_STATUS VOS_FreeMemPart(MEMPART_ID memPartId, CHAR *pBlock);
  430. CHAR *VOS_GetPhysMemTop(VOID);
  431. WORD32 VOS_GetRnFreeInfo(WORD32 dwRnId);
  432. /********************* 中断处理 ******* ******************/
  433. SWORD32 VOS_LockInt();
  434. VOID VOS_UnlockInt(SWORD32 dwLevel);
  435. /********************* 消息队列 **************************/
  436. MSG_Q_ID VOS_CreateMsgQue(WORD32 dwMaxMsgNum,
  437. WORD32 dwMaxMsgLength,
  438. BYTE ucOptions);
  439. VOS_STATUS VOS_DeleteMsgQue(MSG_Q_ID wMsgId);
  440. VOS_STATUS VOS_SendMsg(MSG_Q_ID wMsgId,
  441. CHAR *pcMsgData,
  442. WORD32 dwlen,
  443. SWORD32 dwtimeout,
  444. BYTE ucPrior);
  445. WORD32 VOS_ReceiveMsg(MSG_Q_ID wMsgId,
  446. CHAR *pcMsgDataBuffer,
  447. WORD32 dwlen,
  448. SWORD32 iTimeout);
  449. WORD32 VOS_GetCurMsgs(MSG_Q_ID wMsgId);
  450. /********************* 时钟模块 **************************/
  451. VOS_STATUS VOS_ConnectClk(VOS_VOIDFUNCPTR clkIntEntry);
  452. SWORD32 VOS_GetSysClkRate(VOID);
  453. WORD32 VOS_GetTick();
  454. VOS_STATUS VOS_IniSysClk(T_SYS_CLOCK *pSysSoftClk);
  455. VOS_STATUS VOS_SetSysClkRate(SWORD32 sdTicPerSend);
  456. VOS_STATUS VOS_TimeSet(T_SYS_CLOCK *pSysSoftClk);
  457. VOS_STATUS VOS_TimeGet(T_SYS_CLOCK *pSysSoftClk);
  458. VOS_TIMER_ID VOS_RelTimer(
  459. WORD32 dwTimeLength,
  460. VOS_TIMERCALLBACK lpTimeProc,
  461. WORD32 dwUser,
  462. WORD32 dwEvents
  463. );
  464. VOS_TIMER_ID VOS_AbsTimer(
  465. T_SYS_CLOCK tRelTimerSet,
  466. VOS_TIMERCALLBACK lpTimeProc,
  467. WORD32 dwUser,
  468. WORD32 dwEvents
  469. );
  470. VOS_TIMER_ID VOS_PerTimer(
  471. WORD32 dwTimeLength,
  472. VOS_TIMERCALLBACK lpTimeProc,
  473. WORD32 dwUser,
  474. WORD32 dwEvents
  475. );
  476. VOS_STATUS VOS_TimerKill(VOS_TIMER_ID TimerId);
  477. /********************* 错误异常 **************************/
  478. SWORD32 VOS_GetErrno(VOID);
  479. VOID VOS_AddExcHook(VOS_FUNCPTR excHookEntry);
  480. /********************* 初始化VOS *************************/
  481. VOS_STATUS VOS_InitVOS(VOID);
  482. /****************** 当前进程PCB操作 **********************/
  483. VOS_STATUS VOS_SetCurPCBIndex(WORD16 wIndex);
  484. WORD16 VOS_GetCurPCBIndex(VOID);
  485. VOS_STATUS VOS_FreeTlsData(VOID);
  486. /****************** 事件模块 **********************/
  487. VOS_STATUS VOS_SendEvent(TASK_ID taskId, WORD32 dwEvents);
  488. VOS_STATUS VOS_ReceiveEvent(WORD32 dwEvents, WORD32 dwTimeout,
  489. WORD32 *ptEventsR);
  490. /****************** 调试打印函数 **********************/
  491. VOID VOS_Display(const CHAR *fmt, ... );
  492. /********************文件系统模块**********************/
  493. SWORD32 VOS_Create(CHAR *pcFileName);
  494. VOS_STATUS VOS_Delete(CHAR *pcFileName);
  495. SWORD32 VOS_Open(CHAR *pcFileName,SWORD32 sdwFlag,SWORD32 sdwMode);
  496. VOS_STATUS VOS_Close(SWORD32 sdwFileHandle);
  497. VOS_STATUS VOS_Rename(CHAR *pcOldFileName,CHAR *pcNewFileName);
  498. SWORD32 VOS_Read(SWORD32 sdFileHandle,VOID *pBuffer,SWORD32 sdCount);
  499. SWORD32 VOS_Write(SWORD32 sdFileHandle,VOID *pBuffer,SWORD32 sdCount);
  500. SWORD32 VOS_FileLength(CHAR *pcFileName);
  501. SWORD32 VOS_Lseek(SWORD32 sdFileHandle,SWORD32 sdOffset,SWORD32 sdOrigin);
  502. VOS_STATUS VOS_CreateDir(CHAR *pcDirName);
  503. VOS_STATUS VOS_DeleteDir(CHAR *pcDirName);
  504. VOS_STATUS VOS_RenameDir(CHAR *pcOldDirName,CHAR *pcNewDirName);
  505. DIR *VOS_OpenDir(CHAR *pcDirName);
  506. struct dirent *VOS_ReadDir(DIR *pDir);
  507. VOS_STATUS VOS_CloseDir(DIR *pDir);
  508. VOS_STATUS VOS_Stat(CHAR *pcFileName, T_FileStat *pStat);
  509. VOS_STATUS VOS_CreateMemDev(CHAR *pcRamDiskName,
  510. CHAR *pcRamAddr,
  511. SWORD32 sdwCHARsPerBlk,
  512. SWORD32 sdwBlksPerTrack,
  513. SWORD32 sdwNBlocks,
  514. SWORD32 sdwBlkOffset);
  515. VOS_STATUS VOS_StartFtpServer(LPVOID pLoginRtn,
  516. SWORD32 sdwStackSize);
  517. VOS_STATUS VOS_StopFtpServer(VOID);
  518. #if OS_TYPE == OS_PSOS
  519. VOS_STATUS VOS_FileSystemInit(VOID);
  520. #endif
  521. /****************** SOCKET **********************/
  522. VOS_STATUS VOS_InitSocketLib(VOID);
  523. SOCKET VOS_Socket(SWORD32 family, SWORD32 type,SWORD32 protocol );
  524. VOS_STATUS VOS_Bind(SWORD32 s, const struct sockaddr * name, SWORD32 namelen);
  525. VOS_STATUS VOS_Accept(SOCKET s ,struct sockaddr * addr,SWORD32* addrlen );
  526. VOS_STATUS VOS_Listen(SOCKET s ,SWORD32 backlog );
  527. SWORD32 VOS_Send(SOCKET s,const char * buffer,SWORD32 len, SWORD32 flags);
  528. SWORD32 VOS_Recv(SOCKET s,const char * buffer,SWORD32 len,SWORD32 flags);
  529. VOS_STATUS VOS_CloseSocket(SOCKET s);
  530. VOS_STATUS VOS_CleanUp(void);
  531. VOS_STATUS VOS_ConnectWithTimeout(SOCKET s, struct sockaddr * adrs, int adrsLen,
  532. struct timeval * timeVal );
  533. SWORD32 VOS_SendTo(SOCKET s,const char *buffer,SWORD32 len, SWORD32 flags,
  534. struct sockaddr *to, int tolen );
  535. SWORD32 VOS_SendSocketMsg(SOCKET s, struct msghdr *mp, SWORD32 flags);
  536. SWORD32 VOS_RecvFrom(SOCKET s,const char *buffer,SWORD32 len, SWORD32 flags,
  537. struct sockaddr *from, int * pFromLen);
  538. SWORD32 VOS_RecvSocketMsg(SOCKET s, struct msghdr *mp, SWORD32 flags);
  539. VOS_STATUS VOS_Shutdown(SOCKET s, int how);
  540. VOS_STATUS VOS_SetSockOpt (SOCKET s, int level, int optname, char * optval, int optlen );
  541. VOS_STATUS VOS_GetSockOpt (SOCKET s, int level, int optname, char * optval, int *optlen );
  542. VOS_STATUS VOS_GetSockName(SOCKET s, struct sockaddr * name, int * namelen);
  543. VOS_STATUS VOS_GetPeerName (SOCKET s, struct sockaddr * name, int * namelen);
  544. SWORD32 VOS_Select(int width, fd_set *pReadFds, fd_set * pWriteFds,
  545. fd_set * pExceptFds, struct timeval * pTimeOut);
  546. SWORD32 VOS_Ioctl(int fd, int function,int arg);
  547. /****************** Exec **********************/
  548. VOS_STATUS VOS_Exec(
  549. const CHAR * strFile, ///要执行的程序名称
  550. const CHAR * strArgs ///要传入的命令行参数
  551. );
  552. VOS_STATUS VOS_ExecByFork(
  553. const CHAR * strFile, ///要执行的程序名称
  554. const CHAR * strArgs ///要传入的命令行参数
  555. );
  556. VOS_STATUS VOS_ForceDelete(CHAR *pcFileName);
  557. SWORD32 VOS_Chmod(
  558. const CHAR * pcFileName, ///文件名
  559. int iPermissions ///要进行设置的文件属性
  560. );
  561. VOS_STATUS VOS_SetRLimit(const int iCoreFileSize);
  562. VOS_STATUS VOS_GetTimeOfDay(struct timeval *tv, struct timezone *tz);
  563. #ifdef __cplusplus
  564. }
  565. #endif
  566. #endif
  567. /************** End of vos.h *******************************************/