/**************************************************************************//**
 * @item     CosyOS-III Kernel
 * @file     os_var.c
 * @brief    系统全局变量定义
 * @author   迟凯峰
 * @version  v3.0.0
 * @date     2026.07.21
 ******************************************************************************/

#include "os_redef.h"

/* The Soft-RTC */
#if (SYSCFG_SOFTRTC == __ENABLED__)
s_u8_t          const _CONST_MEM_   s_month0day[13] = {31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; /*!< 每月各有几天？*/
s_u8_t                  _RTC_MEM_   s_month2day = 28;                      /*!< 二月有几天？*/
s_every_ts              _SYS_MEM_   s_sign_every/**/sZeroInstall_Group;    /*!< 每信号 */
m_rtccount_t            _SYS_MEM_   s_rtc_counter/**/sZeroInstall;         /*!< RTC计数器 */
s_rtc_ts                _RTC_MEM_   s_rtc = {SYSCFG_MANUFACTUREDATE};      /*!< RTC */
#endif
/* The Task */
m_bit_t       volatile/*_SYS_MEM_*/ s_sign_startup = true;
s_schesign_tu volatile  _SYS_MEM_   s_sign_schedule = {{0, 1}};            /*!< 调度信号 */
m_bit_t       volatile/*_SYS_MEM_*/ s_sign_delay/**/sZeroInstall;          /*!< 就绪延时信号 */
s_u8_t                  _SYS_MEM_   s_schedulelock_counter/**/sZeroInstall;/*!< 调度锁嵌套计数器 */
s_taskstart_ts			_SYS_MEM_   s_task_starter/**/sZeroInstall_Group;  /*!< 任务启动器 */
s_taskctrl_tsp          _SYS_MEM_   s_task_current/**/sZeroInstall;        /*!< 当前任务句柄 */
s_taskctrl_tsp                      s_timer_list[OS_TIMESLOTNUM]/**/sZeroInstall_Group; /*!< 定时器链表 */
s_u8_t                  _SYS_MEM_   s_timer_pointer = OS_TIMESLOTNUM - 1UL;
#if (SYSCFG_SAMEPRISCHEDULE == __TIMESHARING__ && SYSCFG_TIMESHARINGMODE == 2)
s_sharing_t     const _CONST_MEM_   s_time_sharing[SYSCFG_TASKPRIORITY] = {SYSCFG_CUSTOMTIMESHARING}; /*!< 自定义时间片 -> 时间片数组 */
#endif
#if (SYSCFG_KERNELLOCKNESTING == __ENABLED__)
s_u8_t                  _SYS_MEM_   s_kernellock_counter/**/sZeroInstall;  /*!< 内核锁嵌套计数器 */
#endif
/* The Safe runtime */
#if (SYSCFG_SAFERUNTIME == __ENABLED__)
m_bit_t               /*_SYS_MEM_*/ s_timeout_sign/**/sZeroInstall;        /*!< 超时信号 */
s_taskctrl_tsp       _STATIC_MEM_   s_timeout_list/**/sZeroInstall;        /*!< 超时链表 */
#endif
/* The Timing Interrupt */
#if (OS_TIMINTTOTAL > 0)
s_timinthand_tsp                    s_timint_handle[OS_TIMINTTOTAL];       /*!< 定时中断句柄 */
#endif
/* The Timing Query */
#if (OS_TIMQRYTOTAL > 0)
s_timqryhand_tsp                    s_timqry_handle[OS_TIMQRYTOTAL];       /*!< 定时查询句柄 */
#endif
/* The Task Message */
#if (SYSCFG_TASKMSG == __ENABLED__)
s_u8_t        volatile  _SYS_MEM_   s_taskmsg_sign/**/sZeroInstall;        /*!< 发送私信信号 */
#endif
/* The Debug Interface */
#if (SYSCFG_DEBUGGING == __ENABLED__)
m_bit_t               /*_SYS_MEM_*/ s_debug_sendsign/**/sZeroInstall;
s_u8_t                  _SYS_MEM_   s_debug_sendtype/**/sZeroInstall;
s_u8_t                  _SYS_MEM_   s_debug_recvlen/**/sZeroInstall;
char *                _XDATA_MEM_   s_debug_recvptr;/*
char                  _XDATA_MEM_   s_cmdline_sendbuff[OS_CMDLINESENDBUFFSIZE];
#if (SYSCFG_DEBUG_SENDLEN == __ENABLED__)
s_u16_t               _XDATA_MEM_   s_cmdline_sendlen;
#endif*/
m_bit_t               /*_SYS_MEM_*/ s_taskmgr_sign = SYSCFG_TASKMGR_AUTOSTART;
char                  _XDATA_MEM_   s_taskmgr_sendbuff[OS_TASKMGRSENDBUFFSIZE];
#if (SYSCFG_DEBUG_SENDLEN == __ENABLED__)
s_u16_t               _XDATA_MEM_   s_taskmgr_sendlen;
#endif
s_u32_t               _DEBUG_MEM_   s_taskmgr_upspeed/**/sZeroInstall;
s_alarm_ts            _DEBUG_MEM_   s_alarm/**/sZeroInstall_Group;
s_fault_ts            _DEBUG_MEM_   s_fault/**/sZeroInstall_Group;
#if (SYSCFG_SYSTICKTIME_COUNT == __ENABLED__)
s_u32_t               _DEBUG_MEM_   s_tick_count1/**/sZeroInstall;
s_u32_t               _DEBUG_MEM_   s_tick_count2/**/sZeroInstall;
#endif
#if (SYSCFG_TASKPC_MONITOR == __ENABLED__)
m_pc_t                  _SYS_MEM_   s_pc/**/sZeroInstall;
#endif
#if (SYSCFG_RUNTIME_COUNT == __ENABLED__)
s_runtime_ts          _DEBUG_MEM_   s_runtime/**/sZeroInstall_Group;
#endif
#endif
/* The Task */
s_u8_t const _CONST_MEM_ s_task_pickmap[SYSCFG_TASKPICKBITMAP * 128] =
{
	#if   (SYSCFG_TASKPICKBITMAP == 1)
     /* 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F */
/* 0 */ 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4,
/* 1 */ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
/* 2 */ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
/* 3 */ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
/* 4 */ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
/* 5 */ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
/* 6 */ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
/* 7 */ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
	#elif (SYSCFG_TASKPICKBITMAP == 2)
     /* 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F */
/* 0 */~0, 0, 1, 1, 2, 2,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_MEM_ s_task_table_index/**/sZeroInstall; /*!< 任务表索引 */
s_u8_t _QUE_MEM_ s_task_bytes_index[SYSCFG_TASKPRIORITY / 64 + !!(SYSCFG_TASKPRIORITY % 64)]/**/sZeroInstall_Group;
s_u8_t _QUE_MEM_ s_task_ready_table[SYSCFG_TASKPRIORITY / 64 + !!(SYSCFG_TASKPRIORITY % 64)][8]/**/sZeroInstall_Group;
#elif (SYSCFG_TASKPRIORITY > 8)
s_u8_t _QUE_MEM_ s_task_bytes_index/**/sZeroInstall; /*!< 任务字节索引 */
s_u8_t _QUE_MEM_ s_task_ready_table[SYSCFG_TASKPRIORITY / 8 + !!(SYSCFG_TASKPRIORITY % 8)]/**/sZeroInstall_Group;
#else
s_u8_t _QUE_MEM_ s_task_ready_table/**/sZeroInstall; /*!< 任务就绪表 */
#endif
#if   (SYSCFG_SAMEPRISCHEDULE)
s_u8_t _QUE_MEM_ s_task_ready_count[SYSCFG_TASKPRIORITY]/**/sZeroInstall_Group;
#elif (SYSCFG_MUTEX == __ENABLED__)
s_u8_t _SYS_MEM_ s_taskpri_ceiling = SYSCFG_BASEPRI_CEILING; /*!< 天花板优先级 */
#endif
#if (SYSCFG_PENDSVFIFO_DEPTH > 0 && SYSCFG_PENDSVFIFO_ERRORCALLBACK == __ENABLED__)
s_ecode_t _SYS_MEM_ s_psvfifo_ecode; /*!< 中断挂起服务_FIFO-错误调用返回.错误码 */
#endif
