SDK3.5
This document shows Ameba SDK 3.5 APIs
Data Structures | Typedefs | Functions | Variables

RTOS functions. More...

Data Structures

struct  timer_list
 
struct  task_struct
 
struct  rtw_worker_thread_t
 
struct  rtw_event_message_t
 
struct  worker_timer_entry
 
struct  work_struct
 
struct  delayed_work
 
struct  mem_entry
 
struct  osdep_service_ops
 

Typedefs

typedef thread_return(* thread_func_t) (thread_context context)
 
typedef void(* TIMER_FUN) (void *context)
 
typedef int(* event_handler_t) (char *buf, int buf_len, int flags, void *user_data)
 
typedef void(* work_func_t) (void *context)
 

Functions

void init_mem_monitor (_list *pmem_table, int *used_num)
 This function initializes a memory table. More...
 
void deinit_mem_monitor (_list *pmem_table, int *used_num)
 This function deinitializes a memory table. More...
 
void add_mem_usage (_list *pmem_table, void *ptr, int size, int *used_num, int flag)
 This function alloc mem_entry to the memory table. More...
 
void del_mem_usage (_list *pmem_table, void *ptr, int *used_num, int flag)
 This function frees memory from the memory table. More...
 
int get_mem_usage (_list *pmem_table)
 This function get the memory usage of a memory table. More...
 
u8 * _rtw_vmalloc (u32 sz)
 
u8 * _rtw_zvmalloc (u32 sz)
 
void _rtw_vmfree (u8 *pbuf, u32 sz)
 
u8 * _rtw_zmalloc (u32 sz)
 
u8 * _rtw_malloc (u32 sz)
 
void _rtw_mfree (u8 *pbuf, u32 sz)
 
u8 * rtw_vmalloc (u32 sz)
 This function allocates the virtually contiguous memory. More...
 
u8 * rtw_zvmalloc (u32 sz)
 This function allocates the virtually contiguous memory and the values of the memory are setted to 0. More...
 
void rtw_vmfree (u8 *pbuf, u32 sz)
 This function frees the virtually contiguous memory. More...
 
u8 * rtw_zmalloc (u32 sz)
 This function allocates the memory and the values of the memory are setted to 0. More...
 
u8 * rtw_malloc (u32 sz)
 This function allocates the memory. More...
 
void rtw_mfree (u8 *pbuf, u32 sz)
 This function frees the virtually contiguous memory. More...
 
void * rtw_malloc2d (int h, int w, int size)
 This function allocates a 2 dimensional array memory. More...
 
void rtw_mfree2d (void *pbuf, int h, int w, int size)
 This function deallocates the block of memory previously allocated to make it available again. More...
 
void rtw_memcpy (void *dst, void *src, u32 sz)
 This function copies the values of "sz" bytes from the location pointed to by "src" directly to the memory block pointed to by "des". More...
 
int rtw_memcmp (void *dst, void *src, u32 sz)
 This function compares the first "sz" bytes of the block of memory pointed by "dst" to the first "sz" bytes pointed by "src". More...
 
void rtw_memset (void *pbuf, int c, u32 sz)
 This function sets the first "sz" bytes of the block of memory pointed by "pbuf" to the specified "c". More...
 
void rtw_init_listhead (_list *list)
 This function initializes the head of the list. More...
 
u32 rtw_is_list_empty (_list *phead)
 This function tests whether a list is empty. More...
 
void rtw_list_insert_head (_list *plist, _list *phead)
 This function adds a new entry after "phead" for the list. More...
 
void rtw_list_insert_tail (_list *plist, _list *phead)
 This function adds a new entry before "phead" for the list. More...
 
void rtw_list_delete (_list *plist)
 This function deletes entry from list and reinitialize it. More...
 
void rtw_init_sema (_sema *sema, int init_val)
 This function initializes the unnamed semaphore referred to by "sema" to the value "init_val". More...
 
void rtw_free_sema (_sema *sema)
 This function deletes the semaphore. More...
 
void rtw_up_sema (_sema *sema)
 This function releases the semaphore. This macro must not be used from an ISR. More...
 
void rtw_up_sema_from_isr (_sema *sema)
 This function releases the semaphore. This macro can be used from an ISR. More...
 
u32 rtw_down_sema (_sema *sema)
 This function acquires the semaphore. If no more tasks are allowed to acquire the semaphore, calling this function will put the task to sleep until the semaphore is up. More...
 
u32 rtw_down_timeout_sema (_sema *sema, u32 timeout)
 This function acquires the semaphore. If no more tasks are allowed to acquire the semaphore, calling this function will put the task to sleep until the semaphore is up. More...
 
void rtw_mutex_init (_mutex *pmutex)
 This function implements a mutex semaphore by using the existing queue mechanism. More...
 
void rtw_mutex_free (_mutex *pmutex)
 This function deletes the mutex semaphore. More...
 
void rtw_mutex_put (_mutex *pmutex)
 This function releases a mutex semaphore. More...
 
void rtw_mutex_get (_mutex *pmutex)
 This function obtains a mutex semaphore. More...
 
int rtw_mutex_get_timeout (_mutex *pmutex, u32 timeout_ms)
 This function obtains a mutex semaphore with a timeout setting. More...
 
void rtw_enter_critical (_lock *plock, _irqL *pirqL)
 This function marks the start of a critical code region. Preemptive context switches cannot occur when in a critical region. More...
 
void rtw_exit_critical (_lock *plock, _irqL *pirqL)
 This function marks end of a critical code region. Preemptive context switches cannot occur when in a critical region. More...
 
void rtw_enter_critical_from_isr (_lock *plock, _irqL *pirqL)
 This function marks the start of a critical code region from isr. More...
 
void rtw_exit_critical_from_isr (_lock *plock, _irqL *pirqL)
 This function marks the end of a critical code region from isr. More...
 
void rtw_enter_critical_bh (_lock *plock, _irqL *pirqL)
 This function obtains a spin lock semaphore. More...
 
void rtw_exit_critical_bh (_lock *plock, _irqL *pirqL)
 This function releases a spin lock semaphore. More...
 
int rtw_enter_critical_mutex (_mutex *pmutex, _irqL *pirqL)
 This function obtains a semaphore. More...
 
