/* * Here we define all the compile-time 'special' virtual * addresses. The point is to have a constant address at * compile time, but to set the physical address only * in the boot process. * * These 'compile-time allocated' memory buffers are * page-sized. Use set_fixmap(idx,phys) to associate * physical memory with fixmap indices. * */
/* * Reserve a virtual window for the FDT that is 2 MB larger than the * maximum supported size, and put it at the top of the fixmap region. * The additional space ensures that any FDT that does not exceed * MAX_FDT_SIZE can be mapped regardless of whether it crosses any * 2 MB alignment boundaries. * * Keep this at the top so it remains 2 MB aligned. */ #define FIX_FDT_SIZE (MAX_FDT_SIZE + SZ_2M) FIX_FDT_END, FIX_FDT = FIX_FDT_END + FIX_FDT_SIZE / PAGE_SIZE - 1,
FIX_EARLYCON_MEM_BASE, FIX_TEXT_POKE0,
#ifdef CONFIG_ACPI_APEI_GHES /* Used for GHES mapping from assorted contexts */ FIX_APEI_GHES_IRQ, FIX_APEI_GHES_NMI, #endif/* CONFIG_ACPI_APEI_GHES */
// ----------------------------------------------------------------------------------------------------- (3) // if this entry is not NULL, just use it --> this is passed in live run if (CONFIG_PGTABLE_LEVELS > 3 && !(pgd_none(pgd) || pgd_page_paddr(pgd) == __pa_symbol(bm_pud))) { /* * We only end up here if the kernel mapping and the fixmap * share the top level pgd entry, which should only happen on * 16k/4 levels configurations. */ BUG_ON(!IS_ENABLED(CONFIG_ARM64_16K_PAGES)); pudp = pud_offset_kimg(pgdp, addr); } else { // ------------------------------------------------------------------------------------------------- (4) // if this entry is NULL, need to map it first if (pgd_none(pgd)) __pgd_populate(pgdp, __pa_symbol(bm_pud), PUD_TYPE_TABLE);
// ------------------------------------------------------------------------------------------------- (5) // fixmap_pxd() 1) uses PGD/PUD/PMD to get physical base address of the next level table // 2) uses addr to get table index and uses it to get entry's physical address // 3) add offset to get entry's virtual address pudp = fixmap_pud(addr); // 0XFFFF0000121AAFF8 // pudp.pud = 0X421A9003 }
/* * The boot-ioremap range spans multiple pmds, for which * we are not prepared: */ BUILD_BUG_ON((__fix_to_virt(FIX_BTMAP_BEGIN) >> PMD_SHIFT) != (__fix_to_virt(FIX_BTMAP_END) >> PMD_SHIFT));
/* * For dynamically allocated mm_structs, there is a dynamically sized cpumask * at the end of the structure, the size of which depends on the maximum CPU * number the system can see. That way we allocate only as much memory for * mm_cpumask() as needed for the hundreds, or thousands of processes that * a system typically runs. * * Since there is only one init_mm in the entire system, keep it simple * and size this cpu_bitmask to NR_CPUS. */ structmm_structinit_mm = { .mm_rb = RB_ROOT, .pgd = swapper_pg_dir, .mm_users = ATOMIC_INIT(2), .mm_count = ATOMIC_INIT(1), .mmap_sem = __RWSEM_INITIALIZER(init_mm.mmap_sem), .page_table_lock = __SPIN_LOCK_UNLOCKED(init_mm.page_table_lock), .arg_lock = __SPIN_LOCK_UNLOCKED(init_mm.arg_lock), .mmlist = LIST_HEAD_INIT(init_mm.mmlist), .user_ns = &init_user_ns, .cpu_bitmap = { [BITS_TO_LONGS(NR_CPUS)] = 0}, INIT_MM_CONTEXT(init_mm) };
// ---------------------------------------------------------------------- (2) if (!dt_virt || !early_init_dt_scan(dt_virt)) { pr_crit("\n" "Error: invalid device tree blob at physical address %pa (virtual address 0x%p)\n" "The dtb must be 8-byte aligned and must not exceed 2 MB in size\n" "\nPlease check your bootloader.", &dt_phys, dt_virt);
while (true) cpu_relax(); }
name = of_flat_dt_get_machine_name(); if (!name) return;