9.5.1. Updating an MPU region using CP15 equivalent code

Using CP15 equivalent code:

; R1 = region number
; R2 = size/enable
; R3 = attributes
; R4 = address
MOV	R0,#NVIC_BASE 
ADD	R0,#MPU_REG_CTRL 
STR	R1,[R0,#0]		; region number
STR	R4,[R0,#4]		; address 
STRH	R2,[R0,#8]		; size and enable
STRH	R3,[R0,#10]		; attributes

Note

If interrupts could pre-empt during this period, this region could affect them. This means that the region must be disabled, written, and then enabled. This is usually not necessary for a context switcher, but would be necessary if updated elsewhere.

; R1 = region number
; R2 = size/enable
; R3 = attributes
; R4 = address
MOV	R0,#NVIC_BASE 
ADD	R0,#MPU_REG_CTRL 
STR	R1,[R0,#0]		; region number
BIC	R2,R2, #1		; disable
STRH	R2,[R0,#8]		; size and enable
STR	R4,[R0,#4]		; address 
STRH	R3,[R0,#10]		; attributes
ORR	R2,#1		; enable
STRH	R2,[R0,#8]		; size and enable

DMB/DSB is not necessary because the Private Peripheral Bus is a strongly ordered memory area. However, a DSB is necessary before the effect on the MPU takes place, such as the end of a context switcher.

An ISB is necessary if the code that programs the MPU region or regions is entered using a branch or call. If the code is entered using a return from exception, or by taking an exception, then an ISB is not necessary.

Copyright © 2005, 2006 ARM Limited. All rights reserved.ARM DDI 0337E
Non-Confidential