processor.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 1994 Waldorf GMBH
  4. * Copyright (C) 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2003 Ralf Baechle
  5. * Copyright (C) 1996 Paul M. Antoine
  6. * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
  7. */
  8. #ifndef _ASM_PROCESSOR_H
  9. #define _ASM_PROCESSOR_H
  10. #include <asm/isadep.h>
  11. #include <asm/cachectl.h>
  12. #include <asm/mipsregs.h>
  13. #include <asm/reg.h>
  14. #include <asm/system.h>
  15. /*
  16. * Return current * instruction pointer ("program counter").
  17. */
  18. #define current_text_addr() ({ __label__ _l; _l: &&_l;})
  19. /*
  20. * System setup and hardware flags..
  21. */
  22. extern void (*cpu_wait)(void);
  23. extern unsigned int vced_count, vcei_count;
  24. #define NUM_FPU_REGS 32
  25. typedef __u64 fpureg_t;
  26. /*
  27. * It would be nice to add some more fields for emulator statistics, but there
  28. * are a number of fixed offsets in offset.h and elsewhere that would have to
  29. * be recalculated by hand. So the additional information will be private to
  30. * the FPU emulator for now. See asm-mips/fpu_emulator.h.
  31. */
  32. struct mips_fpu_struct {
  33. fpureg_t fpr[NUM_FPU_REGS];
  34. unsigned int fcr31;
  35. };
  36. #define NUM_DSP_REGS 6
  37. typedef __u32 dspreg_t;
  38. struct mips_dsp_state {
  39. dspreg_t dspr[NUM_DSP_REGS];
  40. unsigned int dspcontrol;
  41. };
  42. typedef struct {
  43. unsigned long seg;
  44. } mm_segment_t;
  45. #define ARCH_MIN_TASKALIGN 8
  46. struct mips_abi;
  47. /*
  48. * If you change thread_struct remember to change the #defines below too!
  49. */
  50. struct thread_struct {
  51. /* Saved main processor registers. */
  52. unsigned long reg16;
  53. unsigned long reg17, reg18, reg19, reg20, reg21, reg22, reg23;
  54. unsigned long reg29, reg30, reg31;
  55. /* Saved cp0 stuff. */
  56. unsigned long cp0_status;
  57. /* Saved fpu/fpu emulator stuff. */
  58. struct mips_fpu_struct fpu;
  59. #ifdef CONFIG_MIPS_MT_FPAFF
  60. /* Emulated instruction count */
  61. unsigned long emulated_fp;
  62. /* Saved per-thread scheduler affinity mask */
  63. cpumask_t user_cpus_allowed;
  64. #endif /* CONFIG_MIPS_MT_FPAFF */
  65. /* Saved state of the DSP ASE, if available. */
  66. struct mips_dsp_state dsp;
  67. /* Other stuff associated with the thread. */
  68. unsigned long cp0_badvaddr; /* Last user fault */
  69. unsigned long cp0_baduaddr; /* Last kernel fault accessing USEG */
  70. unsigned long error_code;
  71. unsigned long trap_no;
  72. unsigned long irix_trampoline; /* Wheee... */
  73. unsigned long irix_oldctx;
  74. struct mips_abi *abi;
  75. };
  76. struct task_struct;
  77. /* Free all resources held by a thread. */
  78. #define release_thread(thread) do { } while(0)
  79. /* Prepare to copy thread state - unlazy all lazy status */
  80. #define prepare_to_copy(tsk) do { } while (0)
  81. #define cpu_relax() barrier()
  82. /*
  83. * Return_address is a replacement for __builtin_return_address(count)
  84. * which on certain architectures cannot reasonably be implemented in GCC
  85. * (MIPS, Alpha) or is unuseable with -fomit-frame-pointer (i386).
  86. * Note that __builtin_return_address(x>=1) is forbidden because GCC
  87. * aborts compilation on some CPUs. It's simply not possible to unwind
  88. * some CPU's stackframes.
  89. *
  90. * __builtin_return_address works only for non-leaf functions. We avoid the
  91. * overhead of a function call by forcing the compiler to save the return
  92. * address register on the stack.
  93. */
  94. #define return_address() ({__asm__ __volatile__("":::"$31");__builtin_return_address(0);})
  95. #ifdef CONFIG_CPU_HAS_PREFETCH
  96. #define ARCH_HAS_PREFETCH
  97. static inline void prefetch(const void *addr)
  98. {
  99. __asm__ __volatile__(
  100. " .set mips4 \n"
  101. " pref %0, (%1) \n"
  102. " .set mips0 \n"
  103. :
  104. : "i" (Pref_Load), "r" (addr));
  105. }
  106. #endif
  107. #endif /* _ASM_PROCESSOR_H */