您的位置:首页 > Web前端

arm 待机指令 WFI和WFE

2017-05-18 16:30 337 查看
百度百科上对于待机的解释:

待机是将当前处于运行状态的数据保存在内存中,机器只对内存供电,而硬盘、屏幕和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指令进入待机状态,然后等待外围中断唤醒。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: