更新日期: 2022/06/01 来源: https://gitee.com/weharmony/kernel_liteos_a_note
los_pm.c 文件参考

浏览源代码.

结构体

struct  OsPmLockCB
 
struct  LosPmCB
 

类型定义

typedef UINT32(* Suspend) (UINT32 mode)
 电源锁控制块 更多...
 

函数

STATIC SPIN_LOCK_INIT (g_pmSpin)
 电源模块自旋锁 更多...
 
STATIC VOID OsPmSysctrlInit (VOID)
 
STATIC VOID OsPmTickTimerStart (LosPmCB *pm)
 
STATIC BOOL OsPmTickTimerStop (LosPmCB *pm)
 
STATIC VOID OsPmCpuResume (LosPmCB *pm)
 
VOID OsPmCpuSuspend (LosPmCB *pm)
 
STATIC VOID OsPmResumePrepare (LosPmCB *pm, UINT32 mode, UINT32 prepare)
 
STATIC UINT32 OsPmSuspendPrepare (Suspend sysSuspendEarly, Suspend deviceSuspend, UINT32 mode, UINT32 *prepare)
 
STATIC UINT32 OsPmSuspendCheck (LosPmCB *pm, Suspend *sysSuspendEarly, Suspend *deviceSuspend, LOS_SysSleepEnum *mode)
 
STATIC UINT32 OsPmSuspendSleep (LosPmCB *pm)
 
STATIC UINT32 OsPmDeviceRegister (LosPmCB *pm, LosPmDevice *device)
 
STATIC UINT32 OsPmSysctrlRegister (LosPmCB *pm, LosPmSysctrl *sysctrl)
 
UINT32 LOS_PmRegister (LOS_PmNodeType type, VOID *node)
 Register a power management node. 更多...
 
STATIC UINT32 OsPmDeviceUnregister (LosPmCB *pm, LosPmDevice *device)
 
STATIC UINT32 OsPmSysctrlUnregister (LosPmCB *pm, LosPmSysctrl *sysctrl)
 
UINT32 LOS_PmUnregister (LOS_PmNodeType type, VOID *node)
 Unregister a power management node. 更多...
 
VOID LOS_PmWakeSet (VOID)
 Set the system wake up flag. 更多...
 
LOS_SysSleepEnum LOS_PmModeGet (VOID)
 获取电源模式 更多...
 
UINT32 LOS_PmModeSet (LOS_SysSleepEnum mode)
 Set low power mode. 更多...
 
UINT32 LOS_PmLockCountGet (VOID)
 获取电源锁数量 更多...
 
VOID LOS_PmLockInfoShow (struct SeqBuf *m)
 显示所有电源锁信息 更多...
 
UINT32 OsPmLockRequest (const CHAR *name, UINT32 swtmrID)
 请求获取指定的锁 更多...
 
UINT32 LOS_PmLockRequest (const CHAR *name)
 Request to obtain the lock in current mode, so that the system will not enter this mode when it enters the idle task next time. 更多...
 
UINT32 LOS_PmLockRelease (const CHAR *name)
 Release the lock in current mode so that the next time the system enters the idle task, it will enter this mode. 更多...
 
STATIC VOID OsPmSwtmrHandler (UINT32 arg)
 
UINT32 LOS_PmTimeLockRequest (const CHAR *name, UINT64 millisecond)
 Request to obtain the lock in current mode, so that the system will not enter this mode when it enters the idle task next time. After the specified interval, the lock is automatically released. 更多...
 
UINT32 LOS_PmReadLock (VOID)
 Gets the current PM lock status. 更多...
 
UINT32 LOS_PmSuspend (UINT32 wakeCount)
 The system enters the low-power flow. 更多...
 
BOOL OsIsPmMode (VOID)
 
STATIC UINT32 OsPmSuspendDefaultHandler (VOID)
 
UINT32 OsPmInit (VOID)
 
 LOS_MODULE_INIT (OsPmInit, LOS_INIT_LEVEL_KMOD_EXTENDED)
 

变量

STATIC EVENT_CB_S g_pmEvent
 
STATIC LosPmCB g_pmCB
 电源控制块全局遍历 更多...
 
STATIC LosPmSysctrl g_sysctrl
 

类型定义说明

◆ Suspend

typedef UINT32(* Suspend) (UINT32 mode)

电源锁控制块

在文件 los_pm.c96 行定义.

函数说明

◆ LOS_MODULE_INIT()

LOS_MODULE_INIT ( OsPmInit  ,
LOS_INIT_LEVEL_KMOD_EXTENDED   
)

◆ LOS_PmLockCountGet()

UINT32 LOS_PmLockCountGet ( VOID  )

获取电源锁数量

Get the low power mode of the current system.

在文件 los_pm.c443 行定义.

444{
445 UINT16 count;
446 LosPmCB *pm = &g_pmCB;
447
448 LOS_SpinLock(&g_pmSpin);
449 count = pm->lock;
450 LOS_SpinUnlock(&g_pmSpin);
451
452 return (UINT32)count;
453}
STATIC LosPmCB g_pmCB
电源控制块全局遍历
Definition: los_pm.c:119
VOID LOS_SpinLock(SPIN_LOCK_S *lock)
Definition: los_spinlock.c:50
VOID LOS_SpinUnlock(SPIN_LOCK_S *lock)
Definition: los_spinlock.c:84
unsigned short UINT16
Definition: los_typedef.h:56
unsigned int UINT32
Definition: los_typedef.h:57
UINT16 lock
锁数量
Definition: los_pm.c:108
函数调用图:

