VSF Documented
vsf_os.h File Reference
#include "kernel/vsf_kernel_cfg.h"
#include "./vsf_evtq.h"
#include "./task/vsf_task.h"
#include "hal/arch/vsf_arch.h"

Go to the source code of this file.

Data Structures

struct  __vsf_eda_frame_buffer_t
 
struct  vsf_kernel_resource_t
 

Macros

#define VSF_USER_ENTRY   user_main
 User application entry point symbol. If not defined externally, it defaults to user_main when the kernel entry is configured as main, otherwise it defaults to main.
 
#define VSF_SCHED_SAFE_CODE_REGION   DEFAULT_CODE_REGION_NONE
 Empty stub variant when VSF_OS_CFG_PRIORITY_NUM <= 1; shares the documentation of the first variant above.
 
#define vsf_sched_lock()
 No-op stub variant when VSF_OS_CFG_PRIORITY_NUM <= 1; shares the documentation of the first variant above.
 
#define vsf_sched_unlock(__level)
 No-op stub variant when VSF_OS_CFG_PRIORITY_NUM <= 1; shares the documentation of the first variant above.
 
#define vsf_sched_safe()
 Stub variant when VSF_OS_CFG_PRIORITY_NUM <= 1 (the following block always runs); shares the documentation of the first variant above.
 
#define __vsf_sched_safe(__code)
 No-op stub variant when VSF_OS_CFG_PRIORITY_NUM <= 1; shares the documentation of the first variant above.
 
#define vsf_sched_safe_exit()
 No-op stub variant when VSF_OS_CFG_PRIORITY_NUM <= 1; shares the documentation of the first variant above.
 
#define vsf_protect_scheduler()
 Lock the scheduler, alias of vsf_sched_lock()
 
#define vsf_unprotect_scheduler(__state)
 Unlock the scheduler, alias of vsf_sched_unlock()
 
#define vsf_protect_sched()
 Lock the scheduler and return the previous status as vsf_protect_t.
 
#define vsf_unprotect_sched(__prot)
 Restore the scheduler lock status saved by vsf_protect_sched()
 
#define __vsf_kernel_host_request_init(__req)
 Initialize a host IRQ request.
 
#define __vsf_kernel_host_request_fini(__req)
 Finalize a host IRQ request.
 
#define __vsf_kernel_host_request_send(__req)
 Send (trigger) a host IRQ request.
 
#define __vsf_kernel_host_request_pend(__req)
 Pend (wait) on a host IRQ request.
 
#define __vsf_kernel_host_thread_init(__thread, __name, __entry, __prio, __stack, __stacksize)
 Initialize a host IRQ thread.
 
#define __vsf_kernel_host_thread_restart(__thread, __request_pending)
 Restart a host IRQ thread.
 
#define __vsf_kernel_host_thread_exit(__thread)
 Exit a host IRQ thread.
 
#define vsf_sleep(...)
 Put the CPU into sleep (low-power) mode; an optional sleep level (architecture-specific, 0 by default) may be passed.
 
#define vsf_protect_region_sched   vsf_protect_region_none
 

Typedefs

typedef vsf_arch_prio_t vsf_sched_lock_status_t
 Scheduler lock status, returned by vsf_sched_lock() / vsf_forced_sched_lock() and passed back to vsf_sched_unlock() / vsf_forced_sched_unlock()
 
typedef vsf_evt_node_t struct __vsf_eda_frame_buffer_t __vsf_eda_frame_buffer_t
 
typedef __vsf_eda_frame_buffer_t struct vsf_kernel_resource_t vsf_kernel_resource_t
 

