processor.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * linux/include/asm-arm/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/ptrace.h>
  19. #include <asm/procinfo.h>
  20. #include <asm/types.h>
  21. union debug_insn {
  22. u32 arm;
  23. u16 thumb;
  24. };
  25. struct debug_entry {
  26. u32 address;
  27. union debug_insn insn;
  28. };
  29. struct debug_info {
  30. int nsaved;
  31. struct debug_entry bp[2];
  32. };
  33. struct thread_struct {
  34. /* fault info */
  35. unsigned long address;
  36. unsigned long trap_no;
  37. unsigned long error_code;
  38. /* debugging */
  39. struct debug_info debug;
  40. };
  41. #define INIT_THREAD { }
  42. #define start_thread(regs,pc,sp) \
  43. ({ \
  44. unsigned long *stack = (unsigned long *)sp; \
  45. set_fs(USER_DS); \
  46. memzero(regs->uregs, sizeof(regs->uregs)); \
  47. if (current->personality & ADDR_LIMIT_32BIT) \
  48. regs->ARM_cpsr = USR_MODE; \
  49. else \
  50. regs->ARM_cpsr = USR26_MODE; \
  51. if (elf_hwcap & HWCAP_THUMB && pc & 1) \
  52. regs->ARM_cpsr |= PSR_T_BIT; \
  53. regs->ARM_pc = pc & ~1; /* pc */ \
  54. regs->ARM_sp = sp; /* sp */ \
  55. regs->ARM_r2 = stack[2]; /* r2 (envp) */ \
  56. regs->ARM_r1 = stack[1]; /* r1 (argv) */ \
  57. regs->ARM_r0 = stack[0]; /* r0 (argc) */ \
  58. })
  59. /* Forward declaration, a strange C thing */
  60. struct task_struct;
  61. /* Free all resources held by a thread. */
  62. extern void release_thread(struct task_struct *);
  63. /* Prepare to copy thread state - unlazy all lazy status */
  64. #define prepare_to_copy(tsk) do { } while (0)
  65. unsigned long get_wchan(struct task_struct *p);
  66. #define cpu_relax() barrier()
  67. /*
  68. * Create a new kernel thread
  69. */
  70. extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
  71. #define KSTK_REGS(tsk) (((struct pt_regs *)(THREAD_START_SP + (unsigned long)(tsk)->thread_info)) - 1)
  72. #define KSTK_EIP(tsk) KSTK_REGS(tsk)->ARM_pc
  73. #define KSTK_ESP(tsk) KSTK_REGS(tsk)->ARM_sp
  74. /*
  75. * Prefetching support - only ARMv5.
  76. */
  77. #if __LINUX_ARM_ARCH__ >= 5
  78. #define ARCH_HAS_PREFETCH
  79. #define prefetch(ptr) \
  80. ({ \
  81. __asm__ __volatile__( \
  82. "pld\t%0" \
  83. : \
  84. : "o" (*(char *)(ptr)) \
  85. : "cc"); \
  86. })
  87. #define ARCH_HAS_PREFETCHW
  88. #define prefetchw(ptr) prefetch(ptr)
  89. #define ARCH_HAS_SPINLOCK_PREFETCH
  90. #define spin_lock_prefetch(x) do { } while (0)
  91. #endif
  92. #endif
  93. #endif /* __ASM_ARM_PROCESSOR_H */