void rtw_exit_critical_mutex (_mutex *pmutex, _irqL *pirqL)
 This function releases a semaphore. More...
 
void rtw_spinlock_init (_lock *plock)
 This function implements a spin lock semaphore by using the existing queue mechanism. More...
 
void rtw_spinlock_free (_lock *plock)
 This function deletes the spin lock semaphore. More...
 
void rtw_spin_lock (_lock *plock)
 This function obtains a spin lock semaphore. More...
 
void rtw_spin_unlock (_lock *plock)
 This function releases a spin lock semaphore. More...
 
void rtw_spinlock_irqsave (_lock *plock, _irqL *irqL)
 This function marks the start of a critical code region and obtains a spin lock semaphore. More...
 
void rtw_spinunlock_irqsave (_lock *plock, _irqL *irqL)
 This function releases a spin lock semaphore and marks the end of a critical code region. More...
 
int rtw_init_xqueue (_xqueue *queue, const char *name, u32 message_size, u32 number_of_messages)
 This function creates a new queue instance. More...
 
int rtw_push_to_xqueue (_xqueue *queue, void *message, u32 timeout_ms)
 This function posts a message to the back of a queue. The message is queued by copy, not by reference. More...
 
int rtw_pop_from_xqueue (_xqueue *queue, void *message, u32 timeout_ms)
 This function receives a message from a queue. The message is recieved by copy so a buffer adequate size must be provided. More...
 
int rtw_deinit_xqueue (_xqueue *queue)
 Delete a queue - freeing all the memory allocated for storing of messages placed on the queue. More...
 
void rtw_init_queue (_queue *pqueue)
 This function creates a new queue instance. More...
 
void rtw_deinit_queue (_queue *pqueue)
 
u32 rtw_is_queue_empty (_queue *pqueue)
 
u32 rtw_queue_empty (_queue *pqueue)
 This function tests whether the queue is empty. More...
 
u32 rtw_end_of_queue_search (_list *queue, _list *pelement)
 This function tests whether the "pelement" is at the "queue". More...
 
_list * rtw_get_queue_head (_queue *queue)
 
u32 rtw_get_current_time (void)
 Get the count of ticks since the vTaskStartScheduler was called. More...
 
u32 rtw_systime_to_ms (u32 systime)
 Convert system time to milliseconds. More...
 
u32 rtw_systime_to_sec (u32 systime)
 Convert system time to seconds. More...
 
u32 rtw_ms_to_systime (u32 ms)
 Convert milliseconds to system time. More...
 
u32 rtw_sec_to_systime (u32 sec)
 Convert seconds to system time. More...
 
s32 rtw_get_passing_time_ms (u32 start)
 Get the passing time from the "start" in milliseconds. More...
 
s32 rtw_get_time_interval_ms (u32 start, u32 end)
 Get the interval time from the "start" to "end" in milliseconds. More...
 
void rtw_msleep_os (int ms)
 This function suspends execution of the calling thread for "ms" milliseconds. More...
 
void rtw_usleep_os (int us)
 This function suspends execution of the calling thread for "us" microseconds. More...
 
u32 rtw_atoi (u8 *s)
 This function converts the initial portion of the string to integer. More...
 
void rtw_mdelay_os (int ms)
 This function delays a task for the giving time in milliseconds. More...
 
void rtw_udelay_os (int us)
 This function delays a task for the giving time in microseconds. More...
 
void rtw_yield_os (void)
 This function for forcing a context switch. More...
 
void ATOMIC_SET (ATOMIC_T *v, int i)
 This function atomically sets the value of the variable. More...
 
int ATOMIC_READ (ATOMIC_T *v)
 This function atomically reads the value of the variable. More...
 
void ATOMIC_ADD (ATOMIC_T *v, int i)
 This function adds "i" to the contained "v". More...
 
void ATOMIC_SUB (ATOMIC_T *v, int i)
 This function subtracts "i" from th econtained "v". More...
 
void ATOMIC_INC (ATOMIC_T *v)
 This function adds 1 to the contained "v". More...
 
void ATOMIC_DEC (ATOMIC_T *v)
 This function subtracts 1 from th econtained "v". More...
 
int ATOMIC_ADD_RETURN (ATOMIC_T *v, int i)
 This function adds "i" to the contained "v" and returns the result. More...
 
int ATOMIC_SUB_RETURN (ATOMIC_T *v, int i)
 This function subtracts "i" from th econtained "v" and returns the result. More...
 
int ATOMIC_INC_RETURN (ATOMIC_T *v)
 This function adds 1 to the contained "v" and returns the result. More...
 
int ATOMIC_DEC_RETURN (ATOMIC_T *v)
 This function subtracts 1 from th econtained "v" and returns the result. More...
 
int ATOMIC_DEC_AND_TEST (ATOMIC_T *v)
 This function subtracts 1 from th econtained "v" and test if the result equals 0. More...
 
u64 rtw_modular64 (u64 x, u64 y)
 
int rtw_get_random_bytes (void *dst, u32 size)
 This function generates random bytes. More...
 
u32 rtw_getFreeHeapSize (void)
 This function gets the available heap size. More...
 
void flush_signals_thread (void)
 
void rtw_acquire_wakelock (void)
 This function indicates that the WLAN needs to stay on which means cannot go into power saving mode. More...
 
void rtw_release_wakelock (void)
 This function indicates that the WLAN does not need to stay on which means can go into power saving mode. More...
 
void rtw_wakelock_timeout (u32 timeout)
 
int rtw_create_task (struct task_struct *task, const char *name, u32 stack_size, u32 priority, thread_func_t func, void *thctx)
 This function creates a new task and adds it to the list of tasks that are ready to run. More...
 
void rtw_delete_task (struct task_struct *task)
 This function deletes a task. More...
 
void rtw_wakeup_task (struct task_struct *task)
 This function wake up a task. More...
 
int rtw_create_worker_thread (rtw_worker_thread_t *worker_thread, u8 priority, u32 stack_size, u32 event_queue_size)
 This function creates a new worker thread. More...
 
int rtw_delete_worker_thread (rtw_worker_thread_t *worker_thread)
 This function deletes a worker thread. More...
 
void rtw_init_delayed_work (struct delayed_work *dwork, work_func_t func, const char *name)
 