◆ LOS_PmLockInfoShow()

VOID LOS_PmLockInfoShow ( struct SeqBuf m)

显示所有电源锁信息

Output the locking information of the pm lock.

在文件 los_pm.c455 行定义.

456{
457 LosPmCB *pm = &g_pmCB;
458 OsPmLockCB *lock = NULL;
459 LOS_DL_LIST *head = &pm->lockList;
460 LOS_DL_LIST *list = head->pstNext;
461
462 LOS_SpinLock(&g_pmSpin);
463 while (list != head) {//遍历链表
464 lock = LOS_DL_LIST_ENTRY(list, OsPmLockCB, list);//获取 OsPmLockCB 实体
465 PM_INFO_SHOW(m, "%-30s%5u\n\r", lock->name, lock->count); //打印名称和数量
466 list = list->pstNext;
467 }
468 LOS_SpinUnlock(&g_pmSpin);
469
470 return;
471}
struct LOS_DL_LIST * pstNext
Definition: los_list.h:84
LOS_DL_LIST lockList
电源锁链表头,上面挂的是 OsPmLockCB
Definition: los_pm.c:113
UINT32 count
数量
Definition: los_pm.c:100
CHAR name[OS_PM_LOCK_NAME_MAX]
电源锁名称
Definition: los_pm.c:99
函数调用图:
这是这个函数的调用关系图:

◆ LOS_PmLockRelease()

UINT32 LOS_PmLockRelease ( const CHAR name)

Release the lock in current mode so that the next time the system enters the idle task, it will enter this mode.

Description:
This API is used to release the lock in current mode.
注意
None.
参数
name[IN] Who releases the lock.
返回值
errorcode, LOS_OK means success.
Dependency:
  • los_pm.h: the header file that contains the API declaration.
参见
LOS_PmLockRequest

在文件 los_pm.c552 行定义.

553{
554 UINT32 ret = LOS_EINVAL;
555 LosPmCB *pm = &g_pmCB;
556 OsPmLockCB *lock = NULL;
557 LOS_DL_LIST *head = &pm->lockList;
558 LOS_DL_LIST *list = head->pstNext;
559 OsPmLockCB *lockFree = NULL;
560 BOOL isRelease = FALSE;
561 UINT32 mode;
562
563 if (name == NULL) {
564 return LOS_EINVAL;
565 }
566
567 if (OS_INT_ACTIVE) {
568 return LOS_EINTR;
569 }
570
571 LOS_SpinLock(&g_pmSpin);
572 if (pm->lock == 0) {
573 LOS_SpinUnlock(&g_pmSpin);
574 return LOS_EINVAL;
575 }
576
577 mode = (UINT32)pm->pmMode;
578 while (list != head) {//遍历找到参数对应的 OsPmLockCB
579 OsPmLockCB *listNode = LOS_DL_LIST_ENTRY(list, OsPmLockCB, list);
580 if (strcmp(name, listNode->name) == 0) {
581 lock = listNode;
582 break;//找到返回
583 }
584
585 list = list->pstNext;//继续遍历下一个结点
586 }
587
588 if (lock == NULL) {
589 LOS_SpinUnlock(&g_pmSpin);
590 return LOS_EINVAL;
591 } else if (lock->count > 0) {//有记录且有数量
592 lock->count--; //数量减少
593 if (lock->count == 0) {//没有了
594 LOS_ListDelete(&lock->list);//讲自己从链表中摘除
595 lockFree = lock;
596 }
597 }
598
599 if (pm->lock > 0) {
600 pm->lock--;
601 if (pm->lock == 0) {
602 isRelease = TRUE;
603 }
604 ret = LOS_OK;
605 }
606 LOS_SpinUnlock(&g_pmSpin);
607
608 if (lockFree != NULL) {
609 (VOID)LOS_SwtmrDelete(lockFree->swtmrID);
610 (VOID)LOS_MemFree((VOID *)OS_SYS_MEM_ADDR, lockFree);
611 }
612
613 if (isRelease && (mode > LOS_SYS_NORMAL_SLEEP)) {
614 (VOID)LOS_EventWrite(&g_pmEvent, PM_EVENT_LOCK_RELEASE);
615 }
616
617 return ret;
618}
LITE_OS_SEC_TEXT UINT32 LOS_EventWrite(PEVENT_CB_S eventCB, UINT32 events)
写指定的事件类型
Definition: los_event.c:318
LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListDelete(LOS_DL_LIST *node)
Definition: los_list.h:292
UINT32 LOS_MemFree(VOID *pool, VOID *ptr)
释放从指定动态内存中申请的内存
Definition: los_memory.c:1369
LITE_OS_SEC_TEXT UINT32 LOS_SwtmrDelete(UINT16 swtmrID)
接口函数 删除定时器
Definition: los_swtmr.c:889
STATIC EVENT_CB_S g_pmEvent
Definition: los_pm.c:118
@ LOS_SYS_NORMAL_SLEEP
Definition: los_pm.h:42
size_t BOOL
Definition: los_typedef.h:88
LOS_SysSleepEnum pmMode
模式类型
Definition: los_pm.c:106
UINT32 swtmrID
Definition: los_pm.c:101
LOS_DL_LIST list
电源锁链表,上面挂的是 OsPmLockCB
Definition: los_pm.c:102
函数调用图:
这是这个函数的调用关系图:

