Understanding of MMU address translation in arm

Source: Internet
Author: User

First, we need to distinguish between three addresses on the ARM CPU: virtual address, transformed virtual address (mva,modified va,virtual), Physical address (pa,physical addresses)

After starting the MMU, the CPU core sends out the virtual address Va,va is converted to MVA for the MMU use, where MVA is converted to PA, and finally the actual device is read and written by Pa.

The role of the MMU is to convert virtual addresses into physical addresses (physical address). The 32-bit CPU has a virtual address space of 4GB, using 4,096 descriptors in the first-level page table to represent this 4GB space, each descriptor represents a 1M virtual address , or it stores the starting address of its corresponding physical address. Either the address of the next Level page table is stored . Use mva[31:20] to index the first-level page table (4,096 descriptors ) (because it is indexed by the high 12 bits of MVA, so the size is 2^12 = 4096)

     Register C2 (18 bits high, i.e. [31:14] is the conversion table base address , low 14 bits is 0) is primary conversion table Base address , the memory that points to 2^14=16kb is divisible by 16K, which is called a first-level conversion table; MVA's high 12-bit, ascended the throne [31:20] as the address index of the primary conversion table, the primary conversion table has the 2^12=4096 item , the address of each item is 32 bits, the highest 18 bits [31:14] is the high 18 bits of the register C2, and the middle 12 bit is the high 12 bits of MVA [ 31:20], the minimum 2 bits is 0b00. The content of each item is called a descriptor, under paragraph (section) , the high 12 bits of the first descriptor are subgrade addresses of size 1MB, and the address (offset address) in the segment is the lower 20 bits of MVA, i.e. Span style= "color: #ed1c24;" The address of each memory in the segment is composed of : High 12 bits are high 12 bits for the first descriptor, low 20 bits for low 20-bit MVA . In this way, a MVA is converted to a PA by means of a register C2 and a first-level descriptor. (It must be noted here: MVA high 12 bits are used to index 4,096 items, and then use the contents of the item (that is, the descriptor) of the high 12 bits of the segment high 12 bits, similar to the pointer inside the address, 4096 similar pointers, descriptors like the contents of the pointer )

Virtual Address (note: Is a definite address, not a space) is divided into 2 parts by the MMU , the first part is the 4096-page index (descriptor index) is used to select 4096 (2^12) Number of a page number, analogy description Index is 768, page number 768 holds the starting address of a page box for a physical address (0x300), and the second part is offset from the starting address space of 1M (offset) (for example), as compared to section base (0x300) (e.g.): Assuming now execute instructions MOV REG, 0x30100013, the binary code of the virtual address is 00110000 00010000 00000000 00010011, the first 12 bits are descriptor Index = 2^9+2^8+1 = 769, find 769 corresponding content 0x301, The offset is 0000 00000000 00010011=13, then the segment address is 0x3000000d.

5. Overall process of address translation:
First stage:
(1) Remove the previous 31-20 bits from the virtual address as an index.
(2) The corresponding table entries are found in the translation table (first page table) according to the index.
(3) Determine the conversion mode of the second stage based on the value of the minimum two bits of the table entry.
00: Invalid Conversion
01: Heavy Page Conversion
10: Segment Conversion
11: Fine-page conversion
(4)Linux systems typically use fine-page conversions, there are certain processors and operating systems with segment conversions, rarely with coarse page conversions.


6. About TTB (translation table base)
(1) Translation table is stored in memory.
(2) By programmers, the programmer knows its base address (TTB).
(3) The programmer writes TTB to the CP15 C2 register (TTB Register).
(4) When the MMU works from the C2 register to TTB to find translation table, and then use the virtual address of the 31-20-bit can find the corresponding table entry in the table, start the virtual address to the physical address conversion.

Understanding of MMU address translation in arm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.