processor.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * Copyright (C) 2013 Altera Corporation
  3. * Copyright (C) 2010 Tobias Klauser <[email protected]>
  4. * Copyright (C) 2004 Microtronix Datacom Ltd
  5. * Copyright (C) 2001 Ken Hill ([email protected])
  6. * Vic Phillips ([email protected])
  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. extern unsigned long __get_wchan(struct task_struct *p);
  52. #define task_pt_regs(p) \
  53. ((struct pt_regs *)(THREAD_SIZE + task_stack_page(p)) - 1)
  54. /* Used by procfs */
  55. #define KSTK_EIP(tsk) ((tsk)->thread.kregs->ea)
  56. #define KSTK_ESP(tsk) ((tsk)->thread.kregs->sp)
  57. #define cpu_relax() barrier()
  58. #endif /* __ASSEMBLY__ */
  59. #endif /* _ASM_NIOS2_PROCESSOR_H */