171 lines
4.6 KiB
C
171 lines
4.6 KiB
C
/****************************************************************************
|
|
|
|
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
|
|
|
|
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
|
|
be copied by any method or incorporated into another program without
|
|
the express written consent of Aerospace C.Power. This Information or any portion
|
|
thereof remains the property of Aerospace C.Power. The Information contained herein
|
|
is believed to be accurate and Aerospace C.Power assumes no responsibility or
|
|
liability for its use in any way and conveys no license or title under
|
|
any patent or copyright and makes no representation or warranty that this
|
|
Information is free from patent or copyright infringement.
|
|
|
|
****************************************************************************/
|
|
|
|
#ifndef OS_SHIM_TASK_H
|
|
#define OS_SHIM_TASK_H
|
|
|
|
/* export includes */
|
|
#include "os_task_api.h"
|
|
#include "iot_system.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define BACKTRACE_DUMP_DEEP_LEN 6
|
|
typedef struct {
|
|
uint32_t ra;
|
|
uint32_t s0;
|
|
uint32_t stack;
|
|
} backtrace_regs_t;
|
|
|
|
typedef struct {
|
|
uint8_t deep_len;
|
|
backtrace_regs_t regs[BACKTRACE_DUMP_DEEP_LEN];
|
|
} backtrace_dump_t;
|
|
|
|
/* the pattern of task exception dump */
|
|
#define TCD_PATTERN 0xABCDDCBA
|
|
/* the max cnt of task crash dump that can be saved into flash */
|
|
#define TCD_TASK_MAX_CNT 7
|
|
/* the max cnt of task's stack data that can be saved into flash */
|
|
#define TCD_TASK_STACK_MAX_CNT 3
|
|
|
|
/* The structure size must be an integer multiple of 4 */
|
|
typedef struct tcd_task_info_s {
|
|
char name[30];
|
|
uint8_t backtrace_cnt;
|
|
uint8_t state;
|
|
uint32_t run_time_counter;
|
|
uint32_t mpec;
|
|
uint32_t stack_base;
|
|
uint32_t sp;
|
|
} tcd_task_info_t;
|
|
|
|
typedef saved_registers tcd_regs_t;
|
|
typedef backtrace_regs_t tcd_backtrace_t;
|
|
|
|
typedef struct tcd_task_stack_s {
|
|
uint32_t addr;
|
|
uint32_t len;
|
|
} tcd_task_stack_t;
|
|
|
|
typedef struct tcd_task_stat_s {
|
|
uint32_t pattern;
|
|
uint32_t layout_offset;
|
|
uint32_t layout_size;
|
|
uint8_t task_max_cnt;
|
|
uint8_t task_stack_max_cnt;
|
|
uint8_t task_cnt;
|
|
uint8_t version_major;
|
|
uint8_t version_minor;
|
|
uint8_t version_micro;
|
|
uint16_t version_build;
|
|
uint32_t run_time;
|
|
} tcd_task_stat_t;
|
|
|
|
/**
|
|
* @brief os_task_systick_cb - os systick callback function, must be defined
|
|
* by IRAM_ATTR
|
|
*/
|
|
typedef void (*os_task_systick_cb)();
|
|
|
|
extern backtrace_dump_t g_backtrace_dump;
|
|
|
|
/**
|
|
* @brief os_start_kernel() - Start the FreeRtos
|
|
*/
|
|
void os_start_kernel(void);
|
|
|
|
/**
|
|
* @brief os_start_scheduler() - Start the scheduler
|
|
*/
|
|
void os_start_scheduler(void);
|
|
|
|
/**
|
|
* @brief os_disable_irq() - disable global interrupt
|
|
*/
|
|
void os_disable_irq(void);
|
|
|
|
/**
|
|
* @brief os_enable_irq() - enable global interrupt
|
|
*/
|
|
void os_enable_irq(void);
|
|
|
|
/**
|
|
* @brief os_disable_irq_from_isr() - disable global interrupt
|
|
* @return: The mask that should pass into os_enable_irq_from_isr
|
|
*/
|
|
int os_disable_irq_from_isr(void);
|
|
|
|
/**
|
|
* @brief os_enable_irq_from_isr() - enable global interrupt
|
|
* @param mask : Mask got from os_disable_irq_from_isr
|
|
*/
|
|
void os_enable_irq_from_isr(int mask);
|
|
|
|
/**
|
|
* @brief os_get_scheduler_state - return OS scheduler's state
|
|
*
|
|
* @return: 1 - not start
|
|
* @return: 0 - started
|
|
*/
|
|
int os_get_scheduler_state(void);
|
|
|
|
/**
|
|
* @brief os_task_switch_context - OS's task context switch
|
|
*/
|
|
void os_task_switch_context(void);
|
|
|
|
/**
|
|
* @brief os_task_crash_get_task_info - Get info of current running task.
|
|
* @param p_buffer : Buffer to store information string.
|
|
* @param m_len : Length of Buffer.
|
|
*
|
|
* @return: The length of string.
|
|
*/
|
|
uint32_t os_task_crash_get_task_info(char *p_buffer, uint32_t m_len);
|
|
|
|
/**
|
|
* @brief os_task_get_crash_info - Get crash info.
|
|
* @param task_cnt : statistical time
|
|
* @param total_run_time : total run time
|
|
*
|
|
* @return: The length of string.
|
|
*/
|
|
uint32_t os_task_get_crash_info(uint32_t *total_run_time, uint32_t *run_time);
|
|
|
|
/**
|
|
* @brief os_task_set_systick_cb - set os systick timer callback
|
|
* @param func : callback function, must be defined by IRAM_ATTR
|
|
*
|
|
* @return: 1 - set systick callback successfully
|
|
* @return: 0 - set systick callback failed
|
|
*/
|
|
int os_task_set_systick_cb(os_task_systick_cb func);
|
|
|
|
/**
|
|
* @brief os_set_task_prio_ext() - set priority of a task internally
|
|
* @param handle: handle of the task to be set
|
|
* @param prio: task priority
|
|
*/
|
|
void os_set_task_prio_ext(os_task_h handle, uint8_t prio);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* OS_SHIM_TASK_H */
|