processor.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /*
  2. * U-boot - processor.h
  3. *
  4. * Copyright (c) 2005-2007 Analog Devices Inc.
  5. *
  6. * This file is based on
  7. * include/asm-m68k/processor.h
  8. * Changes made by Akbar Hussain Lineo, Inc, May 2001 for BLACKFIN
  9. * Copyright (C) 1995 Hamish Macdonald
  10. *
  11. * See file CREDITS for list of people who contributed to this
  12. * project.
  13. *
  14. * This program is free software; you can redistribute it and/or
  15. * modify it under the terms of the GNU General Public License as
  16. * published by the Free Software Foundation; either version 2 of
  17. * the License, or (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
  27. * MA 02110-1301 USA
  28. */
  29. #ifndef __ASM_BLACKFIN_PROCESSOR_H
  30. #define __ASM_BLACKFIN_PROCESSOR_H
  31. /*
  32. * Default implementation of macro that returns current
  33. * instruction pointer ("program counter").
  34. */
  35. #define current_text_addr() ({ __label__ _l; _l: &&_l;})
  36. #include <linux/config.h>
  37. #include <asm/segment.h>
  38. #include <asm/ptrace.h>
  39. #include <asm/current.h>
  40. extern inline unsigned long rdusp(void)
  41. {
  42. unsigned long usp;
  43. __asm__ __volatile__("%0 = usp;\n\t":"=da"(usp));
  44. return usp;
  45. }
  46. extern inline void wrusp(unsigned long usp)
  47. {
  48. __asm__ __volatile__("usp = %0;\n\t"::"da"(usp));
  49. }
  50. /*
  51. * User space process size: 3.75GB. This is hardcoded into a few places,
  52. * so don't change it unless you know what you are doing.
  53. */
  54. #define TASK_SIZE (0xF0000000UL)
  55. /*
  56. * Bus types
  57. */
  58. #define EISA_bus 0
  59. #define MCA_bus 0
  60. /* There is no pc register avaliable for BLACKFIN, so we are going to get
  61. * it indirectly
  62. */
  63. #if 0
  64. inline unsigned long obtain_pc_indirectly(void)
  65. {
  66. unsigned long pc;
  67. __asm__ __volatile__("%0 = rets;\n":"=d"(pc));
  68. return (pc - 4); /* call pcrel24 is 4 bytes long */
  69. }
  70. #endif
  71. /*
  72. * if you change this structure, you must change the code and offsets
  73. * in m68k/machasm.S
  74. */
  75. struct thread_struct {
  76. unsigned long ksp; /* kernel stack pointer */
  77. unsigned long usp; /* user stack pointer */
  78. unsigned short seqstat; /* saved status register */
  79. unsigned long esp0; /* points to SR of stack frame pt_regs */
  80. unsigned long pc; /* instruction pointer */
  81. };
  82. #define INIT_MMAP { &init_mm, 0, 0x40000000, NULL, __pgprot(_PAGE_PRESENT|_PAGE_ACCESSED), VM_READ | VM_WRITE | VM_EXEC, 1, NULL, NULL }
  83. #define INIT_THREAD { \
  84. sizeof(init_stack) + (unsigned long) init_stack, 0, \
  85. PS_S, 0\
  86. }
  87. /*
  88. * Do necessary setup to start up a newly executed thread.
  89. *
  90. * pass the data segment into user programs if it exists,
  91. * it can't hurt anything as far as I can tell
  92. */
  93. #define start_thread(_regs, _pc, _usp) \
  94. do { \
  95. set_fs(USER_DS); /* reads from user space */ \
  96. (_regs)->pc = (_pc); \
  97. if (current->mm) \
  98. (_regs)->r5 = current->mm->start_data; \
  99. (_regs)->seqstat &= ~0x0c00; \
  100. wrusp(_usp); \
  101. /* Adde by HuTao, May 26, 2003 3:39PM */\
  102. if ((_regs)->ipend & 0x8000) /* check whether system in supper mode - StChen */\
  103. (_regs)->ipend = 0x0;\
  104. } while(0)
  105. /* Forward declaration, a strange C thing */
  106. struct task_struct;
  107. /* Free all resources held by a thread. */
  108. static inline void release_thread(struct task_struct *dead_task)
  109. {
  110. }
  111. extern int kernel_thread(int (*fn) (void *), void *arg, unsigned long flags);
  112. #define copy_segments(tsk, mm) do { } while (0)
  113. #define release_segments(mm) do { } while (0)
  114. #define forget_segments() do { } while (0)
  115. /*
  116. * Free current thread data structures etc..
  117. */
  118. static inline void exit_thread(void)
  119. {
  120. }
  121. /*
  122. * Return saved PC of a blocked thread.
  123. */
  124. extern inline unsigned long thread_saved_pc(struct thread_struct *t)
  125. {
  126. extern void scheduling_functions_start_here(void);
  127. extern void scheduling_functions_end_here(void);
  128. return 0;
  129. }
  130. unsigned long get_wchan(struct task_struct *p);
  131. #define KSTK_EIP(tsk) \
  132. ({ \
  133. unsigned long eip = 0; \
  134. if ((tsk)->thread.esp0 > PAGE_SIZE && \
  135. MAP_NR((tsk)->thread.esp0) < max_mapnr) \
  136. eip = ((struct pt_regs *) (tsk)->thread.esp0)->pc; \
  137. eip; })
  138. #define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->thread.usp)
  139. #define THREAD_SIZE (2*PAGE_SIZE)
  140. /* Allocation and freeing of basic task resources. */
  141. #define alloc_task_struct() \
  142. ((struct task_struct *) __get_free_pages(GFP_KERNEL,1))
  143. #define free_task_struct(p) free_pages((unsigned long)(p),1)
  144. #define get_task_struct(tsk) atomic_inc(&mem_map[MAP_NR(tsk)].count)
  145. #define init_task (init_task_union.task)
  146. #define init_stack (init_task_union.stack)
  147. #endif