processor.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. # define TASK_SIZE 0x7FFF0000UL
  33. # define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
  34. /* The Nios processor specific thread struct. */
  35. struct thread_struct {
  36. struct pt_regs *kregs;
  37. /* Context switch saved kernel state. */
  38. unsigned long ksp;
  39. unsigned long kpsr;
  40. };
  41. #define INIT_MMAP \
  42. { &init_mm, (0), (0), __pgprot(0x0), VM_READ | VM_WRITE | VM_EXEC }
  43. # define INIT_THREAD { \
  44. .kregs = NULL, \
  45. .ksp = 0, \
  46. .kpsr = 0, \
  47. }
  48. extern void start_thread(struct pt_regs *regs, unsigned long pc,
  49. unsigned long sp);
  50. struct task_struct;
  51. /* Free all resources held by a thread. */
  52. static inline void release_thread(struct task_struct *dead_task)
  53. {
  54. }
  55. extern unsigned long get_wchan(struct task_struct *p);
  56. #define task_pt_regs(p) \
  57. ((struct pt_regs *)(THREAD_SIZE + task_stack_page(p)) - 1)
  58. /* Used by procfs */
  59. #define KSTK_EIP(tsk) ((tsk)->thread.kregs->ea)
  60. #define KSTK_ESP(tsk) ((tsk)->thread.kregs->sp)
  61. #define cpu_relax() barrier()
  62. #endif /* __ASSEMBLY__ */
  63. #endif /* _ASM_NIOS2_PROCESSOR_H */