processor.h 4.8 KB

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