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. ENTRY(save_coprocessor_extra)
  78. entry sp, 16
  79. xchal_extra_store_funcbody
  80. retw
  81. ENTRY(restore_coprocessor_extra)
  82. entry sp, 16
  83. xchal_extra_load_funcbody
  84. retw
  85. ENTRY(save_coprocessor_registers)
  86. entry sp, 16
  87. xchal_cpi_store_funcbody
  88. retw
  89. ENTRY(restore_coprocessor_registers)
  90. entry sp, 16
  91. xchal_cpi_load_funcbody
  92. retw
  93. /*
  94. * The Xtensa compile-time HAL (core.h) XCHAL_*_SA_CONTENTS_LIBDB macros
  95. * describe the contents of coprocessor & extra save areas in terms of
  96. * undefined CONTENTS_LIBDB_{SREG,UREG,REGF} macros. We define these
  97. * latter macros here; they expand into a table of the format we want.
  98. * The general format is:
  99. *
  100. * CONTENTS_LIBDB_SREG(libdbnum, offset, size, align, rsv1, name, sregnum,
  101. * bitmask, rsv2, rsv3)
  102. * CONTENTS_LIBDB_UREG(libdbnum, offset, size, align, rsv1, name, uregnum,
  103. * bitmask, rsv2, rsv3)
  104. * CONTENTS_LIBDB_REGF(libdbnum, offset, size, align, rsv1, name, index,
  105. * numentries, contentsize, regname_base,
  106. * regfile_name, rsv2, rsv3)
  107. *
  108. * For this table, we only care about the <libdbnum>, <offset> and <size>
  109. * fields.
  110. */
  111. /* Map all XCHAL CONTENTS macros to the reg_entry asm macro defined below: */
  112. #define CONTENTS_LIBDB_SREG(libdbnum,offset,size,align,rsv1,name,sregnum, \
  113. bitmask, rsv2, rsv3) \
  114. reg_entry libdbnum, offset, size ;
  115. #define CONTENTS_LIBDB_UREG(libdbnum,offset,size,align,rsv1,name,uregnum, \
  116. bitmask, rsv2, rsv3) \
  117. reg_entry libdbnum, offset, size ;
  118. #define CONTENTS_LIBDB_REGF(libdbnum, offset, size, align, rsv1, name, index, \
  119. numentries, contentsize, regname_base, \
  120. regfile_name, rsv2, rsv3) \
  121. reg_entry libdbnum, offset, size ;
  122. /* A single table entry: */
  123. .macro reg_entry libdbnum, offset, size
  124. .ifne (__last_offset-(__last_group_offset+\offset))
  125. /* padding entry */
  126. .word (0xFC000000+__last_offset-(__last_group_offset+\offset))
  127. .endif
  128. .word \libdbnum /* actual entry */
  129. .set __last_offset, __last_group_offset+\offset+\size
  130. .endm /* reg_entry */
  131. /* Table entry that marks the beginning of a group (coprocessor or "extra"): */
  132. .macro reg_group cpnum, num_entries, align
  133. .set __last_group_offset, (__last_offset + \align- 1) & -\align
  134. .ifne \num_entries
  135. .word 0xFD000000+(\cpnum<<16)+\num_entries
  136. .endif
  137. .endm /* reg_group */
  138. /*
  139. * Register info tables.
  140. */
  141. .section .rodata, "a"
  142. .globl _xtensa_reginfo_tables
  143. .globl _xtensa_reginfo_table_size
  144. .align 4
  145. _xtensa_reginfo_table_size:
  146. .word _xtensa_reginfo_table_end - _xtensa_reginfo_tables
  147. _xtensa_reginfo_tables:
  148. .set __last_offset, 0
  149. reg_group 0xFF, XCHAL_EXTRA_SA_CONTENTS_LIBDB_NUM, XCHAL_EXTRA_SA_ALIGN
  150. XCHAL_EXTRA_SA_CONTENTS_LIBDB
  151. reg_group 0, XCHAL_CP0_SA_CONTENTS_LIBDB_NUM, XCHAL_CP0_SA_ALIGN
  152. XCHAL_CP0_SA_CONTENTS_LIBDB
  153. reg_group 1, XCHAL_CP1_SA_CONTENTS_LIBDB_NUM, XCHAL_CP1_SA_ALIGN
  154. XCHAL_CP1_SA_CONTENTS_LIBDB
  155. reg_group 2, XCHAL_CP2_SA_CONTENTS_LIBDB_NUM, XCHAL_CP2_SA_ALIGN
  156. XCHAL_CP2_SA_CONTENTS_LIBDB
  157. reg_group 3, XCHAL_CP3_SA_CONTENTS_LIBDB_NUM, XCHAL_CP3_SA_ALIGN
  158. XCHAL_CP3_SA_CONTENTS_LIBDB
  159. reg_group 4, XCHAL_CP4_SA_CONTENTS_LIBDB_NUM, XCHAL_CP4_SA_ALIGN
  160. XCHAL_CP4_SA_CONTENTS_LIBDB
  161. reg_group 5, XCHAL_CP5_SA_CONTENTS_LIBDB_NUM, XCHAL_CP5_SA_ALIGN
  162. XCHAL_CP5_SA_CONTENTS_LIBDB
  163. reg_group 6, XCHAL_CP6_SA_CONTENTS_LIBDB_NUM, XCHAL_CP6_SA_ALIGN
  164. XCHAL_CP6_SA_CONTENTS_LIBDB
  165. reg_group 7, XCHAL_CP7_SA_CONTENTS_LIBDB_NUM, XCHAL_CP7_SA_ALIGN
  166. XCHAL_CP7_SA_CONTENTS_LIBDB
  167. .word 0xFC000000 /* invalid register number,marks end of table*/
  168. _xtensa_reginfo_table_end:
  169. #endif