feat: L0 支持低功耗框架

1.【需求描述】
 L0 支持低功耗投票框架, 使内核与应用、驱动分离开,通过注册及投票机制控制系统的低功耗模式,
  减低系统功耗,提升设备电池寿命。
2.【方案描述】
 (1).提供注册机制,使驱动与内核分离
  (2).提供投票机制,判断系统运行模式
  (3).记录持锁设备,便于回溯
  进入:系统运行进入idle任务时判断当前的功耗模式,如果上层应用未对当前功耗模式(deep和shutdown)
 持锁,则系统准备进入当前模式,首先所有设备依次进入当前模式,如果有设备进入当前模式失败,则恢复
 已进入当前模式的所有设备,并且功耗模式变为normal模式;设备依次进入当前功耗模式后cpu再进入当前
 功耗模式。
  恢复:功耗模式为deep时,需要恢复逻辑,时系统恢复运行。当有中断出发时,系统会退出低功耗模式,
  恢复顺序为:首先cpu先恢复,然后设备依次恢复。

BREAKING CHANGE:
1.原调度中基于tick timer的低功耗扩展和当前的pm模块合并,删除原对外接口LOS_SchedSleepInit,
 变为pm模块统一提供的LOS_PmRegistered接口.
2.原来在arch los_timer.h下提供的低功耗模式为枚举LOS_SysSleepEnum,其中OS_SYS_NORMAL_SLEEP
  和OS_SYS_DEEP_SLEEP不符合对外定义,统一修改为LOS_SYS_NORMAL_SLEEP和LOS_SYS_DEEP_SLEEP,
  并移至los_pm.h中.
3.VOID HalEnterSleep(LOS_SysSleepEnum sleep) 变更为UINT32 HalEnterSleep(VOID).

Close #I3UDNV

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: Id5382c42c8055ba7850895a3f575130a73e38a65
This commit is contained in:
zhushengle
2021-06-16 15:05:49 +08:00
parent 468ce69f27
commit 558ce14bec
35 changed files with 1239 additions and 272 deletions

View File

@@ -634,10 +634,34 @@ extern UINT8 *m_aucSysMem0;
/**
* @ingroup los_config
* When the tick timer is a non-64/128-bit timer, it has ultra-low power compensation.
* Configuration item for low power frame tailoring
*/
#ifndef LOSCFG_BASE_CORE_SCHED_SLEEP
#define LOSCFG_BASE_CORE_SCHED_SLEEP 0
#ifndef LOSCFG_KERNEL_PM
#define LOSCFG_KERNEL_PM 1
#endif
/**
* @ingroup los_config
* Configuration item for priority of low-power task.
*/
#ifndef LOSCFG_KERNEL_PM_TASK_PTIORITY
#define LOSCFG_KERNEL_PM_TASK_PTIORITY 1
#endif
/**
* @ingroup los_config
* Configuration item for stack size of low-power task.
*/
#ifndef LOSCFG_KERNEL_PM_TASK_STACKSIZE
#define LOSCFG_KERNEL_PM_TASK_STACKSIZE 0x800
#endif
/**
* @ingroup los_config
* Configuration item for low power frame debug tailoring
*/
#ifndef LOSCFG_KERNEL_PM_DEBUG
#define LOSCFG_KERNEL_PM_DEBUG 0
#endif
/**

View File

@@ -53,7 +53,7 @@ VOID OsSchedSetIdleTaskSchedParam(LosTaskCB *idleTask);
UINT32 OsSchedSwtmrScanRegister(SchedScan func);
VOID OsSchedUpdateExpireTime(UINT64 startTime);
VOID OsSchedUpdateExpireTime(UINT64 startTime, BOOL timeUpdate);
VOID OsSchedTaskDeQueue(LosTaskCB *taskCB);
@@ -81,27 +81,64 @@ BOOL OsSchedTaskSwitch(VOID);
LosTaskCB *OsGetTopTask(VOID);
UINT32 OsSchedRealSleepTimeSet(VOID (*func)(UINT64));
VOID OsSchedTimerBaseReset(UINT64 currTime);
/**
* @ingroup los_sched
* @brief Get the time, in nanoseconds, remaining before the next tick interrupt response.
*
* @par Description:
* This API is used to get the time, in nanoseconds, remaining before the next tick interrupt response.
*
* @attention None.
*
* @param None.
*
* @retval #time, in nanoseconds.
* @par Dependency:
* <ul><li>los_sched.h: the header file that contains the API declaration.</li></ul>
* @see
*/
extern UINT64 LOS_SchedTickTimeoutNsGet(VOID);
/**
* @ingroup los_sched
* @brief The system-provided tick interrupt handler.
*
* @par Description:
* This API is used to wake up a task that is blocked by time.
*
* @attention None.
*
* @param None.
*
* @retval None.
* @par Dependency:
* <ul><li>los_sched.h: the header file that contains the API declaration.</li></ul>
* @see
*/
extern VOID LOS_SchedTickHandler(VOID);
/**
* @ingroup los_sched
* @brief Trigger a system dispatch.
*
* @par Description:
* This API is used to trigger a system dispatch.
*
* @attention None.
*
* @param None.
*
* @retval None.
* @par Dependency:
* <ul><li>los_sched.h: the header file that contains the API declaration.</li></ul>
* @see
*/
extern VOID LOS_Schedule(VOID);
#if (LOSCFG_BASE_CORE_SCHED_SLEEP == 1)
VOID OsSchedUpdateSleepTime(VOID);
VOID OsSchedToSleep(VOID);
typedef UINT32 (*SchedSleepInit)(VOID);
typedef VOID (*SchedSleepStart)(UINT64);
typedef VOID (*SchedSleepStop)(VOID);
typedef UINT64 (*SchedSleepGetSleepTimeNs)(VOID);
extern UINT32 LOS_SchedSleepInit(SchedSleepInit init, SchedSleepStart start,
SchedSleepStop stop, SchedSleepGetSleepTimeNs getTime);
#endif
#ifdef __cplusplus
#if __cplusplus
}

View File

@@ -1636,6 +1636,8 @@ extern UINT32 OsGetAllTskInfo(VOID);
extern VOID *OsTskUserStackInit(VOID* stackPtr, VOID* userSP, UINT32 userStackSize);
extern UINT32 OsPmEnterHandlerSet(VOID (*func)(BOOL));
#ifdef __cplusplus
#if __cplusplus
}

View File

@@ -124,6 +124,12 @@ extern UINT64 LOS_SysCycleGet(VOID);
#define OS_NS_PER_TICK (OS_SYS_NS_PER_SECOND / LOSCFG_BASE_CORE_TICK_PER_SECOND)
#define OS_SYS_CYCLE_TO_NS(cycle, freq) (((cycle) / (freq)) * OS_SYS_NS_PER_SECOND + \
((cycle) % OS_SYS_CLOCK) * OS_SYS_NS_PER_SECOND / (freq))
#define OS_SYS_NS_TO_CYCLE(time, freq) (((time) / OS_SYS_NS_PER_SECOND) * (freq) + \
(time % OS_SYS_NS_PER_SECOND) * (freq) / OS_SYS_NS_PER_SECOND)
/**
* @ingroup los_tick
* System time basic function error code: Null pointer.