◆ LOS_PmLockRequest()

UINT32 LOS_PmLockRequest ( const CHAR name)

Request to obtain the lock in current mode, so that the system will not enter this mode when it enters the idle task next time.

Description:
This API is used to obtain the lock in current mode.
注意
None.
参数
name[IN] Who requests the lock.
返回值
errorcode, LOS_OK means success.
Dependency:
  • los_pm.h: the header file that contains the API declaration.
参见
LOS_PmLockRelease

在文件 los_pm.c543 行定义.

544{
545 if (name == NULL) {
546 return LOS_EINVAL;
547 }
548
549 return OsPmLockRequest(name, OS_INVALID);
550}
UINT32 OsPmLockRequest(const CHAR *name, UINT32 swtmrID)
请求获取指定的锁
Definition: los_pm.c:473
函数调用图:
这是这个函数的调用关系图:

◆ LOS_PmModeGet()

LOS_SysSleepEnum LOS_PmModeGet ( VOID  )

获取电源模式

Get the low power mode of the current system.

在文件 los_pm.c400 行定义.

401{
402 LOS_SysSleepEnum mode;
403 LosPmCB *pm = &g_pmCB;
404
405 LOS_SpinLock(&g_pmSpin);
406 mode = pm->pmMode;
407 LOS_SpinUnlock(&g_pmSpin);
408
409 return mode;
410}
LOS_SysSleepEnum
Definition: los_pm.h:41
函数调用图:

◆ LOS_PmModeSet()

UINT32 LOS_PmModeSet ( LOS_SysSleepEnum  mode)

Set low power mode.

Description:
This API is used to set low power mode.
注意
None.
参数
mode[IN] low power mode.
返回值
errorcode, LOS_OK means success.
Dependency:
  • los_pm.h: the header file that contains the API declaration.
参见
LOS_PmModeGet

在文件 los_pm.c411 行定义.

412{
413 LosPmCB *pm = &g_pmCB;
414 INT32 sleepMode = (INT32)mode;
415
416 if ((sleepMode < 0) || (sleepMode > LOS_SYS_SHUTDOWN)) {
417 return LOS_EINVAL;
418 }
419
420 LOS_SpinLock(&g_pmSpin);
421 if ((mode == LOS_SYS_LIGHT_SLEEP) && (pm->sysctrl->lightSuspend == NULL)) {
422 LOS_SpinUnlock(&g_pmSpin);
423 return LOS_EINVAL;
424 }
425
426 if ((mode == LOS_SYS_DEEP_SLEEP) && (pm->sysctrl->deepSuspend == NULL)) {
427 LOS_SpinUnlock(&g_pmSpin);
428 return LOS_EINVAL;
429 }
430
431 if ((mode == LOS_SYS_SHUTDOWN) && (pm->sysctrl->shutdownSuspend == NULL)) {
432 LOS_SpinUnlock(&g_pmSpin);
433 return LOS_EINVAL;
434 }
435
436 pm->pmMode = mode;
437 LOS_SpinUnlock(&g_pmSpin);
438
439 return LOS_OK;
440}
@ LOS_SYS_DEEP_SLEEP
Definition: los_pm.h:44
@ LOS_SYS_LIGHT_SLEEP
Definition: los_pm.h:43
@ LOS_SYS_SHUTDOWN
Definition: los_pm.h:45
signed int INT32
Definition: los_typedef.h:60
LosPmSysctrl * sysctrl
Definition: los_pm.c:111
UINT32(* deepSuspend)(VOID)
Definition: los_pm.h:89
UINT32(* lightSuspend)(VOID)
Definition: los_pm.h:81
UINT32(* shutdownSuspend)(VOID)
Definition: los_pm.h:97
函数调用图:
这是这个函数的调用关系图:

◆ LOS_PmReadLock()

UINT32 LOS_PmReadLock ( VOID  )

Gets the current PM lock status.

Description:
This API is used to Get the current PM lock status.
注意
None.
参数
None.
返回值
Numberof awakening sources of the device.
Dependency:
  • los_pm.h: the header file that contains the API declaration.
参见

在文件 los_pm.c664 行定义.

665{
666 UINT32 ret = LOS_EventRead(&g_pmEvent, PM_EVENT_LOCK_MASK, LOS_WAITMODE_OR | LOS_WAITMODE_CLR, LOS_WAIT_FOREVER);
667 if (ret > PM_EVENT_LOCK_MASK) {
668 PRINT_ERR("%s event read failed! ERROR: 0x%x\n", __FUNCTION__, ret);
669 }
670
671 return LOS_OK;
672}
LITE_OS_SEC_TEXT UINT32 LOS_EventRead(PEVENT_CB_S eventCB, UINT32 eventMask, UINT32 mode, UINT32 timeout)
读取指定事件类型,超时时间为相对时间:单位为Tick
Definition: los_event.c:313
函数调用图:
这是这个函数的调用关系图:

