head.S
/****************************************************
定义宏pgtbl,带两个参数rd ,phys。
The byte offset of the kernel image in RAM from the start of RAM.
TEXT_OFFSET := $(textofs-y)
textofs-y := 0x00008000 //32k
#define PG_DIR_SIZE 0x4000 //16k
以phy +16k ~ phy+32k存放一级页表
*****************************************************/
.macro pgtbl, rd, phys
add \rd, \phys, #TEXT_OFFSET - PG_DIR_SIZE //phys + 16k --> rd.endm
/* PAGE_SHIFT determines the page size */
#define PAGE_SHIFT 13
#define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT) //页面的大小为2^13 (8k)
highmem.c
#define PA_HASH_ORDER 7
/*
* Describes one page->virtual association
*/
struct page_address_map {
struct page *page;
void *virtual;
struct list_head list;
};
static struct page_address_map page_address_maps[LAST_PKMAP]; //在32bit中LAST_PKMAP为512,64bit为8192
//低端内存映射
/*
* Hash table bucket
*/
static struct page_address_slot {
struct list_head lh; /* List of page_address_maps */
spinlock_t lock; /* Protect this bucket's list */
} ____cacheline_aligned_in_smp page_address_htable[1<<PA_HASH_ORDER];//128k大小hash数组,存放内存映射(page_address_maps)
static struct page_address_slot *page_slot(const struct page *page)//通过page地址得到hash表的地址
{
return &page_address_htable[hash_ptr(page, PA_HASH_ORDER)];
}