SC2440 virtual address to physical address conversion

Publisher:数字奇迹Latest update time:2018-06-05 Source: eefocusKeywords:SC2440 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Disclaimer: The conclusions drawn in this article are all from the "Embedded Linux Complete Development Manual". They are summarized in my own words after trying to understand its meaning, so as to better understand the contents of this section.

VA: virtual address 
WVA: converted virtual address 
PA: physical address 
PID: process identification number, obtained by C13 of CP15.

  • 1. The virtual address gets the converted virtual address

  • If VA < 32M, then MVA = VA | (PID << 25), 
    otherwise VA = MVA. 
    32M = 2^25, so PID needs to be shifted left by 25 bits to get a non-duplicate physical address space.

Tip: VA < 32M, as for why it is 32, I think it may be because the code space of the program will not exceed the virtual address space of the following 32M when it is running. Since this method of obtaining MVA is to simplify the work of preventing different processes with overlapping virtual addresses from being mapped to the same physical address space, and the virtual memory space after 32M stores system components and dynamic link libraries, etc., which can be shared by different processes, there is no need to distinguish the physical address space corresponding to the virtual address space after 32M for each process.

  • 2. Page table classification

  • 2.1. Level 1 page table entries 
    Level 1 page table

  • Identifies the lower 2 bitsEntry Type
    00Invalid entry
    01Coarse page table entries
    10Segment Entries
    11Fine page table entries
  • 2.2. Secondary page table entries 
    Secondary page table

  • Identifies the lower 2 bitsEntry Type
    00Invalid entry
    01Huge Page Entries
    10Minipage Entries
    11Minipage entries
  • 3. Relationship between page tables

  • Page table relationship

  • 3.1、Directional relationship 
    Direction relationship

  • It can be understood that segments, large pages, small pages, and tiny pages belong to the same level, because they can directly obtain physical addresses. 
    Coarse page tables and fine page tables belong to the second-level page table, and page tables belong to the first-level page table.

  • 3.2. Inclusion Relationship 
    (1) A page table can contain 4096 segment entries (i.e., segment descriptors), and each segment stores 1M of physical address space.

  • (2) The page table can contain 4096 coarse page tables. 
    1. Each coarse page table contains 256 entries, and each entry can index a 4K physical address. 
    2. A large page can index a 64K physical address, and every 16 entries in the coarse page table can point to the same large page 
    . 3. A small page can index a 4K physical address, and each entry in the coarse page table can point to a small page. 
    4. A tiny page can index a 1K physical address, and the coarse page table cannot point to a tiny page.

  • (3) The page table can contain 4096 fine page tables. 
    1. Each fine page table contains 1024 entries, and each entry can index a 1K physical address. 
    2. A large page can index a 64K physical address, and every 64 entries in the fine page table can point to the same large page 
    . 3. A small page can index a 4K physical address, and every 4 entries in the fine page table can point to a small page. 
    4. A tiny page can index a 1K physical address, and every 1 entry in the fine page table can point to a tiny page.

  • 4. Indexing steps

  • (1) The segment mode 
    obtains the physical address of the first-level page table (bits [31:14]) from C2 (page table base address register) of CP15, and uses bits [31:20] of MVA to index the corresponding segment descriptor in the first-level page table. The physical address of the corresponding segment is obtained from bits [31:20] of the segment descriptor, and bits [19:0] of MVA index the physical address to be operated in the segment.

  • (2) Coarse page table mode (large pages are stored): 
    Get the physical address of the first-level page table (bits [31:14]) from C2 (page table base address register) of CP15, and use bits [31:20] of MVA to index the corresponding coarse page table descriptor in the first-level page table. Use bits [31:10] of the coarse page table descriptor to get the physical address of the corresponding coarse page table. Use bits [19:12] of MVA to index a large page descriptor in the coarse page table. Use bits [31:16] of the large page descriptor to get the physical address of the large page. Use bits [15:0] of MVA to index the physical address to be operated in the large page. 
    The indexing method of large pages stored in fine page tables is similar.

  • (3) Coarse page table mode (small pages are stored) 
    obtains the physical address of the first-level page table (bits [31:14]) from C2 (page table base address register) of CP15, and uses bits [31:20] of MVA to index the corresponding coarse page table descriptor in the first-level page table. Use bits [31:10] of the coarse page table descriptor to obtain the physical address of the corresponding coarse page table. Use bits [19:12] of MVA to index a small page descriptor in the coarse page table, take out descriptor [31:12] to obtain the physical address of the small page table, and then use bits [11:0] of MVA to index the physical address stored in the small page table.

  • (4) The fine page table (which stores the tiny page table) 
    obtains the physical address of the first-level page table (bits [31:14]) from C2 (page table base address register) of CP15, and uses bits [31:20] of MVA to index the corresponding fine page table descriptor in the first-level page table. Bits [31:12] of the fine page table descriptor index into the base address of a tiny page table, and then bits [19:10] of MVA index into a descriptor in the tiny page table. [31:10] of the descriptor is taken out to index into the physical address of the tiny page, and then bits [9:0] of MVA index into the physical address to be operated in the tiny page.

  • Summary:

  • Segment index: 
    TTB[31:14] MVA[31:20] Get segment descriptor 
    DUB[31:20] MVA[19:0] Get physical address

  • Coarse page table large page: 
    TTB[31:14] MVA[31:20] Get the coarse page table descriptor 
    SOB[31:10] MVA[19:12] Get the large page table descriptor 
    BIB[31:16] MVA[15:0] Get the physical address

  • Fine page table large page: 
    TTB[31:14] MVA[31:20] Get fine page table descriptor 
    FIB[31:12] MVA[19:12] Get large page table descriptor 
    BIB[31:16] MVA[15:0] Get physical address

  • Coarse page table small page: 
    TTB[31:14] MVA[31:20] Get the coarse page table descriptor 
    SOB[31:10] MVA[19:12] Get the small page table descriptor 
    SMB[31:12] MVA[11:0] Get the physical address

  • Fine page table small page: 
    TTB[31:14] MVA[31:20] Get fine page table descriptor 
    FIB[31:12] MVA[19:12] Get small page table descriptor 
    SMB[31:12] MVA[11:0] Get physical address

  • Fine page table tiny page: 
    TTB[31:14] MVA[31:20] Get fine page table descriptor 
    FIB[31:12] MVA[19:10] Get tiny page descriptor 
    VSB[31:10] MVA[9:0] Get physical address

  • Tip:

  • SOB: coarse base 
    FIB: fine base 
    DUB: section base 
    SMB: small base 
    VSB: very small base 
    BIB: big base


Keywords:SC2440 Reference address:SC2440 virtual address to physical address conversion

Previous article:ARM address remapping mechanism
Next article:The relationship between the virtual address and physical address of the s3c2440 register based on linux2.6.30.4

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号