◆ LOS_PmRegister()

UINT32 LOS_PmRegister ( LOS_PmNodeType  type,
VOID *  node 
)

Register a power management node.

Description:
This API is used to register a power management node.
注意
None.
参数
type[IN] The types supported by the PM module.
node[IN] power management node.
返回值
errorcode, LOS_OK means success.
Dependency:
  • los_pm.h: the header file that contains the API declaration.
参见
LOS_PmUnregister

在文件 los_pm.c319 行定义.

320{
321 LosPmCB *pm = &g_pmCB;
322
323 if (node == NULL) {
324 return LOS_EINVAL;
325 }
326
327 switch (type) {
329 return OsPmDeviceRegister(pm, (LosPmDevice *)node);
331 PRINT_ERR("Pm, %d is an unsupported type\n", type);
332 return LOS_EINVAL;
334 return OsPmSysctrlRegister(pm, (LosPmSysctrl *)node);
335 default:
336 break;
337 }
338
339 return LOS_EINVAL;
340}
STATIC UINT32 OsPmSysctrlRegister(LosPmCB *pm, LosPmSysctrl *sysctrl)
Definition: los_pm.c:281
STATIC UINT32 OsPmDeviceRegister(LosPmCB *pm, LosPmDevice *device)
Definition: los_pm.c:268
@ LOS_PM_TYPE_TICK_TIMER
Definition: los_pm.h:50
@ LOS_PM_TYPE_DEVICE
Definition: los_pm.h:49
@ LOS_PM_TYPE_SYSCTRL
Definition: los_pm.h:51
函数调用图:

◆ LOS_PmSuspend()

UINT32 LOS_PmSuspend ( UINT32  wakeCount)

The system enters the low-power flow.

Description:
This API is used to enter the system into a low-power process.
注意
None.
参数
wakeCount[IN] Number of wake sources.
返回值
errorcode, LOS_OK means success.
Dependency:
  • los_pm.h: the header file that contains the API declaration.
参见

在文件 los_pm.c674 行定义.

675{
676 (VOID)wakeCount;
677 return OsPmSuspendSleep(&g_pmCB);
678}
STATIC UINT32 OsPmSuspendSleep(LosPmCB *pm)
Definition: los_pm.c:220
函数调用图:
这是这个函数的调用关系图:

◆ LOS_PmTimeLockRequest()

UINT32 LOS_PmTimeLockRequest ( const CHAR name,
UINT64  millisecond 
)

Request to obtain the lock in current mode, so that the system will not enter this mode when it enters the idle task next time. After the specified interval, the lock is automatically released.

Description:
This API is used to obtain the delay lock in current mode.
注意
None.
参数
name[IN] Who requests the lock.
millisecond[IN] Specifies the time to automatically release the lock.
返回值
errorcode, LOS_OK means success.
Dependency:
  • los_pm.h: the header file that contains the API declaration.
参见
LOS_PmLockRelease

在文件 los_pm.c629 行定义.

630{
631 UINT32 ticks;
632 UINT16 swtmrID;
633 UINT32 ret;
634
635 if ((name == NULL) || !millisecond) {
636 return LOS_EINVAL;
637 }
638
639 ticks = (UINT32)((millisecond + OS_MS_PER_TICK - 1) / OS_MS_PER_TICK);
640#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1)
641 ret = LOS_SwtmrCreate(ticks, LOS_SWTMR_MODE_ONCE, OsPmSwtmrHandler, &swtmrID, (UINT32)(UINTPTR)name,
642 OS_SWTMR_ROUSES_ALLOW, OS_SWTMR_ALIGN_INSENSITIVE);
643#else
644 ret = LOS_SwtmrCreate(ticks, LOS_SWTMR_MODE_ONCE, OsPmSwtmrHandler, &swtmrID, (UINT32)(UINTPTR)name);
645#endif
646 if (ret != LOS_OK) {
647 return ret;
648 }
649
650 ret = OsPmLockRequest(name, swtmrID);
651 if (ret != LOS_OK) {
652 (VOID)LOS_SwtmrDelete(swtmrID);
653 return ret;
654 }
655
656 ret = LOS_SwtmrStart(swtmrID);
657 if (ret != LOS_OK) {
658 (VOID)LOS_PmLockRelease(name);
659 }
660
661 return ret;
662}
LITE_OS_SEC_TEXT UINT32 LOS_SwtmrStart(UINT16 swtmrID)
接口函数 启动定时器 参数定时任务ID
Definition: los_swtmr.c:764
LITE_OS_SEC_TEXT_INIT UINT32 LOS_SwtmrCreate(UINT32 interval, UINT8 mode, SWTMR_PROC_FUNC handler, UINT16 *swtmrID, UINTPTR arg)
创建定时器,设置定时器的定时时长、定时器模式、回调函数,并返回定时器ID
Definition: los_swtmr.c:712
@ LOS_SWTMR_MODE_ONCE
Definition: los_swtmr.h:232
STATIC VOID OsPmSwtmrHandler(UINT32 arg)
Definition: los_pm.c:620
UINT32 LOS_PmLockRelease(const CHAR *name)
Release the lock in current mode so that the next time the system enters the idle task,...
Definition: los_pm.c:552
unsigned long UINTPTR
Definition: los_typedef.h:68
函数调用图:

