pgtable.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:4k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  *  linux/include/asm-arm/proc-armo/pgtable.h
  3.  *
  4.  *  Copyright (C) 1995-2001 Russell King
  5.  *
  6.  * This program is free software; you can redistribute it and/or modify
  7.  * it under the terms of the GNU General Public License version 2 as
  8.  * published by the Free Software Foundation.
  9.  *
  10.  *  18-Oct-1997 RMK Now two-level (32x32)
  11.  */
  12. #ifndef __ASM_PROC_PGTABLE_H
  13. #define __ASM_PROC_PGTABLE_H
  14. /*
  15.  * entries per page directory level: they are two-level, so
  16.  * we don't really have any PMD directory.
  17.  */
  18. #define PTRS_PER_PTE 32
  19. #define PTRS_PER_PMD 1
  20. #define PTRS_PER_PGD 32
  21. /*
  22.  * The vmalloc() routines leaves a hole of 4kB between each vmalloced
  23.  * area for the same reason. ;)
  24.  */
  25. #define VMALLOC_START   0x01a00000
  26. #define VMALLOC_VMADDR(x) ((unsigned long)(x))
  27. #define VMALLOC_END   0x01c00000
  28. #define _PAGE_TABLE     (0x01)
  29. #define pmd_bad(pmd) ((pmd_val(pmd) & 0xfc000002))
  30. #define set_pmd(pmdp,pmd) ((*(pmdp)) = (pmd))
  31. static inline pmd_t __mk_pmd(pte_t *ptep, unsigned long prot)
  32. {
  33. unsigned long pte_ptr = (unsigned long)ptep;
  34. pmd_t pmd;
  35. pmd_val(pmd) = __virt_to_phys(pte_ptr) | prot;
  36. return pmd;
  37. }
  38. static inline unsigned long pmd_page(pmd_t pmd)
  39. {
  40. return __phys_to_virt(pmd_val(pmd) & ~_PAGE_TABLE);
  41. }
  42. #define set_pte(pteptr, pteval) ((*(pteptr)) = (pteval))
  43. #define _PAGE_PRESENT 0x01
  44. #define _PAGE_READONLY 0x02
  45. #define _PAGE_NOT_USER 0x04
  46. #define _PAGE_OLD 0x08
  47. #define _PAGE_CLEAN 0x10
  48. /*                               -- present --   -- !dirty --  --- !write ---   ---- !user --- */
  49. #define PAGE_NONE       __pgprot(_PAGE_PRESENT | _PAGE_CLEAN | _PAGE_READONLY | _PAGE_NOT_USER)
  50. #define PAGE_SHARED     __pgprot(_PAGE_PRESENT | _PAGE_CLEAN                                  )
  51. #define PAGE_COPY       __pgprot(_PAGE_PRESENT | _PAGE_CLEAN | _PAGE_READONLY                 )
  52. #define PAGE_READONLY   __pgprot(_PAGE_PRESENT | _PAGE_CLEAN | _PAGE_READONLY                 )
  53. #define PAGE_KERNEL     __pgprot(_PAGE_PRESENT                                | _PAGE_NOT_USER)
  54. #define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_OLD | _PAGE_CLEAN)
  55. /*
  56.  * The following only work if pte_present() is true.
  57.  * Undefined behaviour if not..
  58.  */
  59. #define pte_present(pte) (pte_val(pte) & _PAGE_PRESENT)
  60. #define pte_read(pte) (!(pte_val(pte) & _PAGE_NOT_USER))
  61. #define pte_write(pte) (!(pte_val(pte) & _PAGE_READONLY))
  62. #define pte_exec(pte) (!(pte_val(pte) & _PAGE_NOT_USER))
  63. #define pte_dirty(pte) (!(pte_val(pte) & _PAGE_CLEAN))
  64. #define pte_young(pte) (!(pte_val(pte) & _PAGE_OLD))
  65. static inline pte_t pte_wrprotect(pte_t pte)    { pte_val(pte) |= _PAGE_READONLY;  return pte; }
  66. static inline pte_t pte_rdprotect(pte_t pte)    { pte_val(pte) |= _PAGE_NOT_USER;  return pte; }
  67. static inline pte_t pte_exprotect(pte_t pte)    { pte_val(pte) |= _PAGE_NOT_USER;  return pte; }
  68. static inline pte_t pte_mkclean(pte_t pte)      { pte_val(pte) |= _PAGE_CLEAN;     return pte; }
  69. static inline pte_t pte_mkold(pte_t pte)        { pte_val(pte) |= _PAGE_OLD;       return pte; }
  70. static inline pte_t pte_mkwrite(pte_t pte)      { pte_val(pte) &= ~_PAGE_READONLY; return pte; }
  71. static inline pte_t pte_mkread(pte_t pte)       { pte_val(pte) &= ~_PAGE_NOT_USER; return pte; }
  72. static inline pte_t pte_mkexec(pte_t pte)       { pte_val(pte) &= ~_PAGE_NOT_USER; return pte; }
  73. static inline pte_t pte_mkdirty(pte_t pte)      { pte_val(pte) &= ~_PAGE_CLEAN;    return pte; }
  74. static inline pte_t pte_mkyoung(pte_t pte)      { pte_val(pte) &= ~_PAGE_OLD;      return pte; }
  75. #define pte_alloc_kernel        pte_alloc
  76. /*
  77.  * We don't store cache state bits in the page table here.
  78.  */
  79. #define pgprot_noncached(prot) (prot)
  80. #endif /* __ASM_PROC_PGTABLE_H */