162306a36Sopenharmony_ci============================= 262306a36Sopenharmony_ciMMUv3 initialization sequence 362306a36Sopenharmony_ci============================= 462306a36Sopenharmony_ci 562306a36Sopenharmony_ciThe code in the initialize_mmu macro sets up MMUv3 memory mapping 662306a36Sopenharmony_ciidentically to MMUv2 fixed memory mapping. Depending on 762306a36Sopenharmony_ciCONFIG_INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX symbol this code is 862306a36Sopenharmony_cilocated in addresses it was linked for (symbol undefined), or not 962306a36Sopenharmony_ci(symbol defined), so it needs to be position-independent. 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ciThe code has the following assumptions: 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci - This code fragment is run only on an MMU v3. 1462306a36Sopenharmony_ci - TLBs are in their reset state. 1562306a36Sopenharmony_ci - ITLBCFG and DTLBCFG are zero (reset state). 1662306a36Sopenharmony_ci - RASID is 0x04030201 (reset state). 1762306a36Sopenharmony_ci - PS.RING is zero (reset state). 1862306a36Sopenharmony_ci - LITBASE is zero (reset state, PC-relative literals); required to be PIC. 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ciTLB setup proceeds along the following steps. 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ci Legend: 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_ci - VA = virtual address (two upper nibbles of it); 2562306a36Sopenharmony_ci - PA = physical address (two upper nibbles of it); 2662306a36Sopenharmony_ci - pc = physical range that contains this code; 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_ciAfter step 2, we jump to virtual address in the range 0x40000000..0x5fffffff 2962306a36Sopenharmony_cior 0x00000000..0x1fffffff, depending on whether the kernel was loaded below 3062306a36Sopenharmony_ci0x40000000 or above. That address corresponds to next instruction to execute 3162306a36Sopenharmony_ciin this code. After step 4, we jump to intended (linked) address of this code. 3262306a36Sopenharmony_ciThe scheme below assumes that the kernel is loaded below 0x40000000. 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ci ====== ===== ===== ===== ===== ====== ===== ===== 3562306a36Sopenharmony_ci - Step0 Step1 Step2 Step3 Step4 Step5 3662306a36Sopenharmony_ci 3762306a36Sopenharmony_ci VA PA PA PA PA VA PA PA 3862306a36Sopenharmony_ci ====== ===== ===== ===== ===== ====== ===== ===== 3962306a36Sopenharmony_ci E0..FF -> E0 -> E0 -> E0 F0..FF -> F0 -> F0 4062306a36Sopenharmony_ci C0..DF -> C0 -> C0 -> C0 E0..EF -> F0 -> F0 4162306a36Sopenharmony_ci A0..BF -> A0 -> A0 -> A0 D8..DF -> 00 -> 00 4262306a36Sopenharmony_ci 80..9F -> 80 -> 80 -> 80 D0..D7 -> 00 -> 00 4362306a36Sopenharmony_ci 60..7F -> 60 -> 60 -> 60 4462306a36Sopenharmony_ci 40..5F -> 40 -> pc -> pc 40..5F -> pc 4562306a36Sopenharmony_ci 20..3F -> 20 -> 20 -> 20 4662306a36Sopenharmony_ci 00..1F -> 00 -> 00 -> 00 4762306a36Sopenharmony_ci ====== ===== ===== ===== ===== ====== ===== ===== 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_ciThe default location of IO peripherals is above 0xf0000000. This may be changed 5062306a36Sopenharmony_ciusing a "ranges" property in a device tree simple-bus node. See the Devicetree 5162306a36Sopenharmony_ciSpecification, section 4.5 for details on the syntax and semantics of 5262306a36Sopenharmony_cisimple-bus nodes. The following limitations apply: 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_ci1. Only top level simple-bus nodes are considered 5562306a36Sopenharmony_ci 5662306a36Sopenharmony_ci2. Only one (first) simple-bus node is considered 5762306a36Sopenharmony_ci 5862306a36Sopenharmony_ci3. Empty "ranges" properties are not supported 5962306a36Sopenharmony_ci 6062306a36Sopenharmony_ci4. Only the first triplet in the "ranges" property is considered 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ci5. The parent-bus-address value is rounded down to the nearest 256MB boundary 6362306a36Sopenharmony_ci 6462306a36Sopenharmony_ci6. The IO area covers the entire 256MB segment of parent-bus-address; the 6562306a36Sopenharmony_ci "ranges" triplet length field is ignored 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_ci 6862306a36Sopenharmony_ciMMUv3 address space layouts. 6962306a36Sopenharmony_ci============================ 7062306a36Sopenharmony_ci 7162306a36Sopenharmony_ciDefault MMUv2-compatible layout:: 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_ci Symbol VADDR Size 7462306a36Sopenharmony_ci +------------------+ 7562306a36Sopenharmony_ci | Userspace | 0x00000000 TASK_SIZE 7662306a36Sopenharmony_ci +------------------+ 0x40000000 7762306a36Sopenharmony_ci +------------------+ 7862306a36Sopenharmony_ci | Page table | XCHAL_PAGE_TABLE_VADDR 0x80000000 XCHAL_PAGE_TABLE_SIZE 7962306a36Sopenharmony_ci +------------------+ 8062306a36Sopenharmony_ci | KASAN shadow map | KASAN_SHADOW_START 0x80400000 KASAN_SHADOW_SIZE 8162306a36Sopenharmony_ci +------------------+ 0x8e400000 8262306a36Sopenharmony_ci +------------------+ 8362306a36Sopenharmony_ci | VMALLOC area | VMALLOC_START 0xc0000000 128MB - 64KB 8462306a36Sopenharmony_ci +------------------+ VMALLOC_END 8562306a36Sopenharmony_ci +------------------+ 8662306a36Sopenharmony_ci | Cache aliasing | TLBTEMP_BASE_1 0xc8000000 DCACHE_WAY_SIZE 8762306a36Sopenharmony_ci | remap area 1 | 8862306a36Sopenharmony_ci +------------------+ 8962306a36Sopenharmony_ci | Cache aliasing | TLBTEMP_BASE_2 DCACHE_WAY_SIZE 9062306a36Sopenharmony_ci | remap area 2 | 9162306a36Sopenharmony_ci +------------------+ 9262306a36Sopenharmony_ci +------------------+ 9362306a36Sopenharmony_ci | KMAP area | PKMAP_BASE PTRS_PER_PTE * 9462306a36Sopenharmony_ci | | DCACHE_N_COLORS * 9562306a36Sopenharmony_ci | | PAGE_SIZE 9662306a36Sopenharmony_ci | | (4MB * DCACHE_N_COLORS) 9762306a36Sopenharmony_ci +------------------+ 9862306a36Sopenharmony_ci | Atomic KMAP area | FIXADDR_START KM_TYPE_NR * 9962306a36Sopenharmony_ci | | NR_CPUS * 10062306a36Sopenharmony_ci | | DCACHE_N_COLORS * 10162306a36Sopenharmony_ci | | PAGE_SIZE 10262306a36Sopenharmony_ci +------------------+ FIXADDR_TOP 0xcffff000 10362306a36Sopenharmony_ci +------------------+ 10462306a36Sopenharmony_ci | Cached KSEG | XCHAL_KSEG_CACHED_VADDR 0xd0000000 128MB 10562306a36Sopenharmony_ci +------------------+ 10662306a36Sopenharmony_ci | Uncached KSEG | XCHAL_KSEG_BYPASS_VADDR 0xd8000000 128MB 10762306a36Sopenharmony_ci +------------------+ 10862306a36Sopenharmony_ci | Cached KIO | XCHAL_KIO_CACHED_VADDR 0xe0000000 256MB 10962306a36Sopenharmony_ci +------------------+ 11062306a36Sopenharmony_ci | Uncached KIO | XCHAL_KIO_BYPASS_VADDR 0xf0000000 256MB 11162306a36Sopenharmony_ci +------------------+ 11262306a36Sopenharmony_ci 11362306a36Sopenharmony_ci 11462306a36Sopenharmony_ci256MB cached + 256MB uncached layout:: 11562306a36Sopenharmony_ci 11662306a36Sopenharmony_ci Symbol VADDR Size 11762306a36Sopenharmony_ci +------------------+ 11862306a36Sopenharmony_ci | Userspace | 0x00000000 TASK_SIZE 11962306a36Sopenharmony_ci +------------------+ 0x40000000 12062306a36Sopenharmony_ci +------------------+ 12162306a36Sopenharmony_ci | Page table | XCHAL_PAGE_TABLE_VADDR 0x80000000 XCHAL_PAGE_TABLE_SIZE 12262306a36Sopenharmony_ci +------------------+ 12362306a36Sopenharmony_ci | KASAN shadow map | KASAN_SHADOW_START 0x80400000 KASAN_SHADOW_SIZE 12462306a36Sopenharmony_ci +------------------+ 0x8e400000 12562306a36Sopenharmony_ci +------------------+ 12662306a36Sopenharmony_ci | VMALLOC area | VMALLOC_START 0xa0000000 128MB - 64KB 12762306a36Sopenharmony_ci +------------------+ VMALLOC_END 12862306a36Sopenharmony_ci +------------------+ 12962306a36Sopenharmony_ci | Cache aliasing | TLBTEMP_BASE_1 0xa8000000 DCACHE_WAY_SIZE 13062306a36Sopenharmony_ci | remap area 1 | 13162306a36Sopenharmony_ci +------------------+ 13262306a36Sopenharmony_ci | Cache aliasing | TLBTEMP_BASE_2 DCACHE_WAY_SIZE 13362306a36Sopenharmony_ci | remap area 2 | 13462306a36Sopenharmony_ci +------------------+ 13562306a36Sopenharmony_ci +------------------+ 13662306a36Sopenharmony_ci | KMAP area | PKMAP_BASE PTRS_PER_PTE * 13762306a36Sopenharmony_ci | | DCACHE_N_COLORS * 13862306a36Sopenharmony_ci | | PAGE_SIZE 13962306a36Sopenharmony_ci | | (4MB * DCACHE_N_COLORS) 14062306a36Sopenharmony_ci +------------------+ 14162306a36Sopenharmony_ci | Atomic KMAP area | FIXADDR_START KM_TYPE_NR * 14262306a36Sopenharmony_ci | | NR_CPUS * 14362306a36Sopenharmony_ci | | DCACHE_N_COLORS * 14462306a36Sopenharmony_ci | | PAGE_SIZE 14562306a36Sopenharmony_ci +------------------+ FIXADDR_TOP 0xaffff000 14662306a36Sopenharmony_ci +------------------+ 14762306a36Sopenharmony_ci | Cached KSEG | XCHAL_KSEG_CACHED_VADDR 0xb0000000 256MB 14862306a36Sopenharmony_ci +------------------+ 14962306a36Sopenharmony_ci | Uncached KSEG | XCHAL_KSEG_BYPASS_VADDR 0xc0000000 256MB 15062306a36Sopenharmony_ci +------------------+ 15162306a36Sopenharmony_ci +------------------+ 15262306a36Sopenharmony_ci | Cached KIO | XCHAL_KIO_CACHED_VADDR 0xe0000000 256MB 15362306a36Sopenharmony_ci +------------------+ 15462306a36Sopenharmony_ci | Uncached KIO | XCHAL_KIO_BYPASS_VADDR 0xf0000000 256MB 15562306a36Sopenharmony_ci +------------------+ 15662306a36Sopenharmony_ci 15762306a36Sopenharmony_ci 15862306a36Sopenharmony_ci512MB cached + 512MB uncached layout:: 15962306a36Sopenharmony_ci 16062306a36Sopenharmony_ci Symbol VADDR Size 16162306a36Sopenharmony_ci +------------------+ 16262306a36Sopenharmony_ci | Userspace | 0x00000000 TASK_SIZE 16362306a36Sopenharmony_ci +------------------+ 0x40000000 16462306a36Sopenharmony_ci +------------------+ 16562306a36Sopenharmony_ci | Page table | XCHAL_PAGE_TABLE_VADDR 0x80000000 XCHAL_PAGE_TABLE_SIZE 16662306a36Sopenharmony_ci +------------------+ 16762306a36Sopenharmony_ci | KASAN shadow map | KASAN_SHADOW_START 0x80400000 KASAN_SHADOW_SIZE 16862306a36Sopenharmony_ci +------------------+ 0x8e400000 16962306a36Sopenharmony_ci +------------------+ 17062306a36Sopenharmony_ci | VMALLOC area | VMALLOC_START 0x90000000 128MB - 64KB 17162306a36Sopenharmony_ci +------------------+ VMALLOC_END 17262306a36Sopenharmony_ci +------------------+ 17362306a36Sopenharmony_ci | Cache aliasing | TLBTEMP_BASE_1 0x98000000 DCACHE_WAY_SIZE 17462306a36Sopenharmony_ci | remap area 1 | 17562306a36Sopenharmony_ci +------------------+ 17662306a36Sopenharmony_ci | Cache aliasing | TLBTEMP_BASE_2 DCACHE_WAY_SIZE 17762306a36Sopenharmony_ci | remap area 2 | 17862306a36Sopenharmony_ci +------------------+ 17962306a36Sopenharmony_ci +------------------+ 18062306a36Sopenharmony_ci | KMAP area | PKMAP_BASE PTRS_PER_PTE * 18162306a36Sopenharmony_ci | | DCACHE_N_COLORS * 18262306a36Sopenharmony_ci | | PAGE_SIZE 18362306a36Sopenharmony_ci | | (4MB * DCACHE_N_COLORS) 18462306a36Sopenharmony_ci +------------------+ 18562306a36Sopenharmony_ci | Atomic KMAP area | FIXADDR_START KM_TYPE_NR * 18662306a36Sopenharmony_ci | | NR_CPUS * 18762306a36Sopenharmony_ci | | DCACHE_N_COLORS * 18862306a36Sopenharmony_ci | | PAGE_SIZE 18962306a36Sopenharmony_ci +------------------+ FIXADDR_TOP 0x9ffff000 19062306a36Sopenharmony_ci +------------------+ 19162306a36Sopenharmony_ci | Cached KSEG | XCHAL_KSEG_CACHED_VADDR 0xa0000000 512MB 19262306a36Sopenharmony_ci +------------------+ 19362306a36Sopenharmony_ci | Uncached KSEG | XCHAL_KSEG_BYPASS_VADDR 0xc0000000 512MB 19462306a36Sopenharmony_ci +------------------+ 19562306a36Sopenharmony_ci | Cached KIO | XCHAL_KIO_CACHED_VADDR 0xe0000000 256MB 19662306a36Sopenharmony_ci +------------------+ 19762306a36Sopenharmony_ci | Uncached KIO | XCHAL_KIO_BYPASS_VADDR 0xf0000000 256MB 19862306a36Sopenharmony_ci +------------------+ 199