◆ LOS_PmUnregister()

UINT32 LOS_PmUnregister ( LOS_PmNodeType  type,
VOID *  node 
)

Unregister a power management node.

Description:
This API is used to unregister a power management node.
注意
None.
参数
type[IN] The types supported by the PM module.
node[IN] power management node.
返回值
errorcode, LOS_OK means success.
Dependency:
  • los_pm.h: the header file that contains the API declaration.
参见
LOS_PmRegister

在文件 los_pm.c367 行定义.

368{
369 LosPmCB *pm = &g_pmCB;
370
371 if (node == NULL) {
372 return LOS_EINVAL;
373 }
374
375 switch (type) {
377 return OsPmDeviceUnregister(pm, (LosPmDevice *)node);
379 PRINT_ERR("Pm, %d is an unsupported type\n", type);
380 return LOS_EINVAL;
382 return OsPmSysctrlUnregister(pm, (LosPmSysctrl *)node);
383 default:
384 break;
385 }
386
387 return LOS_EINVAL;
388}
STATIC UINT32 OsPmSysctrlUnregister(LosPmCB *pm, LosPmSysctrl *sysctrl)
Definition: los_pm.c:356
STATIC UINT32 OsPmDeviceUnregister(LosPmCB *pm, LosPmDevice *device)
Definition: los_pm.c:342
函数调用图:

◆ LOS_PmWakeSet()

VOID LOS_PmWakeSet ( VOID  )

Set the system wake up flag.

Description:
This API is used to set the system wake-up flag.
注意
None.
参数
None.
返回值
None.
Dependency:
  • los_pm.h: the header file that contains the API declaration.
参见

在文件 los_pm.c390 行定义.

391{
392 LosPmCB *pm = &g_pmCB;
393
394 LOS_SpinLock(&g_pmSpin);
395 pm->isWake = TRUE;
396 LOS_SpinUnlock(&g_pmSpin);
397 return;
398}
BOOL isWake
Definition: los_pm.c:109
函数调用图:

◆ OsIsPmMode()

STATIC INLINE BOOL OsIsPmMode ( VOID  )

在文件 los_pm.c680 行定义.

681{
682 LosPmCB *pm = &g_pmCB;
683
684 LOS_SpinLock(&g_pmSpin);
685 if ((pm->sysMode != LOS_SYS_NORMAL_SLEEP) && (pm->lock == 0)) {
686 LOS_SpinUnlock(&g_pmSpin);
687 return TRUE;
688 }
689 LOS_SpinUnlock(&g_pmSpin);
690 return FALSE;
691}
LOS_SysSleepEnum sysMode
Definition: los_pm.c:107
函数调用图:
这是这个函数的调用关系图:

◆ OsPmCpuResume()

STATIC VOID OsPmCpuResume ( LosPmCB pm)

在文件 los_pm.c137 行定义.

138{
139 if ((pm->sysMode == LOS_SYS_NORMAL_SLEEP) && (pm->sysctrl->normalResume != NULL)) {
140 pm->sysctrl->normalResume();
141 } else if ((pm->sysMode == LOS_SYS_LIGHT_SLEEP) && (pm->sysctrl->lightResume != NULL)) {
142 pm->sysctrl->lightResume();
143 } else if ((pm->sysMode == LOS_SYS_DEEP_SLEEP) && (pm->sysctrl->deepResume != NULL)) {
144 pm->sysctrl->deepResume();
145 }
146}
VOID(* lightResume)(VOID)
Definition: los_pm.h:85
VOID(* normalResume)(VOID)
Definition: los_pm.h:77
VOID(* deepResume)(VOID)
Definition: los_pm.h:93
这是这个函数的调用关系图:

◆ OsPmCpuSuspend()

VOID OsPmCpuSuspend ( LosPmCB pm)

在文件 los_pm.c148 行定义.

149{
150 /* cpu enter low power mode */
151 LOS_ASSERT(pm->sysctrl != NULL);
152
153 if (pm->sysMode == LOS_SYS_NORMAL_SLEEP) {
154 pm->sysctrl->normalSuspend();
155 } else if (pm->sysMode == LOS_SYS_LIGHT_SLEEP) {
156 pm->sysctrl->lightSuspend();
157 } else if (pm->sysMode == LOS_SYS_DEEP_SLEEP) {
158 pm->sysctrl->deepSuspend();
159 } else {
161 }
162}
UINT32(* normalSuspend)(VOID)
Definition: los_pm.h:73
这是这个函数的调用关系图:

◆ OsPmDeviceRegister()

STATIC UINT32 OsPmDeviceRegister ( LosPmCB pm,
LosPmDevice device 
)

在文件 los_pm.c268 行定义.

269{
270 if ((device->suspend == NULL) || (device->resume == NULL)) {
271 return LOS_EINVAL;
272 }
273
274 LOS_SpinLock(&g_pmSpin);
275 pm->device = device;
276 LOS_SpinUnlock(&g_pmSpin);
277
278 return LOS_OK;
279}
LosPmDevice * device
Definition: los_pm.c:110
VOID(* resume)(UINT32 mode)
Definition: los_pm.h:56
UINT32(* suspend)(UINT32 mode)
Definition: los_pm.h:55
函数调用图:
这是这个函数的调用关系图:

