2005-06-26 01:58:11 +04:00
/ *
* arch/ s39 0 / k e r n e l / r e l o c a t e _ k e r n e l . S
*
* ( C) C o p y r i g h t I B M C o r p . 2 0 0 5
*
2006-09-28 18:56:37 +04:00
* Author( s ) : R o l f A d e l s b e r g e r ,
2005-08-02 08:11:33 +04: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-26 01:58:11 +04:00
*
* /
2011-07-24 12:48:19 +04:00
# include < l i n u x / l i n k a g e . h >
2005-06-26 01:58:11 +04: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
* % r1 0 i s a p a g e m a s k
* /
.text
2011-07-24 12:48:19 +04:00
ENTRY( r e l o c a t e _ k e r n e l )
2006-09-28 18:56:37 +04:00
basr % r13 ,0 # b a s e a d d r e s s
2005-06-26 01:58:11 +04:00
.base :
2006-12-04 17:40:26 +03: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-02 08:11:33 +04:00
stctl % c0 ,% c15 ,c t l r e g s - . b a s e ( % r13 )
stm % r0 ,% r15 ,g p r r e g s - . b a s e ( % r13 )
la % r1 ,l o a d _ p s w - . b a s e ( % r13 )
2006-09-28 18:56:37 +04:00
mvc 0 ( 8 ,% r0 ) ,0 ( % r1 )
2005-08-02 08:11:33 +04:00
la % r0 ,. b a c k - . b a s e ( % r13 )
st % r0 ,4 ( % r0 )
oi 4 ( % r0 ) ,0 x80
mvc 0 x68 ( 8 ,% r0 ) ,0 ( % r1 )
la % r0 ,. b a c k _ p g m - . b a s e ( % r13 )
st % r0 ,0 x6 c ( % r0 )
oi 0 x6 c ( % r0 ) ,0 x80
lhi % r0 ,0
diag % r0 ,% r0 ,0 x30 8
.back :
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
lctl % c0 ,% c15 ,c t l r e g s - . b a c k _ b a s e ( % r13 )
lm % r0 ,% r15 ,g p r r e g s - . b a c k _ b a s e ( % r13 )
j . s t a r t _ r e l o c
.back_pgm :
lm % r0 ,% r15 ,g p r r e g s - . b a s e ( % r13 )
.start_reloc :
2006-09-28 18:56:37 +04:00
lhi % r10 ,- 1 # p r e p a r i n g t h e m a s k
sll % r10 ,1 2 # s h i f t i t s u c h t h a t i t b e c o m e s 0xf000
2005-06-26 01:58:11 +04:00
.top :
2006-09-28 18:56:37 +04:00
lhi % r7 ,4 0 9 6 # l o a d P A G E _ S I Z E i n r 7
lhi % r9 ,4 0 9 6 # l o a d P A G E _ S I Z E i n r 9
l % 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
ahi % r2 ,4 # 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 "
lr % r6 ,% r5 # r 6 = r5
nr % r6 ,% r10 # 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-26 01:58:11 +04:00
.indir_check :
2006-09-28 18:56:37 +04: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 "
nr % r5 ,% r10 # Y E S , m a s k o u t ,
lr % 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-26 01:58:11 +04:00
.done_test :
2006-09-28 18:56:37 +04: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-26 01:58:11 +04:00
.source_test :
2006-09-28 18:56:37 +04: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 . . .
lr % r8 ,% r5 # r 8 = r5
nr % r8 ,% r10 # 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-26 01:58:11 +04:00
jo 0 b
j . t o p
.done :
2006-09-28 18:56:37 +04:00
sr % 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-26 01:58:11 +04:00
st % r3 ,4 ( % r4 )
2006-09-28 18:56:37 +04: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-02 08:11:33 +04: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 18:56:37 +04:00
sr % r1 ,% r1 # c l e a r % r 1
sr % r2 ,% r2 # c l e a r % r 2
sigp % r1 ,% r2 ,0 x12 # s e t c p u i d t o z e r o
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-26 01:58:11 +04:00
.align 8
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-02 08:11:33 +04:00
ctlregs :
.rept 16
.long 0
.endr
gprregs :
.rept 16
.long 0
.endr
have_diag308 :
.byte 0
.align 8
2005-06-26 01:58:11 +04:00
relocate_kernel_end :
2011-07-24 12:48:19 +04:00
.align 8
2005-06-26 01:58:11 +04:00
.globl relocate_kernel_len
relocate_kernel_len :
.quad relocate_kernel_end - relocate_ k e r n e l