2019-05-27 09:55:01 +03:00
/* SPDX-License-Identifier: GPL-2.0-or-later */
2005-10-10 16:36:14 +04:00
/ *
* PowerPC v e r s i o n
* Copyright ( C ) 1 9 9 5 - 1 9 9 6 G a r y T h o m a s ( g d t @linuxppc.org)
* Rewritten b y C o r t D o u g a n ( c o r t @cs.nmt.edu) for PReP
* Copyright ( C ) 1 9 9 6 C o r t D o u g a n < c o r t @cs.nmt.edu>
* Adapted f o r P o w e r M a c i n t o s h b y P a u l M a c k e r r a s .
* Low- l e v e l e x c e p t i o n h a n d l e r s a n d M M U s u p p o r t
* rewritten b y P a u l M a c k e r r a s .
* Copyright ( C ) 1 9 9 6 P a u l M a c k e r r a s .
* MPC8 x x m o d i f i c a t i o n s C o p y r i g h t ( C ) 1 9 9 7 D a n M a l e k ( d m a l e k @jlc.net).
*
2023-06-06 16:24:47 +03:00
* This f i l e c o n t a i n s t h e 6 4 - b i t p r o m e n t r y c o d e .
2005-10-10 16:36:14 +04:00
* /
# include < a s m / a s m - o f f s e t s . h >
2018-01-09 19:07:15 +03:00
# ifdef C O N F I G _ P P C _ B O O K 3 S
# include < a s m / e x c e p t i o n - 6 4 s . h >
# else
# include < a s m / e x c e p t i o n - 6 4 e . h >
# endif
2023-06-06 16:24:47 +03:00
# include < a s m / p p c _ a s m . h >
2005-10-10 16:36:14 +04:00
2023-06-06 16:24:47 +03:00
.section " .text " , " ax" ,@progbits
2012-08-31 23:48:05 +04:00
2005-10-10 16:36:14 +04:00
_ GLOBAL( e n t e r _ p r o m )
mflr r0
std r0 ,1 6 ( r1 )
2018-10-12 05:44:06 +03:00
stdu r1 ,- S W I T C H _ F R A M E _ S I Z E ( r1 ) / * S a v e S P a n d c r e a t e s t a c k s p a c e * /
2005-10-10 16:36:14 +04:00
/ * Because P R O M i s r u n n i n g i n 3 2 b m o d e , i t c l o b b e r s t h e h i g h o r d e r h a l f
* of a l l r e g i s t e r s t h a t i t s a v e s . W e t h e r e f o r e s a v e t h o s e r e g i s t e r s
* PROM m i g h t t o u c h t o t h e s t a c k . ( r0 , r3 - r13 a r e c a l l e r s a v e d )
* /
2009-07-24 03:15:07 +04:00
SAVE_ G P R ( 2 , r1 )
2005-10-10 16:36:14 +04:00
SAVE_ G P R ( 1 3 , r1 )
2019-12-11 05:35:52 +03:00
SAVE_ N V G P R S ( r1 )
2009-07-24 03:15:07 +04:00
mfcr r10
2005-10-10 16:36:14 +04:00
mfmsr r11
2009-07-24 03:15:07 +04:00
std r10 ,_ C C R ( r1 )
2005-10-10 16:36:14 +04:00
std r11 ,_ M S R ( r1 )
2013-09-23 06:04:45 +04:00
/* Put PROM address in SRR0 */
mtsrr0 r4
/* Setup our trampoline return addr in LR */
bcl 2 0 ,3 1 ,$ + 4
0 : mflr r4
addi r4 ,r4 ,( 1 f - 0 b )
mtlr r4
2005-10-10 16:36:14 +04:00
2013-09-23 06:04:45 +04:00
/ * Prepare a 3 2 - b i t m o d e b i g e n d i a n M S R
2005-10-10 16:36:14 +04:00
* /
2022-09-19 20:01:33 +03:00
# ifdef C O N F I G _ P P C _ B O O K 3 E _ 6 4
2009-07-24 03:15:59 +04:00
rlwinm r11 ,r11 ,0 ,1 ,3 1
2013-09-23 06:04:45 +04:00
mtsrr1 r11
rfi
2022-09-19 20:01:33 +03:00
# else / * C O N F I G _ P P C _ B O O K 3 E _ 6 4 * /
2020-11-06 07:53:40 +03:00
LOAD_ R E G _ I M M E D I A T E ( r12 , M S R _ S F | M S R _ L E )
2013-09-23 06:04:45 +04:00
andc r11 ,r11 ,r12
mtsrr1 r11
2018-01-09 19:07:15 +03:00
RFI_ T O _ K E R N E L
2022-09-19 20:01:33 +03:00
# endif / * C O N F I G _ P P C _ B O O K 3 E _ 6 4 * /
2005-10-10 16:36:14 +04:00
2013-09-23 06:04:45 +04:00
1 : /* Return from OF */
FIXUP_ E N D I A N
2005-10-10 16:36:14 +04:00
/ * Just m a k e s u r e t h a t r1 t o p 3 2 b i t s d i d n ' t g e t
* corrupt b y O F
* /
rldicl r1 ,r1 ,0 ,3 2
/* Restore the MSR (back to 64 bits) */
ld r0 ,_ M S R ( r1 )
2009-07-24 03:15:07 +04:00
MTMSRD( r0 )
2005-10-10 16:36:14 +04:00
isync
/* Restore other registers */
REST_ G P R ( 2 , r1 )
REST_ G P R ( 1 3 , r1 )
2019-12-11 05:35:52 +03:00
REST_ N V G P R S ( r1 )
2005-10-10 16:36:14 +04:00
ld r4 ,_ C C R ( r1 )
mtcr r4
2018-10-12 05:44:06 +03:00
addi r1 ,r1 ,S W I T C H _ F R A M E _ S I Z E
2005-10-10 16:36:14 +04:00
ld r0 ,1 6 ( r1 )
mtlr r0
blr