fix all board compile for v3.0

fix all board compile for v3.0
This commit is contained in:
supowang
2021-08-11 16:30:15 +08:00
parent 1f694e2156
commit 8253a953bd
615 changed files with 96466 additions and 80894 deletions

View File

@@ -1,38 +0,0 @@
###################################################################
#automatic detection QTOP and LOCALDIR
CUR_DIR := $(patsubst %/,%,$(dir $(realpath $(firstword $(MAKEFILE_LIST)))))
TRYQTOP := $(shell if [ -n "$$QTOP" ] ; then\
echo $$QTOP;\
else\
cd $(CUR_DIR); while /usr/bin/test ! -d qmk ; do \
dir=`cd ../;pwd`; \
if [ "$$dir" = "/" ] ; then \
echo Cannot find QTOP in $(firstword $(MAKEFILE_LIST)) 1>&2; \
exit 1; \
fi ; \
cd $$dir; \
done ; \
pwd; \
fi)
QTOP ?= $(realpath ${TRYQTOP})
ifeq ($(QTOP),)
$(error Please run this in a tree)
endif
LOCALDIR = $(patsubst %/,%,$(subst $(realpath $(QTOP))/,,$(CUR_DIR)))
####################################################################
TREE_LIB_ENABLE=1
lib=
subdirs=
CFGFLAGS += -I${QTOP}/kernel/core/include
CFGFLAGS += -I${QTOP}/kernel/evtdrv/include
CFGFLAGS += -I${QTOP}/kernel/hal/include
CFGFLAGS += -I${QTOP}/kernel/pm/include
include ${QTOP}/qmk/generic/Make.tpl

View File

@@ -1,33 +0,0 @@
/*----------------------------------------------------------------------------
* Tencent is pleased to support the open source community by making TencentOS
* available.
*
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
* If you have downloaded a copy of the TencentOS binary from Tencent, please
* note that the TencentOS binary is licensed under the BSD 3-Clause License.
*
* If you have downloaded a copy of the TencentOS source code from Tencent,
* please note that TencentOS source code is licensed under the BSD 3-Clause
* License, except for the third-party components listed below which are
* subject to different license terms. Your integration of TencentOS into your
* own projects may require compliance with the BSD 3-Clause License, as well
* as the other licenses applicable to the third-party components included
* within TencentOS.
*---------------------------------------------------------------------------*/
#ifndef _TOS_EVTDRV_H_
#define _TOS_EVTDRV_H_
#include "tos_k.h"
#include "tos_evtdrv_err.h"
#include "tos_evtdrv_types.h"
#include "tos_evtdrv_event.h"
#include "tos_evtdrv_msg.h"
#include "tos_evtdrv_timer.h"
#include "tos_evtdrv_task.h"
#include "tos_evtdrv_tick.h"
#include "tos_evtdrv_sys.h"
#include "tos_evtdrv_global.h"
#endif

View File

@@ -1,37 +0,0 @@
/*----------------------------------------------------------------------------
* Tencent is pleased to support the open source community by making TencentOS
* available.
*
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
* If you have downloaded a copy of the TencentOS binary from Tencent, please
* note that the TencentOS binary is licensed under the BSD 3-Clause License.
*
* If you have downloaded a copy of the TencentOS source code from Tencent,
* please note that TencentOS source code is licensed under the BSD 3-Clause
* License, except for the third-party components listed below which are
* subject to different license terms. Your integration of TencentOS into your
* own projects may require compliance with the BSD 3-Clause License, as well
* as the other licenses applicable to the third-party components included
* within TencentOS.
*---------------------------------------------------------------------------*/
#ifndef _TOS_EVTDRV_ERR_H_
#define _TOS_EVTDRV_ERR_H_
typedef enum evtdrv_err_en {
EVTDRV_ERR_NONE = 0x0u,
EVTDRV_ERR_MEM_ALLOC_FAILED = 0x1u,
EVTDRV_ERR_PTR_NULL = 0x2u,
EVTDRV_ERR_MSG_BUSY = 0x3u,
EVTDRV_ERR_TASK_INVALID = 0x4u,
EVTDRV_ERR_MMHEAP_INIT_FAILED = 0x5u,
EVTDRV_ERR_EVENT_INVALID = 0x10u,
EVTDRV_ERR_EVENT_OVERFLOW = 0x11u,
EVTDRV_ERR_TIMER_ALREADY_EXIST = 0x20u,
EVTDRV_ERR_TIMER_INACTIVE = 0x21u,
} evtdrv_err_t;
#endif

View File

