LINUX 2.4.22 内存管理 之三ARM物理内存初始化(二)

上一篇:物理内存初始化(一)
下一篇:页表管理(上)

概述

前文介绍系统启动后 内存的初始化入口,以及BOOTMEM 分配器的初始化,接下来进入paging_init函数,该函数主要负责页表初始化,

数据结构


struct map_desc {
unsigned long virtual; //node start vitural address
unsigned long physical; // node start physical address
unsigned long length; //node size with bytes unit
int domain:4,
prot_read:1,
prot_write:1,
cacheable:1,
bufferable:1,
last:1;
};

memtable_init

void __init memtable_init(struct meminfo *mi)
{
	struct map_desc *init_maps, *p, *q;
	unsigned long address = 0;
	int i;
	// [1
	init_maps = p = alloc_bootmem_low_pages(PAGE_SIZE);
 
	for (i = 0; i < mi->nr_banks; i++) {
		if (mi->bank[i].size == 0)
			continue;

		p->physical   = mi->bank[i].start;
		p->virtual    = __phys_to_virt(p->physical);
		p->length     = mi->bank[i].size;
		p->domain     = DOMAIN_KERNEL;
		p->prot_read  = 0;
		p->prot_write = 1;
		p->cacheable  = 1;
		p->bufferable = 1;

		p ++;
	}//1]
	...
	/*
	 * Go through the initial mappings, but clear out any
	 * pgdir entries that are not in the description.
	 */
	q = init_maps;
	do {
		if (address < q->virtual || q == p) {
			clear_mapping(address);
			address += PGDIR_SIZE;
		} else {
			create_mapping(q);

			address = q->virtual + q->length;
			address = (address + PGDIR_SIZE - 1) & PGDIR_MASK;

			q ++;
		}
	} while (address != 0);

	/*
	 * Create a mapping for the machine vectors at virtual address 0
	 * or 0xffff0000.  We should always try the high mapping.
	 */
	init_maps->physical   = virt_to_phys(init_maps);
	init_maps->virtual    = vectors_base();
	init_maps->length     = PAGE_SIZE;
	init_maps->domain     = DOMAIN_USER;
	init_maps->prot_read  = 0;
	init_maps->prot_write = 0;
	init_maps->cacheable  = 1;
	init_maps->bufferable = 0;

	create_mapping(init_maps);
}

1.为initmaps分配一页并初始化,每个node对应一个map(struct map_desc

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值