processor.h 3.4 KB

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