processor.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2012 Regents of the University of California
  4. */
  5. #ifndef _ASM_RISCV_PROCESSOR_H
  6. #define _ASM_RISCV_PROCESSOR_H
  7. #include <linux/const.h>
  8. #include <vdso/processor.h>
  9. #include <asm/ptrace.h>
  10. /*
  11. * This decides where the kernel will search for a free chunk of vm
  12. * space during mmap's.
  13. */
  14. #define TASK_UNMAPPED_BASE PAGE_ALIGN(TASK_SIZE / 3)
  15. #define STACK_TOP TASK_SIZE
  16. #ifdef CONFIG_64BIT
  17. #define STACK_TOP_MAX TASK_SIZE_64
  18. #else
  19. #define STACK_TOP_MAX STACK_TOP
  20. #endif
  21. #define STACK_ALIGN 16
  22. #ifndef __ASSEMBLY__
  23. struct task_struct;
  24. struct pt_regs;
  25. #ifdef CONFIG_VECTOR_EMU
  26. struct vsetvl_info {
  27. unsigned long last_vector_pc;
  28. unsigned long regid;
  29. unsigned long vl;
  30. unsigned long vtype;
  31. };
  32. #endif
  33. /* CPU-specific state of a task */
  34. struct thread_struct {
  35. /* Callee-saved registers */
  36. unsigned long ra;
  37. unsigned long sp; /* Kernel mode stack */
  38. unsigned long s[12]; /* s[0]: frame pointer */
  39. struct __riscv_d_ext_state fstate;
  40. unsigned long bad_cause;
  41. struct __riscv_v_state vstate;
  42. #ifdef CONFIG_VECTOR_EMU
  43. struct vsetvl_info vsetvl_state;
  44. #endif
  45. };
  46. #define INIT_THREAD { \
  47. .sp = sizeof(init_stack) + (long)&init_stack, \
  48. }
  49. #define task_pt_regs(tsk) \
  50. ((struct pt_regs *)(task_stack_page(tsk) + THREAD_SIZE \
  51. - ALIGN(sizeof(struct pt_regs), STACK_ALIGN)))
  52. #define KSTK_EIP(tsk) (task_pt_regs(tsk)->epc)
  53. #define KSTK_ESP(tsk) (task_pt_regs(tsk)->sp)
  54. /* Do necessary setup to start up a newly executed thread. */
  55. extern void start_thread(struct pt_regs *regs,
  56. unsigned long pc, unsigned long sp);
  57. #ifdef CONFIG_COMPAT
  58. #define DEFAULT_MAP_WINDOW_64 TASK_SIZE_64
  59. #else
  60. #define DEFAULT_MAP_WINDOW_64 TASK_SIZE
  61. #endif
  62. /* Free all resources held by a thread. */
  63. static inline void release_thread(struct task_struct *dead_task)
  64. {
  65. }
  66. extern unsigned long get_wchan(struct task_struct *p);
  67. static inline void wait_for_interrupt(void)
  68. {
  69. __asm__ __volatile__ ("wfi");
  70. }
  71. struct device_node;
  72. int riscv_of_processor_hartid(struct device_node *node);
  73. int riscv_of_parent_hartid(struct device_node *node);
  74. extern void riscv_fill_hwcap(void);
  75. #endif /* __ASSEMBLY__ */
  76. #endif /* _ASM_RISCV_PROCESSOR_H */