processor_32.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* include/asm/processor.h
  3. *
  4. * Copyright (C) 1994 David S. Miller (davem@caip.rutgers.edu)
  5. */
  6. #ifndef __ASM_SPARC_PROCESSOR_H
  7. #define __ASM_SPARC_PROCESSOR_H
  8. /*
  9. * Sparc32 implementation of macro that returns current
  10. * instruction pointer ("program counter").
  11. */
  12. #define current_text_addr() ({ void *pc; __asm__("sethi %%hi(1f), %0; or %0, %%lo(1f), %0;\n1:" : "=r" (pc)); pc; })
  13. #include <asm/psr.h>
  14. #include <asm/ptrace.h>
  15. #include <asm/head.h>
  16. #include <asm/signal.h>
  17. #include <asm/page.h>
  18. /* Whee, this is STACK_TOP + PAGE_SIZE and the lowest kernel address too...
  19. * That one page is used to protect kernel from intruders, so that
  20. * we can make our access_ok test faster
  21. */
  22. #define TASK_SIZE PAGE_OFFSET
  23. #ifdef __KERNEL__
  24. #define STACK_TOP (PAGE_OFFSET - PAGE_SIZE)
  25. #define STACK_TOP_MAX STACK_TOP
  26. #endif /* __KERNEL__ */
  27. struct task_struct;
  28. #ifdef __KERNEL__
  29. struct fpq {
  30. unsigned long *insn_addr;
  31. unsigned long insn;
  32. };
  33. #endif
  34. typedef struct {
  35. int seg;
  36. } mm_segment_t;
  37. /* The Sparc processor specific thread struct. */
  38. struct thread_struct {
  39. struct pt_regs *kregs;
  40. unsigned int _pad1;
  41. /* Special child fork kpsr/kwim values. */
  42. unsigned long fork_kpsr __attribute__ ((aligned (8)));
  43. unsigned long fork_kwim;
  44. /* Floating point regs */
  45. unsigned long float_regs[32] __attribute__ ((aligned (8)));
  46. unsigned long fsr;
  47. unsigned long fpqdepth;
  48. struct fpq fpqueue[16];
  49. unsigned long flags;
  50. mm_segment_t current_ds;
  51. };
  52. #define SPARC_FLAG_KTHREAD 0x1 /* task is a kernel thread */
  53. #define SPARC_FLAG_UNALIGNED 0x2 /* is allowed to do unaligned accesses */
  54. #define INIT_THREAD { \
  55. .flags = SPARC_FLAG_KTHREAD, \
  56. .current_ds = KERNEL_DS, \
  57. }
  58. /* Do necessary setup to start up a newly executed thread. */
  59. static inline void start_thread(struct pt_regs * regs, unsigned long pc,
  60. unsigned long sp)
  61. {
  62. register unsigned long zero asm("g1");
  63. regs->psr = (regs->psr & (PSR_CWP)) | PSR_S;
  64. regs->pc = ((pc & (~3)) - 4);
  65. regs->npc = regs->pc + 4;
  66. regs->y = 0;
  67. zero = 0;
  68. __asm__ __volatile__("std\t%%g0, [%0 + %3 + 0x00]\n\t"
  69. "std\t%%g0, [%0 + %3 + 0x08]\n\t"
  70. "std\t%%g0, [%0 + %3 + 0x10]\n\t"
  71. "std\t%%g0, [%0 + %3 + 0x18]\n\t"
  72. "std\t%%g0, [%0 + %3 + 0x20]\n\t"
  73. "std\t%%g0, [%0 + %3 + 0x28]\n\t"
  74. "std\t%%g0, [%0 + %3 + 0x30]\n\t"
  75. "st\t%1, [%0 + %3 + 0x38]\n\t"
  76. "st\t%%g0, [%0 + %3 + 0x3c]"
  77. : /* no outputs */
  78. : "r" (regs),
  79. "r" (sp - sizeof(struct reg_window32)),
  80. "r" (zero),
  81. "i" ((const unsigned long)(&((struct pt_regs *)0)->u_regs[0]))
  82. : "memory");
  83. }
  84. /* Free all resources held by a thread. */
  85. #define release_thread(tsk) do { } while(0)
  86. unsigned long get_wchan(struct task_struct *);
  87. #define task_pt_regs(tsk) ((tsk)->thread.kregs)
  88. #define KSTK_EIP(tsk) ((tsk)->thread.kregs->pc)
  89. #define KSTK_ESP(tsk) ((tsk)->thread.kregs->u_regs[UREG_FP])
  90. #ifdef __KERNEL__
  91. extern struct task_struct *last_task_used_math;
  92. int do_mathemu(struct pt_regs *regs, struct task_struct *fpt);
  93. #define cpu_relax() barrier()
  94. extern void (*sparc_idle)(void);
  95. #endif
  96. #endif /* __ASM_SPARC_PROCESSOR_H */