2005-04-16 15:20:36 -07:00
/ *
2005-11-07 00:59:12 -08:00
* arch/ s39 0 / k e r n e l / h e a d64 . S
2005-04-16 15:20:36 -07:00
*
2006-06-29 14:58:17 +02:00
* Copyright ( C ) I B M C o r p . 1 9 9 9 ,2 0 0 6
2005-11-07 00:59:12 -08:00
*
* Author( s ) : H a r t m u t P e n n e r < h p @de.ibm.com>
* Martin S c h w i d e f s k y < s c h w i d e f s k y @de.ibm.com>
* Rob v a n d e r H e i j < r v d h e i @iae.nl>
* 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-04-16 15:20:36 -07:00
*
* /
#
2005-11-07 00:59:12 -08:00
# startup- c o d e a t 0 x10 0 0 0 , r u n n i n g i n a b s o l u t e a d d r e s s i n g m o d e
2005-04-16 15:20:36 -07:00
# this i s c a l l e d e i t h e r b y t h e i p l l o a d e r o r d i r e c t l y b y P S W r e s t a r t
# or l i n l o a d o r S A L I P L
#
2006-06-29 14:58:17 +02:00
.org 0x10000
startup : basr % r13 ,0 # g e t b a s e
.LPG0 : l % r13 ,0 f - . L P G 0 ( % r13 )
b 0 ( % r13 )
0 : .long s t a r t u p _ c o n t i n u e
#
# params a t 1 0 4 0 0 ( s e t u p . h )
#
.org PARMAREA
.quad 0 # IPL_ D E V I C E
2006-09-20 15:58:41 +02:00
.quad 0 # INITRD_ S T A R T
.quad 0 # INITRD_ S I Z E
2006-06-29 14:58:17 +02:00
.org COMMAND_LINE
.byte " root= / d e v / r a m 0 r o "
.byte 0
.org 0x11000
startup_continue :
basr % r13 ,0 # g e t b a s e
2005-04-16 15:20:36 -07:00
.LPG1 : sll % r13 ,1 # r e m o v e h i g h o r d e r b i t
srl % r13 ,1
2006-06-29 14:58:17 +02:00
GET_ I P L _ D E V I C E
2005-04-16 15:20:36 -07:00
lhi % r1 ,1 # m o d e 1 = e s a m e
slr % r0 ,% r0 # s e t c p u i d t o z e r o
sigp % r1 ,% r0 ,0 x12 # s w i t c h t o e s a m e m o d e
sam6 4 # s w i t c h t o 64 b i t m o d e
lctlg % c0 ,% c15 ,. L c t l - . L P G 1 ( % r13 ) # l o a d c o n t r o l r e g i s t e r s
2006-06-29 14:58:17 +02:00
lg % r12 ,. L p a r m a d d r - . L P G 1 ( % r13 ) # p o i n t e r t o p a r a m e t e r a r e a
2005-04-16 15:20:36 -07:00
# move I P L d e v i c e t o l o w c o r e
mvc _ _ L C _ I P L D E V ( 4 ) ,I P L _ D E V I C E + 4 - P A R M A R E A ( % r12 )
#
# clear b s s m e m o r y
#
larl % r2 ,_ _ b s s _ s t a r t # s t a r t o f b s s s e g m e n t
larl % r3 ,_ e n d # e n d o f b s s s e g m e n t
sgr % r3 ,% r2 # l e n g t h o f b s s
sgr % r4 ,% r4 #
sgr % r5 ,% r5 # s e t s r c , l e n g t h a n d p a d t o z e r o
mvcle % r2 ,% r4 ,0 # c l e a r m e m
jo . - 4 # b r a n c h b a c k , i f n o t f i n i s h
l % r2 ,. L r c p - . L P G 1 ( % r13 ) # R e a d S C P f o r c e d c o m m a n d w o r d
.Lservicecall :
stosm . L p m a s k - . L P G 1 ( % r13 ) ,0 x01 # a u t h o r i z e e x t i n t e r r u p t s
stctg % r0 ,% r0 ,. L c r - . L P G 1 ( % r13 ) # g e t c r 0
la % r1 ,0 x20 0 # s e t b i t 22
og % r1 ,. L c r - . L P G 1 ( % r13 ) # o r o l d c r 0 w i t h r1
stg % r1 ,. L c r - . L P G 1 ( % r13 )
lctlg % r0 ,% r0 ,. L c r - . L P G 1 ( % r13 ) # l o a d m o d i f i e d c r 0
mvc _ _ L C _ E X T _ N E W _ P S W ( 8 ) ,. L p c m s k - . L P G 1 ( % r13 ) # s e t p o s t c a l l p s w
larl % r1 ,. L s c l p h
stg % r1 ,_ _ L C _ E X T _ N E W _ P S W + 8 # s e t h a n d l e r
2006-06-29 14:58:17 +02:00
larl % r4 ,. L s c c b # % r 4 i s o u r i n d e x f o r s c c b s t u f f
lgr % r1 ,% r4 # o u r s c c b
2005-04-16 15:20:36 -07:00
.insn rre,0 x b22 0 0 0 0 0 ,% r2 ,% r1 # s e r v i c e c a l l
ipm % r1
srl % r1 ,2 8 # g e t c c c o d e
xr % r3 ,% r3
chi % r1 ,3
be . L f c h u n k - . L P G 1 ( % r13 ) # l e a v e
chi % r1 ,2
be . L s e r v i c e c a l l - . L P G 1 ( % r13 )
2005-11-07 00:59:04 -08:00
lpswe . L w a i t s c l p - . L P G 1 ( % r13 )
2005-04-16 15:20:36 -07:00
.Lsclph :
2006-06-29 14:58:17 +02:00
lh % r1 ,. L s c c b r - . L s c c b ( % r4 )
2005-04-16 15:20:36 -07:00
chi % r1 ,0 x10 # 0x0010 i s t h e s u c e s s c o d e
je . L p r o c s c c b # l e t ' s p r o c e s s t h e s c c b
chi % r1 ,0 x1 f0
bne . L f c h u n k - . L P G 1 ( % r13 ) # u n h a n d l e d e r r o r c o d e
c % r2 ,. L r c p - . L P G 1 ( % r13 ) # D i d w e t r y R e a d S C P f o r c e d
bne . L f c h u n k - . L P G 1 ( % r13 ) # i f n o , g i v e u p
l % r2 ,. L r c p2 - . L P G 1 ( % r13 ) # t r y w i t h R e a d S C P
b . L s e r v i c e c a l l - . L P G 1 ( % r13 )
.Lprocsccb :
2005-06-21 17:16:30 -07:00
lghi % r1 ,0
2006-06-29 14:58:17 +02:00
icm % r1 ,3 ,. L s c p i n c r1 - . L s c c b ( % r4 ) # u s e t h i s o n e i f ! = 0
2005-06-21 17:16:30 -07:00
jnz . L s c n d
2006-06-29 14:58:17 +02:00
lg % r1 ,. L s c p i n c r2 - . L s c c b ( % r4 ) # o t h e r w i s e u s e t h i s o n e
2005-04-16 15:20:36 -07:00
.Lscnd :
xr % r3 ,% r3 # s a m e l o g i c
2006-06-29 14:58:17 +02:00
ic % r3 ,. L s c p a1 - . L s c c b ( % r4 )
2005-04-16 15:20:36 -07:00
chi % r3 ,0 x00
jne . L c o m p m e m
2006-06-29 14:58:17 +02:00
l % r3 ,. L s c p a2 - . L s c c b ( % r4 )
2005-04-16 15:20:36 -07:00
.Lcompmem :
mlgr % r2 ,% r1 # m e m i n M B o n 128 - b i t
l % r1 ,. L o n e m b - . L P G 1 ( % r13 )
mlgr % r2 ,% r1 # m e m s i z e i n b y t e s i n % r 3
b . L f c h u n k - . L P G 1 ( % r13 )
2005-10-30 15:00:11 -08:00
.align 4
2005-04-16 15:20:36 -07:00
.Lpmask :
.byte 0
.align 8
.Lcr :
.quad 0x00 # place h o l d e r f o r c r0
.Lwaitsclp :
2005-11-07 00:59:04 -08:00
.quad 0 x0 1 0 2 0 0 0 1 8 0 0 0 0 0 0 0 ,. L s c l p h
2005-04-16 15:20:36 -07:00
.Lrcp :
.int 0x00120001 # Read S C P f o r c e d c o d e
.Lrcp2 :
.int 0x00020001 # Read S C P c o d e
.Lonemb :
.int 0x100000
.Lfchunk :
# set p r o g r a m c h e c k n e w p s w m a s k
mvc _ _ L C _ P G M _ N E W _ P S W ( 8 ) ,. L p c m s k - . L P G 1 ( % r13 )
#
# find m e m o r y c h u n k s .
#
lgr % r9 ,% r3 # e n d o f m e m
larl % r1 ,. L c h k m e m # s e t p r o g r a m c h e c k a d d r e s s
stg % r1 ,_ _ L C _ P G M _ N E W _ P S W + 8
la % r1 ,1 # t e s t i n i n c r e m e n t s o f 128 K B
sllg % r1 ,% r1 ,1 7
larl % r3 ,m e m o r y _ c h u n k
slgr % r4 ,% r4 # s e t s t a r t o f c h u n k t o z e r o
slgr % r5 ,% r5 # s e t e n d o f c h u n k t o z e r o
slr % r6 ,% r6 # s e t a c c e s s c o d e t o z e r o
la % r10 ,M E M O R Y _ C H U N K S # n u m b e r o f c h u n k s
.Lloop :
tprot 0 ( % r5 ) ,0 # t e s t p r o t e c t i o n o f f i r s t b y t e
ipm % r7
srl % r7 ,2 8
clr % r6 ,% r7 # c o m p a r e c c w i t h l a s t a c c e s s c o d e
je . L s a m e
j . L c h k m e m
.Lsame :
algr % r5 ,% r1 # a d d 128 K B t o e n d o f c h u n k
# no n e e d t o c h e c k h e r e ,
brc 1 2 ,. L l o o p # t h i s i s t h e s a m e c h u n k
.Lchkmem : # > 1 6 EB o r t p r o t g o t a p r o g r a m c h e c k
clgr % r4 ,% r5 # c h u n k s i z e > 0 ?
je . L c h k l o o p
stg % r4 ,0 ( % r3 ) # s t o r e s t a r t a d d r e s s o f c h u n k
lgr % r0 ,% r5
slgr % r0 ,% r4
stg % r0 ,8 ( % r3 ) # s t o r e s i z e o f c h u n k
st % r6 ,2 0 ( % r3 ) # s t o r e t y p e o f c h u n k
la % r3 ,2 4 ( % r3 )
larl % r8 ,m e m o r y _ s i z e
stg % r5 ,0 ( % r8 ) # s t o r e m e m o r y s i z e
ahi % r10 ,- 1 # u p d a t e c h u n k n u m b e r
.Lchkloop :
lr % r6 ,% r7 # s e t a c c e s s c o d e t o l a s t c c
# we g o t a n e x c e p t i o n o r w e ' r e s t a r t i n g a n e w
# chunk , w e m u s t c h e c k i f w e s h o u l d
# still t r y t o f i n d v a l i d m e m o r y ( i f w e d e t e c t e d
# the a m o u n t o f a v a i l a b l e s t o r a g e ) , a n d i f w e
# have c h u n k s l e f t
lghi % r4 ,1
sllg % r4 ,% r4 ,3 1
clgr % r5 ,% r4
je . L h s a s k i p
xr % r0 , % r0
clgr % r0 , % r9 # d i d w e d e t e c t m e m o r y ?
je . L d o n e m e m # i f n o t , l e a v e
chi % r10 , 0 # d o w e h a v e c h u n k s l e f t ?
je . L d o n e m e m
.Lhsaskip :
algr % r5 ,% r1 # a d d 128 K B t o e n d o f c h u n k
lgr % r4 ,% r5 # p o t e n t i a l n e w c h u n k
clgr % r5 ,% r9 # s h o u l d w e g o o n ?
jl . L l o o p
.Ldonemem :
larl % r12 ,m a c h i n e _ f l a g s
#
# find o u t i f w e a r e r u n n i n g u n d e r V M
#
stidp _ _ L C _ C P U I D # s t o r e c p u i d
tm _ _ L C _ C P U I D ,0 x f f # r u n n i n g u n d e r V M ?
bno 0 f - . L P G 1 ( % r13 )
oi 7 ( % r12 ) ,1 # s e t V M f l a g
0 : lh % r0 ,_ _ L C _ C P U I D + 4 # g e t c p u v e r s i o n
chi % r0 ,0 x74 9 0 # r u n n i n g o n a P / 390 ?
bne 1 f - . L P G 1 ( % r13 )
oi 7 ( % r12 ) ,4 # s e t P / 390 f l a g
1 :
#
# find o u t i f w e h a v e t h e M V P G i n s t r u c t i o n
#
la % r1 ,0 f - . L P G 1 ( % r13 ) # s e t p r o g r a m c h e c k a d d r e s s
stg % r1 ,_ _ L C _ P G M _ N E W _ P S W + 8
sgr % r0 ,% r0
lghi % r1 ,0
lghi % r2 ,0
mvpg % r1 ,% r2 # t e s t M V P G i n s t r u c t i o n
oi 7 ( % r12 ) ,1 6 # s e t M V P G f l a g
0 :
#
# find o u t i f t h e d i a g 0 x44 w o r k s i n 6 4 b i t m o d e
#
la % r1 ,0 f - . L P G 1 ( % r13 ) # s e t p r o g r a m c h e c k a d d r e s s
stg % r1 ,_ _ L C _ P G M _ N E W _ P S W + 8
diag 0 ,0 ,0 x44 # t e s t d i a g 0x44
oi 7 ( % r12 ) ,3 2 # s e t d i a g 44 f l a g
0 :
#
# find o u t i f w e h a v e t h e I D T E i n s t r u c t i o n
#
la % r1 ,0 f - . L P G 1 ( % r13 ) # s e t p r o g r a m c h e c k a d d r e s s
stg % r1 ,_ _ L C _ P G M _ N E W _ P S W + 8
.long 0xb2b10000 # store f a c i l i t y l i s t
tm 0 x c8 ,0 x08 # c h e c k b i t f o r c l e a r i n g - b y - A S C E
bno 0 f - . L P G 1 ( % r13 )
lhi % r1 ,2 0 9 4
lhi % r2 ,0
.long 0xb98e2001
oi 7 ( % r12 ) ,0 x80 # s e t I D T E f l a g
0 :
lpswe . L e n t r y - . L P G 1 ( 1 3 ) # j u m p t o _ s t e x t i n p r i m a r y - s p a c e ,
# virtual a n d n e v e r r e t u r n . . .
.align 16
.Lentry : .quad 0 x0 0 0 0 0 0 0 1 8 0 0 0 0 0 0 0 ,_ s t e x t
.Lctl : .quad 0x04b50002 # cr0 : various t h i n g s
.quad 0 # cr1 : primary s p a c e s e g m e n t t a b l e
.quad .Lduct # cr2 : dispatchable u n i t c o n t r o l t a b l e
.quad 0 # cr3 : instruction a u t h o r i z a t i o n
.quad 0 # cr4 : instruction a u t h o r i z a t i o n
.quad 0xffffffffffffffff # cr5 : primary- a s t e o r i g i n
.quad 0 # cr6 : I/ O i n t e r r u p t s
.quad 0 # cr7 : secondary s p a c e s e g m e n t t a b l e
.quad 0 # cr8 : access r e g i s t e r s t r a n s l a t i o n
.quad 0 # cr9 : tracing o f f
.quad 0 # cr10 : tracing o f f
.quad 0 # cr11 : tracing o f f
.quad 0 # cr12 : tracing o f f
.quad 0 # cr13 : home s p a c e s e g m e n t t a b l e
.quad 0xc0000000 # cr14 : machine c h e c k h a n d l i n g o f f
.quad 0 # cr15 : linkage s t a c k o p e r a t i o n s
2006-06-29 14:58:17 +02:00
.Lduct : .long 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0
.long 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0
2005-04-16 15:20:36 -07:00
.Lpcmsk : .quad 0x0000000180000000
.L4malign : .quad 0xffffffffffc00000
.Lscan2g : .quad 0x80000000 + 0 x2 0 0 0 0 - 8 # 2 G B + 1 2 8 K - 8
.Lnop : .long 0x07000700
2006-06-29 14:58:17 +02:00
.Lparmaddr :
.quad PARMAREA
2005-04-16 15:20:36 -07:00
2006-07-18 13:44:57 +02:00
.org 0x12000
2005-04-16 15:20:36 -07:00
.Lsccb :
.hword 0x1000 # length, o n e p a g e
.byte 0 x0 0 ,0 x00 ,0 x00
.byte 0x80 # variable r e s p o n s e b i t s e t
.Lsccbr :
.hword 0x00 # response c o d e
.Lscpincr1 :
.hword 0x00
.Lscpa1 :
.byte 0x00
.fill 8 9 , 1 , 0
.Lscpa2 :
.int 0x00
.Lscpincr2 :
.quad 0x00
.fill 3 9 8 4 , 1 , 0
2006-07-18 13:44:57 +02:00
.org 0x13000
2005-10-30 15:00:11 -08:00
2005-04-16 15:20:36 -07:00
# ifdef C O N F I G _ S H A R E D _ K E R N E L
.org 0x100000
# endif
#
2006-06-29 14:58:17 +02:00
# startup- c o d e , r u n n i n g i n a b s o l u t e a d d r e s s i n g m o d e
2005-04-16 15:20:36 -07:00
#
.globl _stext
_stext : basr % r13 ,0 # g e t b a s e
2005-10-30 15:00:11 -08:00
.LPG3 :
2005-04-16 15:20:36 -07:00
#
# Setup s t a c k
#
larl % r15 ,i n i t _ t h r e a d _ u n i o n
lg % r14 ,_ _ T I _ t a s k ( % r15 ) # c a c h e c u r r e n t i n l o w c o r e
stg % r14 ,_ _ L C _ C U R R E N T
aghi % r15 ,1 < < ( P A G E _ S H I F T + T H R E A D _ O R D E R ) # i n i t _ t a s k _ u n i o n + T H R E A D _ S I Z E
stg % r15 ,_ _ L C _ K E R N E L _ S T A C K # s e t e n d o f k e r n e l s t a c k
aghi % r15 ,- 1 6 0
xc _ _ S F _ B A C K C H A I N ( 4 ,% r15 ) ,_ _ S F _ B A C K C H A I N ( % r15 ) # c l e a r b a c k c h a i n
# check c o n t r o l r e g i s t e r s
stctg % c0 ,% c15 ,0 ( % r15 )
2005-07-27 11:45:00 -07:00
oi 6 ( % r15 ) ,0 x40 # e n a b l e s i g p e m e r g e n c y s i g n a l
2005-04-16 15:20:36 -07:00
oi 4 ( % r15 ) ,0 x10 # s w i t c h o n l o w a d d r e s s p r o c t e c t i o n
lctlg % c0 ,% c15 ,0 ( % r15 )
#
2005-10-30 15:00:11 -08:00
lam 0 ,1 5 ,. L a r e g s - . L P G 3 ( % r13 ) # l o a d a c c e s s r e g s n e e d e d b y u a c c e s s
2005-04-16 15:20:36 -07:00
brasl % r14 ,s t a r t _ k e r n e l # g o t o C c o d e
#
# We r e t u r n e d f r o m s t a r t _ k e r n e l ? ! ? P A N I K
#
basr % r13 ,0
lpswe . L d w - . ( % r13 ) # l o a d d i s a b l e d w a i t p s w
#
.align 8
.Ldw : .quad 0 x0 0 0 2 0 0 0 1 8 0 0 0 0 0 0 0 ,0 x00 0 0 0 0 0 0 0 0 0 0 0 0 0 0
.Laregs : .long 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0