My Project
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Classes | Typedefs | Enumerations | Functions
task.h File Reference
#include <sw_types.h>
#include <sw_list.h>
#include <otz_common.h>
#include <cpu_task.h>
#include <sw_wait.h>

Go to the source code of this file.

Classes

struct  sa_config_t
 Secure API configuration details for task. More...
 
struct  sw_tls
 Task local storage. More...
 
struct  user_access_control
 
struct  sw_task
 Task structure. More...
 

Typedefs

typedef struct sa_config_t sa_config_t
 Secure API configuration details for task. More...
 
typedef struct sw_tls sw_tls
 Task local storage. More...
 
typedef struct user_access_control acl_t
 

Enumerations

enum  task_state_e { TASK_STATE_SUSPEND = 0, TASK_STATE_WAIT, TASK_STATE_READY_TO_RUN, TASK_STATE_RUNNING }
 Task state constants. More...
 

Functions

int create_task (sa_config_t *psa_config, int *task_id)
 Create a task. More...
 
int destroy_task (int task_id)
 Destroy the created task. More...
 
int start_task (int task_id, pa_t *params)
 Start the task. More...
 
void task_context_switch (struct sw_task *new_task, struct sw_task *old_task, void *regs)
 Task context switch function. More...
 
int get_task_state (int task_id)
 Get task state. More...
 
int print_task (int task_id)
 Helper function to print the task context. More...
 
void resume_async_task (int task_id)
 This functions wakes up a task from sleep. It is used for async tasks. More...
 
sw_tlsget_task_tls (int task_id)
 Get task local storage. More...
 
struct sw_taskget_task (int task_id)
 Helper function to return task structure. More...
 

Typedef Documentation

typedef struct user_access_control acl_t

User Access Control

typedef struct sa_config_t sa_config_t

Secure API configuration details for task.

typedef struct sw_tls sw_tls

Task local storage.

Enumeration Type Documentation

Task state constants.

Enumerator
TASK_STATE_SUSPEND 
TASK_STATE_WAIT 
TASK_STATE_READY_TO_RUN 
TASK_STATE_RUNNING 

Function Documentation

int create_task ( sa_config_t psa_config,
int *  task_id 
)

Create a task.

This function helps in task creation. It allocates the task structure, task local storage, task stack. It puts the task in suspend state and adds to global task list.

Parameters
psa_configConfiguration for task creation
task_idOutput parameter for the task ID.
Returns
otz_return_t: OTZ_OK - Session established successfully
OTZ_* - An implementation-defined error code for any other error.
int destroy_task ( int  task_id)

Destroy the created task.

This function cleans up the created task. It frees the resources which got allocated in task creation. It removes the task for global task list

Parameters
task_idTask ID
Returns
otz_return_t: OTZ_OK - Session established successfully
OTZ_* - An implementation-defined error code for any other error.
struct sw_task* get_task ( int  task_id)

Helper function to return task structure.

This helper function returns the task structure for the given task ID

Parameters
task_idTask ID
Returns
Returns the pointer to task structure or NULL
int get_task_state ( int  task_id)

Get task state.

Parameters
task_idTask ID
Returns
Returns the task state: TASK_STATE_SUSPEND - Task in suspend state
TASK_STATE_WAIT - Task in wait state
TASK_STATE_READY_TO_RUN - Task is in ready to run state
TASK_STATE_RUNNING - Task is in running state
sw_tls* get_task_tls ( int  task_id)

Get task local storage.

This helper function returns the task local storage

Parameters
task_idTask ID
Returns
Returns the task local storage pointer or NULL.
int print_task ( int  task_id)

Helper function to print the task context.

Parameters
task_idTask ID
Returns
otz_return_t: OTZ_OK - Session established successfully
OTZ_* - An implementation-defined error code for any other error.
void resume_async_task ( int  task_id)

This functions wakes up a task from sleep. It is used for async tasks.

Parameters
task_idThe task to be resumed
Returns
int start_task ( int  task_id,
pa_t *  params 
)

Start the task.

This function gets called on command invocation and init the task context the schedule the task.

Parameters
task_idTask ID
paramsCommand parameters
Returns
otz_return_t: OTZ_OK - Session established successfully
OTZ_* - An implementation-defined error code for any other error.
void task_context_switch ( struct sw_task new_task,
struct sw_task old_task,
void *  regs 
)

Task context switch function.

This function switches the context between two tasks

Parameters
new_taskTask for which context need to be restored
old_taskTask for which context need to be saved