processor.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * Copyright (C) 2013 Altera Corporation
  3. * Copyright (C) 2010 Tobias Klauser <tklauser@distanz.ch>
  4. * Copyright (C) 2004 Microtronix Datacom Ltd
  5. * Copyright (C) 2001 Ken Hill (khill@microtronix.com)
  6. * Vic Phillips (vic@microtronix.com)
  7. *
  8. * based on SPARC asm/processor_32.h which is:
  9. *
  10. * Copyright (C) 1994 David S. Miller
  11. *
  12. * This file is subject to the terms and conditions of the GNU General Public
  13. * License. See the file "COPYING" in the main directory of this archive
  14. * for more details.
  15. */
  16. #ifndef _ASM_NIOS2_PROCESSOR_H
  17. #define _ASM_NIOS2_PROCESSOR_H
  18. #include <asm/ptrace.h>
  19. #include <asm/registers.h>
  20. #include <asm/page.h>
  21. #define NIOS2_FLAG_KTHREAD 0x00000001 /* task is a kernel thread */
  22. #define NIOS2_OP_NOP 0x1883a
  23. #define NIOS2_OP_BREAK 0x3da03a
  24. #ifdef __KERNEL__
  25. #define STACK_TOP TASK_SIZE
  26. #define STACK_TOP_MAX STACK_TOP
  27. #endif /* __KERNEL__ */
  28. /* Kuser helpers is mapped to this user space address */
  29. #define KUSER_BASE 0x1000
  30. #define KUSER_SIZE (PAGE_SIZE)
  31. #ifndef __ASSEMBLY__
  32. /*
  33. * Default implementation of macro that returns current
  34. * instruction pointer ("program counter").
  35. */
  36. #define current_text_addr() ({ __label__ _l; _l: &&_l; })
  37. # define TASK_SIZE 0x7FFF0000UL
  38. # define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
  39. /* The Nios processor specific thread struct. */
  40. struct thread_struct {
  41. struct pt_regs *kregs;
  42. /* Context switch saved kernel state. */
  43. unsigned long ksp;
  44. unsigned long kpsr;
  45. };
  46. #define INIT_MMAP \
  47. { &init_mm, (0), (0), __pgprot(0x0), VM_READ | VM_WRITE | VM_EXEC }
  48. # define INIT_THREAD { \
  49. .kregs = NULL, \
  50. .ksp = 0, \
  51. .kpsr = 0, \
  52. }
  53. extern void start_thread(struct pt_regs *regs, unsigned long pc,
  54. unsigned long sp);
  55. struct task_struct;
  56. /* Free all resources held by a thread. */
  57. static inline void release_thread(struct task_struct *dead_task)
  58. {
  59. }
  60. /* Return saved PC of a blocked thread. */
  61. #define thread_saved_pc(tsk) ((tsk)->thread.kregs->ea)
  62. extern unsigned long get_wchan(struct task_struct *p);
  63. #define task_pt_regs(p) \
  64. ((struct pt_regs *)(THREAD_SIZE + task_stack_page(p)) - 1)
  65. /* Used by procfs */
  66. #define KSTK_EIP(tsk) ((tsk)->thread.kregs->ea)
  67. #define KSTK_ESP(tsk) ((tsk)->thread.kregs->sp)
  68. #define cpu_relax() barrier()
  69. #define cpu_relax_lowlatency() cpu_relax()
  70. #endif /* __ASSEMBLY__ */
  71. #endif /* _ASM_NIOS2_PROCESSOR_H */