pgtable.h

来自「linux 内核源代码」· C头文件 代码 · 共 541 行 · 第 1/2 页

H
541
字号
/* pgtable.h: FR-V page table mangling * * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved. * Written by David Howells (dhowells@redhat.com) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. * * Derived from: *	include/asm-m68knommu/pgtable.h *	include/asm-i386/pgtable.h */#ifndef _ASM_PGTABLE_H#define _ASM_PGTABLE_H#include <asm/mem-layout.h>#include <asm/setup.h>#include <asm/processor.h>#ifndef __ASSEMBLY__#include <linux/threads.h>#include <linux/slab.h>#include <linux/list.h>#include <linux/spinlock.h>#include <linux/sched.h>struct vm_area_struct;#endif#ifndef __ASSEMBLY__#if defined(CONFIG_HIGHPTE)typedef unsigned long pte_addr_t;#elsetypedef pte_t *pte_addr_t;#endif#endif/*****************************************************************************//* * MMU-less operation case first */#ifndef CONFIG_MMU#define pgd_present(pgd)	(1)		/* pages are always present on NO_MM */#define pgd_none(pgd)		(0)#define pgd_bad(pgd)		(0)#define pgd_clear(pgdp)#define kern_addr_valid(addr)	(1)#define	pmd_offset(a, b)	((void *) 0)#define PAGE_NONE		__pgprot(0)	/* these mean nothing to NO_MM */#define PAGE_SHARED		__pgprot(0)	/* these mean nothing to NO_MM */#define PAGE_COPY		__pgprot(0)	/* these mean nothing to NO_MM */#define PAGE_READONLY		__pgprot(0)	/* these mean nothing to NO_MM */#define PAGE_KERNEL		__pgprot(0)	/* these mean nothing to NO_MM */#define __swp_type(x)		(0)#define __swp_offset(x)		(0)#define __swp_entry(typ,off)	((swp_entry_t) { ((typ) | ((off) << 7)) })#define __pte_to_swp_entry(pte)	((swp_entry_t) { pte_val(pte) })#define __swp_entry_to_pte(x)	((pte_t) { (x).val })#ifndef __ASSEMBLY__static inline int pte_file(pte_t pte) { return 0; }#endif#define ZERO_PAGE(vaddr)	({ BUG(); NULL; })#define swapper_pg_dir		((pgd_t *) NULL)#define pgtable_cache_init()		do {} while (0)#define arch_enter_lazy_mmu_mode()	do {} while (0)#define arch_leave_lazy_mmu_mode()	do {} while (0)#define arch_enter_lazy_cpu_mode()	do {} while (0)#define arch_leave_lazy_cpu_mode()	do {} while (0)#else /* !CONFIG_MMU *//*****************************************************************************//* * then MMU operation *//* * ZERO_PAGE is a global shared page that is always zero: used * for zero-mapped memory areas etc.. */#ifndef __ASSEMBLY__extern unsigned long empty_zero_page;#define ZERO_PAGE(vaddr)	virt_to_page(empty_zero_page)#endif/* * we use 2-level page tables, folding the PMD (mid-level table) into the PGE (top-level entry) * [see Documentation/fujitsu/frv/mmu-layout.txt] * * Page Directory: *  - Size: 16KB *  - 64 PGEs per PGD *  - Each PGE holds 1 PUD and covers 64MB * * Page Upper Directory: *  - Size: 256B *  - 1 PUE per PUD *  - Each PUE holds 1 PMD and covers 64MB * * Page Mid-Level Directory *  - Size: 256B *  - 1 PME per PMD *  - Each PME holds 64 STEs, all of which point to separate chunks of the same Page Table *  - All STEs are instantiated at the same time * * Page Table *  - Size: 16KB *  - 4096 PTEs per PT *  - Each Linux PT is subdivided into 64 FR451 PT's, each of which holds 64 entries * * Pages *  - Size: 4KB * * total PTEs *	= 1 PML4E * 64 PGEs * 1 PUEs * 1 PMEs * 4096 PTEs *	= 1 PML4E * 64 PGEs * 64 STEs * 64 PTEs/FR451-PT *	= 262144 (or 256 * 1024) */#define PGDIR_SHIFT		26#define PGDIR_SIZE		(1UL << PGDIR_SHIFT)#define PGDIR_MASK		(~(PGDIR_SIZE - 1))#define PTRS_PER_PGD		64#define PUD_SHIFT		26#define PTRS_PER_PUD		1#define PUD_SIZE		(1UL << PUD_SHIFT)#define PUD_MASK		(~(PUD_SIZE - 1))#define PUE_SIZE		256#define PMD_SHIFT		26#define PMD_SIZE		(1UL << PMD_SHIFT)#define PMD_MASK		(~(PMD_SIZE - 1))#define PTRS_PER_PMD		1#define PME_SIZE		256#define __frv_PT_SIZE		256#define PTRS_PER_PTE		4096#define USER_PGDS_IN_LAST_PML4	(TASK_SIZE / PGDIR_SIZE)#define FIRST_USER_ADDRESS	0#define USER_PGD_PTRS		(PAGE_OFFSET >> PGDIR_SHIFT)#define KERNEL_PGD_PTRS		(PTRS_PER_PGD - USER_PGD_PTRS)#define TWOLEVEL_PGDIR_SHIFT	26#define BOOT_USER_PGD_PTRS	(__PAGE_OFFSET >> TWOLEVEL_PGDIR_SHIFT)#define BOOT_KERNEL_PGD_PTRS	(PTRS_PER_PGD - BOOT_USER_PGD_PTRS)#ifndef __ASSEMBLY__extern pgd_t swapper_pg_dir[PTRS_PER_PGD];#define pte_ERROR(e) \	printk("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, (e).pte)#define pmd_ERROR(e) \	printk("%s:%d: bad pmd %08lx.\n", __FILE__, __LINE__, pmd_val(e))#define pud_ERROR(e) \	printk("%s:%d: bad pud %08lx.\n", __FILE__, __LINE__, pmd_val(pud_val(e)))#define pgd_ERROR(e) \	printk("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pmd_val(pud_val(pgd_val(e))))/* * Certain architectures need to do special things when PTEs * within a page table are directly modified.  Thus, the following * hook is made available. */#define set_pte(pteptr, pteval)				\do {							\	*(pteptr) = (pteval);				\	asm volatile("dcf %M0" :: "U"(*pteptr));	\} while(0)#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)/* * pgd_offset() returns a (pgd_t *) * pgd_index() is used get the offset into the pgd page's array of pgd_t's; */#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))/* * a shortcut which implies the use of the kernel's pgd, instead * of a process's */#define pgd_offset_k(address) pgd_offset(&init_mm, address)/* * The "pgd_xxx()" functions here are trivial for a folded two-level * setup: the pud is never bad, and a pud always exists (as it's folded * into the pgd entry) */static inline int pgd_none(pgd_t pgd)		{ return 0; }static inline int pgd_bad(pgd_t pgd)		{ return 0; }static inline int pgd_present(pgd_t pgd)	{ return 1; }static inline void pgd_clear(pgd_t *pgd)	{ }#define pgd_populate(mm, pgd, pud)		do { } while (0)/* * (puds are folded into pgds so this doesn't get actually called, * but the define is needed for a generic inline function.) */#define set_pgd(pgdptr, pgdval)				\do {							\	memcpy((pgdptr), &(pgdval), sizeof(pgd_t));	\	asm volatile("dcf %M0" :: "U"(*(pgdptr)));	\} while(0)static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address){	return (pud_t *) pgd;}#define pgd_page(pgd)				(pud_page((pud_t){ pgd }))#define pgd_page_vaddr(pgd)			(pud_page_vaddr((pud_t){ pgd }))/* * allocating and freeing a pud is trivial: the 1-entry pud is * inside the pgd, so has no extra memory associated with it. */#define pud_alloc_one(mm, address)		NULL#define pud_free(x)				do { } while (0)#define __pud_free_tlb(tlb, x)			do { } while (0)/* * The "pud_xxx()" functions here are trivial for a folded two-level * setup: the pmd is never bad, and a pmd always exists (as it's folded * into the pud entry) */static inline int pud_none(pud_t pud)		{ return 0; }static inline int pud_bad(pud_t pud)		{ return 0; }static inline int pud_present(pud_t pud)	{ return 1; }static inline void pud_clear(pud_t *pud)	{ }#define pud_populate(mm, pmd, pte)		do { } while (0)/* * (pmds are folded into puds so this doesn't get actually called, * but the define is needed for a generic inline function.) */#define set_pud(pudptr, pudval)			set_pmd((pmd_t *)(pudptr), (pmd_t) { pudval })#define pud_page(pud)				(pmd_page((pmd_t){ pud }))#define pud_page_vaddr(pud)			(pmd_page_vaddr((pmd_t){ pud }))/* * (pmds are folded into pgds so this doesn't get actually called, * but the define is needed for a generic inline function.) */extern void __set_pmd(pmd_t *pmdptr, unsigned long __pmd);#define set_pmd(pmdptr, pmdval)			\do {						\	__set_pmd((pmdptr), (pmdval).ste[0]);	\} while(0)#define __pmd_index(address)			0static inline pmd_t *pmd_offset(pud_t *dir, unsigned long address){	return (pmd_t *) dir + __pmd_index(address);}#define pte_same(a, b)		((a).pte == (b).pte)

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?