@@ -1,88 +0,0 @@
/*----------------------------------------------------------------------------
* Tencent is pleased to support the open source community by making TencentOS
* available.
*
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
* If you have downloaded a copy of the TencentOS binary from Tencent, please
* note that the TencentOS binary is licensed under the BSD 3-Clause License.
*
* If you have downloaded a copy of the TencentOS source code from Tencent,
* please note that TencentOS source code is licensed under the BSD 3-Clause
* License, except for the third-party components listed below which are
* subject to different license terms. Your integration of TencentOS into your
* own projects may require compliance with the BSD 3-Clause License, as well
* as the other licenses applicable to the third-party components included
* within TencentOS.
*---------------------------------------------------------------------------*/
#ifndef _TOS_EVTDRV_EVENT_H_
#define _TOS_EVTDRV_EVENT_H_
#if TOS_CFG_EVENT_DRIVEN_EN > 0u
typedef uint16_t evtdrv_event_flag_t;
typedef uint16_t evtdrv_event_nesting_t;
#define EVTDRV_SYS_EVENT_MASK (evtdrv_event_flag_t)(0x3 << (sizeof(evtdrv_event_flag_t) * 8 - 2))
#define EVTDRV_USR_EVENT_MASK (evtdrv_event_flag_t)(~(EVTDRV_SYS_EVENT_MASK))
/* highest two bits are reserved for system event
0x8000 init all tasks
0x4000 msg received
*/
#define TOS_EVTDRV_EVENT_NONE (evtdrv_event_flag_t)0x0u
#define TOS_EVTDRV_SYS_EVENT_INIT (evtdrv_event_flag_t)(0x2 << (sizeof(evtdrv_event_flag_t) * 8 - 2))
#define TOS_EVTDRV_SYS_EVENT_MSG (evtdrv_event_flag_t)(0x1 << (sizeof(evtdrv_event_flag_t) * 8 - 2))
typedef struct evtdrv_event_st {
evtdrv_event_flag_t flags;
evtdrv_event_nesting_t nesting[sizeof(evtdrv_event_flag_t) * 8];
} evtdrv_event_t;
/**
* @brief Set event to the target task.
* Set event to the target task, next time the target task is "scheduled", the task will handle the event.
*
* @attention None
*
* @param[in] task_id id of the target task.
* @param[in] event_flags the event flags set to the task
*
* @return errcode
* @retval #EVTDRV_ERR_TASK_INVALID task id is invalid.
* @retval #EVTDRV_ERR_NONE return successfully.
*/
__API__ evtdrv_err_t tos_evtdrv_event_set(evtdrv_task_id_t task_id, evtdrv_event_flag_t event_flags);
/**
* @brief Reset the event of the target task.
*
* @attention None
*
* @param[in] task_id id of the target task.
* @param[in] event_flags the event flags reset of the task
*
* @return errcode
* @retval #EVTDRV_ERR_TASK_INVALID task id is invalid.
* @retval #EVTDRV_ERR_NONE return successfully.
*/
__API__ evtdrv_err_t tos_evtdrv_event_reset(evtdrv_task_id_t task_id, evtdrv_event_flag_t event_flags);
__KNL__ evtdrv_err_t evtdrv_event_init(void);
__KNL__ evtdrv_event_flag_t evtdrv_event_fetch(evtdrv_task_id_t *task_id);
__STATIC_INLINE__ evtdrv_bool_t evtdrv_event_is_usr(evtdrv_event_flag_t event_flag)
{
return event_flag & EVTDRV_USR_EVENT_MASK;
}
__STATIC_INLINE__ evtdrv_bool_t evtdrv_event_is_sys(evtdrv_event_flag_t event_flag)
{
return event_flag & EVTDRV_SYS_EVENT_MASK;
}
#endif /* TOS_CFG_EVENT_DRIVEN_EN */
#endif /* _TOS_EVTDRV_EVENT_H_ */

View File

@@ -1,41 +0,0 @@
/*----------------------------------------------------------------------------
* Tencent is pleased to support the open source community by making TencentOS
* available.
*
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
* If you have downloaded a copy of the TencentOS binary from Tencent, please
* note that the TencentOS binary is licensed under the BSD 3-Clause License.
*
* If you have downloaded a copy of the TencentOS source code from Tencent,
* please note that TencentOS source code is licensed under the BSD 3-Clause
* License, except for the third-party components listed below which are
* subject to different license terms. Your integration of TencentOS into your
* own projects may require compliance with the BSD 3-Clause License, as well
* as the other licenses applicable to the third-party components included
* within TencentOS.
*---------------------------------------------------------------------------*/
#ifndef _TOS_EVTDRV_GLOBAL_H_
#define _TOS_EVTDRV_GLOBAL_H_
#if TOS_CFG_EVENT_DRIVEN_EN > 0u
extern evtdrv_task_entry_t *evtdrv_task_table;
extern evtdrv_ttb_sz_t evtdrv_task_table_size;
extern evtdrv_task_id_t evtdrv_curr_task;
extern evtdrv_event_t *evtdrv_events;
extern k_list_t evtdrv_msg_list;
extern k_list_t evtdrv_timer_list;
extern k_evtdrv_poll_t evtdrv_poll;
extern evtdrv_tick_t evtdrv_tick_count;
#endif /* TOS_CFG_EVENT_DRIVEN_EN */
#endif /* _TOS_EVTDRV_GLOBAL_H_ */

View File