Functions

 dcl_vsf_pool (vsf_evt_node_pool) def_vsf_pool(vsf_evt_node_pool
 
 dcl_vsf_pool (vsf_eda_frame_pool) def_vsf_pool(vsf_eda_frame_pool
 
void __vsf_kernel_os_start (void)
 __vsf_kernel_os_start and __vsf_kernel_os_run_priority are ONLY used when embedded weak vsf_main_entry is not used
 
void __vsf_kernel_os_run_priority (vsf_prio_t priority)
 Run the event queue of the given priority (dispatch pending events)
 
void vsf_kernel_err_report (enum vsf_kernel_error_t err)
 Report a kernel error.
 
void vsf_cpu_usage_start (vsf_cpu_usage_ctx_t *ctx)
 Start CPU usage measurement.
 
void vsf_cpu_usage_stop (void)
 Stop CPU usage measurement.
 
void __vsf_sleep (int level)
 Implementation of vsf_sleep(), put the CPU into sleep (low-power) mode.
 

Macro Definition Documentation

◆ VSF_USER_ENTRY

#define VSF_USER_ENTRY   user_main

User application entry point symbol. If not defined externally, it defaults to user_main when the kernel entry is configured as main, otherwise it defaults to main.

◆ VSF_SCHED_SAFE_CODE_REGION

#define VSF_SCHED_SAFE_CODE_REGION   DEFAULT_CODE_REGION_NONE

Empty stub variant when VSF_OS_CFG_PRIORITY_NUM <= 1; shares the documentation of the first variant above.

◆ vsf_sched_lock

#define vsf_sched_lock ( )
Value:
0

No-op stub variant when VSF_OS_CFG_PRIORITY_NUM <= 1; shares the documentation of the first variant above.

◆ vsf_sched_unlock

#define vsf_sched_unlock ( __level)
Value:
#define VSF_UNUSED_PARAM(__VAL)
Definition __type.h:190

No-op stub variant when VSF_OS_CFG_PRIORITY_NUM <= 1; shares the documentation of the first variant above.

◆ vsf_sched_safe

#define vsf_sched_safe ( )
Value:
if (1)

Stub variant when VSF_OS_CFG_PRIORITY_NUM <= 1 (the following block always runs); shares the documentation of the first variant above.

◆ __vsf_sched_safe

#define __vsf_sched_safe ( __code)
Value:
__code

No-op stub variant when VSF_OS_CFG_PRIORITY_NUM <= 1; shares the documentation of the first variant above.

◆ vsf_sched_safe_exit

#define vsf_sched_safe_exit ( )

No-op stub variant when VSF_OS_CFG_PRIORITY_NUM <= 1; shares the documentation of the first variant above.

◆ vsf_protect_scheduler

#define vsf_protect_scheduler ( )
Value:
#define vsf_sched_lock()
No-op stub variant when VSF_OS_CFG_PRIORITY_NUM <= 1; shares the documentation of the first variant a...
Definition vsf_os.h:144

Lock the scheduler, alias of vsf_sched_lock()

Returns
vsf_sched_lock_status_t: the previous scheduler lock status, to be passed to vsf_unprotect_scheduler()
Note
Typically called in task context to protect a short critical section from scheduling.

◆ vsf_unprotect_scheduler

#define vsf_unprotect_scheduler ( __state)
Value:
vsf_sched_unlock((__state))
#define vsf_sched_unlock(__level)
No-op stub variant when VSF_OS_CFG_PRIORITY_NUM <= 1; shares the documentation of the first variant a...
Definition vsf_os.h:152

Unlock the scheduler, alias of vsf_sched_unlock()

Parameters
[in]__statethe lock status returned by vsf_protect_scheduler()
Note
Typically called in task context to protect a short critical section from scheduling.

◆ vsf_protect_sched

#define vsf_protect_sched ( )
Value:
uintalu_t vsf_protect_t
Definition vsf_arch_abstraction.h:60
#define vsf_protect_scheduler()
Lock the scheduler, alias of vsf_sched_lock()
Definition vsf_os.h:200

Lock the scheduler and return the previous status as vsf_protect_t.

Returns
vsf_protect_t: the previous scheduler lock status, to be passed to vsf_unprotect_sched()
Note
Typically called in task context to protect a short critical section from scheduling.

◆ vsf_unprotect_sched

#define vsf_unprotect_sched ( __prot)
Value:
#define vsf_unprotect_scheduler(__state)
Unlock the scheduler, alias of vsf_sched_unlock()
Definition vsf_os.h:212

Restore the scheduler lock status saved by vsf_protect_sched()

Parameters
[in]__protthe status returned by vsf_protect_sched()
Note
Typically called in task context to protect a short critical section from scheduling.

◆ __vsf_kernel_host_request_init

#define __vsf_kernel_host_request_init ( __req)
Value:
void __vsf_arch_irq_request_init(vsf_arch_irq_request_t *request)
Definition linux_generic.c:167

Initialize a host IRQ request.

Parameters
[in]__reqpointer to the host IRQ request
Note
Internal use only.

◆ __vsf_kernel_host_request_fini

#define __vsf_kernel_host_request_fini ( __req)
Value:
void __vsf_arch_irq_request_fini(vsf_arch_irq_request_t *request)
Definition linux_generic.c:188

Finalize a host IRQ request.

Parameters
[in]__reqpointer to the host IRQ request
Note
Internal use only.

◆ __vsf_kernel_host_request_send

#define __vsf_kernel_host_request_send ( __req)
Value:
void __vsf_arch_irq_request_send(vsf_arch_irq_request_t *request)
Definition linux_generic.c:228

Send (trigger) a host IRQ request.

Parameters
[in]__reqpointer to the host IRQ request
Note
Internal use only.

◆ __vsf_kernel_host_request_pend

#define __vsf_kernel_host_request_pend ( __req)
Value:
void __vsf_arch_irq_request_pend(vsf_arch_irq_request_t *request)
Definition linux_generic.c:205

Pend (wait) on a host IRQ request.

Parameters
[in]__reqpointer to the host IRQ request
Note
Internal use only.

◆ __vsf_kernel_host_thread_init

#define __vsf_kernel_host_thread_init ( __thread,
__name,
__entry,
__prio,
__stack,
__stacksize )
Value:
__vsf_arch_irq_init(__thread, __name, __entry, __prio)
#define __name
Definition hci_transport_aic8800.c:555
void __vsf_arch_irq_init(vsf_arch_irq_thread_t *irq_thread, char *name, vsf_arch_irq_entry_t entry, vsf_arch_prio_t priority)
Definition win_generic.c:696

Initialize a host IRQ thread.

Parameters
[in]__threadpointer to the host thread
[in]__namename of the thread
[in]__entryentry function of the thread
[in]__priopriority of the thread
[in]__stackignored when the arch does not support user-provided stack
[in]__stacksizeignored when the arch does not support user-provided stack
Note
Internal use only.

◆ __vsf_kernel_host_thread_restart

#define __vsf_kernel_host_thread_restart ( __thread,
__request_pending )
Value:
__vsf_arch_irq_restart((__thread), (__request_pending))
vsf_err_t __vsf_arch_irq_restart(vsf_arch_irq_thread_t *irq_thread, vsf_arch_irq_request_t *request_pending)
Definition linux_generic.c:309

