2005-06-25 14:58:11 -07:00
/ *
2012-07-20 11:15:04 +02:00
* Copyright I B M C o r p . 2 0 0 5
2005-06-25 14:58:11 -07:00
*
2006-09-28 16:56:37 +02:00
* Author( s ) : R o l f A d e l s b e r g e r ,
2005-08-01 21:11:33 -07:00
* Heiko C a r s t e n s < h e i k o . c a r s t e n s @de.ibm.com>
2005-06-25 14:58:11 -07:00
*
* /
2011-07-24 10:48:19 +02:00
# include < l i n u x / l i n k a g e . h >
2012-06-04 15:05:43 +02:00
# include < a s m / s i g p . h >
2011-07-24 10:48:19 +02:00
2005-06-25 14:58:11 -07:00
/ *
* moves t h e n e w k e r n e l t o i t s d e s t i n a t i o n . . .
* % r2 = p o i n t e r t o f i r s t k i m a g e _ e n t r y _ t
* % r3 = s t a r t a d d r e s s - w h e r e t o j u m p t o a f t e r t h e j o b i s d o n e . . .
*
* % r5 w i l l b e u s e d a s t e m p . s t o r a g e
* % r6 h o l d s t h e d e s t i n a t i o n a d d r e s s
* % r7 = P A G E _ S I Z E
* % r8 h o l d s t h e s o u r c e a d d r e s s
* % r9 = P A G E _ S I Z E
*
* 0 xf0 0 0 i s a p a g e _ m a s k
* /
.text
2011-07-24 10:48:19 +02:00
ENTRY( r e l o c a t e _ k e r n e l )
2006-09-28 16:56:37 +02:00
basr % r13 ,0 # b a s e a d d r e s s
2005-06-25 14:58:11 -07:00
.base :
2006-12-04 15:40:26 +01:00
stnsm s y s _ m s k - . b a s e ( % r13 ) ,0 x f b # d i s a b l e D A T
2005-08-01 21:11:33 -07:00
stctg % c0 ,% c15 ,c t l r e g s - . b a s e ( % r13 )
stmg % r0 ,% r15 ,g p r r e g s - . b a s e ( % r13 )
lghi % r0 ,3
sllg % r0 ,% r0 ,3 1
stg % r0 ,0 x1 d0 ( % r0 )
la % r0 ,. b a c k _ p g m - . b a s e ( % r13 )
stg % r0 ,0 x1 d8 ( % r0 )
la % r1 ,l o a d _ p s w - . b a s e ( % r13 )
2006-09-28 16:56:37 +02:00
mvc 0 ( 8 ,% r0 ) ,0 ( % r1 )
2005-08-01 21:11:33 -07:00
la % r0 ,. b a c k - . b a s e ( % r13 )
st % r0 ,4 ( % r0 )
oi 4 ( % r0 ) ,0 x80
lghi % r0 ,0
diag % r0 ,% r0 ,0 x30 8
.back :
2006-09-28 16:56:37 +02:00
lhi % r1 ,1 # m o d e 1 = e s a m e
2012-06-04 15:05:43 +02:00
sigp % r1 ,% r0 ,S I G P _ S E T _ A R C H I T E C T U R E # s w i t c h t o e s a m e m o d e
2006-09-28 16:56:37 +02:00
sam6 4 # s w i t c h t o 64 b i t a d d r e s s i n g m o d e
2005-08-01 21:11:33 -07:00
basr % r13 ,0
.back_base :
oi h a v e _ d i a g 3 0 8 - . b a c k _ b a s e ( % r13 ) ,0 x01
lctlg % c0 ,% c15 ,c t l r e g s - . b a c k _ b a s e ( % r13 )
lmg % r0 ,% r15 ,g p r r e g s - . b a c k _ b a s e ( % r13 )
j . t o p
.back_pgm :
lmg % r0 ,% r15 ,g p r r e g s - . b a s e ( % r13 )
2005-06-25 14:58:11 -07:00
.top :
2006-09-28 16:56:37 +02:00
lghi % r7 ,4 0 9 6 # l o a d P A G E _ S I Z E i n r 7
lghi % r9 ,4 0 9 6 # l o a d P A G E _ S I Z E i n r 9
lg % r5 ,0 ( % r2 ) # r e a d a n o t h e r w o r d f o r i n d i r e c t i o n p a g e
aghi % r2 ,8 # i n c r e m e n t p o i n t e r
tml % r5 ,0 x1 # i s i t a d e s t i n a t i o n p a g e ?
je . i n d i r _ c h e c k # N O , g o t o " indir_check "
lgr % r6 ,% r5 # r 6 = r5
nill % r6 ,0 x f00 0 # m a s k i t o u t a n d . . .
j . t o p # . . . n e x t i t e r a t i o n
2005-06-25 14:58:11 -07:00
.indir_check :
2006-09-28 16:56:37 +02:00
tml % r5 ,0 x2 # i s i t a i n d i r e c t i o n p a g e ?
je . d o n e _ t e s t # N O , g o t o " done_test "
nill % r5 ,0 x f00 0 # Y E S , m a s k o u t ,
lgr % r2 ,% r5 # m o v e i t i n t o t h e r i g h t r e g i s t e r ,
j . t o p # a n d r e a d n e x t . . .
2005-06-25 14:58:11 -07:00
.done_test :
2006-09-28 16:56:37 +02:00
tml % r5 ,0 x4 # i s i t t h e d o n e i n d i c a t o r ?
je . s o u r c e _ t e s t # N O ! W e l l , t h e n i t s h o u l d b e t h e s o u r c e i n d i c a t o r . . .
j . d o n e # o k , l e t s f i n i s h i t h e r e . . .
2005-06-25 14:58:11 -07:00
.source_test :
2006-09-28 16:56:37 +02:00
tml % r5 ,0 x8 # i t s h o u l d b e a s o u r c e i n d i c a t o r . . .
je . t o p # N O , i g n o r e i t . . .
lgr % r8 ,% r5 # r 8 = r5
nill % r8 ,0 x f00 0 # m a s k i n g
0 : mvcle % r6 ,% r8 ,0 x0 # c o p y P A G E _ S I Z E b y t e s f r o m r 8 t o r6 - p a d w i t h 0
2005-06-25 14:58:11 -07:00
jo 0 b
2006-09-28 16:56:37 +02:00
j . t o p
2005-06-25 14:58:11 -07:00
.done :
2006-09-28 16:56:37 +02:00
sgr % r0 ,% r0 # c l e a r r e g i s t e r r 0
la % r4 ,l o a d _ p s w - . b a s e ( % r13 ) # l o a d p s w - a d d r e s s i n t o t h e r e g i s t e r
o % r3 ,4 ( % r4 ) # o r l o a d a d d r e s s i n t o p s w
2005-06-25 14:58:11 -07:00
st % r3 ,4 ( % r4 )
2006-09-28 16:56:37 +02:00
mvc 0 ( 8 ,% r0 ) ,0 ( % r4 ) # c o p y p s w t o a b s o l u t e a d d r e s s 0
2005-08-01 21:11:33 -07:00
tm h a v e _ d i a g 3 0 8 - . b a s e ( % r13 ) ,0 x01
jno . n o _ d i a g 3 0 8
diag % r0 ,% r0 ,0 x30 8
.no_diag308 :
2006-09-28 16:56:37 +02:00
sam3 1 # 31 b i t m o d e
sr % r1 ,% r1 # e r a s e r e g i s t e r r 1
sr % r2 ,% r2 # e r a s e r e g i s t e r r 2
2012-06-04 15:05:43 +02:00
sigp % r1 ,% r2 ,S I G P _ S E T _ A R C H I T E C T U R E # s e t c p u i d t o z e r o
2006-09-28 16:56:37 +02:00
lpsw 0 # h o p e f u l l y s t a r t n e w k e r n e l . . .
2005-06-25 14:58:11 -07:00
2006-09-28 16:56:37 +02:00
.align 8
2005-06-25 14:58:11 -07:00
load_psw :
.long 0 x0 0 0 8 0 0 0 0 ,0 x80 0 0 0 0 0 0
sys_msk :
.quad 0
2005-08-01 21:11:33 -07:00
ctlregs :
.rept 16
.quad 0
.endr
gprregs :
.rept 16
.quad 0
.endr
have_diag308 :
.byte 0
.align 8
2005-06-25 14:58:11 -07:00
relocate_kernel_end :
2011-07-24 10:48:19 +02:00
.align 8
2005-06-25 14:58:11 -07:00
.globl relocate_kernel_len
relocate_kernel_len :
.quad relocate_kernel_end - relocate_ k e r n e l