void rtw_deinit_delayed_work (struct delayed_work *dwork)
 
int rtw_queue_delayed_work (struct workqueue_struct *wq, struct delayed_work *dwork, u32 delay, void *context)
 
BOOLEAN rtw_cancel_delayed_work (struct delayed_work *dwork)
 
void rtw_thread_enter (char *name)
 This function prints the name of the thread in DBG_INFO. More...
 
void rtw_thread_exit (void)
 This function exits the calling thread. More...
 
u8 rtw_get_scheduler_state (void)
 This function gets the scheduler state of the calling thread. More...
 
_timerHandle rtw_timerCreate (const signed char *pcTimerName, osdepTickType xTimerPeriodInTicks, u32 uxAutoReload, void *pvTimerID, TIMER_FUN pxCallbackFunction)
 This function creates a new software timer instance. More...
 
u32 rtw_timerDelete (_timerHandle xTimer, osdepTickType xBlockTime)
 This function deletes a timer that was previously created using rtw_timerCreate. More...
 
u32 rtw_timerIsTimerActive (_timerHandle xTimer)
 This function queries a timer to see if it is active or dormant. More...
 
u32 rtw_timerStop (_timerHandle xTimer, osdepTickType xBlockTime)
 This function stops a timer that was previously started. More...
 
u32 rtw_timerChangePeriod (_timerHandle xTimer, osdepTickType xNewPeriod, osdepTickType xBlockTime)
 This function changes the period of a timer that was previously created. More...
 
void * rtw_timerGetID (_timerHandle xTimer)
 
u32 rtw_timerStart (_timerHandle xTimer, osdepTickType xBlockTime)
 
u32 rtw_timerStartFromISR (_timerHandle xTimer, osdepBASE_TYPE *pxHigherPriorityTaskWoken)
 
u32 rtw_timerStopFromISR (_timerHandle xTimer, osdepBASE_TYPE *pxHigherPriorityTaskWoken)
 
u32 rtw_timerResetFromISR (_timerHandle xTimer, osdepBASE_TYPE *pxHigherPriorityTaskWoken)
 
u32 rtw_timerChangePeriodFromISR (_timerHandle xTimer, osdepTickType xNewPeriod, osdepBASE_TYPE *pxHigherPriorityTaskWoken)
 
u32 rtw_timerReset (_timerHandle xTimer, osdepTickType xBlockTime)
 

Variables

_timerHandle timer_hdl
 
unsigned long data
 
void(* function )(void *)
 
const char * task_name
 
_thread_hdl_ task
 
const char * name
 
u32 queue_num
 
u32 cur_queue_num
 
_sema wakeup_sema
 
_sema terminate_sema
 
u32 blocked
 
u32 callback_running
 
_xqueue event_queue
 
struct task_struct thread
 
event_handler_t function
 
char * buf
 
int buf_len
 
int flags
 
void * user_data
 
struct list_head list
 
_timerHandle timer_hdl
 
rtw_event_message_t message
 
rtw_worker_thread_tworker_thread
 
u32 timeout
 
_list list
 
u32 data
 
work_func_t func
 
void * context
 
struct task_structused_wq
 
struct work_struct work
 
struct timer_list timer
 
struct list_head list
 
int size
 
void * ptr
 
u8 *(* rtw_vmalloc )(u32 sz)
 
u8 *(* rtw_zvmalloc )(u32 sz)
 
void(* rtw_vmfree )(u8 *pbuf, u32 sz)
 
u8 *(* rtw_malloc )(u32 sz)
 
u8 *(* rtw_zmalloc )(u32 sz)
 
void(* rtw_mfree )(u8 *pbuf, u32 sz)
 
void(* rtw_memcpy )(void *dst, void *src, u32 sz)
 
int(* rtw_memcmp )(void *dst, void *src, u32 sz)
 
void(* rtw_memset )(void *pbuf, int c, u32 sz)
 
void(* rtw_init_sema )(_sema *sema, int init_val)
 
void(* rtw_free_sema )(_sema *sema)
 
void(* rtw_up_sema )(_sema *sema)
 
void(* rtw_up_sema_from_isr )(_sema *sema)
 
u32(* rtw_down_timeout_sema )(_sema *sema, u32 timeout)
 
void(* rtw_mutex_init )(_mutex *pmutex)
 
void(* rtw_mutex_free )(_mutex *pmutex)
 
void(* rtw_mutex_get )(_mutex *pmutex)
 
int(* rtw_mutex_get_timeout )(_mutex *pmutex, u32 timeout_ms)
 
void(* rtw_mutex_put )(_mutex *pmutex)
 
void(* rtw_enter_critical )(_lock *plock, _irqL *pirqL)
 
void(* rtw_exit_critical )(_lock *plock, _irqL *pirqL)
 
void(* rtw_enter_critical_from_isr )(_lock *plock, _irqL *pirqL)
 
void(* rtw_exit_critical_from_isr )(_lock *plock, _irqL *pirqL)
 
void(* rtw_enter_critical_bh )(_lock *plock, _irqL *pirqL)
 
void(* rtw_exit_critical_bh )(_lock *plock, _irqL *pirqL)
 
int(* rtw_enter_critical_mutex )(_mutex *pmutex, _irqL *pirqL)
 
void(* rtw_exit_critical_mutex )(_mutex *pmutex, _irqL *pirqL)
 
void(* rtw_spinlock_init )(_lock *plock)
 
void(* rtw_spinlock_free )(_lock *plock)
 
void(* rtw_spin_lock )(_lock *plock)
 
void(* rtw_spin_unlock )(_lock *plock)
 
void(* rtw_spinlock_irqsave )(_lock *plock, _irqL *irqL)
 
void(* rtw_spinunlock_irqsave )(_lock *plock, _irqL *irqL)
 
int(* rtw_init_xqueue )(_xqueue *queue, const char *name, u32 message_size, u32 number_of_messages)
 
int(* rtw_push_to_xqueue )(_xqueue *queue, void *message, u32 timeout_ms)
 
int(* rtw_pop_from_xqueue )(_xqueue *queue, void *message, u32 timeout_ms)
 
int(* rtw_deinit_xqueue )(_xqueue *queue)
 
u32(* rtw_get_current_time )(void)
 
u32(* rtw_systime_to_ms )(u32 systime)
 
u32(* rtw_systime_to_sec )(u32 systime)
 
u32(* rtw_ms_to_systime )(u32 ms)
 
u32(* rtw_sec_to_systime )(u32 sec)
 
void(* rtw_msleep_os )(int ms)
 
void(* rtw_usleep_os )(int us)
 
void(* rtw_mdelay_os )(int ms)
 
void(* rtw_udelay_os )(int us)
 
void(* rtw_yield_os )(void)
 
void(* ATOMIC_SET )(ATOMIC_T *v, int i)
 
int(* ATOMIC_READ )(ATOMIC_T *v)
 
void(* ATOMIC_ADD )(ATOMIC_T *v, int i)
 
void(* ATOMIC_SUB )(ATOMIC_T *v, int i)
 
void(* ATOMIC_INC )(ATOMIC_T *v)
 
void(* ATOMIC_DEC )(ATOMIC_T *v)
 
int(* ATOMIC_ADD_RETURN )(ATOMIC_T *v, int i)
 
int(* ATOMIC_SUB_RETURN )(ATOMIC_T *v, int i)
 
int(* ATOMIC_INC_RETURN )(ATOMIC_T *v)
 
int(* ATOMIC_DEC_RETURN )(ATOMIC_T *v)
 
u64(* rtw_modular64 )(u64 x, u64 y)
 
int(* rtw_get_random_bytes )(void *dst, u32 size)
 
u32(* rtw_getFreeHeapSize )(void)
 
int(* rtw_create_task )(struct task_struct *task, const char *name, u32 stack_size, u32 priority, thread_func_t func, void *thctx)
 
void(* rtw_delete_task )(struct task_struct *task)
 
void(* rtw_wakeup_task )(struct task_struct *task)
 
void(* rtw_init_delayed_work )(struct delayed_work *dwork, work_func_t func, const char *name)
 
void(* rtw_deinit_delayed_work )(struct delayed_work *dwork)
 
int(* rtw_queue_delayed_work )(struct workqueue_struct *wq, struct delayed_work *dwork, unsigned long delay, void *context)
 
BOOLEAN(* rtw_cancel_delayed_work )(struct delayed_work *dwork)
 
void(* rtw_thread_enter )(char *name)
 
void(* rtw_thread_exit )(void)
 
_timerHandle(* rtw_timerCreate )(const signed char *pcTimerName, osdepTickType xTimerPeriodInTicks, u32 uxAutoReload, void *pvTimerID, TIMER_FUN pxCallbackFunction)
 
u32(* rtw_timerDelete )(_timerHandle xTimer, osdepTickType xBlockTime)
 
u32(* rtw_timerIsTimerActive )(_timerHandle xTimer)
 
u32(* rtw_timerStop )(_timerHandle xTimer, osdepTickType xBlockTime)
 
u32(* rtw_timerChangePeriod )(_timerHandle xTimer, osdepTickType xNewPeriod, osdepTickType xBlockTime)
 
void *(* rtw_timerGetID )(_timerHandle xTimer)
 
u32(* rtw_timerStart )(_timerHandle xTimer, osdepTickType xBlockTime)
 
u32(* rtw_timerStartFromISR )(_timerHandle xTimer, osdepBASE_TYPE *pxHigherPriorityTaskWoken)
 
u32(* rtw_timerStopFromISR )(_timerHandle xTimer, osdepBASE_TYPE *pxHigherPriorityTaskWoken)
 
u32(* rtw_timerResetFromISR )(_timerHandle xTimer, osdepBASE_TYPE *pxHigherPriorityTaskWoken)
 
u32(* rtw_timerChangePeriodFromISR )(_timerHandle xTimer, osdepTickType xNewPeriod, osdepBASE_TYPE *pxHigherPriorityTaskWoken)
 
u32(* rtw_timerReset )(_timerHandle xTimer, osdepTickType xBlockTime)
 
void(* rtw_acquire_wakelock )(void)
 
void(* rtw_release_wakelock )(void)
 
void(* rtw_wakelock_timeout )(u32 timeoutMs)
 
u8(* rtw_get_scheduler_state )(void)
 

Detailed Description

RTOS functions.

Function Documentation

void add_mem_usage ( _list *  pmem_table,
void *  ptr,
int  size,
int *  used_num,
int  flag 
)

This function alloc mem_entry to the memory table.

Parameters
[in]pmem_tableThe pointer to the memory table to be added.
[in]ptrThe pointer to the position to be added.
[in]sizeThe size of added memory.
[in]used_numThe number of mem_entry kept in monitor which will add 1 after.
[in]flagMEM_MONITOR_FLAG_WPAS/MEM_MONITOR_FLAG_WIFI_DRV
Returns
None
void ATOMIC_ADD ( ATOMIC_T *  v,
int  i 
)

This function adds "i" to the contained "v".

Parameters
[in]vPointer of type atomic_t.
[in]ivalue to add.
Returns
None
int ATOMIC_ADD_RETURN ( ATOMIC_T *  v,
int  i 
)

This function adds "i" to the contained "v" and returns the result.

Parameters
[in]vPointer of type atomic_t.
[in]ivalue to add.
Returns
None
void ATOMIC_DEC ( ATOMIC_T *  v)

This function subtracts 1 from th econtained "v".

Parameters
[in]vPointer of type atomic_t.
Returns
None
int ATOMIC_DEC_AND_TEST ( ATOMIC_T *  v)

This function subtracts 1 from th econtained "v" and test if the result equals 0.

Parameters
[in]vPointer of type atomic_t.
Returns
0: The result after subtracting 1 is 0
-1: The result after subtracting 1 is not 0
int ATOMIC_DEC_RETURN ( ATOMIC_T *  v)

This function subtracts 1 from th econtained "v" and returns the result.

Parameters
[in]vPointer of type atomic_t.
Returns
None
void ATOMIC_INC ( ATOMIC_T *  v)

This function adds 1 to the contained "v".

Parameters
[in]vPointer of type atomic_t.
Returns
None
int ATOMIC_INC_RETURN ( ATOMIC_T *  v)

This function adds 1 to the contained "v" and returns the result.