@@ -1,86 +0,0 @@
/*----------------------------------------------------------------------------
* Tencent is pleased to support the open source community by making TencentOS
* available.
*
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
* If you have downloaded a copy of the TencentOS binary from Tencent, please
* note that the TencentOS binary is licensed under the BSD 3-Clause License.
*
* If you have downloaded a copy of the TencentOS source code from Tencent,
* please note that TencentOS source code is licensed under the BSD 3-Clause
* License, except for the third-party components listed below which are
* subject to different license terms. Your integration of TencentOS into your
* own projects may require compliance with the BSD 3-Clause License, as well
* as the other licenses applicable to the third-party components included
* within TencentOS.
*---------------------------------------------------------------------------*/
#ifndef _TOS_EVTDRV_MSG_H_
#define _TOS_EVTDRV_MSG_H_
#if TOS_CFG_EVENT_DRIVEN_EN > 0u
typedef uint16_t evtdrv_msg_len_t;
typedef uint8_t *evtdrv_msg_body_t;
typedef struct evtdrv_message_header_st {
k_list_t list;
evtdrv_task_id_t dst_task_id; // destination task id
evtdrv_msg_len_t len;
} evtdrv_msg_hdr_t;
#define EVTDRV_MSG_BODY2HDR(msg_body) ((evtdrv_msg_hdr_t *)((uint8_t *)msg_body - sizeof(evtdrv_msg_hdr_t)))
#define EVTDRV_MSG_LEN(msg_len) (sizeof(evtdrv_msg_hdr_t) + msg_len)
#define EVTDRV_MSG_HDR2BODY(msg_hdr) ((evtdrv_msg_body_t)((evtdrv_msg_hdr_t *)msg_hdr + 1))
/**
* @brief Allocate a message body.
* Allocate a message body as a payload to hold the message content.
*
* @attention None
*
* @param[in] msg_len the length of the message payload.
*
* @return the message body allocated.
* @retval #NULL allocate failed.
* @retval #NO-NULL allocate successfully.
*/
__API__ evtdrv_msg_body_t tos_evtdrv_msg_alloc(evtdrv_msg_len_t msg_len);
/**
* @brief Free a message body.
*
* @attention if you wanna free a message body, the message must be "dequeued"(already received by the target task)
*
* @param[in] msg_body message body to free.
*
* @return errcode
* @retval #EVTDRV_ERR_PTR_NULL message body is NULL.
* @retval #EVTDRV_ERR_MSG_BUSY message is still in the message queue(not received).
* @retval #EVTDRV_ERR_NONE free successfully.
*/
__API__ evtdrv_err_t tos_evtdrv_msg_free(evtdrv_msg_body_t msg_body);
/**
* @brief Send a message to the target task.
*
* @attention next time the target task should be "wakeup" by the event of TOS_EVTDRV_SYS_EVENT_MSG.
*
* @param[in] task_id id of the target task.
* @param[in] msg_body message body to send.
*
* @return errcode
* @retval #EVTDRV_ERR_PTR_NULL message body is NULL.
* @retval #EVTDRV_ERR_TASK_INVALID target task id is invalid.
* @retval #EVTDRV_ERR_NONE send successfully.
*/
__API__ evtdrv_err_t tos_evtdrv_msg_send(evtdrv_task_id_t dst_task_id, evtdrv_msg_body_t msg_body);
__API__ evtdrv_msg_body_t tos_evtdrv_msg_recv(void);
__KNL__ void evtdrv_msg_init(void);
#endif /* TOS_CFG_EVENT_DRIVEN_EN */
#endif /* _TOS_EVTDRV_MSG_H_ */

View File

@@ -1,53 +0,0 @@
/*----------------------------------------------------------------------------
* Tencent is pleased to support the open source community by making TencentOS
* available.
*
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
* If you have downloaded a copy of the TencentOS binary from Tencent, please
* note that the TencentOS binary is licensed under the BSD 3-Clause License.
*
* If you have downloaded a copy of the TencentOS source code from Tencent,
* please note that TencentOS source code is licensed under the BSD 3-Clause
* License, except for the third-party components listed below which are
* subject to different license terms. Your integration of TencentOS into your
* own projects may require compliance with the BSD 3-Clause License, as well
* as the other licenses applicable to the third-party components included
* within TencentOS.
*---------------------------------------------------------------------------*/
#ifndef _TOS_EVTDRV_SYS_H_
#define _TOS_EVTDRV_SYS_H_
#if TOS_CFG_EVENT_DRIVEN_EN > 0u
typedef void (*k_evtdrv_poll_t)(void);
/**
* @brief Initialize the event-driven system.
*
* @attention event-driven is a simplified schedule model to support the none-context-switch-based multi-task programming.("the big while 1")
*
* @param[in] tasks array of the tasks.
* @param[in] task_table_size size of the tasks.
* @param[in] poll the user defined poll function.
*
* @return errcode
* @retval #EVTDRV_ERR_MMHEAP_NOT_ENABLED mmheap is not enabled.
* @retval #EVTDRV_ERR_MEM_ALLOC_FAILED memory allocate failed.
* @retval #EVTDRV_ERR_NONE initialize successfully.
*/
__API__ evtdrv_err_t tos_evtdrv_sys_init(evtdrv_task_entry_t tasks[], evtdrv_ttb_sz_t task_table_size, k_evtdrv_poll_t poll);
/**
* @brief Start the event-driven system.
*
* @attention start the event-driven multi-task "schedule".
*
* @return None
*/
__API__ void tos_evtdrv_sys_start(void);
#endif /* TOS_CFG_EVENT_DRIVEN_EN */
#endif /* _TOS_EVTDRV_SYS_H_ */

View File

@@ -1,48 +0,0 @@
/*----------------------------------------------------------------------------
* Tencent is pleased to support the open source community by making TencentOS
* available.
*
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
* If you have downloaded a copy of the TencentOS binary from Tencent, please
* note that the TencentOS binary is licensed under the BSD 3-Clause License.
*
* If you have downloaded a copy of the TencentOS source code from Tencent,
* please note that TencentOS source code is licensed under the BSD 3-Clause
* License, except for the third-party components listed below which are
* subject to different license terms. Your integration of TencentOS into your
* own projects may require compliance with the BSD 3-Clause License, as well
* as the other licenses applicable to the third-party components included
* within TencentOS.
*---------------------------------------------------------------------------*/
#ifndef _TOS_EVTDRV_TASK_H_
#define _TOS_EVTDRV_TASK_H_
#if TOS_CFG_EVENT_DRIVEN_EN > 0u
#define TOS_EVTDRV_TASK_ID_NONE ((evtdrv_task_id_t)-1)
// return event handled
typedef evtdrv_event_flag_t (*evtdrv_task_entry_t)(evtdrv_event_flag_t event_flags);
#define EVTDRV_TASK_ID2TASK(task_id) (evtdrv_task_entry_t)(evtdrv_task_table[task_id])
/**
* @brief Get the actived("running") task id.
*
* @attention
*
* @return the actived("running") task id.
*/
__API__ evtdrv_task_id_t tos_evtdrv_task_self(void);
__KNL__ evtdrv_bool_t evtdrv_task_id_is_invalid(evtdrv_task_id_t task_id);
__KNL__ evtdrv_bool_t evtdrv_task_is_self(evtdrv_task_id_t task_id);
__KNL__ void evtdrv_task_init(void);
#endif /* TOS_CFG_EVENT_DRIVEN_EN */
#endif /* _TOS_EVTDRV_TASK_H_ */

