?? wps_osfunc_cream.c
字號:
/*
* WPS_OSFUNC_CREAM.C : WPS OS Function Interface Implemented upon Cream
*
* ver date author comment
* 0.0.1 07/12/26 Gao Hua First
*/
#include "wps_osfunc.h"
#include "../common/metatype.h"
#include "../common/order.h"
#include "../cream/cream.h"
#include "../datalink/datalink.h"
#include "../main/main.h"
#include "../main/wdtmain.h"
#include "../main/mem_pool.h"
#include "../main/eapol.h"
#include "../main/init.h"
void WPS_set_word(WPS_u8 *dst, WPS_u16 val)
{
set_word_func(dst, val);
}
WPS_u16 WPS_get_word(WPS_u8 *dst)
{
return get_word_func(dst);
}
void WPS_set_dword(WPS_u8 *dst, WPS_u32 val)
{
set_dword_func(dst, val);
}
WPS_u32 WPS_get_dword(WPS_u8 *dst)
{
return get_dword_func(dst);
}
WPS_u16 WPS_h2n16(WPS_u16 h16)
{
return htons(h16);
}
WPS_u16 WPS_n2h16(WPS_u16 n16)
{
return ntohs(n16);
}
WPS_u32 WPS_h2n32(WPS_u32 h32)
{
return htonl(h32);
}
WPS_u32 WPS_n2h32(WPS_u32 n32)
{
return ntohl(n32);
}
WPS_u32 WPS_GetSysTime(void)
{
dword tick;
tick = crm_getsystime();
return (tick * SYSTEM_TICK);
}
void WPS_Sleep(WPS_s32 ms)
{
crm_sleep(ms/SYSTEM_TICK);
}
#define TASK_STACK_SIZE 2048
WPS_THREAD_DESC WPS_CreateThread(void (*entry)(void))
{
task *tp = (task *)sx_mempool_get(sizeof(task) + TASK_STACK_SIZE);
if (tp == NULL) {
return NULL;
}
crm_cretsk(tp, entry, ((byte *)tp + sizeof(task)), TASK_STACK_SIZE, 255);
return (WPS_THREAD_DESC)tp;
}
void WPS_DeleteThread(WPS_THREAD_DESC thread)
{
task *tp = (task *)thread;
crm_deltsk(tp);
sx_mempool_free(tp); /* Free 'task' struct and stack */
}
WPS_SEM_DESC WPS_CreateSemaphore(int isLocked)
{
semaphore *s = (semaphore *)sx_mempool_get(sizeof(semaphore));
if (s == NULL) {
return NULL;
}
crm_init_semaphore(s, isLocked ? 0 : 1);
return (WPS_SEM_DESC)s;
}
void WPS_WaitSemaphore(WPS_SEM_DESC sem)
{
semaphore *s = (semaphore *)sem;
crm_wait_semaphore(s, 1);
}
void WPS_PostSemaphore(WPS_SEM_DESC sem)
{
semaphore *s = (semaphore *)sem;
crm_post_semaphore(s, 1);
}
void WPS_DeleteSemaphore(WPS_SEM_DESC sem)
{
semaphore *s = (semaphore *)sem;
crm_discard_semaphore(s);
sx_mempool_free(s);
}
WPS_TIMER_DESC WPS_CreateTimer(void)
{
WDTIME *wdp = (WDTIME *)sx_mempool_get(sizeof(WDTIME));
if (wdp == NULL) {
return NULL;
}
wdt_init(wdp);
return (WPS_TIMER_DESC)wdp;
}
void WPS_StartTimer(WPS_TIMER_DESC timer, int delay_ms, void (*func)(void *), void *param)
{
WDTIME *wdp = (WDTIME *)timer;
wdt_start(wdp, (delay_ms / WDT_BASE_MSEC), func, param);
}
void WPS_StopTimer(WPS_TIMER_DESC timer)
{
WDTIME *wdp = (WDTIME *)timer;
wdt_cancel(wdp);
}
void WPS_DeleteTimer(WPS_TIMER_DESC timer)
{
WDTIME *wdp = (WDTIME *)timer;
wdt_cancel(wdp);
crm_sleep(100);
sx_mempool_free(wdp);
}
int WPS_osfunc_init(void)
{
return 0;
}
#if 1
int _getpid_r(void *p)
{
return 0;
}
#endif
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -