分享

arm 待机指令 WFI和WFE

 云将东游 2018-10-12
百度百科上对于待机的解释:
待机是将当前处于运行状态的数据保存在内存中,机器只对内存供电,而硬盘、屏幕和CPU等部件则停止供电。由于数据存储在速度快的内存中,因此进入等待状态和唤醒的速度比较快。
对于手机而言,待机就是除了DDR保持低频刷新,维护DDR中数据以外,其他的外围设备都断电,cpu core也进入low power 模式,
停止工作,等待外部事件唤醒。


arm core进入待机依赖两个arm 指令,WFI(Wait for interrupt)和WFE(Wait for event)。
这两个指令都可以使cpu core进入低电模式,但是也有细微差别,
具体看下arm解释。


Wait for Event WFE:
If the event register is currently set, WFE (Wait For Event) clears it and returns immediately. If the event register is not set, the processor suspends execution (Clock is stopped) until one of the following events take place:
An IRQ interrupt, unless masked by the CPSR I Bit
An FIQ interrupt, unless masked by the CPSR F Bit
A Debug Entry request made to the processor and Debug is enabled
An event is signaled by another processor using Send Event.
Another MP11 CPU return from exception.


Wait for Interrupt WFI:
WFI (Wait For Interrupt) makes the processor suspend execution (Clock is stopped) until one of the following events take place:
An IRQ interrupt
An FIQ interrupt
A Debug Entry request made to the processor.


对WFI来说,执行WFI指令后,ARM core会立即进入low-power standby state,直到有WFI Wakeup events发生。
而WFE则稍微不同,执行WFE指令后,根据Event Register(一个单bit的寄存器,每个PE一个)的状态,有两种情况:如果Event Register为1,该指令会把它清零,然后执行完成(不会standby);如果Event Register为0,和WFI类似,进入low-power standby state,直到有WFE Wakeup events发生。


而在系统待机时候,当执行完task freeze,所有device suspend后,执行WFI指令进入待机状态,然后等待外围中断唤醒。

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多