View File

@@ -1,62 +0,0 @@
/*----------------------------------------------------------------------------
* Tencent is pleased to support the open source community by making TencentOS
* available.
*
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
* If you have downloaded a copy of the TencentOS binary from Tencent, please
* note that the TencentOS binary is licensed under the BSD 3-Clause License.
*
* If you have downloaded a copy of the TencentOS source code from Tencent,
* please note that TencentOS source code is licensed under the BSD 3-Clause
* License, except for the third-party components listed below which are
* subject to different license terms. Your integration of TencentOS into your
* own projects may require compliance with the BSD 3-Clause License, as well
* as the other licenses applicable to the third-party components included
* within TencentOS.
*---------------------------------------------------------------------------*/
#ifndef _TOS_EVTDRV_TICK_H_
#define _TOS_EVTDRV_TICK_H_
#if TOS_CFG_EVENT_DRIVEN_EN > 0u
/**
* @brief Get the current systick count.
*
* @attention
*
* @return current systick count.
*/
__API__ evtdrv_tick_t tos_evtdrv_systick_get(void);
/**
* @brief tick interrupt handler.
*
* @attention if you wanna use event-driven timer, you must deal with the tick.
*
* @return None.
*/
__API__ void tos_evtdrv_tick_handler(void);
/**
* @brief Convert tick count to milli-seconds.
*
* @attention
*
* @return the milli-seconds equals to the tick count.
*/
__API__ evtdrv_time_t tos_evtdrv_tick2millisec(evtdrv_tick_t tick);
/**
* @brief Convert milli-seconds to tick count.
*
* @attention
*
* @return the tick count equals to the tick count.
*/
__API__ evtdrv_tick_t tos_evtdrv_millisec2tick(evtdrv_time_t ms);
#endif /* TOS_CFG_EVENT_DRIVEN_EN */
#endif /* _TOS_EVTDRV_TICK_H_ */

View File

@@ -1,100 +0,0 @@
/*----------------------------------------------------------------------------
* Tencent is pleased to support the open source community by making TencentOS
* available.
*
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
* If you have downloaded a copy of the TencentOS binary from Tencent, please
* note that the TencentOS binary is licensed under the BSD 3-Clause License.
*
* If you have downloaded a copy of the TencentOS source code from Tencent,
* please note that TencentOS source code is licensed under the BSD 3-Clause
* License, except for the third-party components listed below which are
* subject to different license terms. Your integration of TencentOS into your
* own projects may require compliance with the BSD 3-Clause License, as well
* as the other licenses applicable to the third-party components included
* within TencentOS.
*---------------------------------------------------------------------------*/
#ifndef _TOS_EVTDRV_TIMER_H_
#define _TOS_EVTDRV_TIMER_H_
#define EVTDRV_TIME_MILLISEC_PER_SEC (1000u)
typedef enum evtdrv_timer_option_en {
EVTDRV_TIMER_OPT_ONESHOT,
EVTDRV_TIMER_OPT_PERIODIC,
} evtdrv_timer_opt_t;
typedef void (*evtdrv_timer_callback_t)(void *arg);
typedef struct evtdrv_timer_st {
evtdrv_timer_callback_t cb;
void *cb_arg;
k_list_t list;
evtdrv_tick_t expires;
evtdrv_tick_t period;
evtdrv_timer_opt_t opt;
} evtdrv_timer_t;
typedef struct evtdrv_timer_control_st {
evtdrv_tick_t next_expires;
evtdrv_tick_t list;
} evtdrv_timer_ctl_t;
/**
* @brief Create a timer.
* Create a timer.
*
* @attention
*
* @param[in] tmr pointer to the handler of the timer.
* @param[in] callback callback function called when the timer expires.
* @param[in] cb_arg argument for the callback.
* @param[in] opt option for the function call.
*
* @return errcode
* @retval #EVTDRV_ERR_PTR_NULL task_id is invalid.
* @retval #EVTDRV_ERR_NONE event_flags is not valid for user use.
*/
__API__ evtdrv_err_t tos_evtdrv_timer_create(evtdrv_timer_t *tmr,
evtdrv_timer_callback_t callback,
void *cb_arg,
evtdrv_timer_opt_t opt);
/**
* @brief Start a timer.
* Start the timer to run.
*
* @attention None
*
* @param[in] tmr pointer to the handler of the timer.
* @param[in] timeout how much time(in evtdrv_tick_t) the timer would be expired.
*
* @return errcode
* @retval #EVTDRV_ERR_PTR_NULL tmr is a NULL pointer.
* @retval #EVTDRV_ERR_TIMER_ALREADY_EXIST tmr is already exist.
* @retval #EVTDRV_ERR_NONE return successfully.
*/
__API__ evtdrv_err_t tos_evtdrv_timer_start(evtdrv_timer_t *tmr, evtdrv_tick_t timeout);
/**
* @brief Stop a timer.
* Stop the timer from running.
*
* @attention None
*
* @param[in] tmr pointer to the handler of the timer.
*
* @return errcode
* @retval #EVTDRV_ERR_PTR_NULL tmr is a NULL pointer.
* @retval #EVTDRV_ERR_TIMER_INACTIVE the timer is not active yet.
* @retval #EVTDRV_ERR_NONE return successfully.
*/
__API__ evtdrv_err_t tos_evtdrv_timer_stop(evtdrv_timer_t *tmr);
__KNL__ void evtdrv_timer_update(void);
#endif /* _TOS_EVTDRV_TIMER_H_ */

