proc-fns.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*
  2. * arch/arm/include/asm/proc-fns.h
  3. *
  4. * Copyright (C) 1997-1999 Russell King
  5. * Copyright (C) 2000 Deep Blue Solutions Ltd
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #ifndef __ASM_PROCFNS_H
  12. #define __ASM_PROCFNS_H
  13. #ifdef __KERNEL__
  14. #include <asm/glue-proc.h>
  15. #include <asm/page.h>
  16. #ifndef __ASSEMBLY__
  17. struct mm_struct;
  18. /*
  19. * Don't change this structure - ASM code relies on it.
  20. */
  21. extern struct processor {
  22. /* MISC
  23. * get data abort address/flags
  24. */
  25. void (*_data_abort)(unsigned long pc);
  26. /*
  27. * Retrieve prefetch fault address
  28. */
  29. unsigned long (*_prefetch_abort)(unsigned long lr);
  30. /*
  31. * Set up any processor specifics
  32. */
  33. void (*_proc_init)(void);
  34. /*
  35. * Disable any processor specifics
  36. */
  37. void (*_proc_fin)(void);
  38. /*
  39. * Special stuff for a reset
  40. */
  41. void (*reset)(unsigned long addr) __attribute__((noreturn));
  42. /*
  43. * Idle the processor
  44. */
  45. int (*_do_idle)(void);
  46. /*
  47. * Processor architecture specific
  48. */
  49. /*
  50. * clean a virtual address range from the
  51. * D-cache without flushing the cache.
  52. */
  53. void (*dcache_clean_area)(void *addr, int size);
  54. /*
  55. * Set the page table
  56. */
  57. void (*switch_mm)(phys_addr_t pgd_phys, struct mm_struct *mm);
  58. /*
  59. * Set a possibly extended PTE. Non-extended PTEs should
  60. * ignore 'ext'.
  61. */
  62. #ifdef CONFIG_ARM_LPAE
  63. void (*set_pte_ext)(pte_t *ptep, pte_t pte);
  64. #else
  65. void (*set_pte_ext)(pte_t *ptep, pte_t pte, unsigned int ext);
  66. #endif
  67. /* Suspend/resume */
  68. unsigned int suspend_size;
  69. void (*do_suspend)(void *);
  70. void (*do_resume)(void *);
  71. } processor;
  72. #ifndef MULTI_CPU
  73. extern void cpu_proc_init(void);
  74. extern void cpu_proc_fin(void);
  75. extern int cpu_do_idle(void);
  76. extern void cpu_dcache_clean_area(void *, int);
  77. extern void cpu_do_switch_mm(phys_addr_t pgd_phys, struct mm_struct *mm);
  78. #ifdef CONFIG_ARM_LPAE
  79. extern void cpu_set_pte_ext(pte_t *ptep, pte_t pte);
  80. #else
  81. extern void cpu_set_pte_ext(pte_t *ptep, pte_t pte, unsigned int ext);
  82. #endif
  83. extern void cpu_reset(unsigned long addr) __attribute__((noreturn));
  84. /* These three are private to arch/arm/kernel/suspend.c */
  85. extern void cpu_do_suspend(void *);
  86. extern void cpu_do_resume(void *);
  87. #else
  88. #define cpu_proc_init processor._proc_init
  89. #define cpu_proc_fin processor._proc_fin
  90. #define cpu_reset processor.reset
  91. #define cpu_do_idle processor._do_idle
  92. #define cpu_dcache_clean_area processor.dcache_clean_area
  93. #define cpu_set_pte_ext processor.set_pte_ext
  94. #define cpu_do_switch_mm processor.switch_mm
  95. /* These three are private to arch/arm/kernel/suspend.c */
  96. #define cpu_do_suspend processor.do_suspend
  97. #define cpu_do_resume processor.do_resume
  98. #endif
  99. extern void cpu_resume(void);
  100. #include <asm/memory.h>
  101. #ifdef CONFIG_MMU
  102. #define cpu_switch_mm(pgd,mm) cpu_do_switch_mm(virt_to_phys(pgd),mm)
  103. #ifdef CONFIG_ARM_LPAE
  104. #define cpu_get_ttbr(nr) \
  105. ({ \
  106. u64 ttbr; \
  107. __asm__("mrrc p15, " #nr ", %Q0, %R0, c2" \
  108. : "=r" (ttbr)); \
  109. ttbr; \
  110. })
  111. #define cpu_get_pgd() \
  112. ({ \
  113. u64 pg = cpu_get_ttbr(0); \
  114. pg &= ~(PTRS_PER_PGD*sizeof(pgd_t)-1); \
  115. (pgd_t *)phys_to_virt(pg); \
  116. })
  117. #else
  118. #define cpu_get_pgd() \
  119. ({ \
  120. unsigned long pg; \
  121. __asm__("mrc p15, 0, %0, c2, c0, 0" \
  122. : "=r" (pg) : : "cc"); \
  123. pg &= ~0x3fff; \
  124. (pgd_t *)phys_to_virt(pg); \
  125. })
  126. #endif
  127. #else /*!CONFIG_MMU */
  128. #define cpu_switch_mm(pgd,mm) { }
  129. #endif
  130. #endif /* __ASSEMBLY__ */
  131. #endif /* __KERNEL__ */
  132. #endif /* __ASM_PROCFNS_H */