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

#ifndef __OS_VAR_H
#define __OS_VAR_H
#include "os_redef.h"

/* The Soft-RTC */
#if (SYSCFG_SOFTRTC == __ENABLED__)
extern  s_u8_t          const _CONST_MEM_   s_month0day[13];
extern  s_u8_t                  _RTC_MEM_   s_month2day;
extern  s_every_ts              _SYS_MEM_   s_sign_every;
extern  m_rtccount_t            _SYS_MEM_   s_rtc_counter;
extern  s_rtc_ts                _RTC_MEM_   s_rtc;
#endif
/* The Task */
extern  m_bit_t       volatile/*_SYS_MEM_*/ s_sign_startup;
extern  s_schesign_tu volatile  _SYS_MEM_   s_sign_schedule;
extern  m_bit_t       volatile/*_SYS_MEM_*/ s_sign_delay;
extern  s_u8_t                  _SYS_MEM_   s_schedulelock_counter;
extern  s_taskstart_ts			_SYS_MEM_   s_task_starter;
extern  s_taskctrl_tsp          _SYS_MEM_   s_task_current;
extern  s_taskctrl_tsp                      s_timer_list[OS_TIMESLOTNUM];
extern  s_u8_t                  _SYS_MEM_   s_timer_pointer;
#if (SYSCFG_SAMEPRISCHEDULE == __TIMESHARING__ && SYSCFG_TIMESHARINGMODE == 2)
extern  s_sharing_t     const _CONST_MEM_   s_time_sharing[SYSCFG_TASKPRIORITY];
#endif
#if (SYSCFG_KERNELLOCKNESTING == __ENABLED__)
extern  s_u8_t                  _SYS_MEM_   s_kernellock_counter;
#endif
/* The Safe runtime */
#if (SYSCFG_SAFERUNTIME == __ENABLED__)
extern  m_bit_t               /*_SYS_MEM_*/ s_timeout_sign;
extern  s_taskctrl_tsp       _STATIC_MEM_   s_timeout_list;
#endif
/* The Timing Interrupt */
#if (OS_TIMINTTOTAL > 0)
extern  s_timinthand_tsp                    s_timint_handle[OS_TIMINTTOTAL];
#endif
/* The Timing Query */
#if (OS_TIMQRYTOTAL > 0)
extern  s_timqryhand_tsp                    s_timqry_handle[OS_TIMQRYTOTAL];
#endif
/* The Task Message */
#if (SYSCFG_TASKMSG == __ENABLED__)
extern  s_u8_t        volatile  _SYS_MEM_   s_taskmsg_sign;
#endif
/* The Debug Interface */
#if (SYSCFG_DEBUGGING == __ENABLED__)
extern  m_bit_t               /*_SYS_MEM_*/ s_debug_sendsign;
extern  s_u8_t                  _SYS_MEM_   s_debug_sendtype;
extern  s_u8_t                  _SYS_MEM_   s_debug_recvlen;
extern  char *                _XDATA_MEM_   s_debug_recvptr;/*
extern  char                  _XDATA_MEM_   s_cmdline_sendbuff[OS_CMDLINESENDBUFFSIZE];
#if (SYSCFG_DEBUG_SENDLEN == __ENABLED__)
extern  s_u16_t               _XDATA_MEM_   s_cmdline_sendlen;
#endif*/
extern  m_bit_t               /*_SYS_MEM_*/ s_taskmgr_sign;
extern  char                  _XDATA_MEM_   s_taskmgr_sendbuff[OS_TASKMGRSENDBUFFSIZE];
#if (SYSCFG_DEBUG_SENDLEN == __ENABLED__)
extern  s_u16_t               _XDATA_MEM_   s_taskmgr_sendlen;
#endif
extern  s_u32_t               _DEBUG_MEM_   s_taskmgr_upspeed;
extern  s_alarm_ts            _DEBUG_MEM_   s_alarm;
extern  s_fault_ts            _DEBUG_MEM_   s_fault;
#if (SYSCFG_SYSTICKTIME_COUNT == __ENABLED__)
extern  s_u32_t               _DEBUG_MEM_   s_tick_count1;
extern  s_u32_t               _DEBUG_MEM_   s_tick_count2;
#endif
#if (SYSCFG_TASKPC_MONITOR == __ENABLED__)
extern  m_pc_t                  _SYS_MEM_   s_pc;
#endif
#if (SYSCFG_RUNTIME_COUNT == __ENABLED__)
extern  s_runtime_ts          _DEBUG_MEM_   s_runtime;
#endif
#endif
/* The Task */
extern  s_u8_t const _CONST_MEM_ s_task_pickmap[SYSCFG_TASKPICKBITMAP * 128];
extern  s_taskctrl_tsp _QUE_MEM_ s_task_queue[SYSCFG_TASKPRIORITY];
extern  m_tqcount_t    _QUE_MEM_ s_task_queue_count;
#if   (SYSCFG_TASKPRIORITY > 64)
extern  s_u8_t _QUE_MEM_ s_task_table_index;
extern  s_u8_t _QUE_MEM_ s_task_bytes_index[SYSCFG_TASKPRIORITY / 64 + !!(SYSCFG_TASKPRIORITY % 64)];
extern  s_u8_t _QUE_MEM_ s_task_ready_table[SYSCFG_TASKPRIORITY / 64 + !!(SYSCFG_TASKPRIORITY % 64)][8];
#elif (SYSCFG_TASKPRIORITY > 8)
extern  s_u8_t _QUE_MEM_ s_task_bytes_index;
extern  s_u8_t _QUE_MEM_ s_task_ready_table[SYSCFG_TASKPRIORITY / 8 + !!(SYSCFG_TASKPRIORITY % 8)];
#else
extern  s_u8_t _QUE_MEM_ s_task_ready_table;
#endif
#if   (SYSCFG_SAMEPRISCHEDULE)
extern  s_u8_t _QUE_MEM_ s_task_ready_count[SYSCFG_TASKPRIORITY];
#elif (SYSCFG_MUTEX == __ENABLED__)
extern  s_u8_t _SYS_MEM_ s_taskpri_ceiling;
#endif
#if (SYSCFG_PENDSVFIFO_DEPTH > 0 && SYSCFG_PENDSVFIFO_ERRORCALLBACK == __ENABLED__)
extern  s_ecode_t _SYS_MEM_ s_psvfifo_ecode;
#endif
extern  void (_CODE_MEM_ * const _CONST_MEM_ sPendSV_FIFOHandler[OS_SVID_END])(void _STATIC_MEM_ *sv);

#endif
