arm - ARM 系统模式与 arm 监控模式有何不同?

标签 arm embedded embedded-linux cpu-architecture

将 ARM 处理器模式与 x86 操作模式(ring0 到 ring 3)进行比较,用户模式看起来就像 ring3,用户空间程序在其中运行。
但是,我无法将 ring0 与系统模式或主管模式联系起来。根据信息来源,似乎两种模式都可以很好地完成在特权模式下运行内核的工作。
我能找到的两种模式之间的唯一区别是以下几点:

  • 寄存器 13 和 14 在管理模式下存储,而对于系统模式,所有 15 个寄存器都相同。
  • 系统模式不能直接进入异常,而监督模式可以。
  • 系统模式以某种方式防止链接寄存器损坏。

  • 你能解释一下模式之间的区别吗,一个来自 x86 背景的人可以理解吗?

    此外,模式之间细微的架构差异(例如存储寄存器的数量)如何使一种优于另一种?

    最佳答案

    我认为 ARM ARM 说得很清楚(见下文),不要认为 X86 只考虑这种处理器模式允许您做什么或不做什么。以及您在操作系统中需要什么以及哪些模式有用与否。
    您有用户和系统,然后是异常模式。他们的限制记录在 AFAIK 中。较新的 ARM 具有更多功能/限制/保护等。
    从 ARM ARM

    Most application programs execute in User mode. When the processor is in User mode, the program being executed is unable to access some protected system resources or to change mode, other than by causing an exception to occur (see Exceptions on page A2-16). This allows a suitably-written operating system to control the use of system resources. The modes other than User mode are known as privileged modes. They have full access to system resources and can change mode freely. Five of them are known as exception modes:

    -FIQ

    -IRQ

    -Supervisor

    -Abort

    -Undefined.

    These are entered when specific exceptions occur. Each of them has some additional registers to avoid corrupting User mode state when the exception occurs (see Registers on page A2-4 for details).

    The remaining mode is System mode, which is not entered by any exception and has exactly the same registers available as User mode. However, it is a privileged mode and is therefore not subject to the User mode restrictions. It is intended for use by operating system tasks that need access to system resources, but wish to avoid using the additional registers associated with the exception modes. Avoiding such use ensures that the task state is not corrupted by the occurrence of any exception.


    监督模式是您在进行 svc 或 sys 调用时点击的模式(我认为他们将名称从 svc 更改为相同的指令)。类似于 dos 时代的 int 21h,这就是您在没有任何权限的用户模式下要求操作系统做某事的方式。这将控制切换到主管模式,然后一旦进入主管模式,您就可以在那里处理它或切换模式等......一旦您切换到用户,尽管您无法切换出去。因此,例如,如果您想设置用户堆栈,则无法在用户模式下轻松完成此操作,然后再返回操作系统任务。所以你需要一个特权模式,如果没有其他用户注册访问。

    关于arm - ARM 系统模式与 arm 监控模式有何不同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29745892/

    相关文章:

    linux - 如何使用 opengl 和 Qt 在 ARM 平台上启动 linux?

    c - STM32F4 不压入/弹出浮点寄存器

    security - ARM TrustZone,连接外围设备?

    c - 在编译时用单调序列初始化全局整数数组?

    arm - 如何通过 ARM 上的简单指令获得硬故障异常

    c - 为什么 `libusb_bulk_transfer'返回0?

    embedded - 嵌入式代码示例的用例图

    linux - 如何在uclinux中访问USB大容量存储设备...?

    linux - 无法在屏幕上停用省电功能