SDK4.0 This document shows Ameba SDK 4.0 APIs

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

Data Structures | Macros | Typedefs | Functions
osdep_service.h File Reference

This file provides the OS dependent API. More...

`#include <stdio.h>`
`#include "platform_autoconf.h"`

## Data Structures
struct | timer_list
struct | task_struct
struct | rtw_worker_thread_t
struct | rtw_event_message_t
struct | worker_timer_entry
struct | osdep_service_ops

## Macros
#define | CONFIG_LITTLE_ENDIAN
#define | CONFIG_PLATFORM_AMEBA_X
#define | CONFIG_USE_TCM_HEAP 1 /* USE TCM HEAP */
#define | USE_MUTEX_FOR_SPINLOCK 1
#define | CONFIG_MEM_MONITOR MEM_MONITOR_SIMPLE
#define | RTW_MAX_DELAY 0xFFFFFFFF
#define | RTW_WAIT_FOREVER 0xFFFFFFFF
#define | OS_SCHEDULER_NOT_STARTED 0
| Definitions returned by xTaskGetSchedulerState().
#define | OS_SCHEDULER_RUNNING 1
#define | OS_SCHEDULER_SUSPENDED 2
#define | CONFIG_THREAD_COMM_SEMA
#define | MEM_MONITOR_SIMPLE 0x1
#define | MEM_MONITOR_LEAK 0x2
#define | MEM_MONITOR_FLAG_WIFI_DRV 0x1
#define | MEM_MONITOR_FLAG_WPAS 0x2
#define | rtw_free(buf) rtw_mfree((u8 *)buf, 0)
#define | rtw_warn_on(condition) do {} while (0)
#define | LIST_CONTAINOR(ptr, type, member) ((type *)((char *)(ptr)-(SIZE_T)((char *)&((type *)ptr)->member - (char *)ptr)))
#define | time_after(a, b) ((long)(b) - (long)(a) < 0)
#define | time_before(a, b) time_after(b,a)
#define | time_after_eq(a, b) ((long)(a) - (long)(b) >= 0)
#define | time_before_eq(a, b) time_after_eq(b,a)
#define | _RND(sz, r) ((((sz)+((r)-1))/(r))*(r))
#define | RND4(x) (((x >> 2) + (((x & 3) == 0) ? 0: 1)) << 2)
#define | RTW_GET_BE16(a) ((u16) (((a)[0] << 8) | (a)[1]))
#define | RTW_PUT_BE16(a, val)
#define | RTW_GET_LE16(a) ((u16) (((a)[1] << 8) | (a)[0]))
#define | RTW_PUT_LE16(a, val)
#define | RTW_GET_BE24(a)
#define | RTW_PUT_BE24(a, val)
#define | RTW_GET_BE32(a)
#define | RTW_PUT_BE32(a, val)
#define | RTW_GET_LE32(a)
#define | RTW_PUT_LE32(a, val)
#define | RTW_GET_BE64(a)
#define | RTW_PUT_BE64(a, val)
#define | RTW_GET_LE64(a)

## 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)

## 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_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)

## Detailed Description

This file provides the OS dependent API.

Author

Version

Attention

This module is a confidential and proprietary property of RealTek and possession or use of this module requires written permission of RealTek.

Copyright(c) 2016, Realtek Semiconductor Corporation. All rights reserved.