uclinux2.6(bf561)中的bootmem分析(1):猜测

来源:互联网 发布:好的日记软件 编辑:程序博客网 时间:2024/05/16 18:07
 
   
  
在setup_arch(arch/blackfin/kernel/setup.c)函数中,与bootmem相关的代码有:
     int bootmap_size;
 
     /* setup memory defaults from the user config */
     physical_mem_end = 0;
     _ramend = CONFIG_MEM_SIZE * 1024 * 1024;
 
     if (physical_mem_end == 0)
         physical_mem_end = _ramend;
 
     /* by now the stack is part of the init task */
     memory_end = _ramend - DMA_UNCACHED_REGION;
 
     _ramstart = (unsigned long)__bss_stop;
     _rambase = (unsigned long)_stext;
#ifdef CONFIG_MPU
     /* Round up to multiple of 4MB. */
     memory_start = (_ramstart + 0x3fffff) & ~0x3fffff;
#else
     memory_start = PAGE_ALIGN(_ramstart);
#endif
 
     /*
      * give all the memory to the bootmap allocator, tell it to put the
      * boot mem_map at the start of memory
      */
     bootmap_size = init_bootmem_node(NODE_DATA(0), memory_start >> PAGE_SHIFT, /* map goes here */
                        PAGE_OFFSET >> PAGE_SHIFT,
                        memory_end >> PAGE_SHIFT);
     /*
      * free the usable memory, we have to make sure we do not free
      * the bootmem bitmap so we then reserve it after freeing it :-)
      */
     free_bootmem(memory_start, memory_end - memory_start);
 
     reserve_bootmem(memory_start, bootmap_size);
此时,内存管理的初始化函数paging_init尚未调用,因此猜测bootmem的作用似乎是在内核启动完成前提供一种简单的内存管理策略。看看mm/bootmem.c的注释:
/*
 * linux/mm/bootmem.c
 *
 * Copyright (C) 1999 Ingo Molnar
 * Discontiguous memory support, Kanoj Sarcar, SGI, Nov 1999
 *
 * simple boot-time physical memory area allocator and
 * free memory collector. It's used to deal with reserved
 * system memory and memory holes as well.
 */
 
原创粉丝点击