linux/arch/arc/include/asm/page.h
<<
>>
Prefs
   1/*
   2 * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
   3 *
   4 * This program is free software; you can redistribute it and/or modify
   5 * it under the terms of the GNU General Public License version 2 as
   6 * published by the Free Software Foundation.
   7 */
   8#ifndef __ASM_ARC_PAGE_H
   9#define __ASM_ARC_PAGE_H
  10
  11#include <uapi/asm/page.h>
  12
  13#ifndef __ASSEMBLY__
  14
  15#define clear_page(paddr)               memset((paddr), 0, PAGE_SIZE)
  16#define copy_page(to, from)             memcpy((to), (from), PAGE_SIZE)
  17
  18struct vm_area_struct;
  19struct page;
  20
  21#define __HAVE_ARCH_COPY_USER_HIGHPAGE
  22
  23void copy_user_highpage(struct page *to, struct page *from,
  24                        unsigned long u_vaddr, struct vm_area_struct *vma);
  25void clear_user_page(void *to, unsigned long u_vaddr, struct page *page);
  26
  27#undef STRICT_MM_TYPECHECKS
  28
  29#ifdef STRICT_MM_TYPECHECKS
  30/*
  31 * These are used to make use of C type-checking..
  32 */
  33typedef struct {
  34        unsigned long pte;
  35} pte_t;
  36typedef struct {
  37        unsigned long pgd;
  38} pgd_t;
  39typedef struct {
  40        unsigned long pgprot;
  41} pgprot_t;
  42
  43#define pte_val(x)      ((x).pte)
  44#define pgd_val(x)      ((x).pgd)
  45#define pgprot_val(x)   ((x).pgprot)
  46
  47#define __pte(x)        ((pte_t) { (x) })
  48#define __pgd(x)        ((pgd_t) { (x) })
  49#define __pgprot(x)     ((pgprot_t) { (x) })
  50
  51#define pte_pgprot(x) __pgprot(pte_val(x))
  52
  53#else /* !STRICT_MM_TYPECHECKS */
  54
  55#ifdef CONFIG_ARC_HAS_PAE40
  56typedef unsigned long long pte_t;
  57#else
  58typedef unsigned long pte_t;
  59#endif
  60typedef unsigned long pgd_t;
  61typedef unsigned long pgprot_t;
  62
  63#define pte_val(x)      (x)
  64#define pgd_val(x)      (x)
  65#define pgprot_val(x)   (x)
  66#define __pte(x)        (x)
  67#define __pgd(x)        (x)
  68#define __pgprot(x)     (x)
  69#define pte_pgprot(x)   (x)
  70
  71#endif
  72
  73typedef pte_t * pgtable_t;
  74
  75/*
  76 * Use virt_to_pfn with caution:
  77 * If used in pte or paddr related macros, it could cause truncation
  78 * in PAE40 builds
  79 * As a rule of thumb, only use it in helpers starting with virt_
  80 * You have been warned !
  81 */
  82#define virt_to_pfn(kaddr)      (__pa(kaddr) >> PAGE_SHIFT)
  83
  84#define ARCH_PFN_OFFSET         virt_to_pfn(CONFIG_LINUX_LINK_BASE)
  85
  86#ifdef CONFIG_FLATMEM
  87#define pfn_valid(pfn)          (((pfn) - ARCH_PFN_OFFSET) < max_mapnr)
  88#endif
  89
  90/*
  91 * __pa, __va, virt_to_page (ALERT: deprecated, don't use them)
  92 *
  93 * These macros have historically been misnamed
  94 * virt here means link-address/program-address as embedded in object code.
  95 * And for ARC, link-addr = physical address
  96 */
  97#define __pa(vaddr)  ((unsigned long)(vaddr))
  98#define __va(paddr)  ((void *)((unsigned long)(paddr)))
  99
 100#define virt_to_page(kaddr)     pfn_to_page(virt_to_pfn(kaddr))
 101#define virt_addr_valid(kaddr)  pfn_valid(virt_to_pfn(kaddr))
 102
 103/* Default Permissions for stack/heaps pages (Non Executable) */
 104#define VM_DATA_DEFAULT_FLAGS   (VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE)
 105
 106#define WANT_PAGE_VIRTUAL   1
 107
 108#include <asm-generic/memory_model.h>   /* page_to_pfn, pfn_to_page */
 109#include <asm-generic/getorder.h>
 110
 111#endif /* !__ASSEMBLY__ */
 112
 113#endif
 114