2009-06-16 10:30:52 +02:00
/ *
* S3 9 0 6 4 - b i t s w s u s p i m p l e m e n t a t i o n
*
* Copyright I B M C o r p . 2 0 0 9
*
* Author( s ) : H a n s - J o a c h i m P i c h t < h a n s @linux.vnet.ibm.com>
* Michael H o l z h e u < h o l z h e u @linux.vnet.ibm.com>
* /
# include < a s m / p a g e . h >
# include < a s m / p t r a c e . h >
# include < a s m / a s m - o f f s e t s . h >
/ *
* Save r e g i s t e r c o n t e x t i n a b s o l u t e 0 l o w c o r e a n d c a l l s w s u s p _ s a v e ( ) t o
* create i n - m e m o r y k e r n e l i m a g e . T h e c o n t e x t i s s a v e d i n t h e d e s i g n a t e d
* " store s t a t u s " m e m o r y l o c a t i o n s ( s e e P O P ) .
* We r e t u r n f r o m t h i s f u n c t i o n t w i c e . T h e f i r s t t i m e d u r i n g t h e s u s p e n d t o
* disk p r o c e s s . T h e s e c o n d t i m e v i a t h e s w s u s p _ a r c h _ r e s u m e ( ) f u n c t i o n
* ( see b e l o w ) i n t h e r e s u m e p r o c e s s .
* This f u n c t i o n r u n s w i t h d i s a b l e d i n t e r r u p t s .
* /
.section .text
2009-09-11 10:28:37 +02:00
.align 4
2009-06-16 10:30:52 +02:00
.globl swsusp_arch_suspend
swsusp_arch_suspend :
stmg % r6 ,% r15 ,_ _ S F _ G P R S ( % r15 )
lgr % r1 ,% r15
aghi % r15 ,- S T A C K _ F R A M E _ O V E R H E A D
stg % r1 ,_ _ S F _ B A C K C H A I N ( % r15 )
/* Deactivate DAT */
stnsm _ _ S F _ E M P T Y ( % r15 ) ,0 x f b
/* Store prefix register on stack */
stpx _ _ S F _ E M P T Y ( % r15 )
2009-07-24 12:39:49 +02:00
/* Save prefix register contents for lowcore */
llgf % r4 ,_ _ S F _ E M P T Y ( % r15 )
2009-06-16 10:30:52 +02:00
/* Get pointer to save area */
2009-07-24 12:39:49 +02:00
lghi % r1 ,0 x10 0 0
2009-06-16 10:30:52 +02:00
/* Store registers */
mvc 0 x31 8 ( 4 ,% r1 ) ,_ _ S F _ E M P T Y ( % r15 ) / * m o v e p r e f i x t o l o w c o r e * /
stfpc 0 x31 c ( % r1 ) / * s t o r e f p u c o n t r o l * /
std 0 ,0 x20 0 ( % r1 ) / * s t o r e f0 * /
std 1 ,0 x20 8 ( % r1 ) / * s t o r e f1 * /
std 2 ,0 x21 0 ( % r1 ) / * s t o r e f2 * /
std 3 ,0 x21 8 ( % r1 ) / * s t o r e f3 * /
std 4 ,0 x22 0 ( % r1 ) / * s t o r e f4 * /
std 5 ,0 x22 8 ( % r1 ) / * s t o r e f5 * /
std 6 ,0 x23 0 ( % r1 ) / * s t o r e f6 * /
std 7 ,0 x23 8 ( % r1 ) / * s t o r e f7 * /
std 8 ,0 x24 0 ( % r1 ) / * s t o r e f8 * /
std 9 ,0 x24 8 ( % r1 ) / * s t o r e f9 * /
std 1 0 ,0 x25 0 ( % r1 ) / * s t o r e f10 * /
std 1 1 ,0 x25 8 ( % r1 ) / * s t o r e f11 * /
std 1 2 ,0 x26 0 ( % r1 ) / * s t o r e f12 * /
std 1 3 ,0 x26 8 ( % r1 ) / * s t o r e f13 * /
std 1 4 ,0 x27 0 ( % r1 ) / * s t o r e f14 * /
std 1 5 ,0 x27 8 ( % r1 ) / * s t o r e f15 * /
stam % a0 ,% a15 ,0 x34 0 ( % r1 ) / * s t o r e a c c e s s r e g i s t e r s * /
stctg % c0 ,% c15 ,0 x38 0 ( % r1 ) / * s t o r e c o n t r o l r e g i s t e r s * /
stmg % r0 ,% r15 ,0 x28 0 ( % r1 ) / * s t o r e g e n e r a l r e g i s t e r s * /
stpt 0 x32 8 ( % r1 ) / * s t o r e t i m e r * /
stckc 0 x33 0 ( % r1 ) / * s t o r e c l o c k c o m p a r a t o r * /
/* Activate DAT */
stosm _ _ S F _ E M P T Y ( % r15 ) ,0 x04
/* Set prefix page to zero */
xc _ _ S F _ E M P T Y ( 4 ,% r15 ) ,_ _ S F _ E M P T Y ( % r15 )
spx _ _ S F _ E M P T Y ( % r15 )
2009-07-24 12:39:49 +02:00
lghi % r2 ,0
lghi % r3 ,2 * P A G E _ S I Z E
lghi % r5 ,2 * P A G E _ S I Z E
1 : mvcle % r2 ,% r4 ,0
jo 1 b
2009-06-16 10:30:52 +02:00
/* Save image */
brasl % r14 ,s w s u s p _ s a v e
/* Restore prefix register and return */
lghi % r1 ,0 x10 0 0
spx 0 x31 8 ( % r1 )
lmg % r6 ,% r15 ,S T A C K _ F R A M E _ O V E R H E A D + _ _ S F _ G P R S ( % r15 )
lghi % r2 ,0
br % r14
/ *
* Restore s a v e d m e m o r y i m a g e t o c o r r e c t p l a c e a n d r e s t o r e r e g i s t e r c o n t e x t .
* Then w e r e t u r n t o t h e f u n c t i o n t h a t c a l l e d s w s u s p _ a r c h _ s u s p e n d ( ) .
* swsusp_ a r c h _ r e s u m e ( ) r u n s w i t h d i s a b l e d i n t e r r u p t s .
* /
.globl swsusp_arch_resume
swsusp_arch_resume :
stmg % r6 ,% r15 ,_ _ S F _ G P R S ( % r15 )
lgr % r1 ,% r15
aghi % r15 ,- S T A C K _ F R A M E _ O V E R H E A D
stg % r1 ,_ _ S F _ B A C K C H A I N ( % r15 )
2009-09-22 22:58:44 +02:00
/* Make all free pages stable */
lghi % r2 ,1
brasl % r14 ,a r c h _ s e t _ p a g e _ s t a t e s
2009-06-22 12:08:18 +02:00
# ifdef C O N F I G _ S M P
2009-06-16 10:30:52 +02:00
/* Save boot cpu number */
brasl % r14 ,s m p _ g e t _ p h y s _ c p u _ i d
2009-09-22 22:58:45 +02:00
larl % r1 ,s a v e d _ c p u _ i d
st % r2 ,0 ( % r1 )
2009-06-22 12:08:18 +02:00
# endif
2009-06-16 10:30:52 +02:00
/* Deactivate DAT */
stnsm _ _ S F _ E M P T Y ( % r15 ) ,0 x f b
/* Set prefix page to zero */
xc _ _ S F _ E M P T Y ( 4 ,% r15 ) ,_ _ S F _ E M P T Y ( % r15 )
spx _ _ S F _ E M P T Y ( % r15 )
/* Restore saved image */
larl % r1 ,r e s t o r e _ p b l i s t
lg % r1 ,0 ( % r1 )
ltgr % r1 ,% r1
jz 2 f
0 :
lg % r2 ,8 ( % r1 )
lg % r4 ,0 ( % r1 )
lghi % r3 ,P A G E _ S I Z E
lghi % r5 ,P A G E _ S I Z E
1 :
mvcle % r2 ,% r4 ,0
jo 1 b
lg % r1 ,1 6 ( % r1 )
ltgr % r1 ,% r1
jnz 0 b
2 :
ptlb / * f l u s h t l b * /
2009-09-22 22:58:45 +02:00
/* Reset System */
larl % r1 ,r e s t a r t _ e n t r y
larl % r2 ,r e s t a r t _ p s w
og % r1 ,0 ( % r2 )
stg % r1 ,0 ( % r0 )
larl % r1 ,s a v e d _ p g m _ c h e c k _ p s w
mvc 0 ( 1 6 ,% r1 ) ,_ _ L C _ P G M _ N E W _ P S W ( % r0 )
larl % r1 ,n e w _ p g m _ c h e c k _ p s w
epsw % r2 ,% r3
stm % r2 ,% r3 ,0 ( % r1 )
mvc _ _ L C _ P G M _ N E W _ P S W ( 1 6 ,% r0 ) ,0 ( % r1 )
lghi % r0 ,0
diag % r0 ,% r0 ,0 x30 8
restart_entry :
lhi % r1 ,1
sigp % r1 ,% r0 ,0 x12
sam6 4
larl % r1 ,n e w _ p g m _ c h e c k _ p s w
lpswe 0 ( % r1 )
pgm_check_entry :
larl % r1 ,s a v e d _ p g m _ c h e c k _ p s w
mvc _ _ L C _ P G M _ N E W _ P S W ( 1 6 ,% r0 ) ,0 ( % r1 )
2009-06-16 10:30:52 +02:00
/* Restore registers */
lghi % r13 ,0 x10 0 0 / * % r1 = p o i n t e r t o s a v e a r a e * /
spt 0 x32 8 ( % r13 ) / * r e p r o g r a m t i m e r * /
/ / sckc 0 x33 0 ( % r13 ) / * s e t c l o c k c o m p a r a t o r * /
lctlg % c0 ,% c15 ,0 x38 0 ( % r13 ) / * l o a d c o n t r o l r e g i s t e r s * /
lam % a0 ,% a15 ,0 x34 0 ( % r13 ) / * l o a d a c c e s s r e g i s t e r s * /
lfpc 0 x31 c ( % r13 ) / * l o a d f p u c o n t r o l * /
ld 0 ,0 x20 0 ( % r13 ) / * l o a d f0 * /
ld 1 ,0 x20 8 ( % r13 ) / * l o a d f1 * /
ld 2 ,0 x21 0 ( % r13 ) / * l o a d f2 * /
ld 3 ,0 x21 8 ( % r13 ) / * l o a d f3 * /
ld 4 ,0 x22 0 ( % r13 ) / * l o a d f4 * /
ld 5 ,0 x22 8 ( % r13 ) / * l o a d f5 * /
ld 6 ,0 x23 0 ( % r13 ) / * l o a d f6 * /
ld 7 ,0 x23 8 ( % r13 ) / * l o a d f7 * /
ld 8 ,0 x24 0 ( % r13 ) / * l o a d f8 * /
ld 9 ,0 x24 8 ( % r13 ) / * l o a d f9 * /
ld 1 0 ,0 x25 0 ( % r13 ) / * l o a d f10 * /
ld 1 1 ,0 x25 8 ( % r13 ) / * l o a d f11 * /
ld 1 2 ,0 x26 0 ( % r13 ) / * l o a d f12 * /
ld 1 3 ,0 x26 8 ( % r13 ) / * l o a d f13 * /
ld 1 4 ,0 x27 0 ( % r13 ) / * l o a d f14 * /
ld 1 5 ,0 x27 8 ( % r13 ) / * l o a d f15 * /
/* Load old stack */
lg % r15 ,0 x2 f8 ( % r13 )
2009-07-24 12:39:50 +02:00
/* Pointer to save area */
2009-06-16 10:30:52 +02:00
lghi % r13 ,0 x10 0 0
2009-06-22 12:08:18 +02:00
# ifdef C O N F I G _ S M P
2009-06-16 10:30:52 +02:00
/* Switch CPUs */
2009-09-22 22:58:45 +02:00
larl % r1 ,s a v e d _ c p u _ i d
llgf % r2 ,0 ( % r1 )
2009-06-16 10:30:52 +02:00
llgf % r3 ,0 x31 8 ( % r13 )
brasl % r14 ,s m p _ s w i t c h _ b o o t _ c p u _ i n _ r e s u m e
2009-06-22 12:08:18 +02:00
# endif
2009-06-16 10:30:52 +02:00
/* Restore prefix register */
spx 0 x31 8 ( % r13 )
/* Activate DAT */
stosm _ _ S F _ E M P T Y ( % r15 ) ,0 x04
2009-09-22 22:58:44 +02:00
/* Make all free pages unstable */
lghi % r2 ,0
brasl % r14 ,a r c h _ s e t _ p a g e _ s t a t e s
2009-06-16 10:30:52 +02:00
/* Return 0 */
lmg % r6 ,% r15 ,S T A C K _ F R A M E _ O V E R H E A D + _ _ S F _ G P R S ( % r15 )
lghi % r2 ,0
br % r14
2009-09-22 22:58:45 +02:00
.section .data .nosave , " aw" ,@progbits
.align 8
restart_psw :
.long 0 x0 0 0 8 0 0 0 0 ,0 x80 0 0 0 0 0 0
new_pgm_check_psw :
.quad 0 , pgm_ c h e c k _ e n t r y
saved_pgm_check_psw :
.quad 0 , 0
# ifdef C O N F I G _ S M P
saved_cpu_id :
.long 0
# endif