crtsavres.S 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  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. .section ".text"
  44. #ifndef CONFIG_PPC64
  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. .globl _savegpr0_14
  301. _savegpr0_14:
  302. std r14,-144(r1)
  303. .globl _savegpr0_15
  304. _savegpr0_15:
  305. std r15,-136(r1)
  306. .globl _savegpr0_16
  307. _savegpr0_16:
  308. std r16,-128(r1)
  309. .globl _savegpr0_17
  310. _savegpr0_17:
  311. std r17,-120(r1)
  312. .globl _savegpr0_18
  313. _savegpr0_18:
  314. std r18,-112(r1)
  315. .globl _savegpr0_19
  316. _savegpr0_19:
  317. std r19,-104(r1)
  318. .globl _savegpr0_20
  319. _savegpr0_20:
  320. std r20,-96(r1)
  321. .globl _savegpr0_21
  322. _savegpr0_21:
  323. std r21,-88(r1)
  324. .globl _savegpr0_22
  325. _savegpr0_22:
  326. std r22,-80(r1)
  327. .globl _savegpr0_23
  328. _savegpr0_23:
  329. std r23,-72(r1)
  330. .globl _savegpr0_24
  331. _savegpr0_24:
  332. std r24,-64(r1)
  333. .globl _savegpr0_25
  334. _savegpr0_25:
  335. std r25,-56(r1)
  336. .globl _savegpr0_26
  337. _savegpr0_26:
  338. std r26,-48(r1)
  339. .globl _savegpr0_27
  340. _savegpr0_27:
  341. std r27,-40(r1)
  342. .globl _savegpr0_28
  343. _savegpr0_28:
  344. std r28,-32(r1)
  345. .globl _savegpr0_29
  346. _savegpr0_29:
  347. std r29,-24(r1)
  348. .globl _savegpr0_30
  349. _savegpr0_30:
  350. std r30,-16(r1)
  351. .globl _savegpr0_31
  352. _savegpr0_31:
  353. std r31,-8(r1)
  354. std r0,16(r1)
  355. blr
  356. .globl _restgpr0_14
  357. _restgpr0_14:
  358. ld r14,-144(r1)
  359. .globl _restgpr0_15
  360. _restgpr0_15:
  361. ld r15,-136(r1)
  362. .globl _restgpr0_16
  363. _restgpr0_16:
  364. ld r16,-128(r1)
  365. .globl _restgpr0_17
  366. _restgpr0_17:
  367. ld r17,-120(r1)
  368. .globl _restgpr0_18
  369. _restgpr0_18:
  370. ld r18,-112(r1)
  371. .globl _restgpr0_19
  372. _restgpr0_19:
  373. ld r19,-104(r1)
  374. .globl _restgpr0_20
  375. _restgpr0_20:
  376. ld r20,-96(r1)
  377. .globl _restgpr0_21
  378. _restgpr0_21:
  379. ld r21,-88(r1)
  380. .globl _restgpr0_22
  381. _restgpr0_22:
  382. ld r22,-80(r1)
  383. .globl _restgpr0_23
  384. _restgpr0_23:
  385. ld r23,-72(r1)
  386. .globl _restgpr0_24
  387. _restgpr0_24:
  388. ld r24,-64(r1)
  389. .globl _restgpr0_25
  390. _restgpr0_25:
  391. ld r25,-56(r1)
  392. .globl _restgpr0_26
  393. _restgpr0_26:
  394. ld r26,-48(r1)
  395. .globl _restgpr0_27
  396. _restgpr0_27:
  397. ld r27,-40(r1)
  398. .globl _restgpr0_28
  399. _restgpr0_28:
  400. ld r28,-32(r1)
  401. .globl _restgpr0_29
  402. _restgpr0_29:
  403. ld r0,16(r1)
  404. ld r29,-24(r1)
  405. mtlr r0
  406. ld r30,-16(r1)
  407. ld r31,-8(r1)
  408. blr
  409. .globl _restgpr0_30
  410. _restgpr0_30:
  411. ld r30,-16(r1)
  412. .globl _restgpr0_31
  413. _restgpr0_31:
  414. ld r0,16(r1)
  415. ld r31,-8(r1)
  416. mtlr r0
  417. blr
  418. #ifdef CONFIG_ALTIVEC
  419. /* Called with r0 pointing just beyond the end of the vector save area. */
  420. .globl _savevr_20
  421. _savevr_20:
  422. li r12,-192
  423. stvx v20,r12,r0
  424. .globl _savevr_21
  425. _savevr_21:
  426. li r12,-176
  427. stvx v21,r12,r0
  428. .globl _savevr_22
  429. _savevr_22:
  430. li r12,-160
  431. stvx v22,r12,r0
  432. .globl _savevr_23
  433. _savevr_23:
  434. li r12,-144
  435. stvx v23,r12,r0
  436. .globl _savevr_24
  437. _savevr_24:
  438. li r12,-128
  439. stvx v24,r12,r0
  440. .globl _savevr_25
  441. _savevr_25:
  442. li r12,-112
  443. stvx v25,r12,r0
  444. .globl _savevr_26
  445. _savevr_26:
  446. li r12,-96
  447. stvx v26,r12,r0
  448. .globl _savevr_27
  449. _savevr_27:
  450. li r12,-80
  451. stvx v27,r12,r0
  452. .globl _savevr_28
  453. _savevr_28:
  454. li r12,-64
  455. stvx v28,r12,r0
  456. .globl _savevr_29
  457. _savevr_29:
  458. li r12,-48
  459. stvx v29,r12,r0
  460. .globl _savevr_30
  461. _savevr_30:
  462. li r12,-32
  463. stvx v30,r12,r0
  464. .globl _savevr_31
  465. _savevr_31:
  466. li r12,-16
  467. stvx v31,r12,r0
  468. blr
  469. .globl _restvr_20
  470. _restvr_20:
  471. li r12,-192
  472. lvx v20,r12,r0
  473. .globl _restvr_21
  474. _restvr_21:
  475. li r12,-176
  476. lvx v21,r12,r0
  477. .globl _restvr_22
  478. _restvr_22:
  479. li r12,-160
  480. lvx v22,r12,r0
  481. .globl _restvr_23
  482. _restvr_23:
  483. li r12,-144
  484. lvx v23,r12,r0
  485. .globl _restvr_24
  486. _restvr_24:
  487. li r12,-128
  488. lvx v24,r12,r0
  489. .globl _restvr_25
  490. _restvr_25:
  491. li r12,-112
  492. lvx v25,r12,r0
  493. .globl _restvr_26
  494. _restvr_26:
  495. li r12,-96
  496. lvx v26,r12,r0
  497. .globl _restvr_27
  498. _restvr_27:
  499. li r12,-80
  500. lvx v27,r12,r0
  501. .globl _restvr_28
  502. _restvr_28:
  503. li r12,-64
  504. lvx v28,r12,r0
  505. .globl _restvr_29
  506. _restvr_29:
  507. li r12,-48
  508. lvx v29,r12,r0
  509. .globl _restvr_30
  510. _restvr_30:
  511. li r12,-32
  512. lvx v30,r12,r0
  513. .globl _restvr_31
  514. _restvr_31:
  515. li r12,-16
  516. lvx v31,r12,r0
  517. blr
  518. #endif /* CONFIG_ALTIVEC */
  519. #endif /* CONFIG_PPC64 */
  520. #endif