processor.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __ASM_CSKY_PROCESSOR_H
  3. #define __ASM_CSKY_PROCESSOR_H
  4. #include <linux/bitops.h>
  5. #include <linux/cache.h>
  6. #include <asm/ptrace.h>
  7. #include <asm/current.h>
  8. #include <abi/reg_ops.h>
  9. #include <abi/regdef.h>
  10. #include <abi/switch_context.h>
  11. #ifdef CONFIG_CPU_HAS_FPU
  12. #include <abi/fpu.h>
  13. #endif
  14. struct cpuinfo_csky {
  15. unsigned long asid_cache;
  16. } __aligned(SMP_CACHE_BYTES);
  17. extern struct cpuinfo_csky cpu_data[];
  18. /*
  19. * User space process size: 2GB. This is hardcoded into a few places,
  20. * so don't change it unless you know what you are doing. TASK_SIZE
  21. * for a 64 bit kernel expandable to 8192EB, of which the current CSKY
  22. * implementations will "only" be able to use 1TB ...
  23. */
  24. #define TASK_SIZE (PAGE_OFFSET - (PAGE_SIZE * 8))
  25. #ifdef __KERNEL__
  26. #define STACK_TOP TASK_SIZE
  27. #define STACK_TOP_MAX STACK_TOP
  28. #endif
  29. /* This decides where the kernel will search for a free chunk of vm
  30. * space during mmap's.
  31. */
  32. #define TASK_UNMAPPED_BASE (TASK_SIZE / 3)
  33. struct thread_struct {
  34. unsigned long sp; /* kernel stack pointer */
  35. unsigned long trap_no; /* saved status register */
  36. /* FPU regs */
  37. struct user_fp __aligned(16) user_fp;
  38. };
  39. #define INIT_THREAD { \
  40. .sp = sizeof(init_stack) + (unsigned long) &init_stack, \
  41. }
  42. /*
  43. * Do necessary setup to start up a newly executed thread.
  44. *
  45. * pass the data segment into user programs if it exists,
  46. * it can't hurt anything as far as I can tell
  47. */
  48. #define start_thread(_regs, _pc, _usp) \
  49. do { \
  50. (_regs)->pc = (_pc); \
  51. (_regs)->regs[1] = 0; /* ABIV1 is R7, uClibc_main rtdl arg */ \
  52. (_regs)->regs[2] = 0; \
  53. (_regs)->regs[3] = 0; /* ABIV2 is R7, use it? */ \
  54. (_regs)->sr &= ~PS_S; \
  55. (_regs)->usp = (_usp); \
  56. } while (0)
  57. /* Forward declaration, a strange C thing */
  58. struct task_struct;
  59. /* Prepare to copy thread state - unlazy all lazy status */
  60. #define prepare_to_copy(tsk) do { } while (0)
  61. extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
  62. unsigned long __get_wchan(struct task_struct *p);
  63. #define KSTK_EIP(tsk) (task_pt_regs(tsk)->pc)
  64. #define KSTK_ESP(tsk) (task_pt_regs(tsk)->usp)
  65. #define task_pt_regs(p) \
  66. ((struct pt_regs *)(THREAD_SIZE + task_stack_page(p)) - 1)
  67. #define cpu_relax() barrier()
  68. #endif /* __ASM_CSKY_PROCESSOR_H */