增加对ONEOS的支持

pull/67/head
WuZY 3 years ago
parent 328ce32bf8
commit 3fd82d1836

@ -200,17 +200,20 @@ static void get_cur_thread_stack_info(uint32_t sp, uint32_t *start_addr, size_t
*start_addr = (uint32_t) OSTCBCur->OSTCBStkBottom;
*size = OSTCBCur->OSTCBStkSize * sizeof(OS_STK);
#elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_UCOSIII)
extern OS_TCB *OSTCBCurPtr;
extern OS_TCB *OSTCBCurPtr;
*start_addr = (uint32_t) OSTCBCurPtr->StkBasePtr;
*size = OSTCBCurPtr->StkSize * sizeof(CPU_STK_SIZE);
#elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_FREERTOS)
#elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_FREERTOS)
*start_addr = (uint32_t)vTaskStackAddr();
*size = vTaskStackSize() * sizeof( StackType_t );
#elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_RTX5)
osRtxThread_t *thread = osRtxInfo.thread.run.curr;
*start_addr = (uint32_t)thread->stack_mem;
*size = thread->stack_size;
#elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_ONEOS)
*start_addr = (uint32_t) os_task_self()->stack_begin;
*size = (os_uint32_t)((os_ubase_t)os_task_self()->stack_end - (os_ubase_t)os_task_self()->stack_begin);;
#endif
}
@ -230,14 +233,16 @@ static const char *get_cur_thread_name(void) {
#endif /* OS_TASK_NAME_SIZE > 0 || OS_TASK_NAME_EN > 0 */
#elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_UCOSIII)
extern OS_TCB *OSTCBCurPtr;
extern OS_TCB *OSTCBCurPtr;
return (const char *)OSTCBCurPtr->NamePtr;
#elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_FREERTOS)
return vTaskName();
#elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_RTX5)
osThreadId_t id = osThreadGetId();
return osThreadGetName(id);
#elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_ONEOS)
return os_task_self()->name;
#endif
}

@ -0,0 +1,61 @@
#include "arch_interrupt.h"
#include "arch_exception.h"
#include "os_task.h"
#include <os_memory.h>
#include <os_spinlock.h>
#include <arch_interrupt.h>
#include "os_kernel_internal.h"
#include "os_errno.h"
#include "protocol.h"
#include "devdef.h"
#include "stdio.h"
#include "string.h"
#include <cm_backtrace.h>
void cm_backtrace_hard_fault_exception(uint32_t lr, uint32_t sp)
{
os_meminfo_t info;
OS_KERNEL_INIT();
OS_KERNEL_ENTER();
os_memory_info(&info);
os_kprintf("\r\nmemory info:\r\n");
os_kprintf("Used: %d maxUsed: %d total: %d\r\n\n", info.mem_used, info.mem_maxused, info.mem_total);
sh_show_task_info();
cm_backtrace_fault(*((uint32_t*)(cmb_get_sp() + sizeof(uint32_t) * 8)), cmb_get_sp() + sizeof(uint32_t) * 9);
while (1);
OS_KERNEL_EXIT();
}
os_err_t os_hw_hard_fault_exception_hook(void* context, os_size_t* msp, os_size_t* psp)
{
cm_backtrace_hard_fault_exception(0, 0);
return OS_EOK;
}
extern void os_hw_exception_install(os_err_t (*exception_handle)(void*, os_size_t*, os_size_t*));
int cmBacktrace_init(void)
{
char hardware[10];
memset(hardware, 0, sizeof(hardware));
sprintf(hardware, "%d", DAYB_HARD_VER);
/* CmBacktrace initialize */
cm_backtrace_init("oneos", hardware, FIRMWARE_VERSION);
/* set exception hook */
os_hw_exception_install(os_hw_hard_fault_exception_hook);
return OS_EOK;
}
OS_APP_INIT(cmBacktrace_init, OS_INIT_SUBLEVEL_LOW);

