processor.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /*
  2. * Copyright (C) 2008-2009 Michal Simek <monstr@monstr.eu>
  3. * Copyright (C) 2008-2009 PetaLogix
  4. * Copyright (C) 2006 Atmark Techno, Inc.
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file "COPYING" in the main directory of this archive
  8. * for more details.
  9. */
  10. #ifndef _ASM_MICROBLAZE_PROCESSOR_H
  11. #define _ASM_MICROBLAZE_PROCESSOR_H
  12. #include <asm/ptrace.h>
  13. #include <asm/setup.h>
  14. #include <asm/registers.h>
  15. #include <asm/entry.h>
  16. #include <asm/current.h>
  17. # ifndef __ASSEMBLY__
  18. /* from kernel/cpu/mb.c */
  19. extern const struct seq_operations cpuinfo_op;
  20. # define cpu_relax() barrier()
  21. # define cpu_sleep() do {} while (0)
  22. # define prepare_to_copy(tsk) do {} while (0)
  23. #define task_pt_regs(tsk) \
  24. (((struct pt_regs *)(THREAD_SIZE + task_stack_page(tsk))) - 1)
  25. /* Do necessary setup to start up a newly executed thread. */
  26. void start_thread(struct pt_regs *regs, unsigned long pc, unsigned long usp);
  27. # endif /* __ASSEMBLY__ */
  28. # ifndef CONFIG_MMU
  29. /*
  30. * User space process size: memory size
  31. *
  32. * TASK_SIZE on MMU cpu is usually 1GB. However, on no-MMU arch, both
  33. * user processes and the kernel is on the same memory region. They
  34. * both share the memory space and that is limited by the amount of
  35. * physical memory. thus, we set TASK_SIZE == amount of total memory.
  36. */
  37. # define TASK_SIZE (0x81000000 - 0x80000000)
  38. /*
  39. * Default implementation of macro that returns current
  40. * instruction pointer ("program counter").
  41. */
  42. # define current_text_addr() ({ __label__ _l; _l: &&_l; })
  43. /*
  44. * This decides where the kernel will search for a free chunk of vm
  45. * space during mmap's. We won't be using it
  46. */
  47. # define TASK_UNMAPPED_BASE 0
  48. /* definition in include/linux/sched.h */
  49. struct task_struct;
  50. /* thread_struct is gone. use thread_info instead. */
  51. struct thread_struct { };
  52. # define INIT_THREAD { }
  53. /* Free all resources held by a thread. */
  54. static inline void release_thread(struct task_struct *dead_task)
  55. {
  56. }
  57. /* Free all resources held by a thread. */
  58. static inline void exit_thread(void)
  59. {
  60. }
  61. extern unsigned long thread_saved_pc(struct task_struct *t);
  62. extern unsigned long get_wchan(struct task_struct *p);
  63. /*
  64. * create a kernel thread without removing it from tasklists
  65. */
  66. extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
  67. # define KSTK_EIP(tsk) (0)
  68. # define KSTK_ESP(tsk) (0)
  69. # else /* CONFIG_MMU */
  70. /*
  71. * This is used to define STACK_TOP, and with MMU it must be below
  72. * kernel base to select the correct PGD when handling MMU exceptions.
  73. */
  74. # define TASK_SIZE (CONFIG_KERNEL_START)
  75. /*
  76. * This decides where the kernel will search for a free chunk of vm
  77. * space during mmap's.
  78. */
  79. # define TASK_UNMAPPED_BASE (TASK_SIZE / 8 * 3)
  80. # define THREAD_KSP 0
  81. # ifndef __ASSEMBLY__
  82. /*
  83. * Default implementation of macro that returns current
  84. * instruction pointer ("program counter").
  85. */
  86. # define current_text_addr() ({ __label__ _l; _l: &&_l; })
  87. /* If you change this, you must change the associated assembly-languages
  88. * constants defined below, THREAD_*.
  89. */
  90. struct thread_struct {
  91. /* kernel stack pointer (must be first field in structure) */
  92. unsigned long ksp;
  93. unsigned long ksp_limit; /* if ksp <= ksp_limit stack overflow */
  94. void *pgdir; /* root of page-table tree */
  95. struct pt_regs *regs; /* Pointer to saved register state */
  96. };
  97. # define INIT_THREAD { \
  98. .ksp = sizeof init_stack + (unsigned long)init_stack, \
  99. .pgdir = swapper_pg_dir, \
  100. }
  101. /* Do necessary setup to start up a newly executed thread. */
  102. void start_thread(struct pt_regs *regs,
  103. unsigned long pc, unsigned long usp);
  104. /* Free all resources held by a thread. */
  105. extern inline void release_thread(struct task_struct *dead_task)
  106. {
  107. }
  108. extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
  109. /* Free current thread data structures etc. */
  110. static inline void exit_thread(void)
  111. {
  112. }
  113. /* Return saved (kernel) PC of a blocked thread. */
  114. # define thread_saved_pc(tsk) \
  115. ((tsk)->thread.regs ? (tsk)->thread.regs->r15 : 0)
  116. unsigned long get_wchan(struct task_struct *p);
  117. /* The size allocated for kernel stacks. This _must_ be a power of two! */
  118. # define KERNEL_STACK_SIZE 0x2000
  119. /* Return some info about the user process TASK. */
  120. # define task_tos(task) ((unsigned long)(task) + KERNEL_STACK_SIZE)
  121. # define task_regs(task) ((struct pt_regs *)task_tos(task) - 1)
  122. # define task_pt_regs_plus_args(tsk) \
  123. ((void *)task_pt_regs(tsk))
  124. # define task_sp(task) (task_regs(task)->r1)
  125. # define task_pc(task) (task_regs(task)->pc)
  126. /* Grotty old names for some. */
  127. # define KSTK_EIP(task) (task_pc(task))
  128. # define KSTK_ESP(task) (task_sp(task))
  129. /* FIXME */
  130. # define deactivate_mm(tsk, mm) do { } while (0)
  131. # define STACK_TOP TASK_SIZE
  132. # define STACK_TOP_MAX STACK_TOP
  133. # endif /* __ASSEMBLY__ */
  134. # endif /* CONFIG_MMU */
  135. #endif /* _ASM_MICROBLAZE_PROCESSOR_H */