proc-fns.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. * Check for processor bugs
  36. */
  37. void (*check_bugs)(void);
  38. /*
  39. * Disable any processor specifics
  40. */
  41. void (*_proc_fin)(void);
  42. /*
  43. * Special stuff for a reset
  44. */
  45. void (*reset)(unsigned long addr, bool hvc) __attribute__((noreturn));
  46. /*
  47. * Idle the processor
  48. */
  49. int (*_do_idle)(void);
  50. /*
  51. * Processor architecture specific
  52. */
  53. /*
  54. * clean a virtual address range from the
  55. * D-cache without flushing the cache.
  56. */
  57. void (*dcache_clean_area)(void *addr, int size);
  58. /*
  59. * Set the page table
  60. */
  61. void (*switch_mm)(phys_addr_t pgd_phys, struct mm_struct *mm);
  62. /*
  63. * Set a possibly extended PTE. Non-extended PTEs should
  64. * ignore 'ext'.
  65. */
  66. #ifdef CONFIG_ARM_LPAE
  67. void (*set_pte_ext)(pte_t *ptep, pte_t pte);
  68. #else
  69. void (*set_pte_ext)(pte_t *ptep, pte_t pte, unsigned int ext);
  70. #endif
  71. /* Suspend/resume */
  72. unsigned int suspend_size;
  73. void (*do_suspend)(void *);
  74. void (*do_resume)(void *);
  75. } processor;
  76. #ifndef MULTI_CPU
  77. extern void cpu_proc_init(void);
  78. extern void cpu_proc_fin(void);
  79. extern int cpu_do_idle(void);
  80. extern void cpu_dcache_clean_area(void *, int);
  81. extern void cpu_do_switch_mm(phys_addr_t pgd_phys, struct mm_struct *mm);
  82. #ifdef CONFIG_ARM_LPAE
  83. extern void cpu_set_pte_ext(pte_t *ptep, pte_t pte);
  84. #else
  85. extern void cpu_set_pte_ext(pte_t *ptep, pte_t pte, unsigned int ext);
  86. #endif
  87. extern void cpu_reset(unsigned long addr, bool hvc) __attribute__((noreturn));
  88. /* These three are private to arch/arm/kernel/suspend.c */
  89. extern void cpu_do_suspend(void *);
  90. extern void cpu_do_resume(void *);
  91. #else
  92. #define cpu_proc_init processor._proc_init
  93. #define cpu_proc_fin processor._proc_fin
  94. #define cpu_reset processor.reset
  95. #define cpu_do_idle processor._do_idle
  96. #define cpu_dcache_clean_area processor.dcache_clean_area
  97. #define cpu_set_pte_ext processor.set_pte_ext
  98. #define cpu_do_switch_mm processor.switch_mm
  99. /* These three are private to arch/arm/kernel/suspend.c */
  100. #define cpu_do_suspend processor.do_suspend
  101. #define cpu_do_resume processor.do_resume
  102. #endif
  103. extern void cpu_resume(void);
  104. #include <asm/memory.h>
  105. #ifdef CONFIG_MMU
  106. #define cpu_switch_mm(pgd,mm) cpu_do_switch_mm(virt_to_phys(pgd),mm)
  107. #ifdef CONFIG_ARM_LPAE
  108. #define cpu_get_ttbr(nr) \
  109. ({ \
  110. u64 ttbr; \
  111. __asm__("mrrc p15, " #nr ", %Q0, %R0, c2" \
  112. : "=r" (ttbr)); \
  113. ttbr; \
  114. })
  115. #define cpu_get_pgd() \
  116. ({ \
  117. u64 pg = cpu_get_ttbr(0); \
  118. pg &= ~(PTRS_PER_PGD*sizeof(pgd_t)-1); \
  119. (pgd_t *)phys_to_virt(pg); \
  120. })
  121. #else
  122. #define cpu_get_pgd() \
  123. ({ \
  124. unsigned long pg; \
  125. __asm__("mrc p15, 0, %0, c2, c0, 0" \
  126. : "=r" (pg) : : "cc"); \
  127. pg &= ~0x3fff; \
  128. (pgd_t *)phys_to_virt(pg); \
  129. })
  130. #endif
  131. #else /*!CONFIG_MMU */
  132. #define cpu_switch_mm(pgd,mm) { }
  133. #endif
  134. #endif /* __ASSEMBLY__ */
  135. #endif /* __KERNEL__ */
  136. #endif /* __ASM_PROCFNS_H */