Linux内核高-低端内存设置代码跟踪(ARM构架)
时间:11-21
来源:互联网
点击:
- void __init setup_arch(char **cmdline_p)
- {
struct machine_desc *mdesc; unwind_init(); setup_processor(); mdesc = setup_machine_fdt(__atags_pointer); if (!mdesc) mdesc = setup_machine_tags(machine_arch_type); machine_desc = mdesc; machine_name = mdesc->name; if (mdesc->soft_reboot) reboot_setup("s"); init_mm.start_code = (unsigned long) _text; init_mm.end_code = (unsigned long) _etext; init_mm.end_data = (unsigned long) _edata; init_mm.brk = (unsigned long) _end; strlcpy(cmd_line, boot_command_line, COMMAND_LINE_SIZE); *cmdline_p = cmd_line; parse_early_param(); sanity_check_meminfo(); arm_memblock_init(&meminfo, mdesc); paging_init(mdesc); request_standard_resources(mdesc); unflatten_device_tree(); - #ifdef CONFIG_SMP
if (is_smp()) smp_init_cpus(); - #endif
reserve_crashkernel(); cpu_init(); tcm_init(); - #ifdef CONFIG_MULTI_IRQ_HANDLER
handle_arch_irq = mdesc->handle_irq; - #endif
- #ifdef CONFIG_VT
- #if defined(CONFIG_VGA_CONSOLE)
conswitchp = &vga_con; - #elif defined(CONFIG_DUMMY_CONSOLE)
conswitchp = &dummy_con; - #endif
- #endif
early_trap_init(); if (mdesc->init_early) mdesc->init_early(); - }
在上面的注释中,我已经表明了重点和解析,下面我细化下:
(1)获取参数部分
- int __init arm_add_memory(phys_addr_t start, unsigned long size)
- {
struct membank *bank = &meminfo.bank[meminfo.nr_banks]; if (meminfo.nr_banks >= NR_BANKS) { printk(KERN_CRIT "NR_BANKS too low, " "ignoring memory at 0xllx\n", (long long)start); return -EINVAL; } /* * Ensure that start/size are aligned to a page boundary. * Size is appropriately rounded down, start is rounded up. */ size -= start & ~PAGE_MASK; bank->start = PAGE_ALIGN(start); bank->size = size & PAGE_MASK; /* * Check whether this memory region has non-zero size or * invalid node number. */ if (bank->size == 0) return -EINVAL; meminfo.nr_banks++; return 0; - }
- /*
* Pick out the memory size. We look for mem=size@start, * where start and size are "size[KkMm]" */ - static int __init early_mem(char *p)
- {
static int usermem __initdata = 0; unsigned long size; phys_addr_t start; char *endp; /* * If the user specifies memory size, we * blow away any automatically generated * size. */ if (usermem == 0) { usermem = 1; meminfo.nr_banks = 0; } start = PHYS_OFFSET; size = memparse(p, &endp); if (*endp == @) start = memparse(endp + 1, NULL); arm_add_memory(start, size); return 0; - }
- early_param("mem", early_mem);
- static void * __initdata vmalloc_min = (void *)(VMALLOC_END - SZ_128M);
- /*
* vmalloc=size forces the vmalloc area to be exactly size * bytes. This can be used to increase (or decrease) the vmalloc * area - the default is 128m. */ - static int __init early_vmalloc(char *arg)
- {
unsigned long vmalloc_reserve = memparse(arg, NULL); if (vmalloc_reserve < SZ_16M) { vmalloc_reserve = SZ_16M; printk(KERN_WARNING "vmalloc area too small, limiting to %luMB\n", vmalloc_reserve >> 20); } if (vmalloc_reserve > VMALLOC_END - (PAGE_OFFSET + SZ_32M)) { vmalloc_reserve = VMALLOC_END - (PAGE_OFFSET + SZ_32M); printk(KERN_WARNING "vmalloc area is too big, limiting to %luMB\n", vmalloc_reserve >> 20); } vmalloc_min = (void *)(VMALLOC_END - vmalloc_reserve); return 0; - }
- early_param("vmalloc", early_vmalloc);
(2)在获得了必要的信息(初始化好struct meminfo meminfo
Linux内核内存设置代码跟踪ARM构 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)