📄 setup_32.c
字号:
max_mapnr = num_physpages;#endif printk(KERN_NOTICE "%ldMB LOWMEM available.\n", pages_to_mb(max_low_pfn)); setup_bootmem_allocator(); return max_low_pfn;}void __init zone_sizes_init(void){ unsigned long max_zone_pfns[MAX_NR_ZONES]; memset(max_zone_pfns, 0, sizeof(max_zone_pfns)); max_zone_pfns[ZONE_DMA] = virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT; max_zone_pfns[ZONE_NORMAL] = max_low_pfn;#ifdef CONFIG_HIGHMEM max_zone_pfns[ZONE_HIGHMEM] = highend_pfn; add_active_range(0, 0, highend_pfn);#else add_active_range(0, 0, max_low_pfn);#endif free_area_init_nodes(max_zone_pfns);}#elseextern unsigned long __init setup_memory(void);extern void zone_sizes_init(void);#endif /* !CONFIG_NEED_MULTIPLE_NODES */static inline unsigned long long get_total_mem(void){ unsigned long long total; total = max_low_pfn - min_low_pfn;#ifdef CONFIG_HIGHMEM total += highend_pfn - highstart_pfn;#endif return total << PAGE_SHIFT;}#ifdef CONFIG_KEXECstatic void __init reserve_crashkernel(void){ unsigned long long total_mem; unsigned long long crash_size, crash_base; int ret; total_mem = get_total_mem(); ret = parse_crashkernel(boot_command_line, total_mem, &crash_size, &crash_base); if (ret == 0 && crash_size > 0) { if (crash_base > 0) { printk(KERN_INFO "Reserving %ldMB of memory at %ldMB " "for crashkernel (System RAM: %ldMB)\n", (unsigned long)(crash_size >> 20), (unsigned long)(crash_base >> 20), (unsigned long)(total_mem >> 20)); crashk_res.start = crash_base; crashk_res.end = crash_base + crash_size - 1; reserve_bootmem(crash_base, crash_size); } else printk(KERN_INFO "crashkernel reservation failed - " "you have to specify a base address\n"); }}#elsestatic inline void __init reserve_crashkernel(void){}#endifvoid __init setup_bootmem_allocator(void){ unsigned long bootmap_size; /* * Initialize the boot-time allocator (with low memory only): */ bootmap_size = init_bootmem(min_low_pfn, max_low_pfn); register_bootmem_low_pages(max_low_pfn); /* * Reserve the bootmem bitmap itself as well. We do this in two * steps (first step was init_bootmem()) because this catches * the (very unlikely) case of us accidentally initializing the * bootmem allocator with an invalid RAM area. */ reserve_bootmem(__pa_symbol(_text), (PFN_PHYS(min_low_pfn) + bootmap_size + PAGE_SIZE-1) - __pa_symbol(_text)); /* * reserve physical page 0 - it's a special BIOS page on many boxes, * enabling clean reboots, SMP operation, laptop functions. */ reserve_bootmem(0, PAGE_SIZE); /* reserve EBDA region, it's a 4K region */ reserve_ebda_region(); /* could be an AMD 768MPX chipset. Reserve a page before VGA to prevent PCI prefetch into it (errata #56). Usually the page is reserved anyways, unless you have no PS/2 mouse plugged in. */ if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD && boot_cpu_data.x86 == 6) reserve_bootmem(0xa0000 - 4096, 4096);#ifdef CONFIG_SMP /* * But first pinch a few for the stack/trampoline stuff * FIXME: Don't need the extra page at 4K, but need to fix * trampoline before removing it. (see the GDT stuff) */ reserve_bootmem(PAGE_SIZE, PAGE_SIZE);#endif#ifdef CONFIG_ACPI_SLEEP /* * Reserve low memory region for sleep support. */ acpi_reserve_bootmem();#endif#ifdef CONFIG_X86_FIND_SMP_CONFIG /* * Find and reserve possible boot-time SMP configuration: */ find_smp_config();#endif numa_kva_reserve();#ifdef CONFIG_BLK_DEV_INITRD if (boot_params.hdr.type_of_loader && boot_params.hdr.ramdisk_image) { unsigned long ramdisk_image = boot_params.hdr.ramdisk_image; unsigned long ramdisk_size = boot_params.hdr.ramdisk_size; unsigned long ramdisk_end = ramdisk_image + ramdisk_size; unsigned long end_of_lowmem = max_low_pfn << PAGE_SHIFT; if (ramdisk_end <= end_of_lowmem) { reserve_bootmem(ramdisk_image, ramdisk_size); initrd_start = ramdisk_image + PAGE_OFFSET; initrd_end = initrd_start+ramdisk_size; } else { printk(KERN_ERR "initrd extends beyond end of memory " "(0x%08lx > 0x%08lx)\ndisabling initrd\n", ramdisk_end, end_of_lowmem); initrd_start = 0; } }#endif reserve_crashkernel();}/* * The node 0 pgdat is initialized before all of these because * it's needed for bootmem. node>0 pgdats have their virtual * space allocated before the pagetables are in place to access * them, so they can't be cleared then. * * This should all compile down to nothing when NUMA is off. */static void __init remapped_pgdat_init(void){ int nid; for_each_online_node(nid) { if (nid != 0) memset(NODE_DATA(nid), 0, sizeof(struct pglist_data)); }}#ifdef CONFIG_MCAstatic void set_mca_bus(int x){ MCA_bus = x;}#elsestatic void set_mca_bus(int x) { }#endif/* Overridden in paravirt.c if CONFIG_PARAVIRT */char * __init __attribute__((weak)) memory_setup(void){ return machine_specific_memory_setup();}/* * Determine if we were loaded by an EFI loader. If so, then we have also been * passed the efi memmap, systab, etc., so we should use these data structures * for initialization. Note, the efi init code path is determined by the * global efi_enabled. This allows the same kernel image to be used on existing * systems (with a traditional BIOS) as well as on EFI systems. */void __init setup_arch(char **cmdline_p){ unsigned long max_low_pfn; memcpy(&boot_cpu_data, &new_cpu_data, sizeof(new_cpu_data)); pre_setup_arch_hook(); early_cpu_init(); /* * FIXME: This isn't an official loader_type right * now but does currently work with elilo. * If we were configured as an EFI kernel, check to make * sure that we were loaded correctly from elilo and that * the system table is valid. If not, then initialize normally. */#ifdef CONFIG_EFI if ((boot_params.hdr.type_of_loader == 0x50) && boot_params.efi_info.efi_systab) efi_enabled = 1;#endif ROOT_DEV = old_decode_dev(boot_params.hdr.root_dev); screen_info = boot_params.screen_info; edid_info = boot_params.edid_info; apm_info.bios = boot_params.apm_bios_info; ist_info = boot_params.ist_info; saved_videomode = boot_params.hdr.vid_mode; if( boot_params.sys_desc_table.length != 0 ) { set_mca_bus(boot_params.sys_desc_table.table[3] & 0x2); machine_id = boot_params.sys_desc_table.table[0]; machine_submodel_id = boot_params.sys_desc_table.table[1]; BIOS_revision = boot_params.sys_desc_table.table[2]; } bootloader_type = boot_params.hdr.type_of_loader;#ifdef CONFIG_BLK_DEV_RAM rd_image_start = boot_params.hdr.ram_size & RAMDISK_IMAGE_START_MASK; rd_prompt = ((boot_params.hdr.ram_size & RAMDISK_PROMPT_FLAG) != 0); rd_doload = ((boot_params.hdr.ram_size & RAMDISK_LOAD_FLAG) != 0);#endif ARCH_SETUP if (efi_enabled) efi_init(); else { printk(KERN_INFO "BIOS-provided physical RAM map:\n"); print_memory_map(memory_setup()); } copy_edd(); if (!boot_params.hdr.root_flags) root_mountflags &= ~MS_RDONLY; init_mm.start_code = (unsigned long) _text; init_mm.end_code = (unsigned long) _etext; init_mm.end_data = (unsigned long) _edata; init_mm.brk = init_pg_tables_end + PAGE_OFFSET; code_resource.start = virt_to_phys(_text); code_resource.end = virt_to_phys(_etext)-1; data_resource.start = virt_to_phys(_etext); data_resource.end = virt_to_phys(_edata)-1; bss_resource.start = virt_to_phys(&__bss_start); bss_resource.end = virt_to_phys(&__bss_stop)-1; parse_early_param(); if (user_defined_memmap) { printk(KERN_INFO "user-defined physical RAM map:\n"); print_memory_map("user"); } strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE); *cmdline_p = command_line; max_low_pfn = setup_memory();#ifdef CONFIG_VMI /* * Must be after max_low_pfn is determined, and before kernel * pagetables are setup. */ vmi_init();#endif /* * NOTE: before this point _nobody_ is allowed to allocate * any memory using the bootmem allocator. Although the * allocator is now initialised only the first 8Mb of the kernel * virtual address space has been mapped. All allocations before * paging_init() has completed must use the alloc_bootmem_low_pages() * variant (which allocates DMA'able memory) and care must be taken * not to exceed the 8Mb limit. */#ifdef CONFIG_SMP smp_alloc_memory(); /* AP processor realmode stacks in low memory*/#endif paging_init(); remapped_pgdat_init(); sparse_init(); zone_sizes_init(); /* * NOTE: at this point the bootmem allocator is fully available. */ paravirt_post_allocator_init(); dmi_scan_machine();#ifdef CONFIG_X86_GENERICARCH generic_apic_probe();#endif if (efi_enabled) efi_map_memmap();#ifdef CONFIG_ACPI /* * Parse the ACPI tables for possible boot-time SMP configuration. */ acpi_boot_table_init();#endif#ifdef CONFIG_PCI early_quirks();#endif#ifdef CONFIG_ACPI acpi_boot_init();#if defined(CONFIG_SMP) && defined(CONFIG_X86_PC) if (def_to_bigsmp) printk(KERN_WARNING "More than 8 CPUs detected and " "CONFIG_X86_PC cannot handle it.\nUse " "CONFIG_X86_GENERICARCH or CONFIG_X86_BIGSMP.\n");#endif#endif#ifdef CONFIG_X86_LOCAL_APIC if (smp_found_config) get_smp_config();#endif e820_register_memory(); e820_mark_nosave_regions();#ifdef CONFIG_VT#if defined(CONFIG_VGA_CONSOLE) if (!efi_enabled || (efi_mem_type(0xa0000) != EFI_CONVENTIONAL_MEMORY)) conswitchp = &vga_con;#elif defined(CONFIG_DUMMY_CONSOLE) conswitchp = &dummy_con;#endif#endif}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -