sysdep.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. /* Copyright (C) 1999, 2001, 2002, 2006 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, see
  13. <http://www.gnu.org/licenses/>. */
  14. #include <common/sysdep.h>
  15. #include <sys/syscall.h>
  16. /*
  17. * Powerpc Feature masks for the Aux Vector Hardware Capabilities (AT_HWCAP).
  18. * This entry is copied to _dl_hwcap or rtld_global._dl_hwcap during startup.
  19. * The following must match the kernels linux/asm/cputable.h.
  20. */
  21. #define PPC_FEATURE_32 0x80000000 /* 32-bit mode. */
  22. #define PPC_FEATURE_64 0x40000000 /* 64-bit mode. */
  23. #define PPC_FEATURE_601_INSTR 0x20000000 /* 601 chip, Old POWER ISA. */
  24. #define PPC_FEATURE_HAS_ALTIVEC 0x10000000 /* SIMD/Vector Unit. */
  25. #define PPC_FEATURE_HAS_FPU 0x08000000 /* Floating Point Unit. */
  26. #define PPC_FEATURE_HAS_MMU 0x04000000 /* Memory Management Unit. */
  27. #define PPC_FEATURE_HAS_4xxMAC 0x02000000 /* 4xx Multiply Accumulator. */
  28. #define PPC_FEATURE_UNIFIED_CACHE 0x01000000 /* Unified I/D cache. */
  29. #define PPC_FEATURE_HAS_SPE 0x00800000 /* Signal Processing ext. */
  30. #define PPC_FEATURE_HAS_EFP_SINGLE 0x00400000 /* SPE Float. */
  31. #define PPC_FEATURE_HAS_EFP_DOUBLE 0x00200000 /* SPE Double. */
  32. #define PPC_FEATURE_NO_TB 0x00100000 /* 601/403gx have no timebase */
  33. #define PPC_FEATURE_POWER4 0x00080000 /* POWER4 ISA 2.00 */
  34. #define PPC_FEATURE_POWER5 0x00040000 /* POWER5 ISA 2.02 */
  35. #define PPC_FEATURE_POWER5_PLUS 0x00020000 /* POWER5+ ISA 2.03 */
  36. #define PPC_FEATURE_CELL_BE 0x00010000 /* CELL Broadband Engine */
  37. #define PPC_FEATURE_BOOKE 0x00008000
  38. #define PPC_FEATURE_SMT 0x00004000 /* Simultaneous Multi-Threading */
  39. #define PPC_FEATURE_ICACHE_SNOOP 0x00002000
  40. #define PPC_FEATURE_ARCH_2_05 0x00001000 /* ISA 2.05 */
  41. #define PPC_FEATURE_PA6T 0x00000800 /* PA Semi 6T Core */
  42. #define PPC_FEATURE_HAS_DFP 0x00000400 /* Decimal FP Unit */
  43. #define PPC_FEATURE_POWER6_EXT 0x00000200 /* P6 + mffgpr/mftgpr */
  44. #define PPC_FEATURE_ARCH_2_06 0x00000100 /* ISA 2.06 */
  45. #define PPC_FEATURE_HAS_VSX 0x00000080 /* P7 Vector Extension. */
  46. #define PPC_FEATURE_970 (PPC_FEATURE_POWER4 + PPC_FEATURE_HAS_ALTIVEC)
  47. #ifdef __ASSEMBLER__
  48. /* Symbolic names for the registers. The only portable way to write asm
  49. code is to use number but this produces really unreadable code.
  50. Therefore these symbolic names. */
  51. /* Integer registers. */
  52. #define r0 0
  53. #define r1 1
  54. #define r2 2
  55. #define r3 3
  56. #define r4 4
  57. #define r5 5
  58. #define r6 6
  59. #define r7 7
  60. #define r8 8
  61. #define r9 9
  62. #define r10 10
  63. #define r11 11
  64. #define r12 12
  65. #define r13 13
  66. #define r14 14
  67. #define r15 15
  68. #define r16 16
  69. #define r17 17
  70. #define r18 18
  71. #define r19 19
  72. #define r20 20
  73. #define r21 21
  74. #define r22 22
  75. #define r23 23
  76. #define r24 24
  77. #define r25 25
  78. #define r26 26
  79. #define r27 27
  80. #define r28 28
  81. #define r29 29
  82. #define r30 30
  83. #define r31 31
  84. /* Floating-point registers. */
  85. #define fp0 0
  86. #define fp1 1
  87. #define fp2 2
  88. #define fp3 3
  89. #define fp4 4
  90. #define fp5 5
  91. #define fp6 6
  92. #define fp7 7
  93. #define fp8 8
  94. #define fp9 9
  95. #define fp10 10
  96. #define fp11 11
  97. #define fp12 12
  98. #define fp13 13
  99. #define fp14 14
  100. #define fp15 15
  101. #define fp16 16
  102. #define fp17 17
  103. #define fp18 18
  104. #define fp19 19
  105. #define fp20 20
  106. #define fp21 21
  107. #define fp22 22
  108. #define fp23 23
  109. #define fp24 24
  110. #define fp25 25
  111. #define fp26 26
  112. #define fp27 27
  113. #define fp28 28
  114. #define fp29 29
  115. #define fp30 30
  116. #define fp31 31
  117. /* Condition code registers. */
  118. #define cr0 0
  119. #define cr1 1
  120. #define cr2 2
  121. #define cr3 3
  122. #define cr4 4
  123. #define cr5 5
  124. #define cr6 6
  125. #define cr7 7
  126. /* Vector registers. */
  127. #define v0 0
  128. #define v1 1
  129. #define v2 2
  130. #define v3 3
  131. #define v4 4
  132. #define v5 5
  133. #define v6 6
  134. #define v7 7
  135. #define v8 8
  136. #define v9 9
  137. #define v10 10
  138. #define v11 11
  139. #define v12 12
  140. #define v13 13
  141. #define v14 14
  142. #define v15 15
  143. #define v16 16
  144. #define v17 17
  145. #define v18 18
  146. #define v19 19
  147. #define v20 20
  148. #define v21 21
  149. #define v22 22
  150. #define v23 23
  151. #define v24 24
  152. #define v25 25
  153. #define v26 26
  154. #define v27 27
  155. #define v28 28
  156. #define v29 29
  157. #define v30 30
  158. #define v31 31
  159. #define VRSAVE 256
  160. /* This seems to always be the case on PPC. */
  161. #define ALIGNARG(log2) log2
  162. /* For ELF we need the `.type' directive to make shared libs work right. */
  163. #define ASM_TYPE_DIRECTIVE(name,typearg) .type name,typearg;
  164. #define ASM_SIZE_DIRECTIVE(name) .size name,.-name
  165. /* In ELF C symbols are asm symbols. */
  166. #undef NO_UNDERSCORES
  167. #define NO_UNDERSCORES
  168. #define ENTRY(name) \
  169. .globl C_SYMBOL_NAME(name); \
  170. ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
  171. .align ALIGNARG(2); \
  172. C_LABEL(name) \
  173. cfi_startproc; \
  174. #define EALIGN_W_0 /* No words to insert. */
  175. #define EALIGN_W_1 nop
  176. #define EALIGN_W_2 nop;nop
  177. #define EALIGN_W_3 nop;nop;nop
  178. #define EALIGN_W_4 EALIGN_W_3;nop
  179. #define EALIGN_W_5 EALIGN_W_4;nop
  180. #define EALIGN_W_6 EALIGN_W_5;nop
  181. #define EALIGN_W_7 EALIGN_W_6;nop
  182. #define EALIGN(name, alignt, words) \
  183. .globl C_SYMBOL_NAME(name); \
  184. ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
  185. .align ALIGNARG(alignt); \
  186. EALIGN_W_##words; \
  187. C_LABEL(name) \
  188. cfi_startproc;
  189. #undef END
  190. #define END(name) \
  191. cfi_endproc; \
  192. ASM_SIZE_DIRECTIVE(name)
  193. #define DO_CALL(syscall) \
  194. li 0,syscall; \
  195. sc
  196. #undef JUMPTARGET
  197. #ifdef PIC
  198. # define JUMPTARGET(name) name##@plt
  199. #else
  200. # define JUMPTARGET(name) name
  201. #endif
  202. #if defined SHARED && defined DO_VERSIONING && defined PIC \
  203. && !defined NO_HIDDEN
  204. # undef HIDDEN_JUMPTARGET
  205. # define HIDDEN_JUMPTARGET(name) __GI_##name##@local
  206. #endif
  207. #define PSEUDO(name, syscall_name, args) \
  208. .section ".text"; \
  209. ENTRY (name) \
  210. DO_CALL (SYS_ify (syscall_name));
  211. #define PSEUDO_RET \
  212. bnslr+; \
  213. b __syscall_error@local
  214. #define ret PSEUDO_RET
  215. #undef PSEUDO_END
  216. #define PSEUDO_END(name) \
  217. END (name)
  218. #define PSEUDO_NOERRNO(name, syscall_name, args) \
  219. .section ".text"; \
  220. ENTRY (name) \
  221. DO_CALL (SYS_ify (syscall_name));
  222. #define PSEUDO_RET_NOERRNO \
  223. blr
  224. #define ret_NOERRNO PSEUDO_RET_NOERRNO
  225. #undef PSEUDO_END_NOERRNO
  226. #define PSEUDO_END_NOERRNO(name) \
  227. END (name)
  228. #define PSEUDO_ERRVAL(name, syscall_name, args) \
  229. .section ".text"; \
  230. ENTRY (name) \
  231. DO_CALL (SYS_ify (syscall_name));
  232. #define PSEUDO_RET_ERRVAL \
  233. blr
  234. #undef ret_ERRVAL
  235. #define ret_ERRVAL PSEUDO_RET_ERRVAL
  236. #undef PSEUDO_END_ERRVAL
  237. #define PSEUDO_END_ERRVAL(name) \
  238. END (name)
  239. /* Local labels stripped out by the linker. */
  240. #undef L
  241. #define L(x) .L##x
  242. /* Label in text section. */
  243. #define C_TEXT(name) name
  244. #endif /* __ASSEMBLER__ */