Parameters
[in]vPointer of type atomic_t.
Returns
None
int ATOMIC_READ ( ATOMIC_T *  v)

This function atomically reads the value of the variable.

Parameters
[in]vPointer of type atomic_t that to be read.
Returns
The value of the variable.
Note
The guaranteed useful range of an atomic_t is only 24 bits.
void ATOMIC_SET ( ATOMIC_T *  v,
int  i 
)

This function atomically sets the value of the variable.

Parameters
[in]vPointer of type atomic_t that to be set value.
[in]iRequired value.
Returns
None
Note
The guaranteed useful range of an atomic_t is only 24 bits.
void ATOMIC_SUB ( ATOMIC_T *  v,
int  i 
)

This function subtracts "i" from th econtained "v".

Parameters
[in]vPointer of type atomic_t.
[in]ivalue to subtract.
Returns
None
int ATOMIC_SUB_RETURN ( ATOMIC_T *  v,
int  i 
)

This function subtracts "i" from th econtained "v" and returns the result.

Parameters
[in]vPointer of type atomic_t.
[in]ivalue to subtract.
Returns
None
void deinit_mem_monitor ( _list *  pmem_table,
int *  used_num 
)

This function deinitializes a memory table.

Parameters
[in]pmem_tableThe pointer to the memory table.
[in]used_numThe number of mem_entry kept in monitor.
Returns
None
void del_mem_usage ( _list *  pmem_table,
void *  ptr,
int *  used_num,
int  flag 
)

This function frees memory from the memory table.

Parameters
[in]pmem_tableThe pointer to the memory table
[in]ptrThe pointer to the position to be free.
[in]used_numThe number of mem_entry kept in monitor.
[in]flagMEM_MONITOR_FLAG_WPAS/MEM_MONITOR_FLAG_WIFI_DRV
Returns
None
int get_mem_usage ( _list *  pmem_table)

This function get the memory usage of a memory table.

Parameters
[in]pmem_tableThe pointer to the memory table.
Returns
The size of the memory used
void init_mem_monitor ( _list *  pmem_table,
int *  used_num 
)

This function initializes a memory table.

Parameters
[in]pmem_tableThe pointer to the memory table.
[in]used_numThe number of mem_entry kept in monitor which will be set to 0.
Returns
None
void rtw_acquire_wakelock ( void  )

This function indicates that the WLAN needs to stay on which means cannot go into power saving mode.

Returns
None
Note
Defining configUSE_WAKELOCK_PMU 1 in "FreeRTOSConfig.h" needs to be done before compiling, or this API won't be effective.
u32 rtw_atoi ( u8 *  s)

This function converts the initial portion of the string to integer.

Parameters
[in]sThe pointer to the string to be converted.
Returns
The converted value.
int rtw_create_task ( struct task_struct task,
const char *  name,
u32  stack_size,
u32  priority,
thread_func_t  func,
void *  thctx 
)

This function creates a new task and adds it to the list of tasks that are ready to run.

Parameters
[in]taskThe task stucture which will store the task related infomation.
[in]nameA descriptive name for the task.
[in]stack_sizeThe size of the task stack specified as the variables the stack can hold.
[in]priorityThe priority at which the task should run.
[in]funcThe task entry function.
[in]thctxThe pointer that will be used as the parameter for the task being created.
Returns
pdPASS: The task was successfully created and added to a ready list.
other error code defined in the file errors.h.
Note
For the task name, please do not use "rtw_little_wifi_mcu_thread", "rtw_check_in_req_state_thread", "rtw_TDMA_change_state_thread", "xmit_thread", "recv_thread", "rtw_recv_tasklet", "rtw_xmit_tasklet", "rtw_interrupt_thread", "cmd_thread", "usb_init", "MSC_BULK_CMD" and "MSC_BULK_DATA".
int rtw_create_worker_thread ( rtw_worker_thread_t worker_thread,
u8  priority,
u32  stack_size,
u32  event_queue_size 
)

This function creates a new worker thread.

Parameters
[in]worker_threadThe pointer to the worker thread stucture.
[in]priorityThe priority of the thread.
[in]stack_sizeThe size of the thread stack specified as the variables the stack can hold.
[in]event_queue_sizeThe queue size of events.
Returns
SUCCESS/FAIL.
int rtw_deinit_xqueue ( _xqueue *  queue)

Delete a queue - freeing all the memory allocated for storing of messages placed on the queue.

Parameters
[in]queueThe handle to the queue to be deleted.
Returns
0: The queue was successfully deleted.
-1: The queue was not empty so cannot be deleted.
void rtw_delete_task ( struct task_struct task)

This function deletes a task.

Parameters
[in]taskThe task stucture which will be deleted.
Returns
None
int rtw_delete_worker_thread ( rtw_worker_thread_t worker_thread)

This function deletes a worker thread.

Parameters
[in]worker_threadThe pointer to the worker thread stucture to be deleted.
Returns
SUCCESS/FAIL.
u32 rtw_down_sema ( _sema *  sema)

This function acquires the semaphore. If no more tasks are allowed to acquire the semaphore, calling this function will put the task to sleep until the semaphore is up.

Parameters
[in]semaThe semaphore to be acquired.
Returns
pdTRUE: The semaphore was obtained.
pdFALSE: Obtain the semaphore failed.
u32 rtw_down_timeout_sema ( _sema *  sema,
u32  timeout 
)

This function acquires the semaphore. If no more tasks are allowed to acquire the semaphore, calling this function will put the task to sleep until the semaphore is up.

Parameters
[in]semaThe semaphore to be acquired.
[in]timeoutThe time in ms to wait for the semaphore to become available.
Returns
pdTRUE: The semaphore was obtained.
pdFALSE: Timeout without the semaphore becoming available.
u32 rtw_end_of_queue_search ( _list *  queue,
_list *  pelement 
)

This function tests whether the "pelement" is at the "queue".

Parameters
[in]queueThe pointer to the queue that to be tested.
[in]pelementThe element that to be tested.
Returns
_TRUE/_FALSE
void rtw_enter_critical ( _lock *  plock,
_irqL *  pirqL 
)

This function marks the start of a critical code region. Preemptive context switches cannot occur when in a critical region.

