processor.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // SPDX-License-Identifier: GPL-2.0
  2. // Copyright (C) 2005-2017 Andes Technology Corporation
  3. #ifndef __ASM_NDS32_PROCESSOR_H
  4. #define __ASM_NDS32_PROCESSOR_H
  5. /*
  6. * Default implementation of macro that returns current
  7. * instruction pointer ("program counter").
  8. */
  9. #define current_text_addr() ({ __label__ _l; _l: &&_l;})
  10. #ifdef __KERNEL__
  11. #include <asm/ptrace.h>
  12. #include <asm/types.h>
  13. #include <asm/sigcontext.h>
  14. #define KERNEL_STACK_SIZE PAGE_SIZE
  15. #define STACK_TOP TASK_SIZE
  16. #define STACK_TOP_MAX TASK_SIZE
  17. struct cpu_context {
  18. unsigned long r6;
  19. unsigned long r7;
  20. unsigned long r8;
  21. unsigned long r9;
  22. unsigned long r10;
  23. unsigned long r11;
  24. unsigned long r12;
  25. unsigned long r13;
  26. unsigned long r14;
  27. unsigned long fp;
  28. unsigned long pc;
  29. unsigned long sp;
  30. };
  31. struct thread_struct {
  32. struct cpu_context cpu_context; /* cpu context */
  33. /* fault info */
  34. unsigned long address;
  35. unsigned long trap_no;
  36. unsigned long error_code;
  37. };
  38. #define INIT_THREAD { }
  39. #ifdef __NDS32_EB__
  40. #define PSW_DE PSW_mskBE
  41. #else
  42. #define PSW_DE 0x0
  43. #endif
  44. #ifdef CONFIG_WBNA
  45. #define PSW_valWBNA PSW_mskWBNA
  46. #else
  47. #define PSW_valWBNA 0x0
  48. #endif
  49. #ifdef CONFIG_HWZOL
  50. #define PSW_valINIT (PSW_CPL_ANY | PSW_mskAEN | PSW_valWBNA | PSW_mskDT | PSW_mskIT | PSW_DE | PSW_mskGIE)
  51. #else
  52. #define PSW_valINIT (PSW_CPL_ANY | PSW_valWBNA | PSW_mskDT | PSW_mskIT | PSW_DE | PSW_mskGIE)
  53. #endif
  54. #define start_thread(regs,pc,stack) \
  55. ({ \
  56. memzero(regs, sizeof(struct pt_regs)); \
  57. forget_syscall(regs); \
  58. regs->ipsw = PSW_valINIT; \
  59. regs->ir0 = (PSW_CPL_ANY | PSW_valWBNA | PSW_mskDT | PSW_mskIT | PSW_DE | PSW_SYSTEM | PSW_INTL_1); \
  60. regs->ipc = pc; \
  61. regs->sp = stack; \
  62. })
  63. /* Forward declaration, a strange C thing */
  64. struct task_struct;
  65. /* Free all resources held by a thread. */
  66. #define release_thread(thread) do { } while(0)
  67. /* Prepare to copy thread state - unlazy all lazy status */
  68. #define prepare_to_copy(tsk) do { } while (0)
  69. unsigned long get_wchan(struct task_struct *p);
  70. #define cpu_relax() barrier()
  71. #define task_pt_regs(task) \
  72. ((struct pt_regs *) (task_stack_page(task) + THREAD_SIZE \
  73. - 8) - 1)
  74. /*
  75. * Create a new kernel thread
  76. */
  77. extern int kernel_thread(int (*fn) (void *), void *arg, unsigned long flags);
  78. #define KSTK_EIP(tsk) instruction_pointer(task_pt_regs(tsk))
  79. #define KSTK_ESP(tsk) user_stack_pointer(task_pt_regs(tsk))
  80. #endif
  81. #endif /* __ASM_NDS32_PROCESSOR_H */