◆ OsPmDeviceUnregister()

STATIC UINT32 OsPmDeviceUnregister ( LosPmCB pm,
LosPmDevice device 
)

在文件 los_pm.c342 行定义.

343{
344 LOS_SpinLock(&g_pmSpin);
345 if (pm->device == device) {
346 pm->device = NULL;
348 LOS_SpinUnlock(&g_pmSpin);
349 return LOS_OK;
350 }
351
352 LOS_SpinUnlock(&g_pmSpin);
353 return LOS_EINVAL;
354}
函数调用图:
这是这个函数的调用关系图:

◆ OsPmInit()

UINT32 OsPmInit ( VOID  )

在文件 los_pm.c715 行定义.

716{
717 LosPmCB *pm = &g_pmCB;
718
719 (VOID)memset_s(pm, sizeof(LosPmCB), 0, sizeof(LosPmCB));//全局链表置0
720
722 LOS_ListInit(&pm->lockList);//初始化链表
723 (VOID)LOS_EventInit(&g_pmEvent);
724
726 pm->sysctrl = &g_sysctrl;
727 return LOS_OK;
728}
LITE_OS_SEC_TEXT_INIT UINT32 LOS_EventInit(PEVENT_CB_S eventCB)
初始化一个事件控制块
Definition: los_event.c:95
LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListInit(LOS_DL_LIST *list)
Definition: los_list.h:104
STATIC LosPmSysctrl g_sysctrl
Definition: los_pm.c:121
STATIC VOID OsPmSysctrlInit(VOID)
Definition: los_pm.c:700
函数调用图:

◆ OsPmLockRequest()

UINT32 OsPmLockRequest ( const CHAR name,
UINT32  swtmrID 
)

请求获取指定的锁

在文件 los_pm.c473 行定义.

474{
475 INT32 len;
476 errno_t err;
477 UINT32 ret = LOS_EINVAL;
478 LosPmCB *pm = &g_pmCB;
479 OsPmLockCB *lock = NULL;
480 LOS_DL_LIST *head = &pm->lockList;
481 LOS_DL_LIST *list = head->pstNext;
482
483 if (OS_INT_ACTIVE) {
484 return LOS_EINTR;
485 }
486
487 len = strlen(name);
488 if (len <= 0) {
489 return LOS_EINVAL;
490 }
491
492 LOS_SpinLock(&g_pmSpin);
493 if (pm->lock >= OS_PM_LOCK_MAX) {
494 LOS_SpinUnlock(&g_pmSpin);
495 return LOS_EINVAL;
496 }
497 //遍历找到参数对应的 OsPmLockCB
498 while (list != head) {
499 OsPmLockCB *listNode = LOS_DL_LIST_ENTRY(list, OsPmLockCB, list);
500 if (strcmp(name, listNode->name) == 0) {
501 lock = listNode;
502 break;
503 }
504
505 list = list->pstNext;
506 }
507
508 if (lock == NULL) {//没有记录则创建记录
509 lock = LOS_MemAlloc((VOID *)OS_SYS_MEM_ADDR, sizeof(OsPmLockCB));
510 if (lock == NULL) {
511 LOS_SpinUnlock(&g_pmSpin);
512 return LOS_ENOMEM;
513 }
514
515 err = memcpy_s(lock->name, OS_PM_LOCK_NAME_MAX, name, len + 1);
516 if (err != EOK) {
517 LOS_SpinUnlock(&g_pmSpin);
518 (VOID)LOS_MemFree((VOID *)OS_SYS_MEM_ADDR, lock);
519 return err;
520 }
521 lock->count = 1;//数量增加
522 lock->swtmrID = swtmrID;
523 LOS_ListTailInsert(head, &lock->list);//从尾部插入链表中
524 } else if (lock->count < OS_PM_LOCK_MAX) {
525 lock->count++;//存在记录时,数量增加
526 }
527
528 if ((lock->swtmrID != OS_INVALID) && (lock->count > 1)) {
529 lock->count--;
530 LOS_SpinUnlock(&g_pmSpin);
531 return LOS_EINVAL;
532 }
533
534 if (pm->lock < OS_PM_LOCK_MAX) {
535 pm->lock++;//总数量增加
536 ret = LOS_OK;
537 }
538
539 LOS_SpinUnlock(&g_pmSpin);
540 return ret;
541}
LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListTailInsert(LOS_DL_LIST *list, LOS_DL_LIST *node)
Insert a node to the tail of a doubly linked list.
Definition: los_list.h:244
VOID * LOS_MemAlloc(VOID *pool, UINT32 size)
从指定内存池中申请size长度的内存,注意这可不是从内核堆空间中申请内存
Definition: los_memory.c:1123
函数调用图:
这是这个函数的调用关系图:

◆ OsPmResumePrepare()

STATIC VOID OsPmResumePrepare ( LosPmCB pm,
UINT32  mode,
UINT32  prepare 
)

在文件 los_pm.c164 行定义.

165{
166 if ((prepare == 0) && (pm->device != NULL) && (pm->device->resume != NULL)) {
167 pm->device->resume(mode);
168 }
169
170 if (((prepare == 0) || (prepare == OS_PM_SYS_DEVICE_EARLY)) && (pm->sysctrl->late != NULL)) {
171 pm->sysctrl->late(mode);
172 }
173}
VOID(* late)(UINT32 mode)
Definition: los_pm.h:69
这是这个函数的调用关系图:

◆ OsPmSuspendCheck()

STATIC UINT32 OsPmSuspendCheck ( LosPmCB pm,
Suspend sysSuspendEarly,
Suspend deviceSuspend,
LOS_SysSleepEnum mode 
)

在文件 los_pm.c198 行定义.

199{
200 LOS_SpinLock(&g_pmSpin);
201 pm->sysMode = pm->pmMode;
202 if (pm->lock > 0) {
204 LOS_SpinUnlock(&g_pmSpin);
205 return LOS_NOK;
206 }
207
208 pm->isWake = FALSE;
209 *mode = pm->sysMode;
210 *sysSuspendEarly = pm->sysctrl->early;
211 if (pm->device != NULL) {
212 *deviceSuspend = pm->device->suspend;
213 } else {
214 *deviceSuspend = NULL;
215 }
216 LOS_SpinUnlock(&g_pmSpin);
217 return LOS_OK;
218}
UINT32(* early)(UINT32 mode)
Definition: los_pm.h:64
函数调用图:
这是这个函数的调用关系图:

◆ OsPmSuspendDefaultHandler()

STATIC UINT32 OsPmSuspendDefaultHandler ( VOID  )

在文件 los_pm.c693 行定义.

694{
695 PRINTK("Enter pm default handler!!!\n");
696 WFI;
697 return LOS_OK;
698}
这是这个函数的调用关系图:

◆ OsPmSuspendPrepare()

STATIC UINT32 OsPmSuspendPrepare ( Suspend  sysSuspendEarly,
Suspend  deviceSuspend,
UINT32  mode,
UINT32 prepare 
)

在文件 los_pm.c175 行定义.

176{
177 UINT32 ret;
178
179 if (sysSuspendEarly != NULL) {
180 ret = sysSuspendEarly(mode);
181 if (ret != LOS_OK) {
182 *prepare = OS_PM_SYS_EARLY;
183 return ret;
184 }
185 }
186
187 if (deviceSuspend != NULL) {
188 ret = deviceSuspend(mode);
189 if (ret != LOS_OK) {
190 *prepare = OS_PM_SYS_DEVICE_EARLY;
191 return ret;
192 }
193 }
194
195 return LOS_OK;
196}
这是这个函数的调用关系图:

◆ OsPmSuspendSleep()

STATIC UINT32 OsPmSuspendSleep ( LosPmCB pm)

在文件 los_pm.c220 行定义.

221{
222 UINT32 ret, intSave;
223 Suspend sysSuspendEarly, deviceSuspend;
224 LOS_SysSleepEnum mode;
225 UINT32 prepare = 0;
226 BOOL tickTimerStop = FALSE;
227
228 ret = OsPmSuspendCheck(pm, &sysSuspendEarly, &deviceSuspend, &mode);
229 if (ret != LOS_OK) {
230 PRINT_ERR("Pm suspend mode is normal sleep! lock count %d\n", pm->lock);
231 return ret;
232 }
233
234 ret = OsPmSuspendPrepare(sysSuspendEarly, deviceSuspend, (UINT32)mode, &prepare);
235 if (ret != LOS_OK) {
236 LOS_SpinLockSave(&g_pmSpin, &intSave);
237 LOS_TaskLock();
238 goto EXIT;
239 }
240
241 LOS_SpinLockSave(&g_pmSpin, &intSave);
242 LOS_TaskLock();
243 if (pm->isWake || (pm->lock > 0)) {
244 goto EXIT;
245 }
246
247 tickTimerStop = OsPmTickTimerStop(pm);
248 if (!tickTimerStop) {
251 }
252
253 OsPmCpuSuspend(pm);
254
255 OsPmCpuResume(pm);
256
258
259EXIT:
261 OsPmResumePrepare(pm, (UINT32)mode, prepare);
262
263 LOS_SpinUnlockRestore(&g_pmSpin, intSave);
265 return ret;
266}
LITE_OS_SEC_TEXT_MINOR VOID LOS_TaskUnlock(VOID)
Unlock the task scheduling.
Definition: los_task.c:1148
LITE_OS_SEC_TEXT_MINOR VOID LOS_TaskLock(VOID)
Lock the task scheduling.
Definition: los_task.c:1139
VOID OsPmCpuSuspend(LosPmCB *pm)
Definition: los_pm.c:148
STATIC VOID OsPmResumePrepare(LosPmCB *pm, UINT32 mode, UINT32 prepare)
Definition: los_pm.c:164
STATIC UINT32 OsPmSuspendPrepare(Suspend sysSuspendEarly, Suspend deviceSuspend, UINT32 mode, UINT32 *prepare)
Definition: los_pm.c:175
STATIC UINT32 OsPmSuspendCheck(LosPmCB *pm, Suspend *sysSuspendEarly, Suspend *deviceSuspend, LOS_SysSleepEnum *mode)
Definition: los_pm.c:198
STATIC VOID OsPmTickTimerStart(LosPmCB *pm)
Definition: los_pm.c:125
UINT32(* Suspend)(UINT32 mode)
电源锁控制块
Definition: los_pm.c:96
STATIC BOOL OsPmTickTimerStop(LosPmCB *pm)
Definition: los_pm.c:131
STATIC VOID OsPmCpuResume(LosPmCB *pm)
Definition: los_pm.c:137
VOID OsSchedExpireTimeUpdate(VOID)
Definition: los_sched.c:88
VOID OsSchedResponseTimeReset(UINT64 responseTime)
Definition: los_sched.c:189
VOID LOS_SpinUnlockRestore(SPIN_LOCK_S *lock, UINT32 intSave)
Definition: los_spinlock.c:108
VOID LOS_SpinLockSave(SPIN_LOCK_S *lock, UINT32 *intSave)
Definition: los_spinlock.c:98
函数调用图:
这是这个函数的调用关系图:

◆ OsPmSwtmrHandler()

STATIC VOID OsPmSwtmrHandler ( UINT32  arg)

在文件 los_pm.c620 行定义.

621{
622 const CHAR *name = (const CHAR *)arg;
623 UINT32 ret = LOS_PmLockRelease(name);
624 if (ret != LOS_OK) {
625 PRINT_ERR("Pm delay lock %s release faled! : 0x%x\n", name, ret);
626 }
627}
char CHAR
Definition: los_typedef.h:63
函数调用图:
这是这个函数的调用关系图:

◆ OsPmSysctrlInit()

STATIC VOID OsPmSysctrlInit ( VOID  )

在文件 los_pm.c700 行定义.

701{
702 /* Default handler functions, which are implemented by the product */
703 g_sysctrl.early = NULL;
704 g_sysctrl.late = NULL;
706 g_sysctrl.normalResume = NULL;
708 g_sysctrl.lightResume = NULL;
710 g_sysctrl.deepResume = NULL;
713}
STATIC UINT32 OsPmSuspendDefaultHandler(VOID)
Definition: los_pm.c:693
VOID(* shutdownResume)(VOID)
Definition: los_pm.h:101
函数调用图:
这是这个函数的调用关系图:

◆ OsPmSysctrlRegister()

STATIC UINT32 OsPmSysctrlRegister ( LosPmCB pm,
LosPmSysctrl sysctrl 
)

在文件 los_pm.c281 行定义.

282{
283 LOS_SpinLock(&g_pmSpin);
284 if (sysctrl->early != NULL) {
285 pm->sysctrl->early = sysctrl->early;
286 }
287 if (sysctrl->late != NULL) {
288 pm->sysctrl->late = sysctrl->late;
289 }
290 if (sysctrl->normalSuspend != NULL) {
291 pm->sysctrl->normalSuspend = sysctrl->normalSuspend;
292 }
293 if (sysctrl->normalResume != NULL) {
294 pm->sysctrl->normalResume = sysctrl->normalResume;
295 }
296 if (sysctrl->lightSuspend != NULL) {
297 pm->sysctrl->lightSuspend = sysctrl->lightSuspend;
298 }
299 if (sysctrl->lightResume != NULL) {
300 pm->sysctrl->lightResume = sysctrl->lightResume;
301 }
302 if (sysctrl->deepSuspend != NULL) {
303 pm->sysctrl->deepSuspend = sysctrl->deepSuspend;
304 }
305 if (sysctrl->deepResume != NULL) {
306 pm->sysctrl->deepResume = sysctrl->deepResume;
307 }
308 if (sysctrl->shutdownSuspend != NULL) {
310 }
311 if (sysctrl->shutdownResume != NULL) {
312 pm->sysctrl->shutdownResume = sysctrl->shutdownResume;
313 }
314 LOS_SpinUnlock(&g_pmSpin);
315
316 return LOS_OK;
317}
函数调用图:
这是这个函数的调用关系图:

◆ OsPmSysctrlUnregister()

STATIC UINT32 OsPmSysctrlUnregister ( LosPmCB pm,
LosPmSysctrl sysctrl 
)

在文件 los_pm.c356 行定义.

357{
358 (VOID)sysctrl;
359 LOS_SpinLock(&g_pmSpin);
362 LOS_SpinUnlock(&g_pmSpin);
363
364 return LOS_OK;
365}
函数调用图:
这是这个函数的调用关系图:

◆ OsPmTickTimerStart()

STATIC VOID OsPmTickTimerStart ( LosPmCB pm)

在文件 los_pm.c125 行定义.

126{
127 (VOID)pm;
128 return;
129}
这是这个函数的调用关系图:

◆ OsPmTickTimerStop()

STATIC BOOL OsPmTickTimerStop ( LosPmCB pm)

在文件 los_pm.c131 行定义.

132{
133 (VOID)pm;
134 return FALSE;
135}
这是这个函数的调用关系图:

◆ SPIN_LOCK_INIT()

STATIC SPIN_LOCK_INIT ( g_pmSpin  )

电源模块自旋锁

变量说明

◆ g_pmCB

STATIC LosPmCB g_pmCB

电源控制块全局遍历

在文件 los_pm.c119 行定义.

◆ g_pmEvent

STATIC EVENT_CB_S g_pmEvent

在文件 los_pm.c118 行定义.

◆ g_sysctrl

STATIC LosPmSysctrl g_sysctrl

在文件 los_pm.c121 行定义.