coprocessor.S 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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/linkage.h>
  26. #include <asm/processor.h>
  27. #if XCHAL_HAVE_CP
  28. #define CP_LAST ((XCHAL_CP_MAX - 1) * COPROCESSOR_INFO_SIZE)
  29. ENTRY(release_coprocessors)
  30. entry a1, 16
  31. # a2: task
  32. movi a3, 1 << XCHAL_CP_MAX # a3: coprocessor-bit
  33. movi a4, coprocessor_info+CP_LAST # a4: owner-table
  34. # a5: tmp
  35. movi a6, 0 # a6: 0
  36. rsil a7, LOCKLEVEL # a7: PS
  37. 1: /* Check if task is coprocessor owner of coprocessor[i]. */
  38. l32i a5, a4, COPROCESSOR_INFO_OWNER
  39. srli a3, a3, 1
  40. beqz a3, 1f
  41. addi a4, a4, -8
  42. beq a2, a5, 1b
  43. /* Found an entry: Clear entry CPENABLE bit to disable CP. */
  44. rsr a5, CPENABLE
  45. s32i a6, a4, COPROCESSOR_INFO_OWNER
  46. xor a5, a3, a5
  47. wsr a5, CPENABLE
  48. bnez a3, 1b
  49. 1: wsr a7, PS
  50. rsync
  51. retw
  52. ENTRY(disable_coprocessor)
  53. entry sp, 16
  54. rsil a7, LOCKLEVEL
  55. rsr a3, CPENABLE
  56. movi a4, 1
  57. ssl a2
  58. sll a4, a4
  59. and a4, a3, a4
  60. xor a3, a3, a4
  61. wsr a3, CPENABLE
  62. wsr a7, PS
  63. rsync
  64. retw
  65. ENTRY(enable_coprocessor)
  66. entry sp, 16
  67. rsil a7, LOCKLEVEL
  68. rsr a3, CPENABLE
  69. movi a4, 1
  70. ssl a2
  71. sll a4, a4
  72. or a3, a3, a4
  73. wsr a3, CPENABLE
  74. wsr a7, PS
  75. rsync
  76. retw
  77. #endif
  78. ENTRY(save_coprocessor_extra)
  79. entry sp, 16
  80. xchal_extra_store_funcbody
  81. retw
  82. ENTRY(restore_coprocessor_extra)
  83. entry sp, 16
  84. xchal_extra_load_funcbody
  85. retw
  86. ENTRY(save_coprocessor_registers)
  87. entry sp, 16
  88. xchal_cpi_store_funcbody
  89. retw
  90. ENTRY(restore_coprocessor_registers)
  91. entry sp, 16
  92. xchal_cpi_load_funcbody
  93. retw
  94. /*
  95. * The Xtensa compile-time HAL (core.h) XCHAL_*_SA_CONTENTS_LIBDB macros
  96. * describe the contents of coprocessor & extra save areas in terms of
  97. * undefined CONTENTS_LIBDB_{SREG,UREG,REGF} macros. We define these
  98. * latter macros here; they expand into a table of the format we want.
  99. * The general format is:
  100. *
  101. * CONTENTS_LIBDB_SREG(libdbnum, offset, size, align, rsv1, name, sregnum,
  102. * bitmask, rsv2, rsv3)
  103. * CONTENTS_LIBDB_UREG(libdbnum, offset, size, align, rsv1, name, uregnum,
  104. * bitmask, rsv2, rsv3)
  105. * CONTENTS_LIBDB_REGF(libdbnum, offset, size, align, rsv1, name, index,
  106. * numentries, contentsize, regname_base,
  107. * regfile_name, rsv2, rsv3)
  108. *
  109. * For this table, we only care about the <libdbnum>, <offset> and <size>
  110. * fields.
  111. */
  112. /* Map all XCHAL CONTENTS macros to the reg_entry asm macro defined below: */
  113. #define CONTENTS_LIBDB_SREG(libdbnum,offset,size,align,rsv1,name,sregnum, \
  114. bitmask, rsv2, rsv3) \
  115. reg_entry libdbnum, offset, size ;
  116. #define CONTENTS_LIBDB_UREG(libdbnum,offset,size,align,rsv1,name,uregnum, \
  117. bitmask, rsv2, rsv3) \
  118. reg_entry libdbnum, offset, size ;
  119. #define CONTENTS_LIBDB_REGF(libdbnum, offset, size, align, rsv1, name, index, \
  120. numentries, contentsize, regname_base, \
  121. regfile_name, rsv2, rsv3) \
  122. reg_entry libdbnum, offset, size ;
  123. /* A single table entry: */
  124. .macro reg_entry libdbnum, offset, size
  125. .ifne (__last_offset-(__last_group_offset+\offset))
  126. /* padding entry */
  127. .word (0xFC000000+__last_offset-(__last_group_offset+\offset))
  128. .endif
  129. .word \libdbnum /* actual entry */
  130. .set __last_offset, __last_group_offset+\offset+\size
  131. .endm /* reg_entry */
  132. /* Table entry that marks the beginning of a group (coprocessor or "extra"): */
  133. .macro reg_group cpnum, num_entries, align
  134. .set __last_group_offset, (__last_offset + \align- 1) & -\align
  135. .ifne \num_entries
  136. .word 0xFD000000+(\cpnum<<16)+\num_entries
  137. .endif
  138. .endm /* reg_group */
  139. /*
  140. * Register info tables.
  141. */
  142. .section .rodata, "a"
  143. .globl _xtensa_reginfo_tables
  144. .globl _xtensa_reginfo_table_size
  145. .align 4
  146. _xtensa_reginfo_table_size:
  147. .word _xtensa_reginfo_table_end - _xtensa_reginfo_tables
  148. _xtensa_reginfo_tables:
  149. .set __last_offset, 0
  150. reg_group 0xFF, XCHAL_EXTRA_SA_CONTENTS_LIBDB_NUM, XCHAL_EXTRA_SA_ALIGN
  151. XCHAL_EXTRA_SA_CONTENTS_LIBDB
  152. reg_group 0, XCHAL_CP0_SA_CONTENTS_LIBDB_NUM, XCHAL_CP0_SA_ALIGN
  153. XCHAL_CP0_SA_CONTENTS_LIBDB
  154. reg_group 1, XCHAL_CP1_SA_CONTENTS_LIBDB_NUM, XCHAL_CP1_SA_ALIGN
  155. XCHAL_CP1_SA_CONTENTS_LIBDB
  156. reg_group 2, XCHAL_CP2_SA_CONTENTS_LIBDB_NUM, XCHAL_CP2_SA_ALIGN
  157. XCHAL_CP2_SA_CONTENTS_LIBDB
  158. reg_group 3, XCHAL_CP3_SA_CONTENTS_LIBDB_NUM, XCHAL_CP3_SA_ALIGN
  159. XCHAL_CP3_SA_CONTENTS_LIBDB
  160. reg_group 4, XCHAL_CP4_SA_CONTENTS_LIBDB_NUM, XCHAL_CP4_SA_ALIGN
  161. XCHAL_CP4_SA_CONTENTS_LIBDB
  162. reg_group 5, XCHAL_CP5_SA_CONTENTS_LIBDB_NUM, XCHAL_CP5_SA_ALIGN
  163. XCHAL_CP5_SA_CONTENTS_LIBDB
  164. reg_group 6, XCHAL_CP6_SA_CONTENTS_LIBDB_NUM, XCHAL_CP6_SA_ALIGN
  165. XCHAL_CP6_SA_CONTENTS_LIBDB
  166. reg_group 7, XCHAL_CP7_SA_CONTENTS_LIBDB_NUM, XCHAL_CP7_SA_ALIGN
  167. XCHAL_CP7_SA_CONTENTS_LIBDB
  168. .word 0xFC000000 /* invalid register number,marks end of table*/
  169. _xtensa_reginfo_table_end: