crtsavres.S 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  1. /*
  2. * Special support for eabi and SVR4
  3. *
  4. * Copyright (C) 1995, 1996, 1998, 2000, 2001 Free Software Foundation, Inc.
  5. * Copyright 2008 Freescale Semiconductor, Inc.
  6. * Written By Michael Meissner
  7. *
  8. * Based on gcc/config/rs6000/crtsavres.asm from gcc
  9. * 64 bit additions from reading the PPC elf64abi document.
  10. *
  11. * This file is free software; you can redistribute it and/or modify it
  12. * under the terms of the GNU General Public License as published by the
  13. * Free Software Foundation; either version 2, or (at your option) any
  14. * later version.
  15. *
  16. * In addition to the permissions in the GNU General Public License, the
  17. * Free Software Foundation gives you unlimited permission to link the
  18. * compiled version of this file with other programs, and to distribute
  19. * those programs without any restriction coming from the use of this
  20. * file. (The General Public License restrictions do apply in other
  21. * respects; for example, they cover modification of the file, and
  22. * distribution when not linked into another program.)
  23. *
  24. * This file is distributed in the hope that it will be useful, but
  25. * WITHOUT ANY WARRANTY; without even the implied warranty of
  26. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  27. * General Public License for more details.
  28. *
  29. * You should have received a copy of the GNU General Public License
  30. * along with this program; see the file COPYING. If not, write to
  31. * the Free Software Foundation, 51 Franklin Street, Fifth Floor,
  32. * Boston, MA 02110-1301, USA.
  33. *
  34. * As a special exception, if you link this library with files
  35. * compiled with GCC to produce an executable, this does not cause
  36. * the resulting executable to be covered by the GNU General Public License.
  37. * This exception does not however invalidate any other reasons why
  38. * the executable file might be covered by the GNU General Public License.
  39. */
  40. #include <asm/ppc_asm.h>
  41. .file "crtsavres.S"
  42. #ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
  43. #ifndef CONFIG_PPC64
  44. .section ".text"
  45. /* Routines for saving integer registers, called by the compiler. */
  46. /* Called with r11 pointing to the stack header word of the caller of the */
  47. /* function, just beyond the end of the integer save area. */
  48. _GLOBAL(_savegpr_14)
  49. _GLOBAL(_save32gpr_14)
  50. stw 14,-72(11) /* save gp registers */
  51. _GLOBAL(_savegpr_15)
  52. _GLOBAL(_save32gpr_15)
  53. stw 15,-68(11)
  54. _GLOBAL(_savegpr_16)
  55. _GLOBAL(_save32gpr_16)
  56. stw 16,-64(11)
  57. _GLOBAL(_savegpr_17)
  58. _GLOBAL(_save32gpr_17)
  59. stw 17,-60(11)
  60. _GLOBAL(_savegpr_18)
  61. _GLOBAL(_save32gpr_18)
  62. stw 18,-56(11)
  63. _GLOBAL(_savegpr_19)
  64. _GLOBAL(_save32gpr_19)
  65. stw 19,-52(11)
  66. _GLOBAL(_savegpr_20)
  67. _GLOBAL(_save32gpr_20)
  68. stw 20,-48(11)
  69. _GLOBAL(_savegpr_21)
  70. _GLOBAL(_save32gpr_21)
  71. stw 21,-44(11)
  72. _GLOBAL(_savegpr_22)
  73. _GLOBAL(_save32gpr_22)
  74. stw 22,-40(11)
  75. _GLOBAL(_savegpr_23)
  76. _GLOBAL(_save32gpr_23)
  77. stw 23,-36(11)
  78. _GLOBAL(_savegpr_24)
  79. _GLOBAL(_save32gpr_24)
  80. stw 24,-32(11)
  81. _GLOBAL(_savegpr_25)
  82. _GLOBAL(_save32gpr_25)
  83. stw 25,-28(11)
  84. _GLOBAL(_savegpr_26)
  85. _GLOBAL(_save32gpr_26)
  86. stw 26,-24(11)
  87. _GLOBAL(_savegpr_27)
  88. _GLOBAL(_save32gpr_27)
  89. stw 27,-20(11)
  90. _GLOBAL(_savegpr_28)
  91. _GLOBAL(_save32gpr_28)
  92. stw 28,-16(11)
  93. _GLOBAL(_savegpr_29)
  94. _GLOBAL(_save32gpr_29)
  95. stw 29,-12(11)
  96. _GLOBAL(_savegpr_30)
  97. _GLOBAL(_save32gpr_30)
  98. stw 30,-8(11)
  99. _GLOBAL(_savegpr_31)
  100. _GLOBAL(_save32gpr_31)
  101. stw 31,-4(11)
  102. blr
  103. /* Routines for restoring integer registers, called by the compiler. */
  104. /* Called with r11 pointing to the stack header word of the caller of the */
  105. /* function, just beyond the end of the integer restore area. */
  106. _GLOBAL(_restgpr_14)
  107. _GLOBAL(_rest32gpr_14)
  108. lwz 14,-72(11) /* restore gp registers */
  109. _GLOBAL(_restgpr_15)
  110. _GLOBAL(_rest32gpr_15)
  111. lwz 15,-68(11)
  112. _GLOBAL(_restgpr_16)
  113. _GLOBAL(_rest32gpr_16)
  114. lwz 16,-64(11)
  115. _GLOBAL(_restgpr_17)
  116. _GLOBAL(_rest32gpr_17)
  117. lwz 17,-60(11)
  118. _GLOBAL(_restgpr_18)
  119. _GLOBAL(_rest32gpr_18)
  120. lwz 18,-56(11)
  121. _GLOBAL(_restgpr_19)
  122. _GLOBAL(_rest32gpr_19)
  123. lwz 19,-52(11)
  124. _GLOBAL(_restgpr_20)
  125. _GLOBAL(_rest32gpr_20)
  126. lwz 20,-48(11)
  127. _GLOBAL(_restgpr_21)
  128. _GLOBAL(_rest32gpr_21)
  129. lwz 21,-44(11)
  130. _GLOBAL(_restgpr_22)
  131. _GLOBAL(_rest32gpr_22)
  132. lwz 22,-40(11)
  133. _GLOBAL(_restgpr_23)
  134. _GLOBAL(_rest32gpr_23)
  135. lwz 23,-36(11)
  136. _GLOBAL(_restgpr_24)
  137. _GLOBAL(_rest32gpr_24)
  138. lwz 24,-32(11)
  139. _GLOBAL(_restgpr_25)
  140. _GLOBAL(_rest32gpr_25)
  141. lwz 25,-28(11)
  142. _GLOBAL(_restgpr_26)
  143. _GLOBAL(_rest32gpr_26)
  144. lwz 26,-24(11)
  145. _GLOBAL(_restgpr_27)
  146. _GLOBAL(_rest32gpr_27)
  147. lwz 27,-20(11)
  148. _GLOBAL(_restgpr_28)
  149. _GLOBAL(_rest32gpr_28)
  150. lwz 28,-16(11)
  151. _GLOBAL(_restgpr_29)
  152. _GLOBAL(_rest32gpr_29)
  153. lwz 29,-12(11)
  154. _GLOBAL(_restgpr_30)
  155. _GLOBAL(_rest32gpr_30)
  156. lwz 30,-8(11)
  157. _GLOBAL(_restgpr_31)
  158. _GLOBAL(_rest32gpr_31)
  159. lwz 31,-4(11)
  160. blr
  161. /* Routines for restoring integer registers, called by the compiler. */
  162. /* Called with r11 pointing to the stack header word of the caller of the */
  163. /* function, just beyond the end of the integer restore area. */
  164. _GLOBAL(_restgpr_14_x)
  165. _GLOBAL(_rest32gpr_14_x)
  166. lwz 14,-72(11) /* restore gp registers */
  167. _GLOBAL(_restgpr_15_x)
  168. _GLOBAL(_rest32gpr_15_x)
  169. lwz 15,-68(11)
  170. _GLOBAL(_restgpr_16_x)
  171. _GLOBAL(_rest32gpr_16_x)
  172. lwz 16,-64(11)
  173. _GLOBAL(_restgpr_17_x)
  174. _GLOBAL(_rest32gpr_17_x)
  175. lwz 17,-60(11)
  176. _GLOBAL(_restgpr_18_x)
  177. _GLOBAL(_rest32gpr_18_x)
  178. lwz 18,-56(11)
  179. _GLOBAL(_restgpr_19_x)
  180. _GLOBAL(_rest32gpr_19_x)
  181. lwz 19,-52(11)
  182. _GLOBAL(_restgpr_20_x)
  183. _GLOBAL(_rest32gpr_20_x)
  184. lwz 20,-48(11)
  185. _GLOBAL(_restgpr_21_x)
  186. _GLOBAL(_rest32gpr_21_x)
  187. lwz 21,-44(11)
  188. _GLOBAL(_restgpr_22_x)
  189. _GLOBAL(_rest32gpr_22_x)
  190. lwz 22,-40(11)
  191. _GLOBAL(_restgpr_23_x)
  192. _GLOBAL(_rest32gpr_23_x)
  193. lwz 23,-36(11)
  194. _GLOBAL(_restgpr_24_x)
  195. _GLOBAL(_rest32gpr_24_x)
  196. lwz 24,-32(11)
  197. _GLOBAL(_restgpr_25_x)
  198. _GLOBAL(_rest32gpr_25_x)
  199. lwz 25,-28(11)
  200. _GLOBAL(_restgpr_26_x)
  201. _GLOBAL(_rest32gpr_26_x)
  202. lwz 26,-24(11)
  203. _GLOBAL(_restgpr_27_x)
  204. _GLOBAL(_rest32gpr_27_x)
  205. lwz 27,-20(11)
  206. _GLOBAL(_restgpr_28_x)
  207. _GLOBAL(_rest32gpr_28_x)
  208. lwz 28,-16(11)
  209. _GLOBAL(_restgpr_29_x)
  210. _GLOBAL(_rest32gpr_29_x)
  211. lwz 29,-12(11)
  212. _GLOBAL(_restgpr_30_x)
  213. _GLOBAL(_rest32gpr_30_x)
  214. lwz 30,-8(11)
  215. _GLOBAL(_restgpr_31_x)
  216. _GLOBAL(_rest32gpr_31_x)
  217. lwz 0,4(11)
  218. lwz 31,-4(11)
  219. mtlr 0
  220. mr 1,11
  221. blr
  222. #ifdef CONFIG_ALTIVEC
  223. /* Called with r0 pointing just beyond the end of the vector save area. */
  224. _GLOBAL(_savevr_20)
  225. li r11,-192
  226. stvx v20,r11,r0
  227. _GLOBAL(_savevr_21)
  228. li r11,-176
  229. stvx v21,r11,r0
  230. _GLOBAL(_savevr_22)
  231. li r11,-160
  232. stvx v22,r11,r0
  233. _GLOBAL(_savevr_23)
  234. li r11,-144
  235. stvx v23,r11,r0
  236. _GLOBAL(_savevr_24)
  237. li r11,-128
  238. stvx v24,r11,r0
  239. _GLOBAL(_savevr_25)
  240. li r11,-112
  241. stvx v25,r11,r0
  242. _GLOBAL(_savevr_26)
  243. li r11,-96
  244. stvx v26,r11,r0
  245. _GLOBAL(_savevr_27)
  246. li r11,-80
  247. stvx v27,r11,r0
  248. _GLOBAL(_savevr_28)
  249. li r11,-64
  250. stvx v28,r11,r0
  251. _GLOBAL(_savevr_29)
  252. li r11,-48
  253. stvx v29,r11,r0
  254. _GLOBAL(_savevr_30)
  255. li r11,-32
  256. stvx v30,r11,r0
  257. _GLOBAL(_savevr_31)
  258. li r11,-16
  259. stvx v31,r11,r0
  260. blr
  261. _GLOBAL(_restvr_20)
  262. li r11,-192
  263. lvx v20,r11,r0
  264. _GLOBAL(_restvr_21)
  265. li r11,-176
  266. lvx v21,r11,r0
  267. _GLOBAL(_restvr_22)
  268. li r11,-160
  269. lvx v22,r11,r0
  270. _GLOBAL(_restvr_23)
  271. li r11,-144
  272. lvx v23,r11,r0
  273. _GLOBAL(_restvr_24)
  274. li r11,-128
  275. lvx v24,r11,r0
  276. _GLOBAL(_restvr_25)
  277. li r11,-112
  278. lvx v25,r11,r0
  279. _GLOBAL(_restvr_26)
  280. li r11,-96
  281. lvx v26,r11,r0
  282. _GLOBAL(_restvr_27)
  283. li r11,-80
  284. lvx v27,r11,r0
  285. _GLOBAL(_restvr_28)
  286. li r11,-64
  287. lvx v28,r11,r0
  288. _GLOBAL(_restvr_29)
  289. li r11,-48
  290. lvx v29,r11,r0
  291. _GLOBAL(_restvr_30)
  292. li r11,-32
  293. lvx v30,r11,r0
  294. _GLOBAL(_restvr_31)
  295. li r11,-16
  296. lvx v31,r11,r0
  297. blr
  298. #endif /* CONFIG_ALTIVEC */
  299. #else /* CONFIG_PPC64 */
  300. .section ".text.save.restore","ax",@progbits
  301. .globl _savegpr0_14
  302. _savegpr0_14:
  303. std r14,-144(r1)
  304. .globl _savegpr0_15
  305. _savegpr0_15:
  306. std r15,-136(r1)
  307. .globl _savegpr0_16
  308. _savegpr0_16:
  309. std r16,-128(r1)
  310. .globl _savegpr0_17
  311. _savegpr0_17:
  312. std r17,-120(r1)
  313. .globl _savegpr0_18
  314. _savegpr0_18:
  315. std r18,-112(r1)
  316. .globl _savegpr0_19
  317. _savegpr0_19:
  318. std r19,-104(r1)
  319. .globl _savegpr0_20
  320. _savegpr0_20:
  321. std r20,-96(r1)
  322. .globl _savegpr0_21
  323. _savegpr0_21:
  324. std r21,-88(r1)
  325. .globl _savegpr0_22
  326. _savegpr0_22:
  327. std r22,-80(r1)
  328. .globl _savegpr0_23
  329. _savegpr0_23:
  330. std r23,-72(r1)
  331. .globl _savegpr0_24
  332. _savegpr0_24:
  333. std r24,-64(r1)
  334. .globl _savegpr0_25
  335. _savegpr0_25:
  336. std r25,-56(r1)
  337. .globl _savegpr0_26
  338. _savegpr0_26:
  339. std r26,-48(r1)
  340. .globl _savegpr0_27
  341. _savegpr0_27:
  342. std r27,-40(r1)
  343. .globl _savegpr0_28
  344. _savegpr0_28:
  345. std r28,-32(r1)
  346. .globl _savegpr0_29
  347. _savegpr0_29:
  348. std r29,-24(r1)
  349. .globl _savegpr0_30
  350. _savegpr0_30:
  351. std r30,-16(r1)
  352. .globl _savegpr0_31
  353. _savegpr0_31:
  354. std r31,-8(r1)
  355. std r0,16(r1)
  356. blr
  357. .globl _restgpr0_14
  358. _restgpr0_14:
  359. ld r14,-144(r1)
  360. .globl _restgpr0_15
  361. _restgpr0_15:
  362. ld r15,-136(r1)
  363. .globl _restgpr0_16
  364. _restgpr0_16:
  365. ld r16,-128(r1)
  366. .globl _restgpr0_17
  367. _restgpr0_17:
  368. ld r17,-120(r1)
  369. .globl _restgpr0_18
  370. _restgpr0_18:
  371. ld r18,-112(r1)
  372. .globl _restgpr0_19
  373. _restgpr0_19:
  374. ld r19,-104(r1)
  375. .globl _restgpr0_20
  376. _restgpr0_20:
  377. ld r20,-96(r1)
  378. .globl _restgpr0_21
  379. _restgpr0_21:
  380. ld r21,-88(r1)
  381. .globl _restgpr0_22
  382. _restgpr0_22:
  383. ld r22,-80(r1)
  384. .globl _restgpr0_23
  385. _restgpr0_23:
  386. ld r23,-72(r1)
  387. .globl _restgpr0_24
  388. _restgpr0_24:
  389. ld r24,-64(r1)
  390. .globl _restgpr0_25
  391. _restgpr0_25:
  392. ld r25,-56(r1)
  393. .globl _restgpr0_26
  394. _restgpr0_26:
  395. ld r26,-48(r1)
  396. .globl _restgpr0_27
  397. _restgpr0_27:
  398. ld r27,-40(r1)
  399. .globl _restgpr0_28
  400. _restgpr0_28:
  401. ld r28,-32(r1)
  402. .globl _restgpr0_29
  403. _restgpr0_29:
  404. ld r0,16(r1)
  405. ld r29,-24(r1)
  406. mtlr r0
  407. ld r30,-16(r1)
  408. ld r31,-8(r1)
  409. blr
  410. .globl _restgpr0_30
  411. _restgpr0_30:
  412. ld r30,-16(r1)
  413. .globl _restgpr0_31
  414. _restgpr0_31:
  415. ld r0,16(r1)
  416. ld r31,-8(r1)
  417. mtlr r0
  418. blr
  419. #ifdef CONFIG_ALTIVEC
  420. /* Called with r0 pointing just beyond the end of the vector save area. */
  421. .globl _savevr_20
  422. _savevr_20:
  423. li r12,-192
  424. stvx v20,r12,r0
  425. .globl _savevr_21
  426. _savevr_21:
  427. li r12,-176
  428. stvx v21,r12,r0
  429. .globl _savevr_22
  430. _savevr_22:
  431. li r12,-160
  432. stvx v22,r12,r0
  433. .globl _savevr_23
  434. _savevr_23:
  435. li r12,-144
  436. stvx v23,r12,r0
  437. .globl _savevr_24
  438. _savevr_24:
  439. li r12,-128
  440. stvx v24,r12,r0
  441. .globl _savevr_25
  442. _savevr_25:
  443. li r12,-112
  444. stvx v25,r12,r0
  445. .globl _savevr_26
  446. _savevr_26:
  447. li r12,-96
  448. stvx v26,r12,r0
  449. .globl _savevr_27
  450. _savevr_27:
  451. li r12,-80
  452. stvx v27,r12,r0
  453. .globl _savevr_28
  454. _savevr_28:
  455. li r12,-64
  456. stvx v28,r12,r0
  457. .globl _savevr_29
  458. _savevr_29:
  459. li r12,-48
  460. stvx v29,r12,r0
  461. .globl _savevr_30
  462. _savevr_30:
  463. li r12,-32
  464. stvx v30,r12,r0
  465. .globl _savevr_31
  466. _savevr_31:
  467. li r12,-16
  468. stvx v31,r12,r0
  469. blr
  470. .globl _restvr_20
  471. _restvr_20:
  472. li r12,-192
  473. lvx v20,r12,r0
  474. .globl _restvr_21
  475. _restvr_21:
  476. li r12,-176
  477. lvx v21,r12,r0
  478. .globl _restvr_22
  479. _restvr_22:
  480. li r12,-160
  481. lvx v22,r12,r0
  482. .globl _restvr_23
  483. _restvr_23:
  484. li r12,-144
  485. lvx v23,r12,r0
  486. .globl _restvr_24
  487. _restvr_24:
  488. li r12,-128
  489. lvx v24,r12,r0
  490. .globl _restvr_25
  491. _restvr_25:
  492. li r12,-112
  493. lvx v25,r12,r0
  494. .globl _restvr_26
  495. _restvr_26:
  496. li r12,-96
  497. lvx v26,r12,r0
  498. .globl _restvr_27
  499. _restvr_27:
  500. li r12,-80
  501. lvx v27,r12,r0
  502. .globl _restvr_28
  503. _restvr_28:
  504. li r12,-64
  505. lvx v28,r12,r0
  506. .globl _restvr_29
  507. _restvr_29:
  508. li r12,-48
  509. lvx v29,r12,r0
  510. .globl _restvr_30
  511. _restvr_30:
  512. li r12,-32
  513. lvx v30,r12,r0
  514. .globl _restvr_31
  515. _restvr_31:
  516. li r12,-16
  517. lvx v31,r12,r0
  518. blr
  519. #endif /* CONFIG_ALTIVEC */
  520. #endif /* CONFIG_PPC64 */
  521. #endif