processor.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * Process/processor support for the Hexagon architecture
  3. *
  4. * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
  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 and
  8. * only version 2 as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  18. * 02110-1301, USA.
  19. */
  20. #ifndef _ASM_PROCESSOR_H
  21. #define _ASM_PROCESSOR_H
  22. #ifndef __ASSEMBLY__
  23. #include <asm/mem-layout.h>
  24. #include <asm/registers.h>
  25. #include <asm/hexagon_vm.h>
  26. /* must be a macro */
  27. #define current_text_addr() ({ __label__ _l; _l: &&_l; })
  28. /* task_struct, defined elsewhere, is the "process descriptor" */
  29. struct task_struct;
  30. /* this is defined in arch/process.c */
  31. extern pid_t kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
  32. extern unsigned long thread_saved_pc(struct task_struct *tsk);
  33. extern void start_thread(struct pt_regs *, unsigned long, unsigned long);
  34. /*
  35. * thread_struct is supposed to be for context switch data.
  36. * Specifically, to hold the state necessary to perform switch_to...
  37. */
  38. struct thread_struct {
  39. void *switch_sp;
  40. };
  41. /*
  42. * initializes thread_struct
  43. * The only thing we have in there is switch_sp
  44. * which doesn't really need to be initialized.
  45. */
  46. #define INIT_THREAD { \
  47. }
  48. #define cpu_relax() __vmyield()
  49. /*
  50. * "Unlazying all lazy status" occurs here.
  51. */
  52. static inline void prepare_to_copy(struct task_struct *tsk)
  53. {
  54. }
  55. /*
  56. * Decides where the kernel will search for a free chunk of vm space during
  57. * mmaps.
  58. * See also arch_get_unmapped_area.
  59. * Doesn't affect if you have MAX_FIXED in the page flags set though...
  60. *
  61. * Apparently the convention is that ld.so will ask for "unmapped" private
  62. * memory to be allocated SOMEWHERE, but it also asks for memory explicitly
  63. * via MAP_FIXED at the lower * addresses starting at VA=0x0.
  64. *
  65. * If the two requests collide, you get authentic segfaulting action, so
  66. * you have to kick the "unmapped" base requests higher up.
  67. */
  68. #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE/3))
  69. #define task_pt_regs(task) \
  70. ((struct pt_regs *)(task_stack_page(task) + THREAD_SIZE) - 1)
  71. #define KSTK_EIP(tsk) (pt_elr(task_pt_regs(tsk)))
  72. #define KSTK_ESP(tsk) (pt_psp(task_pt_regs(tsk)))
  73. /* Free all resources held by a thread; defined in process.c */
  74. extern void release_thread(struct task_struct *dead_task);
  75. /* Get wait channel for task P. */
  76. extern unsigned long get_wchan(struct task_struct *p);
  77. /* The following stuff is pretty HEXAGON specific. */
  78. /* This is really just here for __switch_to.
  79. Offsets are pulled via asm-offsets.c */
  80. /*
  81. * No real reason why VM and native switch stacks should be different.
  82. * Ultimately this should merge. Note that Rev C. ABI called out only
  83. * R24-27 as callee saved GPRs needing explicit attention (R29-31 being
  84. * dealt with automagically by allocframe), but the current ABI has
  85. * more, R16-R27. By saving more, the worst case is that we waste some
  86. * cycles if building with the old compilers.
  87. */
  88. struct hexagon_switch_stack {
  89. unsigned long long r1716;
  90. unsigned long long r1918;
  91. unsigned long long r2120;
  92. unsigned long long r2322;
  93. unsigned long long r2524;
  94. unsigned long long r2726;
  95. unsigned long fp;
  96. unsigned long lr;
  97. };
  98. #endif /* !__ASSEMBLY__ */
  99. #endif