Parameters
[in]plockPointer to the spin lock semaphore.
[in]pirqLPointer to the IRQ.
Returns
None
Note
: This may alter the stack (depending on the portable implementation) so must be used with care!
void rtw_enter_critical_bh ( _lock *  plock,
_irqL *  pirqL 
)

This function obtains a spin lock semaphore.

Parameters
[in]plockPointer to the spin lock semaphore being taken - obtained when the mutex semaphore was created.
[in]pirqLPointer to the IRQ.
Returns
None
void rtw_enter_critical_from_isr ( _lock *  plock,
_irqL *  pirqL 
)

This function marks the start of a critical code region from isr.

Parameters
[in]plockPointer to the spin lock semaphore.
[in]pirqLPointer to the IRQ.
Returns
None
int rtw_enter_critical_mutex ( _mutex *  pmutex,
_irqL *  pirqL 
)

This function obtains a semaphore.

Parameters
[in]pmutexThe handle to the mutex semaphore to be obtained.
[in]pirqLPointer to the IRQ.
Returns
None
void rtw_exit_critical ( _lock *  plock,
_irqL *  pirqL 
)

This function marks end of a critical code region. Preemptive context switches cannot occur when in a critical region.

Parameters
[in]plockPointer to the spin lock semaphore.
[in]pirqLPointer to the IRQ.
Returns
None
Note
: This may alter the stack (depending on the portable implementation) so must be used with care!
void rtw_exit_critical_bh ( _lock *  plock,
_irqL *  pirqL 
)

This function releases a spin lock semaphore.

Parameters
[in]plockPointer to the spin lock semaphore to be released.
[in]pirqLPointer to the IRQ.
Returns
None
void rtw_exit_critical_from_isr ( _lock *  plock,
_irqL *  pirqL 
)

This function marks the end of a critical code region from isr.

Parameters
[in]plockPointer to the spin lock semaphore.
[in]pirqLPointer to the IRQ.
Returns
None
void rtw_exit_critical_mutex ( _mutex *  pmutex,
_irqL *  pirqL 
)

This function releases a semaphore.

Parameters
[in]pmutexThe handle to the mutex semaphore to be released.
[in]pirqLPointer to the IRQ.
Returns
None
void rtw_free_sema ( _sema *  sema)

This function deletes the semaphore.

Parameters
[in]semaThe semaphore to be deleted.
Returns
None
u32 rtw_get_current_time ( void  )

Get the count of ticks since the vTaskStartScheduler was called.

Returns
The count of ticks since the vTaskStartScheduler was called.
s32 rtw_get_passing_time_ms ( u32  start)

Get the passing time from the "start" in milliseconds.

Parameters
[in]startThe start time which is in system time format.
Returns
: The passing time from "start" in milliseconds.
int rtw_get_random_bytes ( void *  dst,
u32  size 
)

This function generates random bytes.

Parameters
[in]dstThe pointer to the buffer to store the random bytes.
[in]sizeThe size of the random bytes.
Returns
0
u8 rtw_get_scheduler_state ( void  )

This function gets the scheduler state of the calling thread.

Returns
OS_SCHEDULER_NOT_STARTED
OS_SCHEDULER_RUNNING
OS_SCHEDULER_SUSPENDED
s32 rtw_get_time_interval_ms ( u32  start,
u32  end 
)

Get the interval time from the "start" to "end" in milliseconds.

Parameters
[in]startThe start time which is in system time format.
[in]endThe end time which is in system time format.
Returns
: The interval time from "start" to "end" in milliseconds.
u32 rtw_getFreeHeapSize ( void  )

This function gets the available heap size.

Returns
The value of the available heap size.
void rtw_init_listhead ( _list *  list)

This function initializes the head of the list.

Parameters
[in]listPointer to the list to be initialized.
Returns
None
void rtw_init_queue ( _queue *  pqueue)

This function creates a new queue instance.

Parameters
[in]pqueueThe handle to the newly created queue.
Returns
None
void rtw_init_sema ( _sema *  sema,
int  init_val 
)

This function initializes the unnamed semaphore referred to by "sema" to the value "init_val".

Parameters
[in]semaPointer to the semaphore handle to be initialized.
[in]init_valInitial value for semaphore.
Returns
None
int rtw_init_xqueue ( _xqueue *  queue,
const char *  name,
u32  message_size,
u32  number_of_messages 
)

This function creates a new queue instance.

Parameters
[in]queueThe handle to the newly created queue.
[in]nameThe name of the queue
[in]message_sizeThe number of bytes each message in the queue will require.
[in]number_of_messagesThe maximum number of messages that kthe queue can contain.
Returns
0: Creating queue success
-1: Creating queue fail
u32 rtw_is_list_empty ( _list *  phead)

This function tests whether a list is empty.

Parameters
[in]pheadPointer to the list to test.
Returns
_TRUE/_FALSE
void rtw_list_delete ( _list *  plist)

This function deletes entry from list and reinitialize it.

Parameters
[in]plistThe element to delete from the list.
Returns
None
Note
Caller must check if the list is empty before calling rtw_list_delete
void rtw_list_insert_head ( _list *  plist,
_list *  phead 
)

This function adds a new entry after "phead" for the list.

Parameters
[in]plistPointer to the list to be added.
[in]pheadList head to add it after.
Returns
None
void rtw_list_insert_tail ( _list *  plist,
_list *  phead 
)

This function adds a new entry before "phead" for the list.

Parameters
[in]plistPointer to the list to be added.
[in]pheadList head to add it before.
Returns
None
u8* rtw_malloc ( u32  sz)

This function allocates the memory.

Parameters
[in]szThe size of memory to be allocated.
Returns
The pointer to the beginning of the memory
void* rtw_malloc2d ( int  h,
int  w,
int  size 
)

This function allocates a 2 dimensional array memory.

Parameters
[in]hThe height of the 2D array.
[in]wThe width of the 2D array.
[in]sizeThe size of the each charactor in array.
Returns
the pointer to the beginning of the block
void rtw_mdelay_os ( int  ms)

This function delays a task for the giving time in milliseconds.

Parameters
[in]msThe amount of time, in milliseconds, that the calling task should block.
Returns
None
int rtw_memcmp ( void *  dst,
void *  src,
u32  sz 
)

This function compares the first "sz" bytes of the block of memory pointed by "dst" to the first "sz" bytes pointed by "src".

