<< ARM

ARM Cortex-M Processor

1. Basic Concepts

# Definition

ARM(Advanced RISC Machine) is the name of company, a set of microprocessor, and one kind of technology. The RISC design simplify structure of processor, reduce complex instructions, and support processor extension.

The mainstream movement from MISC to RISC relays on the development of memory.

==RISC-V open source.==

# Property

2. Architecture Version

# V1 Architecture (ARM1)
# V2 Architecture (ARM2, ARM3)
# V3 Architecture (ARM6)
# V4 Architecture (ARM7, ARM9)
# V5 Architecture (ARM10)
# V6 Architecture
# V7 Architecture
# V8 Architecture

4. Mode and Privilege

Two operation status includes for Cortex-M4:

Two mode includes for Cortex-M4:

Two priviledges included for Cortex-M4:

The process in deprivileged level calls the system call named SVC(supervisor calls) to enter the privileged level.

stateDiagram
ProcessMode --> ProcessingMode
ProcessMode --> ThreadMode

5. Register

There are 32-bit registers Cortex-M4 process, classified to 7 types: 4 types of general registers and 3 types of special registers:

stateDiagram
%%state ARM_Cortex-M4_Registers {
    Registers --> GeneralRegister
    Registers --> SpecialRegister

    GeneralRegister --> bit32GeneralRegister
    bit32GeneralRegister --> LowRegisterR0_R7
    bit32GeneralRegister --> HighRegisterR8_R12

    GeneralRegister --> R13_SP
    GeneralRegister --> R14_LR
    GeneralRegister --> R15_PC

    SpecialRegister --> PSR
    SpecialRegister --> PRIMASK
    SpecialRegister --> CONTROL
%%}

6. Exception

# Exception Table
Code Type Priority Description
0 - - No exception
1 Reset -3 Reset
2 NMI -2 Non-maskable interruption
3 Catastrophic faults -1 All of the faults will cause catastrophic fault when the configurable fault handing process is prohibited
16 IRQ #0 Programmable IO interrupt #0
17 IRQ #1 Programmable IO interrupt #1
255 IRQ # 239 Programmable IO interrupt #239
# Data Push

When an exception arised, the processor first push the 8 registers into stack:

Address N-8 N-4 N-32 N-28 N-24 N-20 N-16 N-12
Data PC PSR R0 R1 R2 R3 R12 LR
# Exception Handling
stateDiagram

UserThreadMode --> PriviledgedHandlerMode : Raise Exception
PriviledgedHandlerMode --> UserThreadMode : Exception Return
privilegedThereadMode --> UserThreadMode : Change register `CONTROL`
privilegedThereadMode --> PriviledgedHandlerMode : Raise Exception
PriviledgedHandlerMode --> privilegedThereadMode : Exception Return