View File

@@ -1,28 +0,0 @@
/*----------------------------------------------------------------------------
* Tencent is pleased to support the open source community by making TencentOS
* available.
*
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
* If you have downloaded a copy of the TencentOS binary from Tencent, please
* note that the TencentOS binary is licensed under the BSD 3-Clause License.
*
* If you have downloaded a copy of the TencentOS source code from Tencent,
* please note that TencentOS source code is licensed under the BSD 3-Clause
* License, except for the third-party components listed below which are
* subject to different license terms. Your integration of TencentOS into your
* own projects may require compliance with the BSD 3-Clause License, as well
* as the other licenses applicable to the third-party components included
* within TencentOS.
*---------------------------------------------------------------------------*/
#ifndef _TOS_EVTDRV_TYPES_H_
#define _TOS_EVTDRV_TYPES_H_
typedef int8_t evtdrv_bool_t;
typedef uint8_t evtdrv_task_id_t; // task id type
typedef uint8_t evtdrv_ttb_sz_t; // task table size type
typedef uint64_t evtdrv_tick_t;
typedef uint32_t evtdrv_time_t;
#endif

View File

@@ -1,128 +0,0 @@
/*----------------------------------------------------------------------------
* Tencent is pleased to support the open source community by making TencentOS
* available.
*
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
* If you have downloaded a copy of the TencentOS binary from Tencent, please
* note that the TencentOS binary is licensed under the BSD 3-Clause License.
*
* If you have downloaded a copy of the TencentOS source code from Tencent,
* please note that TencentOS source code is licensed under the BSD 3-Clause
* License, except for the third-party components listed below which are
* subject to different license terms. Your integration of TencentOS into your
* own projects may require compliance with the BSD 3-Clause License, as well
* as the other licenses applicable to the third-party components included
* within TencentOS.
*---------------------------------------------------------------------------*/
#include "tos_evtdrv.h"
#if TOS_CFG_EVENT_DRIVEN_EN > 0u
__API__ evtdrv_err_t tos_evtdrv_event_set(evtdrv_task_id_t task_id, evtdrv_event_flag_t event_flags)
{
TOS_CPU_CPSR_ALLOC();
uint8_t i = 0;
evtdrv_event_t *event;
evtdrv_event_flag_t flag;
if (evtdrv_task_id_is_invalid(task_id)) {
return EVTDRV_ERR_TASK_INVALID;
}
TOS_CPU_INT_DISABLE();
event = &evtdrv_events[task_id];
for (i = 0; i < sizeof(evtdrv_event_flag_t) * 8; ++i) {
flag = (1 << i);
if (event_flags & flag) {
if (event->nesting[i] == (evtdrv_event_nesting_t)-1) {
continue;
}
++event->nesting[i];
event->flags |= flag;
}
}
TOS_CPU_INT_ENABLE();
return EVTDRV_ERR_NONE;
}
__API__ evtdrv_err_t tos_evtdrv_event_reset(evtdrv_task_id_t task_id, evtdrv_event_flag_t event_flags)
{
TOS_CPU_CPSR_ALLOC();
uint8_t i = 0;
evtdrv_event_t *event;
evtdrv_event_flag_t flag;
if (evtdrv_task_id_is_invalid(task_id)) {
return EVTDRV_ERR_TASK_INVALID;
}
TOS_CPU_INT_DISABLE();
event = &evtdrv_events[task_id];
for (i = 0; i < sizeof(evtdrv_event_flag_t) * 8; ++i) {
flag = (1 << i);
if (event_flags & flag) {
if (!(event->flags & flag)) {
continue;
}
if (event->nesting[i] > (evtdrv_event_nesting_t)0u) {
--event->nesting[i];
}
if (event->nesting[i] == (evtdrv_event_nesting_t)0u) {
event->flags &= ~flag;
}
}
}
TOS_CPU_INT_ENABLE();
return EVTDRV_ERR_NONE;
}
__KNL__ evtdrv_err_t evtdrv_event_init(void)
{
evtdrv_task_id_t i;
evtdrv_event_t *event;
evtdrv_events = (evtdrv_event_t *)tos_mmheap_calloc(evtdrv_task_table_size, sizeof(evtdrv_event_t));
if (!evtdrv_events) {
return EVTDRV_ERR_MEM_ALLOC_FAILED;
}
for (i = 0; i < evtdrv_task_table_size; ++i) {
event = &evtdrv_events[i];
event->flags = TOS_EVTDRV_EVENT_NONE;
}
return EVTDRV_ERR_NONE;
}
__KNL__ evtdrv_event_flag_t evtdrv_event_fetch(evtdrv_task_id_t *task_id)
{
evtdrv_task_id_t i;
evtdrv_event_t *event;
for (i = 0; i < evtdrv_task_table_size; ++i) {
event = &evtdrv_events[i];
if (event->flags != TOS_EVTDRV_EVENT_NONE) {
if (task_id) {
*task_id = i;
}
return event->flags;
}
}
return TOS_EVTDRV_EVENT_NONE;
}
#endif

