Visible to Intel only — Ixiasoft
Visible to Intel only — Ixiasoft
4.3.2.2.3. MPU Register Details
This section describes the register maps, the meanings of the register fields, and how the register fields are used.
When you initialize the MPU you use two registers: mpubase and mpuacc.
Register mpubase Usage
Bit Fields | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
BASE3 | |||||||||||||||
15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
BASE3 | 0 | INDEX2 | D |
Field | Description | Access | Reset | Available |
---|---|---|---|---|
BASE | BASE is the base memory address of the region identified by the INDEX and D fields. | Read/Write | 0 | Only with MPU |
INDEX | INDEX is the region index number. | Read/Write | 0 | Only with MPU |
D | D is the region access bit. When D =1, INDEX refers to a data region. When D = 0, INDEX refers to an instruction region. | Read/Write | 0 | Only with MPU |
You specify an MPU region by writing a value representing the region's base address to the BASE field, a unique index to the INDEX field, and the region type (data or instruction) to field D.
The BASE field represents the region's base address, in the form described by the equation below. The BASE field can only represent addresses aligned to an integer multiple of <min_region>. For example, if the minimum region size is 16 kilobytes (KB), regions can be located at addresses such as 0x0, 0x4000, 0x8000, ... .
BASE = <base address>/<min_region>
For example, if the region starts at 0x1000 and the minimum region size is 256 bytes, set the BASE field to 0x10, which is 0x1000/256.
The INDEX field provides a unique identifier for the region. INDEX also specifies the priority of the region. The lower the index value, the higher the region’s priority.
Use the D field to specify the region type: data or instruction.
Register mpuacc Usage
mpuacc has two possible layouts, depending on the Platform Designer generation-time option Use limit for region range, as described in Adding the MPU Hardware section. This option controls whether the mpuacc register contains a MASK or LIMIT field. The table below shows the layout of the mpuacc register with the MASK field.
Bit Fields | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
MASK[n-1:p]4 | |||||||||||||||
15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
MASK[n-1:p]4 | 0 | MT | PERM | RD | WR |
Bit Fields | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
LIMIT[n:p]4 | |||||||||||||||
15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
LIMIT[n:p]4 | 0 | MT | PERM | RD | WR |
Field | Description | Access | Reset | Available |
---|---|---|---|---|
MASK | MASK specifies the size of the region. | Read/Write | 0 | Only with MPU |
LIMIT | LIMIT specifies the upper address limit of the region. | Read/Write | 0 | Only with MPU |
MT | (MT) Memory Type:
|
Read/Write | 0 | Only with MPU |
PERM | PERM specifies the access permissions for the region. | Read/Write | 0 | Only with MPU |
RD | RD is the read region flag. When RD = 1, wrctl instructions to the mpuacc register perform a read operation. | Write | 0 | Only with MPU |
WR | WR is the write region flag. When WR = 1, wrctl instructions to the mpuacc register perform a write operation. | Write | 0 | Only with MPU |
If the mpuacc register is configured with the MASK field, the MASK field represents the size of your region. The value of MASK is defined in the equation below.
MASK = 0xFFFFFF << log2 ( <region_size> >> 8 )
The table below lists every possible MASK value for an MPU configured with a256-byte minimum region size.
MASK Encoding | Region Size |
---|---|
0xFFFFFF | 256 bytes |
0xFFFFFE | 512 bytes |
0xFFFFFC | 1 KB |
0xFFFFF8 | 2 KB |
0xFFFFF0 | 4 KB |
0xFFFFE0 | 8 KB |
0xFFFFC0 | 16 KB |
0xFFFF80 | 32 KB |
0xFFFF00 | 64 KB |
0xFFFE00 | 128 KB |
0xFFFC00 | 256 KB |
0xFFF800 | 512 KB |
0xFFF000 | 1 MB |
0xFFE000 | 2 MB |
0xFFC000 | 4 MB |
0xFF8000 | 8 MB |
0xFF0000 | 16 MB |
0xFE0000 | 32 MB |
0xFC0000 | 64 MB |
0xF80000 | 128 MB |
0xF00000 | 256 MB |
0xE00000 | 512 MB |
0xC00000 | 1 GB |
0x800000 | 2 GB |
0x000000 | 4 GB |
If the mpuacc register is configured with the LIMIT field, LIMIT represents the address immediately following the upper end of your region. For example, suppose the MPU’s minimum region size is 256 bytes, and you need to set up the following region:
- The region starts at 0x1000
- The region ends at 0x1FFF
To set up the desired region, configure mpubase.BASE and mpuacc.LIMIT as shown in the following list:
- Set mpubase.BASE to 0x10, which is 0x1000/256 or (0x1000 >> 8)
- Set mpuacc.LIMIT to 0x20, which is 0x2000/256 or (0x2000 >> 8)
Use the C field to specify whether a data region is to be cached. Usually, you set C for memory regions and clear it for regions representing registers or general-purpose memory-mapped I/O.
The PERM field defines the permissions for the region, as shown in the two tables below.
PERM Encoding | Supervisor Permissions | User Permissions |
---|---|---|
000 | None | None |
001 | Execute | None |
010 | Execute | Execute |
PERM Encoding | Supervisor Permissions | User Permissions |
---|---|---|
000 | None | None |
001 | Read | None |
010 | Read | Read |
100 | Read/Write | None |
101 | Read/Write | Read |
110 | Read/Write | Read/Write |
Defining Regions with mpubase and mpuacc
The mpubase register works in conjunction with the mpuacc register to set and retrieve MPU region information. Use the RD and WR fields of mpuacc to instruct the MPU to perform an MPU region read or write, as shown in the following list:
- Set mpuacc.RD = 1 to perform an MPU region read operation.
- Set mpuacc.WR = 1 to perform an MPU region write operation.
An MPU region must be disabled if it is not in use. To disable a region, software sets up the following conditions:
- mpubase.BASE is any nonzero value.
- If the MPU is configured to define region size by mask, mpuacc.MASK represents 0x100000000, which is 232 (the size of the Nios® II address space). For example, if the minimum region size is 256, or 0x100 bytes, mpuacc.MASK is 0x100000000 / 0x100, or 0x10000000.
- If the MPU is configured to define region size by limit, mpuacc.LIMIT = 0.