processor.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. // Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
  3. #ifndef __ASM_CSKY_PROCESSOR_H
  4. #define __ASM_CSKY_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. #include <linux/bitops.h>
  11. #include <asm/segment.h>
  12. #include <asm/ptrace.h>
  13. #include <asm/current.h>
  14. #include <asm/cache.h>
  15. #include <abi/reg_ops.h>
  16. #include <abi/regdef.h>
  17. #ifdef CONFIG_CPU_HAS_FPU
  18. #include <abi/fpu.h>
  19. #endif
  20. struct cpuinfo_csky {
  21. unsigned long udelay_val;
  22. unsigned long asid_cache;
  23. /*
  24. * Capability and feature descriptor structure for CSKY CPU
  25. */
  26. unsigned long options;
  27. unsigned int processor_id[4];
  28. unsigned int fpu_id;
  29. } __aligned(SMP_CACHE_BYTES);
  30. extern struct cpuinfo_csky cpu_data[];
  31. /*
  32. * User space process size: 2GB. This is hardcoded into a few places,
  33. * so don't change it unless you know what you are doing. TASK_SIZE
  34. * for a 64 bit kernel expandable to 8192EB, of which the current CSKY
  35. * implementations will "only" be able to use 1TB ...
  36. */
  37. #define TASK_SIZE 0x7fff8000UL
  38. #ifdef __KERNEL__
  39. #define STACK_TOP TASK_SIZE
  40. #define STACK_TOP_MAX STACK_TOP
  41. #endif
  42. /* This decides where the kernel will search for a free chunk of vm
  43. * space during mmap's.
  44. */
  45. #define TASK_UNMAPPED_BASE (TASK_SIZE / 3)
  46. struct thread_struct {
  47. unsigned long ksp; /* kernel stack pointer */
  48. unsigned long sr; /* saved status register */
  49. unsigned long esp0; /* points to SR of stack frame */
  50. unsigned long hi;
  51. unsigned long lo;
  52. /* Other stuff associated with the thread. */
  53. unsigned long address; /* Last user fault */
  54. unsigned long error_code;
  55. /* FPU regs */
  56. struct user_fp __aligned(16) user_fp;
  57. };
  58. #define INIT_THREAD { \
  59. .ksp = (unsigned long) init_thread_union.stack + THREAD_SIZE, \
  60. .sr = DEFAULT_PSR_VALUE, \
  61. }
  62. /*
  63. * Do necessary setup to start up a newly executed thread.
  64. *
  65. * pass the data segment into user programs if it exists,
  66. * it can't hurt anything as far as I can tell
  67. */
  68. #define start_thread(_regs, _pc, _usp) \
  69. do { \
  70. set_fs(USER_DS); /* reads from user space */ \
  71. (_regs)->pc = (_pc); \
  72. (_regs)->regs[1] = 0; /* ABIV1 is R7, uClibc_main rtdl arg */ \
  73. (_regs)->regs[2] = 0; \
  74. (_regs)->regs[3] = 0; /* ABIV2 is R7, use it? */ \
  75. (_regs)->sr &= ~PS_S; \
  76. (_regs)->usp = (_usp); \
  77. } while (0)
  78. /* Forward declaration, a strange C thing */
  79. struct task_struct;
  80. /* Free all resources held by a thread. */
  81. static inline void release_thread(struct task_struct *dead_task)
  82. {
  83. }
  84. /* Prepare to copy thread state - unlazy all lazy status */
  85. #define prepare_to_copy(tsk) do { } while (0)
  86. extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
  87. #define copy_segments(tsk, mm) do { } while (0)
  88. #define release_segments(mm) do { } while (0)
  89. #define forget_segments() do { } while (0)
  90. extern unsigned long thread_saved_pc(struct task_struct *tsk);
  91. unsigned long get_wchan(struct task_struct *p);
  92. #define KSTK_EIP(tsk) (task_pt_regs(tsk)->pc)
  93. #define KSTK_ESP(tsk) (task_pt_regs(tsk)->usp)
  94. #define task_pt_regs(p) \
  95. ((struct pt_regs *)(THREAD_SIZE + p->stack) - 1)
  96. #define cpu_relax() barrier()
  97. #endif /* __ASM_CSKY_PROCESSOR_H */