coprocessor.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /*
  2. * include/asm-xtensa/coprocessor.h
  3. *
  4. * This file is subject to the terms and conditions of the GNU General Public
  5. * License. See the file "COPYING" in the main directory of this archive
  6. * for more details.
  7. *
  8. * Copyright (C) 2003 - 2007 Tensilica Inc.
  9. */
  10. #ifndef _XTENSA_COPROCESSOR_H
  11. #define _XTENSA_COPROCESSOR_H
  12. #include <variant/tie.h>
  13. #include <asm/core.h>
  14. #include <asm/types.h>
  15. #ifdef __ASSEMBLY__
  16. # include <variant/tie-asm.h>
  17. .macro xchal_sa_start a b
  18. .set .Lxchal_pofs_, 0
  19. .set .Lxchal_ofs_, 0
  20. .endm
  21. .macro xchal_sa_align ptr minofs maxofs ofsalign totalign
  22. .set .Lxchal_ofs_, .Lxchal_ofs_ + .Lxchal_pofs_ + \totalign - 1
  23. .set .Lxchal_ofs_, (.Lxchal_ofs_ & -\totalign) - .Lxchal_pofs_
  24. .endm
  25. #define _SELECT ( XTHAL_SAS_TIE | XTHAL_SAS_OPT \
  26. | XTHAL_SAS_CC \
  27. | XTHAL_SAS_CALR | XTHAL_SAS_CALE )
  28. .macro save_xtregs_opt ptr clb at1 at2 at3 at4 offset
  29. .if XTREGS_OPT_SIZE > 0
  30. addi \clb, \ptr, \offset
  31. xchal_ncp_store \clb \at1 \at2 \at3 \at4 select=_SELECT
  32. .endif
  33. .endm
  34. .macro load_xtregs_opt ptr clb at1 at2 at3 at4 offset
  35. .if XTREGS_OPT_SIZE > 0
  36. addi \clb, \ptr, \offset
  37. xchal_ncp_load \clb \at1 \at2 \at3 \at4 select=_SELECT
  38. .endif
  39. .endm
  40. #undef _SELECT
  41. #define _SELECT ( XTHAL_SAS_TIE | XTHAL_SAS_OPT \
  42. | XTHAL_SAS_NOCC \
  43. | XTHAL_SAS_CALR | XTHAL_SAS_CALE | XTHAL_SAS_GLOB )
  44. .macro save_xtregs_user ptr clb at1 at2 at3 at4 offset
  45. .if XTREGS_USER_SIZE > 0
  46. addi \clb, \ptr, \offset
  47. xchal_ncp_store \clb \at1 \at2 \at3 \at4 select=_SELECT
  48. .endif
  49. .endm
  50. .macro load_xtregs_user ptr clb at1 at2 at3 at4 offset
  51. .if XTREGS_USER_SIZE > 0
  52. addi \clb, \ptr, \offset
  53. xchal_ncp_load \clb \at1 \at2 \at3 \at4 select=_SELECT
  54. .endif
  55. .endm
  56. #undef _SELECT
  57. #endif /* __ASSEMBLY__ */
  58. /*
  59. * XTENSA_HAVE_COPROCESSOR(x) returns 1 if coprocessor x is configured.
  60. *
  61. * XTENSA_HAVE_IO_PORT(x) returns 1 if io-port x is configured.
  62. *
  63. */
  64. #define XTENSA_HAVE_COPROCESSOR(x) \
  65. ((XCHAL_CP_MASK ^ XCHAL_CP_PORT_MASK) & (1 << (x)))
  66. #define XTENSA_HAVE_COPROCESSORS \
  67. (XCHAL_CP_MASK ^ XCHAL_CP_PORT_MASK)
  68. #define XTENSA_HAVE_IO_PORT(x) \
  69. (XCHAL_CP_PORT_MASK & (1 << (x)))
  70. #define XTENSA_HAVE_IO_PORTS \
  71. XCHAL_CP_PORT_MASK
  72. #ifndef __ASSEMBLY__
  73. /*
  74. * Additional registers.
  75. * We define three types of additional registers:
  76. * ext: extra registers that are used by the compiler
  77. * cpn: optional registers that can be used by a user application
  78. * cpX: coprocessor registers that can only be used if the corresponding
  79. * CPENABLE bit is set.
  80. */
  81. #define XCHAL_SA_REG(list,cc,abi,type,y,name,z,align,size,...) \
  82. __REG ## list (cc, abi, type, name, size, align)
  83. #define __REG0(cc,abi,t,name,s,a) __REG0_ ## cc (abi,name)
  84. #define __REG1(cc,abi,t,name,s,a) __REG1_ ## cc (name)
  85. #define __REG2(cc,abi,type,...) __REG2_ ## type (__VA_ARGS__)
  86. #define __REG0_0(abi,name)
  87. #define __REG0_1(abi,name) __REG0_1 ## abi (name)
  88. #define __REG0_10(name) __u32 name;
  89. #define __REG0_11(name) __u32 name;
  90. #define __REG0_12(name)
  91. #define __REG1_0(name) __u32 name;
  92. #define __REG1_1(name)
  93. #define __REG2_0(n,s,a) __u32 name;
  94. #define __REG2_1(n,s,a) unsigned char n[s] __attribute__ ((aligned(a)));
  95. #define __REG2_2(n,s,a) unsigned char n[s] __attribute__ ((aligned(a)));
  96. typedef struct { XCHAL_NCP_SA_LIST(0) } xtregs_opt_t
  97. __attribute__ ((aligned (XCHAL_NCP_SA_ALIGN)));
  98. typedef struct { XCHAL_NCP_SA_LIST(1) } xtregs_user_t
  99. __attribute__ ((aligned (XCHAL_NCP_SA_ALIGN)));
  100. #if XTENSA_HAVE_COPROCESSORS
  101. typedef struct { XCHAL_CP0_SA_LIST(2) } xtregs_cp0_t
  102. __attribute__ ((aligned (XCHAL_CP0_SA_ALIGN)));
  103. typedef struct { XCHAL_CP1_SA_LIST(2) } xtregs_cp1_t
  104. __attribute__ ((aligned (XCHAL_CP1_SA_ALIGN)));
  105. typedef struct { XCHAL_CP2_SA_LIST(2) } xtregs_cp2_t
  106. __attribute__ ((aligned (XCHAL_CP2_SA_ALIGN)));
  107. typedef struct { XCHAL_CP3_SA_LIST(2) } xtregs_cp3_t
  108. __attribute__ ((aligned (XCHAL_CP3_SA_ALIGN)));
  109. typedef struct { XCHAL_CP4_SA_LIST(2) } xtregs_cp4_t
  110. __attribute__ ((aligned (XCHAL_CP4_SA_ALIGN)));
  111. typedef struct { XCHAL_CP5_SA_LIST(2) } xtregs_cp5_t
  112. __attribute__ ((aligned (XCHAL_CP5_SA_ALIGN)));
  113. typedef struct { XCHAL_CP6_SA_LIST(2) } xtregs_cp6_t
  114. __attribute__ ((aligned (XCHAL_CP6_SA_ALIGN)));
  115. typedef struct { XCHAL_CP7_SA_LIST(2) } xtregs_cp7_t
  116. __attribute__ ((aligned (XCHAL_CP7_SA_ALIGN)));
  117. struct thread_info;
  118. void coprocessor_flush(struct thread_info *ti, int cp_index);
  119. void coprocessor_release_all(struct thread_info *ti);
  120. void coprocessor_flush_all(struct thread_info *ti);
  121. void coprocessor_flush_release_all(struct thread_info *ti);
  122. void local_coprocessors_flush_release_all(void);
  123. #endif /* XTENSA_HAVE_COPROCESSORS */
  124. #endif /* !__ASSEMBLY__ */
  125. #endif /* _XTENSA_COPROCESSOR_H */