coprocessor.S 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. /*
  2. * arch/xtensa/kernel/coprocessor.S
  3. *
  4. * Xtensa processor configuration-specific table of coprocessor and
  5. * other custom register layout information.
  6. *
  7. * This file is subject to the terms and conditions of the GNU General Public
  8. * License. See the file "COPYING" in the main directory of this archive
  9. * for more details.
  10. *
  11. * Copyright (C) 2003 - 2005 Tensilica Inc.
  12. *
  13. * Marc Gauthier <marc@tensilica.com> <marc@alumni.uwaterloo.ca>
  14. */
  15. /*
  16. * This module contains a table that describes the layout of the various
  17. * custom registers and states associated with each coprocessor, as well
  18. * as those not associated with any coprocessor ("extra state").
  19. * This table is included with core dumps and is available via the ptrace
  20. * interface, allowing the layout of such register/state information to
  21. * be modified in the kernel without affecting the debugger. Each
  22. * register or state is identified using a 32-bit "libdb target number"
  23. * assigned when the Xtensa processor is generated.
  24. */
  25. #include <linux/config.h>
  26. #include <linux/linkage.h>
  27. #include <asm/processor.h>
  28. #if XCHAL_HAVE_CP
  29. #define CP_LAST ((XCHAL_CP_MAX - 1) * COPROCESSOR_INFO_SIZE)
  30. ENTRY(release_coprocessors)
  31. entry a1, 16
  32. # a2: task
  33. movi a3, 1 << XCHAL_CP_MAX # a3: coprocessor-bit
  34. movi a4, coprocessor_info+CP_LAST # a4: owner-table
  35. # a5: tmp
  36. movi a6, 0 # a6: 0
  37. rsil a7, LOCKLEVEL # a7: PS
  38. 1: /* Check if task is coprocessor owner of coprocessor[i]. */
  39. l32i a5, a4, COPROCESSOR_INFO_OWNER
  40. srli a3, a3, 1
  41. beqz a3, 1f
  42. addi a4, a4, -8
  43. beq a2, a5, 1b
  44. /* Found an entry: Clear entry CPENABLE bit to disable CP. */
  45. rsr a5, CPENABLE
  46. s32i a6, a4, COPROCESSOR_INFO_OWNER
  47. xor a5, a3, a5
  48. wsr a5, CPENABLE
  49. bnez a3, 1b
  50. 1: wsr a7, PS
  51. rsync
  52. retw
  53. ENTRY(disable_coprocessor)
  54. entry sp, 16
  55. rsil a7, LOCKLEVEL
  56. rsr a3, CPENABLE
  57. movi a4, 1
  58. ssl a2
  59. sll a4, a4
  60. and a4, a3, a4
  61. xor a3, a3, a4
  62. wsr a3, CPENABLE
  63. wsr a7, PS
  64. rsync
  65. retw
  66. ENTRY(enable_coprocessor)
  67. entry sp, 16
  68. rsil a7, LOCKLEVEL
  69. rsr a3, CPENABLE
  70. movi a4, 1
  71. ssl a2
  72. sll a4, a4
  73. or a3, a3, a4
  74. wsr a3, CPENABLE
  75. wsr a7, PS
  76. rsync
  77. retw
  78. #endif
  79. ENTRY(save_coprocessor_extra)
  80. entry sp, 16
  81. xchal_extra_store_funcbody
  82. retw
  83. ENTRY(restore_coprocessor_extra)
  84. entry sp, 16
  85. xchal_extra_load_funcbody
  86. retw
  87. ENTRY(save_coprocessor_registers)
  88. entry sp, 16
  89. xchal_cpi_store_funcbody
  90. retw
  91. ENTRY(restore_coprocessor_registers)
  92. entry sp, 16
  93. xchal_cpi_load_funcbody
  94. retw
  95. /*
  96. * The Xtensa compile-time HAL (core.h) XCHAL_*_SA_CONTENTS_LIBDB macros
  97. * describe the contents of coprocessor & extra save areas in terms of
  98. * undefined CONTENTS_LIBDB_{SREG,UREG,REGF} macros. We define these
  99. * latter macros here; they expand into a table of the format we want.
  100. * The general format is:
  101. *
  102. * CONTENTS_LIBDB_SREG(libdbnum, offset, size, align, rsv1, name, sregnum,
  103. * bitmask, rsv2, rsv3)
  104. * CONTENTS_LIBDB_UREG(libdbnum, offset, size, align, rsv1, name, uregnum,
  105. * bitmask, rsv2, rsv3)
  106. * CONTENTS_LIBDB_REGF(libdbnum, offset, size, align, rsv1, name, index,
  107. * numentries, contentsize, regname_base,
  108. * regfile_name, rsv2, rsv3)
  109. *
  110. * For this table, we only care about the <libdbnum>, <offset> and <size>
  111. * fields.
  112. */
  113. /* Map all XCHAL CONTENTS macros to the reg_entry asm macro defined below: */
  114. #define CONTENTS_LIBDB_SREG(libdbnum,offset,size,align,rsv1,name,sregnum, \
  115. bitmask, rsv2, rsv3) \
  116. reg_entry libdbnum, offset, size ;
  117. #define CONTENTS_LIBDB_UREG(libdbnum,offset,size,align,rsv1,name,uregnum, \
  118. bitmask, rsv2, rsv3) \
  119. reg_entry libdbnum, offset, size ;
  120. #define CONTENTS_LIBDB_REGF(libdbnum, offset, size, align, rsv1, name, index, \
  121. numentries, contentsize, regname_base, \
  122. regfile_name, rsv2, rsv3) \
  123. reg_entry libdbnum, offset, size ;
  124. /* A single table entry: */
  125. .macro reg_entry libdbnum, offset, size
  126. .ifne (__last_offset-(__last_group_offset+\offset))
  127. /* padding entry */
  128. .word (0xFC000000+__last_offset-(__last_group_offset+\offset))
  129. .endif
  130. .word \libdbnum /* actual entry */
  131. .set __last_offset, __last_group_offset+\offset+\size
  132. .endm /* reg_entry */
  133. /* Table entry that marks the beginning of a group (coprocessor or "extra"): */
  134. .macro reg_group cpnum, num_entries, align
  135. .set __last_group_offset, (__last_offset + \align- 1) & -\align
  136. .ifne \num_entries
  137. .word 0xFD000000+(\cpnum<<16)+\num_entries
  138. .endif
  139. .endm /* reg_group */
  140. /*
  141. * Register info tables.
  142. */
  143. .section .rodata, "a"
  144. .globl _xtensa_reginfo_tables
  145. .globl _xtensa_reginfo_table_size
  146. .align 4
  147. _xtensa_reginfo_table_size:
  148. .word _xtensa_reginfo_table_end - _xtensa_reginfo_tables
  149. _xtensa_reginfo_tables:
  150. .set __last_offset, 0
  151. reg_group 0xFF, XCHAL_EXTRA_SA_CONTENTS_LIBDB_NUM, XCHAL_EXTRA_SA_ALIGN
  152. XCHAL_EXTRA_SA_CONTENTS_LIBDB
  153. reg_group 0, XCHAL_CP0_SA_CONTENTS_LIBDB_NUM, XCHAL_CP0_SA_ALIGN
  154. XCHAL_CP0_SA_CONTENTS_LIBDB
  155. reg_group 1, XCHAL_CP1_SA_CONTENTS_LIBDB_NUM, XCHAL_CP1_SA_ALIGN
  156. XCHAL_CP1_SA_CONTENTS_LIBDB
  157. reg_group 2, XCHAL_CP2_SA_CONTENTS_LIBDB_NUM, XCHAL_CP2_SA_ALIGN
  158. XCHAL_CP2_SA_CONTENTS_LIBDB
  159. reg_group 3, XCHAL_CP3_SA_CONTENTS_LIBDB_NUM, XCHAL_CP3_SA_ALIGN
  160. XCHAL_CP3_SA_CONTENTS_LIBDB
  161. reg_group 4, XCHAL_CP4_SA_CONTENTS_LIBDB_NUM, XCHAL_CP4_SA_ALIGN
  162. XCHAL_CP4_SA_CONTENTS_LIBDB
  163. reg_group 5, XCHAL_CP5_SA_CONTENTS_LIBDB_NUM, XCHAL_CP5_SA_ALIGN
  164. XCHAL_CP5_SA_CONTENTS_LIBDB
  165. reg_group 6, XCHAL_CP6_SA_CONTENTS_LIBDB_NUM, XCHAL_CP6_SA_ALIGN
  166. XCHAL_CP6_SA_CONTENTS_LIBDB
  167. reg_group 7, XCHAL_CP7_SA_CONTENTS_LIBDB_NUM, XCHAL_CP7_SA_ALIGN
  168. XCHAL_CP7_SA_CONTENTS_LIBDB
  169. .word 0xFC000000 /* invalid register number,marks end of table*/
  170. _xtensa_reginfo_table_end: