[ARM Notes] Memory Management Unit Address Transformation Process

Publisher:安静宁静Latest update time:2016-11-22 Source: eefocusKeywords:ARM Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. Classification of addresses
       In the past, programs were very small and could be loaded into memory and run. With the development of technology, the following two situations have emerged:
1) Some programs are very large and require more memory space than the total memory capacity, so they cannot be loaded into memory at one time;
2) There are many programs in a multitasking system that need to run at the same time, and the memory space they require exceeds the total memory capacity, so all programs cannot be loaded into memory.
       In fact, before a program is run, it is not necessary to load all of it into memory. Instead, only the parts that are currently to be run need to be loaded into memory first, and the rest can be loaded from the disk when needed. When the memory is exhausted, the temporarily unused parts can be loaded out to the disk. This allows a large program to run in a smaller memory space, and also allows more programs to be loaded into memory and executed concurrently. From the user's perspective, the system has a much larger memory capacity than the actual memory capacity. People call such memory virtual memory.
       Virtual memory logically expands the memory capacity, and the large capacity seen by the user is just a feeling, which is virtual. In a 32-bit CPU system, the address range of this virtual memory is 0~0xffff_ffff. We call this address range the virtual address space, and one of the addresses is called a virtual address. Corresponding to the virtual address space and virtual address is the physical address space and physical address, which correspond to the actual memory.
       The virtual address must be converted into a physical address to read and write the actual data. This is done by dividing the virtual address space and physical address space into small spaces of the same size (called segments or pages), and then establishing a mapping relationship between the two types of small spaces. Since the virtual address space is much larger than the physical space, it is possible that multiple virtual address spaces are mapped to the same physical address space, or some virtual address spaces are not mapped to specific physical address spaces (they can be mapped when used). The address conversion process of the ARM CPU involves three concepts: virtual address (VA, Virtual Address), modified virtual address (MVA, Modified Virtual Address), and physical address (PA, Physical Address).
       When the MMU is not started, all components such as the CPU core, cache, MMU, and peripherals use physical addresses.
       After starting the MMU, the CPU core sends out the virtual address VA; VA is converted to MVA for use by the cache and MMU, where MVA is converted to PA; finally, PA is used to read and write the actual device (internal registers of S3C2410/S3C2440 or external devices):
1) The CPU core sees and uses the virtual address VA, and the CPU core does not care how VA is finally implemented on the physical address PA.
2) The cache and MMU cannot see VA either, and they use the PA obtained by MVA conversion.
3) The actual device cannot see VA and MVA, and the physical address PA is used when reading and writing them.
       MVA is the virtual address seen by other parts except the CPU core.
       If VA<32M, the process identification number PID (obtained by reading C13 of CP15) needs to be used to convert it to MVA. The conversion method between VA and MVA is as follows: if
(VA<32M) then
       MVA=VA | (PID<<25) //VA<32M
else
       MVA=VA //VA>=32M

       The purpose of using PID to generate MVA is to reduce the cost of switching processes: if VA is used directly instead of MVA, when the virtual address space (VA) used by two processes overlaps, in order to map the overlapping VA to the unreachable PA when switching processes, it is necessary to rebuild the page table, invalidate caches and TLBS, etc., which is very costly. After using MVA, process switching is much easier; suppose the VAs of two processes 1 and 2 are both 0~(32M-1), but their MVAs do not overlap, namely 0x0200_0000~0x03ff_ffff and 0x0400_0000~0x05ff_ffff, respectively, so there is no need to rebuild the page table and other work.

2. The conversion process from virtual address to physical address
       There are generally two ways to convert a virtual address to a physical address: use a certain mathematical formula to convert or use a table to store the physical address corresponding to the virtual address. This type of table is called a page table, which consists of entries; each entry stores the physical address corresponding to a virtual address and its access rights, or the address of the next level page table. The
       second method is used in ARM CPU. S3C2410/S3C2440 will use at most two levels of page tables: only one level of page table is used when converting in the form of segments (Section, 1MB), and two levels of page tables are used when converting in the form of pages. There are three page sizes: large page (64KB), small page (4KB), and very small page (1KB). Entries are also called "descriptors", including: segment descriptors, large page descriptors, small page descriptors, and tiny page descriptors - they store the starting physical addresses of segments, large pages, small pages, or tiny pages; coarse page table descriptors and fine page table descriptors - they store the physical addresses of secondary page tables.
       The general conversion process is as follows:
1) Find the entry in the primary page table according to the given virtual address;
2) If this descriptor is a segment descriptor, the physical address is returned and the conversion ends;
3) Otherwise, if this descriptor is a secondary page table descriptor, continue to use the virtual address to find the next entry in this secondary page table;
4) If this second entry is a page descriptor, the physical address is returned and the conversion ends;
5) Errors occur in other cases.


Keywords:ARM Reference address:[ARM Notes] Memory Management Unit Address Transformation Process

Previous article:[ARM Notes] Device Driver Overview
Next article:[ARM Notes] How to use the registers of the storage controller

Recommended ReadingLatest update time:2024-11-16 14:53

ARM coprocessor operations mrc and mcr
MRC and MCR instructions The format of the MCR instruction is: MCR{condition} coprocessor code, coprocessor opcode 1, source register, destination register 1, destination register 2, coprocessor opcode 2. The MCR instruction is used to transfer data from the ARM processor register to the coprocessor register. If the co
[Microcontroller]
Design of digital bus station system based on ARM7 and CPLD
In view of the shortcomings of existing printed bus stops, such as insufficient information, inability to provide vehicle arrival forecasts, and troublesome addition or modification of route information, this paper proposes a new digital bus stop system. The system is based on ARM7 and CPLD architecture, communicate
[Microcontroller]
Design of digital bus station system based on ARM7 and CPLD
Low-cost gateway hardware design based on ARM processor
    With the rapid development of Internet of Things technology, the trend of integrating traditional Internet with new wireless sensor networks is becoming more and more obvious. The embedded service gateway is both a coordinator gateway of the wireless sensor network and a remote WEB server. It realizes the communic
[Microcontroller]
Low-cost gateway hardware design based on ARM processor
One-stop smart home circuit and application design
Design Overview         Beineng International’s one-stop smart home solution is committed to achieving more intelligent interactions.         The gateway part of this reference design adopts the mainstream ARM® Cortex®-MX chip in the industry. The industry-leading ARM® Cortex®-Mx series provides unparalleled perform
[Microcontroller]
One-stop smart home circuit and application design
Arm command learning record about the captain's knowledge summary
       I will make a brief summary of the knowledge about captains that I have recorded while studying arm instructions, hoping it will be helpful to everyone.        1. Register R13 is often used as a stack pointer in arm instructions        2. For the R13 register, it corresponds to 6 different physical registers,
[Microcontroller]
Electronic throttle control based on ARM-Linux platform
Introduction The cruise control system (CCS) was developed in the 1960s and is also known as a constant speed driving system. When the cruise control system is working, the ECU determines the operating status of the car based on the signals sent by various sensors, and automatically adjusts the throttle openin
[Microcontroller]
[ARM bare board] Undefined instruction exception analysis and examples
1. Undefined instruction exception example According to 5.1, before executing the exception handling function, the hardware will handle the following:  1. lr_und holds the address of the next instruction to be executed in interrupt mode  2.SPSR_und saves the interrupt mode CPSR  3. CPSR = , enter und mode  4. Jump to
[Microcontroller]
[ARM bare board] Undefined instruction exception analysis and examples
Key circuit design of laser particle size analyzer based on DSP and ARM
O Introduction Laser particle size analyzer is a most advanced particle size measuring instrument with the broadest development prospects. Its measuring principle is based on Mie scattering theory. Mie scattering theory is a classic light scattering theory. Its biggest feature is that it can be used to measure
[Microcontroller]
Key circuit design of laser particle size analyzer based on DSP and ARM
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号