I. Basic knowledge of memory management
1.S3C2440 uses a maximum of two page tables: the first-level page table is used when converting in segments, and the two-level page table is used when converting pages. There are three sizes of pages: Large pages (64KB), small pages (4KB), and minimal pages (1KB). Entries are also referred to as "descriptors", which are: segment descriptors, large page descriptors, small page descriptors, minimal page descriptors--they save large pages, small pages, starting physical addresses for tiny pages, coarse page table descriptors, thin page table descriptors--they save the physical address of a two-level page table.
2. The lowest two bits of the first-level page table descriptor can be divided into the following four scenarios:
(1). 0B00: invalid.
(2). 0B01: Rough page table.
(3). 0B10: paragraph.
(4). 0B11: Fine page table.
3. The lowest two bits of the two-level page table descriptor can be divided into the following four scenarios:
(1). 0B00: invalid.
(2). 0B01: Large page descriptor.
(3). 0B10: Small page descriptor.
(4). 0B11: Minimal page descriptor.
4. First level page table address, write it to coprocessor CP15 register C2 (called page table Base address register)
Two. Address conversion process (base addresses + URL change form)
1. Address conversion process for segments
NO1. Primary page Table base c2[31:14]+mva[31:20]+ The low two-bit 0 constitutes a 32-bit physical address, and the descriptor stored in it is found, and this descriptor is at least two bits 0b10, called the segment descriptor;
NO2. The segment descriptor [31:20]+mva[19:0] constitutes a 32-bit physical address-this is the MVA corresponding Pa.
2. Large-page address conversion process
(1). Large page description characters in the Rough page table
NO1. Primary page Table base c2[31:14]+mva[31:20]+ low two bits for 0 constitute a 32-bit physical address, locate the descriptor stored in it, the lowest two bits of this descriptor is 0b01, called the thick page table descriptor;
NO2. Thick page Table Descriptor [31:10]+mva[19:12]+ low two bits for 0 constitute a new 32-bit address, locate the descriptor stored therein, this descriptor is at least two bits of 0b01, called the large page descriptor;
NO3. The large page descriptor [31:16]+mva[15:0] constitutes a 32-bit physical address-this is the MVA corresponding Pa.
(2). Large page description characters in the Thin page table
NO1. Primary page Table base c2[31:14]+mva[31:20]+ low two bits 0 constitute a 32-bit physical address, locate the descriptor stored in it, the lowest two bits of this descriptor is 0B11, called the thin page table descriptor;
NO2. Fine page Table descriptor [31:12]+mva[19:10]+ low two bits for 0 constitute a new 32-bit address, locate the descriptor stored therein, this descriptor is at least two bits of 0b01, called the large page descriptor;
NO3. The large page descriptor [31:16]+mva[15:0] constitutes a 32-bit physical address-this is the MVA corresponding Pa.
3. Small page address conversion process
(1). Small page description characters in the Rough page table
NO1. Primary page Table base c2[31:14]+mva[31:20]+ low two bits for 0 constitute a 32-bit physical address, locate the descriptor stored in it, the lowest two bits of this descriptor is 0b01, called the thick page table descriptor;
NO2. Thick page Table Descriptor [31:10]+mva[19:12]+ low two bits for 0 constitute a new 32-bit address, locate the descriptor stored therein, this descriptor is at least two bits of 0B10, called the small page descriptor;
NO3. The small page descriptor [31:16]+mva[15:0] constitutes a 32-bit physical address-this is the MVA corresponding Pa.
(2). Small page description characters in a thin page table
NO1. Primary page Table base c2[31:14]+mva[31:20]+ low two bits 0 constitute a 32-bit physical address, locate the descriptor stored in it, the lowest two bits of this descriptor is 0B11, called the thin page table descriptor;
NO2. Fine page Table descriptor [31:12]+mva[19:10]+ low two bits for 0 constitute a new 32-bit address, locate the descriptor stored therein, this descriptor is at least two bits of 0B10, called the small page descriptor;
NO3. The small page descriptor [31:16]+mva[15:0] constitutes a 32-bit physical address-this is the MVA corresponding Pa.
4. Minimum page address conversion process
NO1. Primary page Table base c2[31:14]+mva[31:20]+ low two bits 0 constitute a 32-bit physical address, locate the descriptor stored in it, the lowest two bits of this descriptor is 0B11, called the thin page table descriptor;
NO2. Fine page Table descriptor [31:12]+mva[19:10]+ low two bits for 0 constitute a new 32-bit address, locate the descriptor stored therein, this descriptor is at least two bits of 0b11, called the minimum page descriptor;
NO3. The minimum page descriptor [31:16]+mva[15:0] constitutes a 32-bit physical address-this is the MVA corresponding Pa.
Three. Rough Page table detail the origin of the physical space represented by each entry
1.16 consecutive entries in the Rough page table save the same large page descriptor
The mva[19:12] used for the index of the thick page table has coincident bits for mva[15:0] that are used for large-page addressing, and the descriptor saved in the Rough page table [31:16] as the base address of the physical addresses, in order to guarantee the same base, change the address, i.e. descriptor unchanged, mva[15:0] change, when mva[ 15:12] When changing from 0b0000 to 0b1111, the descriptor stored in it should be the same--so that the 16 consecutive entries in the thick page table hold the same large page descriptor.
2.4 consecutive entries in a thin page table save the same small page descriptor
MVA[19:10] For a fine-page table index] has coincident bits for mva[11:0] that are used for small-page addressing, and the descriptor saved in the Rough page table [31:12] as the base address of the physical addresses, in order to guarantee the same base, change the address, that is, the descriptor unchanged, mva[11:0] changes, when mva[ 11:10] When changing from 0b00 to 0B11, the descriptor stored in it should be the same--so the same small page descriptor is saved for 4 consecutive entries in the Rough page table.
Four. Why minimal page descriptors can only be saved in a thin page table
MVA[31:20] Index-level page table, Mva[19:12] Page table in index two page table, mva[19:10] Page table in index level two page table, mva[9:0] represents the address space of a very small page. And each MVA corresponds to a different physical address PA, when the description of a very small page characters in a rough page table, Mva[11:10] changes, its corresponding physical address is all the same, so it cannot be saved in the Rough page table.
Embedded Linux Learning Note 1-memory management The conversion of the virtual address of the MMU to the physical address