stm32 cortex M0+内核 程序权限
来源:互联网 发布:nginx 禁止某域名访问 编辑:程序博客网 时间:2024/05/21 10:17
两种操作模式分别为:处理者模式和线程模式(thread mode)。
引入两个模式的本意,是用于区别普通应用程序的代码和异常服务例程的代码——包括中断服务例程的代码。
两级特权操作分别为:特权级和用户级。
这可以提供一种存储器访问的保护机制,使得普通的用户程序代码不能意外地,甚至是恶意地执行涉及到要害的操作。
处理器支持两种特权级,这也是一个基本的安全模型。
主应用程序(线程模式),既可以使用特权级,也可以使用用户级;
异常服务例程(处理者模式)必须在特权级下执行。
通过引入特权级和用户级,就能够在硬件水平上限制某些不受信任的或者还没有调试好的程序,
不让它们随便地配置涉及要害的寄存器,因而系统的可靠性得到了提高。
控制寄存器(CONTROL)CONTROL[0]=1,用户级的线程模式CONTROL[0]=0,特权级的线程模式CONTROL[1]=1,选择使用PSPCONTROL[1]=0,选择使用MSP
复位后,处理器默认进入线程模式,特权极访问 ( 使用 MSP 作为堆栈指针 )
EXC_RETURN Description0xFFFFFFF1 Return to Handler mode. Exception return gets state from the main stack. Execution uses MSP after return.0xFFFFFFF9 Return to Thread mode. Exception Return get state from the main stack. Execution uses MSP after return.0xFFFFFFFD Return to Thread mode. Exception return gets state from the process stack. Execution uses PSP after return.
Handler mode always uses the MSP, so the processor ignores explicit writes to the active stack pointer bit of the CONTROL register when in Handler mode. The exception entry and return mechanisms automatically update the CONTROL register based on the EXC_RETURN value
In an OS environment, ARM recommends
the kernel and exception handlers use the main stack.
the threads running in Thread mode use the process stack.
By default, Thread mode uses the MSP.
To switch the stack pointer used in Thread mode to the PSP
(1) use the MSR instruction to set the Active stack pointer bit to 1, CONTROL[1] = 1
(2) perform an exception return to Thread mode with the appropriate EXC_RETURN value
When changing the stack pointer, software must use an ISB instruction immediately after the MSR instruction. This ensures that instructions after the ISB instruction execute using the new stack pointer.
Processor mode and privilege levels for software execution
The processor modes are:
- Thread mode
Used to execute application software.
The processor enters Thread mode when it comes out of reset.- Handler mode
Used to handle exceptions.
The processor returns to Thread mode when it has finished all exception processing.
The privilege levels for software execution are:
- Unprivileged
The software:
has limited access to the
MSR
andMRS
instructions, and cannot use theCPS
instructioncannot access the system timer, NVIC, or system control block
might have restricted access to memory or peripherals.
Unprivileged software executes at the unprivileged level.
- Privileged
The software can use all the instructions and has access to all resources.
Privileged software executes at the privileged level.
In Thread mode, the CONTROL register controls whether software execution is privileged or unprivileged, see CONTROL register.
In Handler mode, software execution is always privileged.
Only privileged software can write to the CONTROL register to change the privilege level for software execution in Thread mode.
Unprivileged software can use the SVC
instruction to make a supervisor call to transfer control to privileged software.
- stm32 cortex M0+内核 程序权限
- Cortex m0+内核架构笔记
- Cortex-M0(+)内核的处理器架构简介
- 基于ARM Cortex-M0+内核的bootloader程序升级原理及代码解析
- cortex M0
- 持续更新《Cortex-M0内核MCU的IAP升级》
- 【Cortex-M0】3 ARM Cortex-M0
- 【Cortex-M0】13看门狗
- Cortex-M0指令集
- Cortex-M0启动文件
- Cortex-M0+指令集
- ARM 指令 CORTEX-M0
- 浅谈ARM Cortex-M0
- Cortex-M的M0,M+,M3,M4,M7几种内核的简单区别
- 【Cortex-M0】2 ARM概述
- 【Cortex-M0】11串口控制器
- 【Cortex-M0】12外部中断
- 【Cortex-M0】19.3 Hex文件
- 算法(第4版本)1.1.15
- JAVA Byte数组与十六进制互转
- 抽象类和接口中的细节
- L1-004. 计算摄氏温度
- 二叉树的三种遍历方式(递归、非递归和Morris遍历)
- stm32 cortex M0+内核 程序权限
- envi光谱库中光谱降采样
- 浅谈循环中setTimeout执行顺序问题
- LeetCode 100. Same Tree
- nginx的配置详解
- 窗口(JFrame)
- jvm莫名启动被linux系统杀掉进程
- tinyHttpd
- 自动备份数据库脚本