您的位置 首页 FPGA

ARM的System Mode

在ARMv4以后的版本里,ARM核都有7中工作模式:User,FIQ,IRQ,Supervisor,Abort,Undefined,和System。7种processormode又分为3…

ARM v4今后的版别里,ARM核都有7中作业形式:User, FIQ, IRQ, Supervisor, Abort, Undefined,和System

7种processor mode又分为3类:

User mode

Privileged mode

system mode

关于System mode的效果一向有些含糊,今天在arm的网站上找到了一份阐明文档,对这个问题的解析很到位,特记载如下:

The ARM Architecture defines a User mode that has 15 generalpurpose registers, a pc, and a CPSR.

除User Mode外,还有5种privileged modes

每一种Priviledged mode都有一个SPSRand a number of registers that replace some of the 15 User mode generalpurpose registers.

当exception产生时:

the current PC is copied into the link register for the exception mode,

theCPSR is copied into the SPSR for the exception mode.

The CPSR isthen altered in an exception-dependent way, and the program counteris set to an exception-defined address to start the

exception handler.

BL指令copiesthe return address into r14 before changing the PC,so the subroutine return instruction moves r14 to pc (MOV pc,lr).

Together these actions imply that ARM modes that handle exceptionsmust ensure that another exception of the same type cannot

occurif they call subroutines, because the subroutine return addresswill be overwritten with the exception return address.

(要避免lr被掩盖)

(In earlier versions of the ARM architecture, this problemhas been solved by either carefully avoiding subroutine calls inexception

code, or changing from the privileged mode to User mode.The first solution is often too restrictive, and the second meansthe task

may not have the privileged access it needs to run correctly.)

从ARMv4架构开端,供给了system mode来处理lr掩盖问题.

System mode is a privileged processormode that shares the User mode registers. (与User Mode共用registers)

Privileged mode taskscan run in this mode, and exceptions no longer overwrite the linkregister.

留意:

System modecannot be entered by an exception.

The exceptionhandlers modify the CPSR to enter System mode. See Reentrant interrupt handlersfor an example.

就不逐字翻译了,大体意思如下:

当处理器反常呈现时,当时程序计数器(也便是 PC+offset,offset与反常品种相关)会被复制的相应反常形式的LR,CPSR也会被复制到

相应反常形式的SPSR。然后CPSR会被设置为相应的反常形式, PC被设置到对应反常的入口处履行其处理函数。

(上面这些都是ARM核主动操作的)

ARM的子程序搬运指令BL会在改动PC前将回来地址放到LR中,所以从子程序回来时能够把r14放到PC来操作。如MOV pc, lr。

一切上面的动作都暗示了假如反常处理函数会调用子程序(运用 BL),那么各反常形式都必须确保反常处理函数履行的过程中不能呈现

相同的反常,因为子函数的回来地址会被反常的回来地址掩盖掉。(在前期的ARM版别中,能够经过制止反常处理函数调用子函数或许切

换处理形式到User形式来处理这个问题。第一种方法过于严厉,而第二种方法能够会因为User形式短少相应的权限而不能履行某些动

作)。

为此,ARM v4及之后的版别供给了system mode这样一种处理器形式来处理这个问题。System mode是一种privileged的形式,并且共用

User形式的一切寄存器。Privileged形式的程序能够运转在这个形式,而不必忧虑处理器反常会擦除LR。

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/fangan/fpga/275648.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部