page.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. #include <uapi/asm/page.h>
  11. #ifndef __ASSEMBLY__
  12. #define get_user_page(vaddr) __get_free_page(GFP_KERNEL)
  13. #define free_user_page(page, addr) free_page(addr)
  14. #define clear_page(paddr) memset((paddr), 0, PAGE_SIZE)
  15. #define copy_page(to, from) memcpy((to), (from), PAGE_SIZE)
  16. struct vm_area_struct;
  17. struct page;
  18. #define __HAVE_ARCH_COPY_USER_HIGHPAGE
  19. void copy_user_highpage(struct page *to, struct page *from,
  20. unsigned long u_vaddr, struct vm_area_struct *vma);
  21. void clear_user_page(void *to, unsigned long u_vaddr, struct page *page);
  22. #undef STRICT_MM_TYPECHECKS
  23. #ifdef STRICT_MM_TYPECHECKS
  24. /*
  25. * These are used to make use of C type-checking..
  26. */
  27. typedef struct {
  28. unsigned long pte;
  29. } pte_t;
  30. typedef struct {
  31. unsigned long pgd;
  32. } pgd_t;
  33. typedef struct {
  34. unsigned long pgprot;
  35. } pgprot_t;
  36. #define pte_val(x) ((x).pte)
  37. #define pgd_val(x) ((x).pgd)
  38. #define pgprot_val(x) ((x).pgprot)
  39. #define __pte(x) ((pte_t) { (x) })
  40. #define __pgd(x) ((pgd_t) { (x) })
  41. #define __pgprot(x) ((pgprot_t) { (x) })
  42. #define pte_pgprot(x) __pgprot(pte_val(x))
  43. #else /* !STRICT_MM_TYPECHECKS */
  44. #ifdef CONFIG_ARC_HAS_PAE40
  45. typedef unsigned long long pte_t;
  46. #else
  47. typedef unsigned long pte_t;
  48. #endif
  49. typedef unsigned long pgd_t;
  50. typedef unsigned long pgprot_t;
  51. #define pte_val(x) (x)
  52. #define pgd_val(x) (x)
  53. #define pgprot_val(x) (x)
  54. #define __pte(x) (x)
  55. #define __pgd(x) (x)
  56. #define __pgprot(x) (x)
  57. #define pte_pgprot(x) (x)
  58. #endif
  59. typedef pte_t * pgtable_t;
  60. #define ARCH_PFN_OFFSET (CONFIG_LINUX_LINK_BASE >> PAGE_SHIFT)
  61. #define pfn_valid(pfn) (((pfn) - ARCH_PFN_OFFSET) < max_mapnr)
  62. /*
  63. * __pa, __va, virt_to_page (ALERT: deprecated, don't use them)
  64. *
  65. * These macros have historically been misnamed
  66. * virt here means link-address/program-address as embedded in object code.
  67. * So if kernel img is linked at 0x8000_0000 onwards, 0x8010_0000 will be
  68. * 128th page, and virt_to_page( ) will return the struct page corresp to it.
  69. * mem_map[ ] is an array of struct page for each page frame in the system
  70. *
  71. * Independent of where linux is linked at, link-addr = physical address
  72. * So the old macro __pa = vaddr + PAGE_OFFSET - CONFIG_LINUX_LINK_BASE
  73. * would have been wrong in case kernel is not at 0x8zs
  74. */
  75. #define __pa(vaddr) ((unsigned long)vaddr)
  76. #define __va(paddr) ((void *)((unsigned long)(paddr)))
  77. #define virt_to_page(kaddr) \
  78. (mem_map + ((__pa(kaddr) - CONFIG_LINUX_LINK_BASE) >> PAGE_SHIFT))
  79. #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
  80. /* Default Permissions for stack/heaps pages (Non Executable) */
  81. #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
  82. #define WANT_PAGE_VIRTUAL 1
  83. #include <asm-generic/memory_model.h> /* page_to_pfn, pfn_to_page */
  84. #include <asm-generic/getorder.h>
  85. #endif /* !__ASSEMBLY__ */
  86. #endif