arch/csky/include/asm/pgtable.h

Source file repositories/reference/linux-study-clean/arch/csky/include/asm/pgtable.h

File Facts

System
Linux kernel
Corpus path
arch/csky/include/asm/pgtable.h
Extension
.h
Size
6420 bytes
Lines
264
Domain
Architecture Layer
Bucket
arch/csky
Inferred role
Architecture Layer: implementation source
Status
source implementation candidate

Why This File Exists

CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.

Dependency Surface

Detected Declarations

Annotated Snippet

#ifndef __ASM_CSKY_PGTABLE_H
#define __ASM_CSKY_PGTABLE_H

#include <asm/fixmap.h>
#include <asm/memory.h>
#include <asm/addrspace.h>
#include <abi/pgtable-bits.h>
#include <asm-generic/pgtable-nopmd.h>

#define PGDIR_SHIFT		22
#define PGDIR_SIZE		(1UL << PGDIR_SHIFT)
#define PGDIR_MASK		(~(PGDIR_SIZE-1))

#define USER_PTRS_PER_PGD	(PAGE_OFFSET/PGDIR_SIZE)

/*
 * C-SKY is two-level paging structure:
 */

#define PTRS_PER_PGD	(PAGE_SIZE / sizeof(pgd_t))
#define PTRS_PER_PMD	1
#define PTRS_PER_PTE	(PAGE_SIZE / sizeof(pte_t))

#define pte_ERROR(e) \
	pr_err("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, (e).pte_low)
#define pgd_ERROR(e) \
	pr_err("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e))

#define PFN_PTE_SHIFT	PAGE_SHIFT
#define pmd_pfn(pmd)	(pmd_phys(pmd) >> PAGE_SHIFT)
#define pmd_page(pmd)	(pfn_to_page(pmd_phys(pmd) >> PAGE_SHIFT))
#define pte_clear(mm, addr, ptep)	set_pte((ptep), \
	(((unsigned int) addr >= PAGE_OFFSET) ? __pte(_PAGE_GLOBAL) : __pte(0)))
#define pte_none(pte)		(!(pte_val(pte) & ~_PAGE_GLOBAL))
#define pte_present(pte)	(pte_val(pte) & _PAGE_PRESENT)
#define pte_pfn(x)	((unsigned long)((x).pte_low >> PAGE_SHIFT))
#define pfn_pte(pfn, prot) __pte(((unsigned long long)(pfn) << PAGE_SHIFT) \
				| pgprot_val(prot))

#define __pte_to_swp_entry(pte)		((swp_entry_t) { pte_val(pte) })
#define __swp_entry_to_pte(x)		((pte_t) { (x).val })

#define pte_page(x)			pfn_to_page(pte_pfn(x))
#define __mk_pte(page_nr, pgprot)	__pte(((page_nr) << PAGE_SHIFT) | \
					pgprot_val(pgprot))

/*
 * C-SKY only has VALID and DIRTY bit in hardware. So we need to use the
 * two bits emulate PRESENT, READ, WRITE, EXEC, MODIFIED, ACCESSED.
 */
#define _PAGE_BASE	(_PAGE_PRESENT | _PAGE_ACCESSED)

#define PAGE_NONE	__pgprot(_PAGE_PROT_NONE)
#define PAGE_READ	__pgprot(_PAGE_BASE | _PAGE_READ | \
				_CACHE_CACHED)
#define PAGE_WRITE	__pgprot(_PAGE_BASE | _PAGE_READ | _PAGE_WRITE | \
				_CACHE_CACHED)
#define PAGE_SHARED PAGE_WRITE

#define PAGE_KERNEL	__pgprot(_PAGE_BASE | _PAGE_READ | _PAGE_VALID | \
				_PAGE_WRITE | _PAGE_DIRTY | _PAGE_MODIFIED | \
				_PAGE_GLOBAL | \
				_CACHE_CACHED)

#define _PAGE_IOREMAP		(_PAGE_BASE | _PAGE_READ | _PAGE_VALID | \
				_PAGE_WRITE | _PAGE_DIRTY | _PAGE_MODIFIED | \
				_PAGE_GLOBAL | \
				_CACHE_UNCACHED | _PAGE_SO)

#define _PAGE_CHG_MASK	(~(unsigned long) \
				(_PAGE_PRESENT | _PAGE_READ | _PAGE_WRITE | \
				_CACHE_MASK | _PAGE_GLOBAL))

#define MAX_SWAPFILES_CHECK() \
		BUILD_BUG_ON(MAX_SWAPFILES_SHIFT != 5)

extern void load_pgd(unsigned long pg_dir);
extern pte_t invalid_pte_table[PTRS_PER_PTE];

static inline void set_pte(pte_t *p, pte_t pte)
{
	*p = pte;
#if defined(CONFIG_CPU_NEED_TLBSYNC)
	dcache_wb_line((u32)p);
#endif
	/* prevent out of order excution */
	smp_mb();
}

static inline pte_t *pmd_page_vaddr(pmd_t pmd)

Annotation

Implementation Notes