View File

@@ -1,38 +0,0 @@
/*----------------------------------------------------------------------------
* Tencent is pleased to support the open source community by making TencentOS
* available.
*
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
* If you have downloaded a copy of the TencentOS binary from Tencent, please
* note that the TencentOS binary is licensed under the BSD 3-Clause License.
*
* If you have downloaded a copy of the TencentOS source code from Tencent,
* please note that TencentOS source code is licensed under the BSD 3-Clause
* License, except for the third-party components listed below which are
* subject to different license terms. Your integration of TencentOS into your
* own projects may require compliance with the BSD 3-Clause License, as well
* as the other licenses applicable to the third-party components included
* within TencentOS.
*---------------------------------------------------------------------------*/
#include "tos_evtdrv.h"
#if TOS_CFG_EVENT_DRIVEN_EN > 0u
evtdrv_task_entry_t *evtdrv_task_table = K_NULL;
evtdrv_ttb_sz_t evtdrv_task_table_size = 0;
evtdrv_task_id_t evtdrv_curr_task = TOS_EVTDRV_TASK_ID_NONE;
evtdrv_event_t *evtdrv_events = K_NULL;
k_evtdrv_poll_t evtdrv_poll = K_NULL;
evtdrv_tick_t evtdrv_tick_count = (evtdrv_tick_t)0u;
TOS_LIST_DEFINE(evtdrv_msg_list);
TOS_LIST_DEFINE(evtdrv_timer_list);
#endif

View File

@@ -1,121 +0,0 @@
/*----------------------------------------------------------------------------
* Tencent is pleased to support the open source community by making TencentOS
* available.
*
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
* If you have downloaded a copy of the TencentOS binary from Tencent, please
* note that the TencentOS binary is licensed under the BSD 3-Clause License.
*
* If you have downloaded a copy of the TencentOS source code from Tencent,
* please note that TencentOS source code is licensed under the BSD 3-Clause
* License, except for the third-party components listed below which are
* subject to different license terms. Your integration of TencentOS into your
* own projects may require compliance with the BSD 3-Clause License, as well
* as the other licenses applicable to the third-party components included
* within TencentOS.
*---------------------------------------------------------------------------*/
#include "tos_evtdrv.h"
#if TOS_CFG_EVENT_DRIVEN_EN > 0u
__API__ evtdrv_msg_body_t tos_evtdrv_msg_alloc(evtdrv_msg_len_t msg_len)
{
evtdrv_msg_hdr_t *msg_hdr = K_NULL;
if (!msg_len) {
return K_NULL;
}
msg_hdr = (evtdrv_msg_hdr_t *)tos_mmheap_alloc(EVTDRV_MSG_LEN(msg_len));
if (!msg_hdr) {
return K_NULL;
}
tos_list_init(&msg_hdr->list);
msg_hdr->len = msg_len;
msg_hdr->dst_task_id = TOS_EVTDRV_TASK_ID_NONE;
return EVTDRV_MSG_HDR2BODY(msg_hdr);
}
__API__ evtdrv_err_t tos_evtdrv_msg_free(evtdrv_msg_body_t msg_body)
{
evtdrv_msg_hdr_t *msg_hdr = K_NULL;
if (!msg_body) {
return EVTDRV_ERR_PTR_NULL;
}
msg_hdr = EVTDRV_MSG_BODY2HDR(msg_body);
if (msg_hdr->dst_task_id != TOS_EVTDRV_TASK_ID_NONE ||
!tos_list_empty(&msg_hdr->list)) {
return EVTDRV_ERR_MSG_BUSY;
}
tos_mmheap_free(msg_hdr);
return EVTDRV_ERR_NONE;
}
__API__ evtdrv_err_t tos_evtdrv_msg_send(evtdrv_task_id_t dst_task_id, evtdrv_msg_body_t msg_body)
{
evtdrv_msg_hdr_t *msg_hdr = K_NULL;
if (!msg_body) {
return EVTDRV_ERR_PTR_NULL;
}
if (evtdrv_task_id_is_invalid(dst_task_id)) {
tos_evtdrv_msg_free(msg_body);
return EVTDRV_ERR_TASK_INVALID;
}
msg_hdr = EVTDRV_MSG_BODY2HDR(msg_body);
msg_hdr->dst_task_id = dst_task_id;
tos_list_add(&msg_hdr->list, &evtdrv_msg_list);
tos_evtdrv_event_set(dst_task_id, TOS_EVTDRV_SYS_EVENT_MSG);
return EVTDRV_ERR_NONE;
}
__STATIC_INLINE__ void evtdrv_msg_prepare4use(evtdrv_msg_hdr_t *msg_hdr)
{
tos_list_del_init(&msg_hdr->list);
msg_hdr->dst_task_id = TOS_EVTDRV_TASK_ID_NONE;
}
__API__ evtdrv_msg_body_t tos_evtdrv_msg_recv(void)
{
TOS_CPU_CPSR_ALLOC();
evtdrv_msg_hdr_t *msg_hdr, *tmp;
TOS_CPU_INT_DISABLE();
TOS_LIST_FOR_EACH_ENTRY_SAFE(msg_hdr, tmp, evtdrv_msg_hdr_t, list, &evtdrv_msg_list) {
if (!evtdrv_task_is_self(msg_hdr->dst_task_id)) {
continue;
}
evtdrv_msg_prepare4use(msg_hdr);
tos_evtdrv_event_set(tos_evtdrv_task_self(), TOS_EVTDRV_SYS_EVENT_MSG);
TOS_CPU_INT_ENABLE();
return EVTDRV_MSG_HDR2BODY(msg_hdr);
}
TOS_CPU_INT_ENABLE();
tos_evtdrv_event_reset(tos_evtdrv_task_self(), TOS_EVTDRV_SYS_EVENT_MSG);
return K_NULL;
}
__KNL__ void evtdrv_msg_init(void)
{
tos_list_init(&evtdrv_msg_list);
}
#endif

