2010-05-17 22:56:52 +04:00
/ *
* Based o n s w s u s p _ 3 2 . S , m o d i f i e d f o r F S L B o o k E b y
* Anton V o r o n t s o v < a v o r o n t s o v @ru.mvista.com>
* Copyright ( c ) 2 0 0 9 - 2 0 1 0 M o n t a V i s t a S o f t w a r e , L L C .
* /
# include < l i n u x / t h r e a d s . h >
# include < a s m / p r o c e s s o r . h >
# include < a s m / p a g e . h >
# include < a s m / c p u t a b l e . h >
# include < a s m / t h r e a d _ i n f o . h >
# include < a s m / p p c _ a s m . h >
# include < a s m / a s m - o f f s e t s . h >
# include < a s m / m m u . h >
/ *
* Structure f o r s t o r i n g C P U r e g i s t e r s o n t h e s a v e a r e a .
* /
# define S L _ S P 0
# define S L _ P C 4
# define S L _ M S R 8
# define S L _ T C R 0 x c
# define S L _ S P R G 0 0 x10
# define S L _ S P R G 1 0 x14
# define S L _ S P R G 2 0 x18
# define S L _ S P R G 3 0 x1 c
# define S L _ S P R G 4 0 x20
# define S L _ S P R G 5 0 x24
# define S L _ S P R G 6 0 x28
# define S L _ S P R G 7 0 x2 c
# define S L _ T B U 0 x30
# define S L _ T B L 0 x34
# define S L _ R 2 0 x38
# define S L _ C R 0 x3 c
# define S L _ L R 0 x40
# define S L _ R 1 2 0 x44 / * r12 t o r31 * /
# define S L _ S I Z E ( S L _ R 1 2 + 8 0 )
.section .data
.align 5
_ GLOBAL( s w s u s p _ s a v e _ a r e a )
.space SL_SIZE
.section .text
.align 5
_ GLOBAL( s w s u s p _ a r c h _ s u s p e n d )
lis r11 ,s w s u s p _ s a v e _ a r e a @h
ori r11 ,r11 ,s w s u s p _ s a v e _ a r e a @l
mflr r0
stw r0 ,S L _ L R ( r11 )
mfcr r0
stw r0 ,S L _ C R ( r11 )
stw r1 ,S L _ S P ( r11 )
stw r2 ,S L _ R 2 ( r11 )
stmw r12 ,S L _ R 1 2 ( r11 )
/* Save MSR & TCR */
mfmsr r4
stw r4 ,S L _ M S R ( r11 )
mfspr r4 ,S P R N _ T C R
stw r4 ,S L _ T C R ( r11 )
/* Get a stable timebase and save it */
1 : mfspr r4 ,S P R N _ T B R U
stw r4 ,S L _ T B U ( r11 )
mfspr r5 ,S P R N _ T B R L
stw r5 ,S L _ T B L ( r11 )
mfspr r3 ,S P R N _ T B R U
cmpw r3 ,r4
bne 1 b
/* Save SPRGs */
2014-01-02 16:37:50 -06:00
mfspr r4 ,S P R N _ S P R G 0
2010-05-17 22:56:52 +04:00
stw r4 ,S L _ S P R G 0 ( r11 )
2014-01-02 16:37:50 -06:00
mfspr r4 ,S P R N _ S P R G 1
2010-05-17 22:56:52 +04:00
stw r4 ,S L _ S P R G 1 ( r11 )
2014-01-02 16:37:50 -06:00
mfspr r4 ,S P R N _ S P R G 2
2010-05-17 22:56:52 +04:00
stw r4 ,S L _ S P R G 2 ( r11 )
2014-01-02 16:37:50 -06:00
mfspr r4 ,S P R N _ S P R G 3
2010-05-17 22:56:52 +04:00
stw r4 ,S L _ S P R G 3 ( r11 )
2014-01-02 16:37:50 -06:00
mfspr r4 ,S P R N _ S P R G 4
2010-05-17 22:56:52 +04:00
stw r4 ,S L _ S P R G 4 ( r11 )
2014-01-02 16:37:50 -06:00
mfspr r4 ,S P R N _ S P R G 5
2010-05-17 22:56:52 +04:00
stw r4 ,S L _ S P R G 5 ( r11 )
2014-01-02 16:37:50 -06:00
mfspr r4 ,S P R N _ S P R G 6
2010-05-17 22:56:52 +04:00
stw r4 ,S L _ S P R G 6 ( r11 )
2014-01-02 16:37:50 -06:00
mfspr r4 ,S P R N _ S P R G 7
2010-05-17 22:56:52 +04:00
stw r4 ,S L _ S P R G 7 ( r11 )
/ * Call t h e l o w l e v e l s u s p e n d s t u f f ( w e s h o u l d p r o b a b l y h a v e m a d e
* a s t a c k f r a m e . . .
* /
bl s w s u s p _ s a v e
/* Restore LR from the save area */
lis r11 ,s w s u s p _ s a v e _ a r e a @h
ori r11 ,r11 ,s w s u s p _ s a v e _ a r e a @l
lwz r0 ,S L _ L R ( r11 )
mtlr r0
blr
_ GLOBAL( s w s u s p _ a r c h _ r e s u m e )
sync
/* Load ptr the list of pages to copy in r3 */
lis r11 ,( r e s t o r e _ p b l i s t ) @h
ori r11 ,r11 ,r e s t o r e _ p b l i s t @l
lwz r3 ,0 ( r11 )
/ * Copy t h e p a g e s . T h i s i s a v e r y b a s i c i m p l e m e n t a t i o n , t o
* be r e p l a c e d b y s o m e t h i n g m o r e c a c h e e f f i c i e n t * /
1 :
li r0 ,2 5 6
mtctr r0
lwz r5 ,p b e _ a d d r e s s ( r3 ) / * s o u r c e * /
lwz r6 ,p b e _ o r i g _ a d d r e s s ( r3 ) / * d e s t i n a t i o n * /
2 :
lwz r8 ,0 ( r5 )
lwz r9 ,4 ( r5 )
lwz r10 ,8 ( r5 )
lwz r11 ,1 2 ( r5 )
addi r5 ,r5 ,1 6
stw r8 ,0 ( r6 )
stw r9 ,4 ( r6 )
stw r10 ,8 ( r6 )
stw r11 ,1 2 ( r6 )
addi r6 ,r6 ,1 6
bdnz 2 b
lwz r3 ,p b e _ n e x t ( r3 )
cmpwi 0 ,r3 ,0
bne 1 b
bl f l u s h _ d c a c h e _ L 1
bl f l u s h _ i n s t r u c t i o n _ c a c h e
lis r11 ,s w s u s p _ s a v e _ a r e a @h
ori r11 ,r11 ,s w s u s p _ s a v e _ a r e a @l
2013-05-14 16:05:56 +08:00
/ *
* Mappings f r o m v i r t u a l a d d r e s s e s t o p h y s i c a l a d d r e s s e s m a y b e
* different t h a n t h e y w e r e p r i o r t o r e s t o r i n g h i b e r n a t i o n s t a t e .
* Invalidate t h e T L B s o t h a t t h e b o o t C P U i s u s i n g t h e n e w
* mappings.
* /
bl _ t l b i l _ a l l
2010-05-17 22:56:52 +04:00
lwz r4 ,S L _ S P R G 0 ( r11 )
2014-01-02 16:37:50 -06:00
mtspr S P R N _ S P R G 0 ,r4
2010-05-17 22:56:52 +04:00
lwz r4 ,S L _ S P R G 1 ( r11 )
2014-01-02 16:37:50 -06:00
mtspr S P R N _ S P R G 1 ,r4
2010-05-17 22:56:52 +04:00
lwz r4 ,S L _ S P R G 2 ( r11 )
2014-01-02 16:37:50 -06:00
mtspr S P R N _ S P R G 2 ,r4
2010-05-17 22:56:52 +04:00
lwz r4 ,S L _ S P R G 3 ( r11 )
2014-01-02 16:37:50 -06:00
mtspr S P R N _ S P R G 3 ,r4
2010-05-17 22:56:52 +04:00
lwz r4 ,S L _ S P R G 4 ( r11 )
2014-01-02 16:37:50 -06:00
mtspr S P R N _ S P R G 4 ,r4
2010-05-17 22:56:52 +04:00
lwz r4 ,S L _ S P R G 5 ( r11 )
2014-01-02 16:37:50 -06:00
mtspr S P R N _ S P R G 5 ,r4
2010-05-17 22:56:52 +04:00
lwz r4 ,S L _ S P R G 6 ( r11 )
2014-01-02 16:37:50 -06:00
mtspr S P R N _ S P R G 6 ,r4
2010-05-17 22:56:52 +04:00
lwz r4 ,S L _ S P R G 7 ( r11 )
2014-01-02 16:37:50 -06:00
mtspr S P R N _ S P R G 7 ,r4
2010-05-17 22:56:52 +04:00
/* restore the MSR */
lwz r3 ,S L _ M S R ( r11 )
mtmsr r3
/* Restore TB */
li r3 ,0
mtspr S P R N _ T B W L ,r3
lwz r3 ,S L _ T B U ( r11 )
lwz r4 ,S L _ T B L ( r11 )
mtspr S P R N _ T B W U ,r3
mtspr S P R N _ T B W L ,r4
/* Restore TCR and clear any pending bits in TSR. */
lwz r4 ,S L _ T C R ( r11 )
mtspr S P R N _ T C R ,r4
lis r4 , ( T S R _ E N W | T S R _ W I S | T S R _ D I S | T S R _ F I S ) @h
mtspr S P R N _ T S R ,r4
/* Kick decrementer */
li r0 ,1
mtdec r0
/* Restore the callee-saved registers and return */
lwz r0 ,S L _ C R ( r11 )
mtcr r0
lwz r2 ,S L _ R 2 ( r11 )
lmw r12 ,S L _ R 1 2 ( r11 )
lwz r1 ,S L _ S P ( r11 )
lwz r0 ,S L _ L R ( r11 )
mtlr r0
li r3 ,0
blr