Parameters
[in]dstPointer to block of memory to be compared.
[in]srcpointer to block of memory to compare.
[in]szSize of memory to compare.
Returns
<0: The first byte that does not match in both memory blocks has a lower value in dst than in src.
0: The contents of both memory blocks are equal.
<0: The first byte that does not match in both memory blocks has a greater value in dst than in src.
void rtw_memcpy ( void *  dst,
void *  src,
u32  sz 
)

This function copies the values of "sz" bytes from the location pointed to by "src" directly to the memory block pointed to by "des".

Parameters
[in]dstPointer to the destination array where the content is to be copied, type-casted to a pointer of type void*.
[in]srcPointer to the source of data to be copied, type-casted to a pointer of type void*.
[in]szSize of memory to copy.
Returns
None
void rtw_memset ( void *  pbuf,
int  c,
u32  sz 
)

This function sets the first "sz" bytes of the block of memory pointed by "pbuf" to the specified "c".

Parameters
[in]pbufPointer to the block of memory to fill.
[in]cValue to be set.
[in]szSize of memory to be set to the value "c".
Returns
None
void rtw_mfree ( u8 *  pbuf,
u32  sz 
)

This function frees the virtually contiguous memory.

Parameters
[in]pbufThe pointer to the beginning of the memory to be free
[in]szThe size of memory allocated.
Returns
None
void rtw_mfree2d ( void *  pbuf,
int  h,
int  w,
int  size 
)

This function deallocates the block of memory previously allocated to make it available again.

Parameters
[in]pbufPointer to a memory block previously allocated.
[in]hThe height of the 2D array.
[in]wThe width of the 2D array.
[in]sizeThe size of the each charactor in array.
Returns
None
u32 rtw_ms_to_systime ( u32  ms)

Convert milliseconds to system time.

Parameters
[in]systimeThe milliseconds to be converted.
Returns
: The system time that converted by the milliseconds.
void rtw_msleep_os ( int  ms)

This function suspends execution of the calling thread for "ms" milliseconds.

Parameters
[in]msThe time that the function sleep in milliseconds
Returns
None
void rtw_mutex_free ( _mutex *  pmutex)

This function deletes the mutex semaphore.

Parameters
[in]pmutexPointer to the mutex semaphore to be deleted.
Returns
None
void rtw_mutex_get ( _mutex *  pmutex)

This function obtains a mutex semaphore.

Parameters
[in]pmutexPointer to the mutex semaphore being taken - obtained when the mutex semaphore was created.
Returns
None
int rtw_mutex_get_timeout ( _mutex *  pmutex,
u32  timeout_ms 
)

This function obtains a mutex semaphore with a timeout setting.

Parameters
[in]pmutexPointer to the mutex semaphore being taken - obtained when the mutex semaphore was created.
[in]timeoutThe time in ms to wait for the semaphore to become available.
Returns
0: The semaphore was obtained.
-1: Timeout without the semaphore becoming available.
void rtw_mutex_init ( _mutex *  pmutex)

This function implements a mutex semaphore by using the existing queue mechanism.

Parameters
[in]pmutexPointer to the created mutex semaphore.
Returns
None
void rtw_mutex_put ( _mutex *  pmutex)

This function releases a mutex semaphore.

Parameters
[in]pmutexPointer to the mutex semaphore to be released.
Returns
None
int rtw_pop_from_xqueue ( _xqueue *  queue,
void *  message,
u32  timeout_ms 
)

This function receives a message from a queue. The message is recieved by copy so a buffer adequate size must be provided.

Parameters
[in]queueThe handle to the queue from which the message is to be received.
[in]messageThe pointer to the buffer into which the received message will be copied.
[in]timeout_msThe maximum amout of time the task should block waiting for a message to receive should the queue be empty at the time of the call. The time is defined in ms.
Returns
0: A message was successfully received from the queue.
-1: No message was received from the queue.
int rtw_push_to_xqueue ( _xqueue *  queue,
void *  message,
u32  timeout_ms 
)

This function posts a message to the back of a queue. The message is queued by copy, not by reference.

Parameters
[in]queueThe handle to the queue on which the message is to be posted.
[in]messageThe pointer to the message that is to be placed on the queue.
[in]timeout_msThe maximum amout of time the task should block waiting for the space to become available on the queue, should it already be full. The time is defined in ms.
Returns
0: The message was successfully posted.
-1: The message was not posted.
u32 rtw_queue_empty ( _queue *  pqueue)

This function tests whether the queue is empty.

Parameters
[in]pqueueThe handle to the queue to be tested.
Returns
None
void rtw_release_wakelock ( void  )

This function indicates that the WLAN does not need to stay on which means can go into power saving mode.

Returns
None
Note
Defining configUSE_WAKELOCK_PMU 1 in "FreeRTOSConfig.h" needs to be done before compiling, or this API won't be effective.
u32 rtw_sec_to_systime ( u32  sec)

Convert seconds to system time.

Parameters
[in]systimeThe seconds to be converted.
Returns
: The system time that converted by the seconds.
void rtw_spin_lock ( _lock *  plock)

This function obtains a spin lock semaphore.

Parameters
[in]plockPointer to the spin lock semaphore being taken - obtained when the mutex semaphore was created.
Returns
None
void rtw_spin_unlock ( _lock *  plock)

This function releases a spin lock semaphore.

Parameters
[in]plockPointer to the spin lock semaphore to be released.
Returns
None
void rtw_spinlock_free ( _lock *  plock)

This function deletes the spin lock semaphore.

Parameters
[in]pmutexPointer to the spin lock semaphore to be deleted.
Returns
None
void rtw_spinlock_init ( _lock *  plock)

This function implements a spin lock semaphore by using the existing queue mechanism.

Parameters
[in]plockPointer to the created spin lock semaphore.
Returns
None
void rtw_spinlock_irqsave ( _lock *  plock,
_irqL *  irqL 
)

This function marks the start of a critical code region and obtains a spin lock semaphore.

Parameters
[in]plockPointer to the spin lock semaphore being taken - obtained when the mutex semaphore was created.
[in]irqLPointer to the IRQ.
Returns
None
void rtw_spinunlock_irqsave ( _lock *  plock,
_irqL *  irqL 
)

