2013-03-19 19:11:07 +04:00
/ *
* hibernate_ a s m . S : H i b e r n a t o n s u p p o r t s p e c i f i c f o r s p a r c64 .
*
* Copyright ( C ) 2 0 1 3 K i r i l l V T k h a i ( t k h a i @yandex.ru)
* /
# include < l i n u x / l i n k a g e . h >
# include < a s m / a s m - o f f s e t s . h >
# include < a s m / c p u d a t a . h >
# include < a s m / p a g e . h >
ENTRY( s w s u s p _ a r c h _ s u s p e n d )
save % s p , - 1 2 8 , % s p
save % s p , - 1 2 8 , % s p
flushw
setuw s a v e d _ c o n t e x t , % g 3
/* Save window regs */
rdpr % c w p , % g 2
stx % g 2 , [ % g 3 + S C _ R E G _ C W P ]
rdpr % w s t a t e , % g 2
stx % g 2 , [ % g 3 + S C _ R E G _ W S T A T E ]
stx % f p , [ % g 3 + S C _ R E G _ F P ]
/* Save state regs */
rdpr % t i c k , % g 2
stx % g 2 , [ % g 3 + S C _ R E G _ T I C K ]
rdpr % p s t a t e , % g 2
stx % g 2 , [ % g 3 + S C _ R E G _ P S T A T E ]
/* Save global regs */
stx % g 4 , [ % g 3 + S C _ R E G _ G 4 ]
stx % g 5 , [ % g 3 + S C _ R E G _ G 5 ]
stx % g 6 , [ % g 3 + S C _ R E G _ G 6 ]
call s w s u s p _ s a v e
nop
mov % o 0 , % i 0
restore
mov % o 0 , % i 0
ret
restore
ENTRY( s w s u s p _ a r c h _ r e s u m e )
/* Write restore_pblist to %l0 */
sethi % h i ( r e s t o r e _ p b l i s t ) , % l 0
ldx [ % l 0 + % l o ( r e s t o r e _ p b l i s t ) ] , % l 0
call _ _ f l u s h _ t l b _ a l l
nop
/* Write PAGE_OFFSET to %g7 */
2014-09-25 08:05:30 +04:00
sethi % h i ( P A G E _ O F F S E T ) , % g 7
ldx [ % g 7 + % l o ( P A G E _ O F F S E T ) ] , % g 7
2013-03-19 19:11:07 +04:00
setuw ( P A G E _ S I Z E - 8 ) , % g 3
/* Use MMU Bypass */
rd % a s i , % g 1
wr % g 0 , A S I _ P H Y S _ U S E _ E C , % a s i
ba f i l l _ i t l b
nop
pbe_loop :
cmp % l 0 , % g 0
be r e s t o r e _ c t x
sub % l 0 , % g 7 , % l 0
ldxa [ % l 0 ] % a s i , % l 1 / * a d d r e s s * /
ldxa [ % l 0 + 8 ] % a s i , % l 2 / * o r i g _ a d d r e s s * /
/* phys addr */
sub % l 1 , % g 7 , % l 1
sub % l 2 , % g 7 , % l 2
mov % g 3 , % l 3 / * P A G E _ S I Z E - 8 * /
copy_loop :
ldxa [ % l 1 + % l 3 ] A S I _ P H Y S _ U S E _ E C , % g 2
stxa % g 2 , [ % l 2 + % l 3 ] A S I _ P H Y S _ U S E _ E C
cmp % l 3 , % g 0
bne c o p y _ l o o p
sub % l 3 , 8 , % l 3
/* next pbe */
ba p b e _ l o o p
ldxa [ % l 0 + 1 6 ] % a s i , % l 0
restore_ctx :
setuw s a v e d _ c o n t e x t , % g 3
/* Restore window regs */
wrpr % g 0 , 0 , % c a n r e s t o r e
wrpr % g 0 , 0 , % o t h e r w i n
wrpr % g 0 , 6 , % c a n s a v e
wrpr % g 0 , 0 , % c l e a n w i n
ldxa [ % g 3 + S C _ R E G _ C W P ] % a s i , % g 2
wrpr % g 2 , % c w p
ldxa [ % g 3 + S C _ R E G _ W S T A T E ] % a s i , % g 2
wrpr % g 2 , % w s t a t e
ldxa [ % g 3 + S C _ R E G _ F P ] % a s i , % f p
/* Restore state regs */
ldxa [ % g 3 + S C _ R E G _ P S T A T E ] % a s i , % g 2
wrpr % g 2 , % p s t a t e
ldxa [ % g 3 + S C _ R E G _ T I C K ] % a s i , % g 2
wrpr % g 2 , % t i c k
/* Restore global regs */
ldxa [ % g 3 + S C _ R E G _ G 4 ] % a s i , % g 4
ldxa [ % g 3 + S C _ R E G _ G 5 ] % a s i , % g 5
ldxa [ % g 3 + S C _ R E G _ G 6 ] % a s i , % g 6
wr % g 1 , % g 0 , % a s i
restore
restore
wrpr % g 0 , 1 4 , % p i l
retl
mov % g 0 , % o 0
fill_itlb :
ba p b e _ l o o p
wrpr % g 0 , 1 5 , % p i l