processor.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. * arch/arm/include/asm/processor.h
  3. *
  4. * Copyright (C) 1995-1999 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. #ifndef __ASM_ARM_PROCESSOR_H
  11. #define __ASM_ARM_PROCESSOR_H
  12. /*
  13. * Default implementation of macro that returns current
  14. * instruction pointer ("program counter").
  15. */
  16. #define current_text_addr() ({ __label__ _l; _l: &&_l;})
  17. #ifdef __KERNEL__
  18. #include <asm/hw_breakpoint.h>
  19. #include <asm/ptrace.h>
  20. #include <asm/types.h>
  21. #include <asm/unified.h>
  22. #ifdef __KERNEL__
  23. #define STACK_TOP ((current->personality & ADDR_LIMIT_32BIT) ? \
  24. TASK_SIZE : TASK_SIZE_26)
  25. #define STACK_TOP_MAX TASK_SIZE
  26. #endif
  27. struct debug_info {
  28. #ifdef CONFIG_HAVE_HW_BREAKPOINT
  29. struct perf_event *hbp[ARM_MAX_HBP_SLOTS];
  30. #endif
  31. };
  32. struct thread_struct {
  33. /* fault info */
  34. unsigned long address;
  35. unsigned long trap_no;
  36. unsigned long error_code;
  37. /* debugging */
  38. struct debug_info debug;
  39. };
  40. #define INIT_THREAD { }
  41. #ifdef CONFIG_MMU
  42. #define nommu_start_thread(regs) do { } while (0)
  43. #else
  44. #define nommu_start_thread(regs) regs->ARM_r10 = current->mm->start_data
  45. #endif
  46. #define start_thread(regs,pc,sp) \
  47. ({ \
  48. memset(regs->uregs, 0, sizeof(regs->uregs)); \
  49. if (current->personality & ADDR_LIMIT_32BIT) \
  50. regs->ARM_cpsr = USR_MODE; \
  51. else \
  52. regs->ARM_cpsr = USR26_MODE; \
  53. if (elf_hwcap & HWCAP_THUMB && pc & 1) \
  54. regs->ARM_cpsr |= PSR_T_BIT; \
  55. regs->ARM_cpsr |= PSR_ENDSTATE; \
  56. regs->ARM_pc = pc & ~1; /* pc */ \
  57. regs->ARM_sp = sp; /* sp */ \
  58. nommu_start_thread(regs); \
  59. })
  60. /* Forward declaration, a strange C thing */
  61. struct task_struct;
  62. /* Free all resources held by a thread. */
  63. extern void release_thread(struct task_struct *);
  64. unsigned long get_wchan(struct task_struct *p);
  65. #if __LINUX_ARM_ARCH__ == 6 || defined(CONFIG_ARM_ERRATA_754327)
  66. #define cpu_relax() \
  67. do { \
  68. smp_mb(); \
  69. __asm__ __volatile__("nop; nop; nop; nop; nop; nop; nop; nop; nop; nop;"); \
  70. } while (0)
  71. #else
  72. #define cpu_relax() barrier()
  73. #endif
  74. #define cpu_relax_lowlatency() cpu_relax()
  75. #define task_pt_regs(p) \
  76. ((struct pt_regs *)(THREAD_START_SP + task_stack_page(p)) - 1)
  77. #define KSTK_EIP(tsk) task_pt_regs(tsk)->ARM_pc
  78. #define KSTK_ESP(tsk) task_pt_regs(tsk)->ARM_sp
  79. #ifdef CONFIG_SMP
  80. #define __ALT_SMP_ASM(smp, up) \
  81. "9998: " smp "\n" \
  82. " .pushsection \".alt.smp.init\", \"a\"\n" \
  83. " .long 9998b\n" \
  84. " " up "\n" \
  85. " .popsection\n"
  86. #else
  87. #define __ALT_SMP_ASM(smp, up) up
  88. #endif
  89. /*
  90. * Prefetching support - only ARMv5.
  91. */
  92. #if __LINUX_ARM_ARCH__ >= 5
  93. #define ARCH_HAS_PREFETCH
  94. static inline void prefetch(const void *ptr)
  95. {
  96. __asm__ __volatile__(
  97. "pld\t%a0"
  98. :: "p" (ptr));
  99. }
  100. #if __LINUX_ARM_ARCH__ >= 7 && defined(CONFIG_SMP)
  101. #define ARCH_HAS_PREFETCHW
  102. static inline void prefetchw(const void *ptr)
  103. {
  104. __asm__ __volatile__(
  105. ".arch_extension mp\n"
  106. __ALT_SMP_ASM(
  107. WASM(pldw) "\t%a0",
  108. WASM(pld) "\t%a0"
  109. )
  110. :: "p" (ptr));
  111. }
  112. #endif
  113. #endif
  114. #define HAVE_ARCH_PICK_MMAP_LAYOUT
  115. #endif
  116. #endif /* __ASM_ARM_PROCESSOR_H */