This function releases a spin lock semaphore and marks the end of a critical code region.

Parameters
[in]plockPointer to the spin lock semaphore to be released.
[in]irqLPointer to the IRQ.
Returns
None
u32 rtw_systime_to_ms ( u32  systime)

Convert system time to milliseconds.

Parameters
[in]systimeThe system time to be converted.
Returns
: The milliseconds that converted by the system time.
u32 rtw_systime_to_sec ( u32  systime)

Convert system time to seconds.

Parameters
[in]systimeThe system time to be converted.
Returns
: The seconds that converted by the system time.
void rtw_thread_enter ( char *  name)

This function prints the name of the thread in DBG_INFO.

Parameters
[in]nameThe name of the thread.
Returns
None
void rtw_thread_exit ( void  )

This function exits the calling thread.

Returns
None
u32 rtw_timerChangePeriod ( _timerHandle  xTimer,
osdepTickType  xNewPeriod,
osdepTickType  xBlockTime 
)

This function changes the period of a timer that was previously created.

Parameters
[in]xTimerThe handle of the timer that is having its period changed.
[in]xNewPeriodThe new period for xTimer.
[in]xBlockTimeSpecifies the time, in ticks, that the calling task should be held in the Blocked state to wait for the change period command to be successfully sent to the timer command queue, should the queue already be full when rtw_timerChangePeriod() was called.
Returns
pdFAIL will be returned if the change period command could not be sent to the timer command queue even after xTicksToWait ticks had passed. pdPASS will be returned if the command was successfully sent to the timer command queue. When the command is actually processed will depend on the priority of the timer service/daemon task relative to other tasks in the system.
_timerHandle rtw_timerCreate ( const signed char *  pcTimerName,
osdepTickType  xTimerPeriodInTicks,
u32  uxAutoReload,
void *  pvTimerID,
TIMER_FUN  pxCallbackFunction 
)

This function creates a new software timer instance.

Parameters
[in]pcTimerNameA text name that is assigned to the timer.
[in]xTimerPeriodInTicksThe timer period which is defined in tick periods.
[in]uxAutoReloadIf uxAutoReload is set to pdTRUE then the timer will expire repeatedly with a frequency set by the xTimerPeriodInTicks parameter. If uxAutoReload is set to pdFALSE then the timer will be a one-shot timer and enter the dormant state after it expires.
[in]pvTimerIDAn identifier that is assigned to the timer being created.
[in]pxCallbackFunctionThe function to call when the timer expires.
Returns
If the timer is successfully create then a handle to the newly created timer is returned. If the timer cannot be created, then 0 is returned.
u32 rtw_timerDelete ( _timerHandle  xTimer,
osdepTickType  xBlockTime 
)

This function deletes a timer that was previously created using rtw_timerCreate.

Parameters
[in]xTimerThe handle of the timer being deleted.
[in]xBlockTimeSpecifies th etime, in ticks, that the calling task should be held in the Blocked State to wait for the delete command to be successfully sent to the timer command queue, should the queue already be full when rtw_timerDelete was called.
Returns
pdFAIL will be returned if the delete command could not be sent to the timer command queue even after xTicksToWait ticks had passed. pdPASS will be returned if the command was successfully sent to the timer command queue. When the command is actually processed will depend on the priority of the timer service/daemon task relative to other tasks in the system.
u32 rtw_timerIsTimerActive ( _timerHandle  xTimer)

This function queries a timer to see if it is active or dormant.

Parameters
[in]xTimerThe timer being queried.
Returns
pdFALSE will be returned if the timer is dormant. A value other than pdFALSE will be returned if the timer is active.
Note
A timer will be dormant if: 1) It has been created but not started, or 2) It is an expired one-shot timer that has not been restarted.
u32 rtw_timerStop ( _timerHandle  xTimer,
osdepTickType  xBlockTime 
)

This function stops a timer that was previously started.

Parameters
[in]xTimerThe handle of the timer being stopped.
[in]xBlockTimeSpecifies the time, in ticks, that the calling task should be held in the Blocked state to wait for the stop command to be successfully sent to the timer command queue, should the queue already be full when rtw_timerStop() was called.
Returns
pdFAIL will be returned if the stop command could not be sent to the timer command queue even after xTicksToWait ticks had passed. pdPASS will be returned if the command was successfully sent to the timer command queue. When the command is actually processed will depend on the priority of the timer service/daemon task relative to other tasks in the system.
void rtw_udelay_os ( int  us)

This function delays a task for the giving time in microseconds.

Parameters
[in]msThe amount of time, in microseconds, that the calling task should block.
Returns
None
void rtw_up_sema ( _sema *  sema)

This function releases the semaphore. This macro must not be used from an ISR.

Parameters
[in]semaThe semaphore to be released.
Returns
None
void rtw_up_sema_from_isr ( _sema *  sema)

This function releases the semaphore. This macro can be used from an ISR.

Parameters
[in]semaThe semaphore to be released.
Returns
None
void rtw_usleep_os ( int  us)

This function suspends execution of the calling thread for "us" microseconds.

Parameters
[in]msThe time that the function sleep in microseconds
Returns
None
u8* rtw_vmalloc ( u32  sz)

This function allocates the virtually contiguous memory.

Parameters
[in]szThe size of memory to be allocated.
Returns
The pointer to the beginning of the memory
void rtw_vmfree ( u8 *  pbuf,
u32  sz 
)

This function frees the virtually contiguous memory.

Parameters
[in]pbufThe pointer to the beginning of the memory to be free
[in]szThe size of memory allocated.
Returns
None
void rtw_wakeup_task ( struct task_struct task)

This function wake up a task.

Parameters
[in]taskThe task stucture which will be waked up.
Returns
None
void rtw_yield_os ( void  )

This function for forcing a context switch.

Returns
None
u8* rtw_zmalloc ( u32  sz)

This function allocates the memory and the values of the memory are setted to 0.

Parameters
[in]szThe size of memory to be allocated.
Returns
The pointer to the beginning of the memory
u8* rtw_zvmalloc ( u32  sz)

This function allocates the virtually contiguous memory and the values of the memory are setted to 0.

Parameters
[in]szThe size of memory to be allocated.
Returns
The pointer to the beginning of the memory