@ -29,18 +29,19 @@
#ifndef _CMB_CFG_H_
#define _CMB_CFG_H_
/* print line, must config by user */
#define cmb_println(...) /* e.g., printf(__VA_ARGS__);printf("\r\n") or SEGGER_RTT_printf(0, __VA_ARGS__);SEGGER_RTT_WriteString(0, "\r\n") */
/* enable bare metal(no OS) platform */
/* #define CMB_USING_BARE_METAL_PLATFORM */
#include <os_types.h>
#include <os_task.h>
/* print line, must config by user */
#define cmb_println(...) os_kprintf(__VA_ARGS__);os_kprintf("\r\n")
/* enable OS platform */
/* #define CMB_USING_OS_PLATFORM */
#define CMB_USING_OS_PLATFORM
/* OS platform type, must config when CMB_USING_OS_PLATFORM is enable */
/* #define CMB_OS_PLATFORM_TYPE CMB_OS_PLATFORM_RTT or CMB_OS_PLATFORM_UCOSII or CMB_OS_PLATFORM_UCOSIII or CMB_OS_PLATFORM_FREERTOS or CMB_OS_PLATFORM_RTX5 */
#define CMB_OS_PLATFORM_TYPE CMB_OS_PLATFORM_ONEOS
/* cpu platform type, must config by user */
#define CMB_CPU_PLATFORM_TYPE /* CMB_CPU_ARM_CORTEX_M0 or CMB_CPU_ARM_CORTEX_M3 or CMB_CPU_ARM_CORTEX_M4 or CMB_CPU_ARM_CORTEX_M7 */
#define CMB_CPU_PLATFORM_TYPE CMB_CPU_ARM_CORTEX_M0
/* enable dump stack information */
/* #define CMB_USING_DUMP_STACK_INFO */
#define CMB_USING_DUMP_STACK_INFO
/* language of print information */
/* #define CMB_PRINT_LANGUAGE CMB_PRINT_LANGUAGE_ENGLISH(default) or CMB_PRINT_LANGUAGE_CHINESE */
#define CMB_PRINT_LANGUAGE CMB_PRINT_LANGUAGE_ENGLISH
#endif /* _CMB_CFG_H_ */

@ -47,6 +47,7 @@
#define CMB_OS_PLATFORM_UCOSIII 2
#define CMB_OS_PLATFORM_FREERTOS 3
#define CMB_OS_PLATFORM_RTX5 4
#define CMB_OS_PLATFORM_ONEOS 5
#define CMB_PRINT_LANGUAGE_ENGLISH 0
#define CMB_PRINT_LANGUAGE_CHINESE 1
@ -333,12 +334,16 @@ if (!(EXPR)) \
#elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_UCOSIII)
#include <os.h>
#elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_FREERTOS)
#include <FreeRTOS.h>
#include <FreeRTOS.h>
extern uint32_t *vTaskStackAddr(void);/* need to modify the FreeRTOS/tasks source code */
extern uint32_t vTaskStackSize(void);
extern char * vTaskName(void);
#elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_RTX5)
#include "rtx_os.h"
#elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_ONEOS)
#include <os_types.h>
#include <os_task.h>
#include <os_util.h>
#else
#error "not supported OS type"
#endif /* (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_RTT) */
@ -376,24 +381,24 @@ if (!(EXPR)) \
}
#elif defined(__ICCARM__)
/* IAR iccarm specific functions */
/* Close Raw Asm Code Warning */
#pragma diag_suppress=Pe940
/* Close Raw Asm Code Warning */
#pragma diag_suppress=Pe940
static uint32_t cmb_get_msp(void)
{
__asm("mrs r0, msp");
__asm("bx lr");
__asm("bx lr");
}
static uint32_t cmb_get_psp(void)
{
__asm("mrs r0, psp");
__asm("bx lr");
__asm("bx lr");
}
static uint32_t cmb_get_sp(void)
{
__asm("mov r0, sp");
__asm("bx lr");
__asm("bx lr");
}
#pragma diag_default=Pe940
#pragma diag_default=Pe940
#elif defined(__GNUC__)
__attribute__( ( always_inline ) ) static inline uint32_t cmb_get_msp(void) {
register uint32_t result;

Loading…
Cancel
Save