Restart a host IRQ thread.

Parameters
[in]__threadpointer to the host thread
[in]__request_pendingpointer to the thread request vsf_arch_irq_request_t pended on after restart
Note
Internal use only.

◆ __vsf_kernel_host_thread_exit

#define __vsf_kernel_host_thread_exit ( __thread)
Value:
void __vsf_arch_irq_exit(vsf_arch_irq_thread_t *irq_thread)
Definition linux_generic.c:303

Exit a host IRQ thread.

Parameters
[in]__threadpointer to the host thread
Note
Internal use only.

◆ vsf_sleep

#define vsf_sleep ( ...)
Value:
__vsf_sleep((0, ##__VA_ARGS__))
void __vsf_sleep(int level)
Implementation of vsf_sleep(), put the CPU into sleep (low-power) mode.
Definition vsf_os.c:484

Put the CPU into sleep (low-power) mode; an optional sleep level (architecture-specific, 0 by default) may be passed.

Note
Can only be called inside the vsf_plug_in_on_kernel_idle plug-in.

◆ vsf_protect_region_sched

#define vsf_protect_region_sched   vsf_protect_region_none

Typedef Documentation

◆ vsf_sched_lock_status_t

Scheduler lock status, returned by vsf_sched_lock() / vsf_forced_sched_lock() and passed back to vsf_sched_unlock() / vsf_forced_sched_unlock()

◆ __vsf_eda_frame_buffer_t

typedef vsf_evt_node_t struct __vsf_eda_frame_buffer_t __vsf_eda_frame_buffer_t

◆ vsf_kernel_resource_t

typedef __vsf_eda_frame_buffer_t struct vsf_kernel_resource_t vsf_kernel_resource_t

Function Documentation

◆ dcl_vsf_pool() [1/2]

dcl_vsf_pool ( vsf_evt_node_pool )

◆ dcl_vsf_pool() [2/2]

dcl_vsf_pool ( vsf_eda_frame_pool )

◆ __vsf_kernel_os_start()

void __vsf_kernel_os_start ( void )
extern

__vsf_kernel_os_start and __vsf_kernel_os_run_priority are ONLY used when embedded weak vsf_main_entry is not used

Initialize and start the VSF kernel (arch, HAL, service and OS initialization)

Note
Internal use only. Only used when the embedded weak vsf_main_entry is not used.

◆ __vsf_kernel_os_run_priority()

void __vsf_kernel_os_run_priority ( vsf_prio_t priority)
extern

Run the event queue of the given priority (dispatch pending events)

Parameters
[in]prioritythe priority whose event queue is handled
Note
Internal use only. Only used when the embedded weak vsf_main_entry is not used.

◆ vsf_kernel_err_report()

void vsf_kernel_err_report ( enum vsf_kernel_error_t err)
extern

Report a kernel error.

Parameters
[in]errthe kernel error of type vsf_kernel_error_t
Note
Weak function, can be re-implemented by defining WEAK_VSF_KERNEL_ERR_REPORT.
Note
This should not happen. Two possible reasons could be:
  1. Forgeting to set VSF_OS_CFG_MAIN_MODE to VSF_OS_CFG_MAIN_MODE_THREAD and using vsf kernel APIs, e.g. vsf_delay_ms, vsf_sem_pend and etc.
  2. When VSF_OS_CFG_MAIN_MODE is not VSF_OS_CFG_MAIN_MODE_THREAD, using any vsf_eda_xxxx APIs.
  3. call APIs depends on eda context in non-eda context
This should not happen. One possible reason is:

‍You start task, e.g. eda, vsf_task, vsf_pt or vsf_thread in the idle task. Please use vsf_prio_0 when you do this in idle task.

◆ vsf_cpu_usage_start()

void vsf_cpu_usage_start ( vsf_cpu_usage_ctx_t * ctx)
extern

Start CPU usage measurement.

Parameters
[in]ctxa pointer to structure vsf_cpu_usage_ctx_t storing the measurement result
Note
Only one measurement can run at a time; stop it with vsf_cpu_usage_stop().

◆ vsf_cpu_usage_stop()

void vsf_cpu_usage_stop ( void )
extern

Stop CPU usage measurement.

Note
After stopping, ctx->duration holds the total elapsed ticks and ctx->ticks holds the busy (non-idle) ticks; CPU usage is ticks / duration.

◆ __vsf_sleep()

void __vsf_sleep ( int level)
extern

Implementation of vsf_sleep(), put the CPU into sleep (low-power) mode.

Parameters
[in]levelsleep level, architecture-specific
Note
Internal use only. Can only be called inside the vsf_plug_in_on_kernel_idle plug-in.
Generated from commit: vsfteam/vsf@a5104db