processor.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. #ifdef __KERNEL__
  22. #define STACK_TOP ((current->personality & ADDR_LIMIT_32BIT) ? \
  23. TASK_SIZE : TASK_SIZE_26)
  24. #define STACK_TOP_MAX TASK_SIZE
  25. #endif
  26. union debug_insn {
  27. u32 arm;
  28. u16 thumb;
  29. };
  30. struct debug_entry {
  31. u32 address;
  32. union debug_insn insn;
  33. };
  34. struct debug_info {
  35. int nsaved;
  36. struct debug_entry bp[2];
  37. #ifdef CONFIG_HAVE_HW_BREAKPOINT
  38. struct perf_event *hbp[ARM_MAX_HBP_SLOTS];
  39. #endif
  40. };
  41. struct thread_struct {
  42. /* fault info */
  43. unsigned long address;
  44. unsigned long trap_no;
  45. unsigned long error_code;
  46. /* debugging */
  47. struct debug_info debug;
  48. };
  49. #define INIT_THREAD { }
  50. #ifdef CONFIG_MMU
  51. #define nommu_start_thread(regs) do { } while (0)
  52. #else
  53. #define nommu_start_thread(regs) regs->ARM_r10 = current->mm->start_data
  54. #endif
  55. #define start_thread(regs,pc,sp) \
  56. ({ \
  57. unsigned long *stack = (unsigned long *)sp; \
  58. set_fs(USER_DS); \
  59. memset(regs->uregs, 0, sizeof(regs->uregs)); \
  60. if (current->personality & ADDR_LIMIT_32BIT) \
  61. regs->ARM_cpsr = USR_MODE; \
  62. else \
  63. regs->ARM_cpsr = USR26_MODE; \
  64. if (elf_hwcap & HWCAP_THUMB && pc & 1) \
  65. regs->ARM_cpsr |= PSR_T_BIT; \
  66. regs->ARM_cpsr |= PSR_ENDSTATE; \
  67. regs->ARM_pc = pc & ~1; /* pc */ \
  68. regs->ARM_sp = sp; /* sp */ \
  69. regs->ARM_r2 = stack[2]; /* r2 (envp) */ \
  70. regs->ARM_r1 = stack[1]; /* r1 (argv) */ \
  71. regs->ARM_r0 = stack[0]; /* r0 (argc) */ \
  72. nommu_start_thread(regs); \
  73. })
  74. /* Forward declaration, a strange C thing */
  75. struct task_struct;
  76. /* Free all resources held by a thread. */
  77. extern void release_thread(struct task_struct *);
  78. /* Prepare to copy thread state - unlazy all lazy status */
  79. #define prepare_to_copy(tsk) do { } while (0)
  80. unsigned long get_wchan(struct task_struct *p);
  81. #if __LINUX_ARM_ARCH__ == 6
  82. #define cpu_relax() smp_mb()
  83. #else
  84. #define cpu_relax() barrier()
  85. #endif
  86. /*
  87. * Create a new kernel thread
  88. */
  89. extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
  90. #define task_pt_regs(p) \
  91. ((struct pt_regs *)(THREAD_START_SP + task_stack_page(p)) - 1)
  92. #define KSTK_EIP(tsk) task_pt_regs(tsk)->ARM_pc
  93. #define KSTK_ESP(tsk) task_pt_regs(tsk)->ARM_sp
  94. /*
  95. * Prefetching support - only ARMv5.
  96. */
  97. #if __LINUX_ARM_ARCH__ >= 5
  98. #define ARCH_HAS_PREFETCH
  99. static inline void prefetch(const void *ptr)
  100. {
  101. __asm__ __volatile__(
  102. "pld\t%a0"
  103. :
  104. : "p" (ptr)
  105. : "cc");
  106. }
  107. #define ARCH_HAS_PREFETCHW
  108. #define prefetchw(ptr) prefetch(ptr)
  109. #define ARCH_HAS_SPINLOCK_PREFETCH
  110. #define spin_lock_prefetch(x) do { } while (0)
  111. #endif
  112. #endif
  113. #endif /* __ASM_ARM_PROCESSOR_H */