View File

@@ -1,89 +0,0 @@
/*----------------------------------------------------------------------------
* Tencent is pleased to support the open source community by making TencentOS
* available.
*
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
* If you have downloaded a copy of the TencentOS binary from Tencent, please
* note that the TencentOS binary is licensed under the BSD 3-Clause License.
*
* If you have downloaded a copy of the TencentOS source code from Tencent,
* please note that TencentOS source code is licensed under the BSD 3-Clause
* License, except for the third-party components listed below which are
* subject to different license terms. Your integration of TencentOS into your
* own projects may require compliance with the BSD 3-Clause License, as well
* as the other licenses applicable to the third-party components included
* within TencentOS.
*---------------------------------------------------------------------------*/
#include "tos_evtdrv.h"
#if TOS_CFG_EVENT_DRIVEN_EN > 0u
__API__ evtdrv_err_t tos_evtdrv_sys_init(evtdrv_task_entry_t tasks[], evtdrv_ttb_sz_t task_table_size, k_evtdrv_poll_t poll)
{
k_err_t kerr;
evtdrv_err_t err;
evtdrv_task_table = &tasks[0];
evtdrv_task_table_size = task_table_size;
evtdrv_poll = poll;
#if TOS_CFG_MMHEAP_EN > 0
#if TOS_CFG_MMHEAP_DEFAULT_POOL_EN > 0u
kerr = mmheap_init_with_pool(k_mmheap_default_pool, TOS_CFG_MMHEAP_DEFAULT_POOL_SIZE);
#else
kerr = mmheap_init();
#endif
if (kerr != K_ERR_NONE) {
return EVTDRV_ERR_MMHEAP_INIT_FAILED;
}
#endif
err = evtdrv_event_init();
if (err != EVTDRV_ERR_NONE) {
return err;
}
evtdrv_msg_init();
evtdrv_task_init();
return EVTDRV_ERR_NONE;
}
__STATIC__ void evtdrv_sys_run(void)
{
evtdrv_event_flag_t event_flag = TOS_EVTDRV_EVENT_NONE;
evtdrv_task_id_t task_id = TOS_EVTDRV_TASK_ID_NONE;
evtdrv_timer_update();
if (evtdrv_poll) {
evtdrv_poll();
}
event_flag = evtdrv_event_fetch(&task_id);
if (event_flag != TOS_EVTDRV_EVENT_NONE) {
evtdrv_curr_task = task_id;
event_flag = (EVTDRV_TASK_ID2TASK(task_id))(event_flag);
evtdrv_curr_task = TOS_EVTDRV_TASK_ID_NONE;
// after task process, event that the task handled is returned.
tos_evtdrv_event_reset(task_id, event_flag);
} else {
#if TOS_CFG_PWR_MGR_EN > 0u
pm_power_manager();
#endif
}
}
__API__ void tos_evtdrv_sys_start(void)
{
while (K_TRUE) {
evtdrv_sys_run();
}
}
#endif

View File

@@ -1,47 +0,0 @@
/*----------------------------------------------------------------------------
* Tencent is pleased to support the open source community by making TencentOS
* available.
*
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
* If you have downloaded a copy of the TencentOS binary from Tencent, please
* note that the TencentOS binary is licensed under the BSD 3-Clause License.
*
* If you have downloaded a copy of the TencentOS source code from Tencent,
* please note that TencentOS source code is licensed under the BSD 3-Clause
* License, except for the third-party components listed below which are
* subject to different license terms. Your integration of TencentOS into your
* own projects may require compliance with the BSD 3-Clause License, as well
* as the other licenses applicable to the third-party components included
* within TencentOS.
*---------------------------------------------------------------------------*/
#include "tos_evtdrv.h"
#if TOS_CFG_EVENT_DRIVEN_EN > 0u
__API__ evtdrv_task_id_t tos_evtdrv_task_self(void)
{
return evtdrv_curr_task;
}
__KNL__ evtdrv_bool_t evtdrv_task_id_is_invalid(evtdrv_task_id_t task_id)
{
return task_id >= evtdrv_task_table_size;
}
__KNL__ evtdrv_bool_t evtdrv_task_is_self(evtdrv_task_id_t task_id)
{
return task_id == evtdrv_curr_task;
}
__KNL__ void evtdrv_task_init(void)
{
evtdrv_task_id_t i;
for (i = 0; i < evtdrv_task_table_size; ++i) {
(evtdrv_task_table[i])(TOS_EVTDRV_SYS_EVENT_INIT);
}
}
#endif

View File

