processor.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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_relax_lowlatency() cpu_relax()
  22. #define task_pt_regs(tsk) \
  23. (((struct pt_regs *)(THREAD_SIZE + task_stack_page(tsk))) - 1)
  24. /* Do necessary setup to start up a newly executed thread. */
  25. void start_thread(struct pt_regs *regs, unsigned long pc, unsigned long usp);
  26. extern void ret_from_fork(void);
  27. extern void ret_from_kernel_thread(void);
  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. # define KSTK_EIP(tsk) (0)
  65. # define KSTK_ESP(tsk) (0)
  66. # else /* CONFIG_MMU */
  67. /*
  68. * This is used to define STACK_TOP, and with MMU it must be below
  69. * kernel base to select the correct PGD when handling MMU exceptions.
  70. */
  71. # define TASK_SIZE (CONFIG_KERNEL_START)
  72. /*
  73. * This decides where the kernel will search for a free chunk of vm
  74. * space during mmap's.
  75. */
  76. # define TASK_UNMAPPED_BASE (TASK_SIZE / 8 * 3)
  77. # define THREAD_KSP 0
  78. # ifndef __ASSEMBLY__
  79. /*
  80. * Default implementation of macro that returns current
  81. * instruction pointer ("program counter").
  82. */
  83. # define current_text_addr() ({ __label__ _l; _l: &&_l; })
  84. /* If you change this, you must change the associated assembly-languages
  85. * constants defined below, THREAD_*.
  86. */
  87. struct thread_struct {
  88. /* kernel stack pointer (must be first field in structure) */
  89. unsigned long ksp;
  90. unsigned long ksp_limit; /* if ksp <= ksp_limit stack overflow */
  91. void *pgdir; /* root of page-table tree */
  92. struct pt_regs *regs; /* Pointer to saved register state */
  93. };
  94. # define INIT_THREAD { \
  95. .ksp = sizeof init_stack + (unsigned long)init_stack, \
  96. .pgdir = swapper_pg_dir, \
  97. }
  98. /* Free all resources held by a thread. */
  99. static inline void release_thread(struct task_struct *dead_task)
  100. {
  101. }
  102. /* Free current thread data structures etc. */
  103. static inline void exit_thread(void)
  104. {
  105. }
  106. /* Return saved (kernel) PC of a blocked thread. */
  107. # define thread_saved_pc(tsk) \
  108. ((tsk)->thread.regs ? (tsk)->thread.regs->r15 : 0)
  109. unsigned long get_wchan(struct task_struct *p);
  110. /* The size allocated for kernel stacks. This _must_ be a power of two! */
  111. # define KERNEL_STACK_SIZE 0x2000
  112. /* Return some info about the user process TASK. */
  113. # define task_tos(task) ((unsigned long)(task) + KERNEL_STACK_SIZE)
  114. # define task_regs(task) ((struct pt_regs *)task_tos(task) - 1)
  115. # define task_pt_regs_plus_args(tsk) \
  116. ((void *)task_pt_regs(tsk))
  117. # define task_sp(task) (task_regs(task)->r1)
  118. # define task_pc(task) (task_regs(task)->pc)
  119. /* Grotty old names for some. */
  120. # define KSTK_EIP(task) (task_pc(task))
  121. # define KSTK_ESP(task) (task_sp(task))
  122. /* FIXME */
  123. # define deactivate_mm(tsk, mm) do { } while (0)
  124. # define STACK_TOP TASK_SIZE
  125. # define STACK_TOP_MAX STACK_TOP
  126. #ifdef CONFIG_DEBUG_FS
  127. extern struct dentry *of_debugfs_root;
  128. #endif
  129. # endif /* __ASSEMBLY__ */
  130. # endif /* CONFIG_MMU */
  131. #endif /* _ASM_MICROBLAZE_PROCESSOR_H */