1.1.1
在这几个相关的函数调用中,涉及到了几个参数:
l
NODE_DATA(0)
这个宏的定义在include/linux/mmzone.h中
extern
struct pglist_data contig_page_data;
#define
NODE_DATA(nid) (&contig_page_data)
就是取一个结构体变量的指针。
而
pglist_data的定义也在mmzone.h中:
/*
* The pg_data_t structure is used in machines with CONFIG_DISCONTIGMEM
* (mostly NUMA machines?) to denote a higher-level memory zone than the
* zone denotes.
*
* On NUMA machines, each NUMA node would have a pg_data_t to describe
* it's memory layout.
*
* Memory statistics and page replacement data structures are maintained on a
* per-zone basis.
*/
struct
bootmem_data;
typedef
struct pglist_data {
struct zone node_zones[MAX_NR_ZONES];
struct zonelist node_zonelists[MAX_NR_ZONES];
int nr_zones;
#ifdef
CONFIG_FLAT_NODE_MEM_MAP
struct page *node_mem_map;
#endif
struct bootmem_data *bdata;
#ifdef
CONFIG_MEMORY_HOTPLUG
/*
* Must be held any time you expect node_start_pfn, node_present_pages
* or node_spanned_pages stay constant. Holding this will also
* guarantee that any pfn_valid() stays that way.
*
* Nests above zone->lock and zone->size_seqlock.
*/
spinlock_t node_size_lock;
#endif
unsigned long node_start_pfn;
unsigned long node_present_pages; /* total number of physical pages */
unsigned long node_spanned_pages; /* total size of physical page
range, including holes */
int node_id;
wait_queue_head_t kswapd_wait;
struct task_struct *kswapd;
int kswapd_max_order;
} pg_data_t;
对于BF561来讲,只有一个连续的内存区域,因此这个结构体可以简化为:
typedef
struct pglist_data {
struct zone node_zones[1];
struct zonelist node_zonelists[1];
int nr_zones;
struct bootmem_data *bdata;
unsigned long node_start_pfn;
unsigned long node_present_pages; /* total number of physical pages */
unsigned long node_spanned_pages; /* total size of physical page
range, including holes */
int node_id;
wait_queue_head_t kswapd_wait;
struct task_struct *kswapd;
int kswapd_max_order;
} pg_data_t;
l
memory_start
从前面的赋值语句:
_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
可以看出,memory_start指向的是uclinux内核代码结束的位置,并且是以页大小对齐的。上述语句中
__bss_stop的定义在LDF文件中:
bsz_sdram ZERO_INIT
{
NO_FORCE_CONTIGUITY
INPUT_SECTION_ALIGN(4)
. = (. + 3) / 4 * 4;
___bss_start = .;
INPUT_SECTIONS($OBJECTS_CORE_A(sdram_bsz) $LIBRARIES_CORE_A(sdram_bsz))
INPUT_SECTIONS($LIBRARIES_CORE_A(.bss .bss.*))
INPUT_SECTIONS($LIBRARIES_CORE_A(COMMON))
INPUT_SECTION_ALIGN(4)
. = (. + 3) / 4 * 4;
___bss_stop = .;
__end = .;
} > MEM_SDRAM
而bsz_sdram这个段是放在最后的。
PAGE_ALIGN的定义在include/asm/page.h中:
/* PAGE_SHIFT determines the page size */
#define
PAGE_SHIFT 12
#ifdef
__ASSEMBLY__
#define PAGE_SIZE (1 << PAGE_SHIFT)
#else
#define
PAGE_SIZE (1UL << PAGE_SHIFT)
#endif
#define
PAGE_MASK (~(PAGE_SIZE-1))
/* to align the pointer to the (next) page boundary */
#define
PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
l
memory_end
从之前的定义
_ramend = CONFIG_MEM_SIZE * 1024 * 1024;
…
/* by now the stack is part of the init task */
memory_end = _ramend - DMA_UNCACHED_REGION;
可以看出,memory_end就是指向SDRAM的结束位置,其中
DMA_UNCACHED_REGION的include/asm/bfin-global.h中:
# define
DMA_UNCACHED_REGION (0)
l
PAGE_OFFSET
这个宏的定义位于include/asm/page.h:
#define
PAGE_OFFSET (PAGE_OFFSET_RAW)
PAGE_OFFSET的定义位于include/asm/page_offset.h:
#ifdef
CONFIG_BLACKFIN
#define PAGE_OFFSET_RAW 0x00000000
#endif