processor.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /* $Id: processor.h,v 1.83 2001/10/08 09:32:13 davem Exp $
  2. * include/asm-sparc/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 <linux/a.out.h>
  14. #include <asm/psr.h>
  15. #include <asm/ptrace.h>
  16. #include <asm/head.h>
  17. #include <asm/signal.h>
  18. #include <asm/segment.h>
  19. #include <asm/btfixup.h>
  20. #include <asm/page.h>
  21. /*
  22. * The sparc has no problems with write protection
  23. */
  24. #define wp_works_ok 1
  25. #define wp_works_ok__is_a_macro /* for versions in ksyms.c */
  26. /* Whee, this is STACK_TOP + PAGE_SIZE and the lowest kernel address too...
  27. * That one page is used to protect kernel from intruders, so that
  28. * we can make our access_ok test faster
  29. */
  30. #define TASK_SIZE PAGE_OFFSET
  31. struct task_struct;
  32. #ifdef __KERNEL__
  33. struct fpq {
  34. unsigned long *insn_addr;
  35. unsigned long insn;
  36. };
  37. #endif
  38. typedef struct {
  39. int seg;
  40. } mm_segment_t;
  41. /* The Sparc processor specific thread struct. */
  42. struct thread_struct {
  43. struct pt_regs *kregs;
  44. unsigned int _pad1;
  45. /* Special child fork kpsr/kwim values. */
  46. unsigned long fork_kpsr __attribute__ ((aligned (8)));
  47. unsigned long fork_kwim;
  48. /* Floating point regs */
  49. unsigned long float_regs[32] __attribute__ ((aligned (8)));
  50. unsigned long fsr;
  51. unsigned long fpqdepth;
  52. struct fpq fpqueue[16];
  53. unsigned long flags;
  54. mm_segment_t current_ds;
  55. struct exec core_exec; /* just what it says. */
  56. int new_signal;
  57. };
  58. #define SPARC_FLAG_KTHREAD 0x1 /* task is a kernel thread */
  59. #define SPARC_FLAG_UNALIGNED 0x2 /* is allowed to do unaligned accesses */
  60. #define INIT_THREAD { \
  61. .flags = SPARC_FLAG_KTHREAD, \
  62. .current_ds = KERNEL_DS, \
  63. }
  64. /* Return saved PC of a blocked thread. */
  65. extern unsigned long thread_saved_pc(struct task_struct *t);
  66. /* Do necessary setup to start up a newly executed thread. */
  67. extern __inline__ void start_thread(struct pt_regs * regs, unsigned long pc,
  68. unsigned long sp)
  69. {
  70. register unsigned long zero asm("g1");
  71. regs->psr = (regs->psr & (PSR_CWP)) | PSR_S;
  72. regs->pc = ((pc & (~3)) - 4);
  73. regs->npc = regs->pc + 4;
  74. regs->y = 0;
  75. zero = 0;
  76. __asm__ __volatile__("std\t%%g0, [%0 + %3 + 0x00]\n\t"
  77. "std\t%%g0, [%0 + %3 + 0x08]\n\t"
  78. "std\t%%g0, [%0 + %3 + 0x10]\n\t"
  79. "std\t%%g0, [%0 + %3 + 0x18]\n\t"
  80. "std\t%%g0, [%0 + %3 + 0x20]\n\t"
  81. "std\t%%g0, [%0 + %3 + 0x28]\n\t"
  82. "std\t%%g0, [%0 + %3 + 0x30]\n\t"
  83. "st\t%1, [%0 + %3 + 0x38]\n\t"
  84. "st\t%%g0, [%0 + %3 + 0x3c]"
  85. : /* no outputs */
  86. : "r" (regs),
  87. "r" (sp - sizeof(struct reg_window)),
  88. "r" (zero),
  89. "i" ((const unsigned long)(&((struct pt_regs *)0)->u_regs[0]))
  90. : "memory");
  91. }
  92. /* Free all resources held by a thread. */
  93. #define release_thread(tsk) do { } while(0)
  94. extern pid_t kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
  95. /* Prepare to copy thread state - unlazy all lazy status */
  96. #define prepare_to_copy(tsk) do { } while (0)
  97. extern unsigned long get_wchan(struct task_struct *);
  98. #define KSTK_EIP(tsk) ((tsk)->thread.kregs->pc)
  99. #define KSTK_ESP(tsk) ((tsk)->thread.kregs->u_regs[UREG_FP])
  100. #ifdef __KERNEL__
  101. extern struct task_struct *last_task_used_math;
  102. #define cpu_relax() barrier()
  103. #endif
  104. #endif /* __ASM_SPARC_PROCESSOR_H */