@@ -1,53 +0,0 @@
/*----------------------------------------------------------------------------
* Tencent is pleased to support the open source community by making TencentOS
* available.
*
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
* If you have downloaded a copy of the TencentOS binary from Tencent, please
* note that the TencentOS binary is licensed under the BSD 3-Clause License.
*
* If you have downloaded a copy of the TencentOS source code from Tencent,
* please note that TencentOS source code is licensed under the BSD 3-Clause
* License, except for the third-party components listed below which are
* subject to different license terms. Your integration of TencentOS into your
* own projects may require compliance with the BSD 3-Clause License, as well
* as the other licenses applicable to the third-party components included
* within TencentOS.
*---------------------------------------------------------------------------*/
#include "tos_evtdrv.h"
#if TOS_CFG_EVENT_DRIVEN_EN > 0u
__API__ evtdrv_time_t tos_evtdrv_tick2millisec(evtdrv_tick_t tick)
{
return (evtdrv_time_t)(tick * EVTDRV_TIME_MILLISEC_PER_SEC / TOS_CFG_CPU_TICK_PER_SECOND);
}
__API__ evtdrv_tick_t tos_evtdrv_millisec2tick(evtdrv_time_t ms)
{
return ((evtdrv_tick_t)ms * TOS_CFG_CPU_TICK_PER_SECOND / EVTDRV_TIME_MILLISEC_PER_SEC);
}
__API__ evtdrv_tick_t tos_evtdrv_systick_get(void)
{
TOS_CPU_CPSR_ALLOC();
evtdrv_tick_t tick;
TOS_CPU_INT_DISABLE();
tick = evtdrv_tick_count;
TOS_CPU_INT_ENABLE();
return tick;
}
__API__ void tos_evtdrv_tick_handler(void)
{
TOS_CPU_CPSR_ALLOC();
TOS_CPU_INT_DISABLE();
++evtdrv_tick_count;
TOS_CPU_INT_ENABLE();
}
#endif

View File

@@ -1,126 +0,0 @@
/*----------------------------------------------------------------------------
* Tencent is pleased to support the open source community by making TencentOS
* available.
*
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
* If you have downloaded a copy of the TencentOS binary from Tencent, please
* note that the TencentOS binary is licensed under the BSD 3-Clause License.
*
* If you have downloaded a copy of the TencentOS source code from Tencent,
* please note that TencentOS source code is licensed under the BSD 3-Clause
* License, except for the third-party components listed below which are
* subject to different license terms. Your integration of TencentOS into your
* own projects may require compliance with the BSD 3-Clause License, as well
* as the other licenses applicable to the third-party components included
* within TencentOS.
*---------------------------------------------------------------------------*/
#include "tos_evtdrv.h"
#if TOS_CFG_EVENT_DRIVEN_EN > 0u
__STATIC__ void evtdrv_timer_place(evtdrv_timer_t *tmr, evtdrv_tick_t timeout)
{
TOS_CPU_CPSR_ALLOC();
evtdrv_timer_t *curr_tmr;
TOS_CPU_INT_DISABLE();
tmr->expires = tos_evtdrv_systick_get() + timeout;
TOS_LIST_FOR_EACH_ENTRY(curr_tmr, evtdrv_timer_t, list, &evtdrv_timer_list) {
if (tmr->expires < curr_tmr->expires) {
break;
}
}
tos_list_add_tail(&tmr->list, &curr_tmr->list);
TOS_CPU_INT_ENABLE();
}
__STATIC__ void evtdrv_timer_takeoff(evtdrv_timer_t *tmr)
{
TOS_CPU_CPSR_ALLOC();
TOS_CPU_INT_DISABLE();
tos_list_del(&tmr->list);
TOS_CPU_INT_ENABLE();
}
__API__ evtdrv_err_t tos_evtdrv_timer_create(evtdrv_timer_t *tmr,
evtdrv_timer_callback_t callback,
void *cb_arg,
evtdrv_timer_opt_t opt)
{
if (!tmr || !callback) {
return EVTDRV_ERR_PTR_NULL;
}
tmr->cb = callback;
tmr->opt = opt;
tos_list_init(&tmr->list);
return EVTDRV_ERR_NONE;
}
__API__ evtdrv_err_t tos_evtdrv_timer_start(evtdrv_timer_t *tmr, evtdrv_tick_t timeout)
{
if (!tmr) {
return EVTDRV_ERR_PTR_NULL;
}
if (!tos_list_empty(&tmr->list)) {
return EVTDRV_ERR_TIMER_ALREADY_EXIST;
}
evtdrv_timer_place(tmr, timeout);
if (tmr->opt == EVTDRV_TIMER_OPT_PERIODIC) {
tmr->period = timeout;
}
return EVTDRV_ERR_NONE;
}
__API__ evtdrv_err_t tos_evtdrv_timer_stop(evtdrv_timer_t *tmr)
{
if (!tmr) {
return EVTDRV_ERR_PTR_NULL;
}
if (tos_list_empty(&tmr->list)) {
return EVTDRV_ERR_TIMER_INACTIVE;
}
evtdrv_timer_takeoff(tmr);
return EVTDRV_ERR_NONE;
}
__KNL__ void evtdrv_timer_update(void)
{
TOS_CPU_CPSR_ALLOC();
evtdrv_timer_t *tmr, *tmp;
TOS_CPU_INT_DISABLE();
TOS_LIST_FOR_EACH_ENTRY_SAFE(tmr, tmp, evtdrv_timer_t, list, &evtdrv_timer_list) {
if (tmr->expires > tos_evtdrv_systick_get()) {
break;
}
// time's up
evtdrv_timer_takeoff(tmr);
if (tmr->opt == EVTDRV_TIMER_OPT_PERIODIC) {
evtdrv_timer_place(tmr, tmr->period);
} else {
evtdrv_timer_takeoff(tmr);
}
(*tmr->cb)(tmr->cb_arg);
}
TOS_CPU_INT_ENABLE();
}
#endif /* TOS_CFG_EVENT_DRIVEN_EN */