2005-04-16 15:20:36 -07:00
/ *
* HPMC ( H i g h P r i o r i t y M a c h i n e C h e c k ) h a n d l e r .
*
* Copyright ( C ) 1 9 9 9 P h i l i p p R u m p f < p r u m p f @tux.org>
* Copyright ( C ) 1 9 9 9 H e w l e t t - P a c k a r d ( F r a n k R o w a n d )
* Copyright ( C ) 2 0 0 0 H e w l e t t - P a c k a r d ( J o h n M a r v i n )
*
* This p r o g r a m i s f r e e s o f t w a r e ; you can redistribute it and/or modify
* it u n d e r t h e t e r m s o f t h e G N U G e n e r a l P u b l i c L i c e n s e a s p u b l i s h e d b y
* the F r e e S o f t w a r e F o u n d a t i o n ; either version 2, or (at your option)
* any l a t e r v e r s i o n .
*
* This p r o g r a m i s d i s t r i b u t e d i n t h e h o p e t h a t i t w i l l b e u s e f u l ,
* but W I T H O U T A N Y W A R R A N T Y ; without even the implied warranty of
* MERCHANTABILITY o r F I T N E S S F O R A P A R T I C U L A R P U R P O S E . S e e t h e
* GNU G e n e r a l P u b l i c L i c e n s e f o r m o r e d e t a i l s .
*
* You s h o u l d h a v e r e c e i v e d a c o p y o f t h e G N U G e n e r a l P u b l i c L i c e n s e
* along w i t h t h i s p r o g r a m ; if not, write to the Free Software
* Foundation, I n c . , 5 9 T e m p l e P l a c e , S u i t e 3 3 0 , B o s t o n , M A 0 2 1 1 1 - 1 3 0 7 U S A
* /
/ *
* This H P M C h a n d l e r r e t r i e v e s t h e H P M C p i m d a t a , r e s e t s I O a n d
* returns t o t h e d e f a u l t t r a p h a n d l e r w i t h c o d e s e t t o 1 ( H P M C ) .
* The d e f a u l t t r a p h a n d l e r c a l l s h a n d l e i n t e r r u p t i o n , w h i c h
* does a s t a c k a n d r e g i s t e r d u m p . T h i s a t l e a s t a l l o w s k e r n e l
* developers t o g e t b a c k t o C c o d e i n v i r t u a l m o d e , w h e r e t h e y
* have t h e o p t i o n t o e x a m i n e a n d p r i n t v a l u e s f r o m m e m o r y t h a t
* would h e l p i n d e b u g g i n g a n H P M C c a u s e d b y a s o f t w a r e b u g .
*
* There i s m o r e t o d o h e r e :
*
* 1 ) On M P s y s t e m s w e n e e d t o s y n c h r o n i z e p r o c e s s o r s
* before c a l l i n g p d c / i o d c .
* 2 ) We s h o u l d b e c h e c k i n g t h e s y s t e m s t a t e a n d n o t
* returning t o t h e f a u l t h a n d l e r i f t h i n g s a r e r e a l l y
* bad.
*
* /
.level 1 .1
.data
# include < a s m / a s s e m b l y . h >
# include < a s m / p d c . h >
2007-01-24 22:36:32 +01:00
# include < l i n u x / l i n k a g e . h >
2005-04-16 15:20:36 -07:00
/ *
* stack f o r o s _ h p m c , t h e H P M C h a n d l e r .
* buffer f o r I O D C p r o c e d u r e s ( f o r t h e H P M C h a n d l e r ) .
*
* IODC r e q u i r e s 7 K b y t e s t a c k . T h a t l e a v e s 1 K b y t e f o r o s _ h p m c .
* /
2007-10-18 00:04:53 -07:00
.align PAGE_SIZE
2005-04-16 15:20:36 -07:00
hpmc_stack :
.block 16384
# define H P M C _ I O D C _ B U F _ S I Z E 0 x80 0 0
2007-10-18 00:04:53 -07:00
.align PAGE_SIZE
2005-04-16 15:20:36 -07:00
hpmc_iodc_buf :
.block HPMC_IODC_BUF_SIZE
.align 8
hpmc_raddr :
.block 128
# define H P M C _ P I M _ D A T A _ S I Z E 8 9 6 / * E n o u g h t o h o l d a l l a r c h i t e c t e d 2 . 0 s t a t e * /
.align 8
2007-01-24 22:36:32 +01:00
ENTRY( h p m c _ p i m _ d a t a )
2005-04-16 15:20:36 -07:00
.block HPMC_PIM_DATA_SIZE
2007-01-24 22:36:32 +01:00
END( h p m c _ p i m _ d a t a )
2005-04-16 15:20:36 -07:00
2008-05-22 14:36:31 -04:00
.text
2005-04-16 15:20:36 -07:00
.import intr_ s a v e , c o d e
2007-01-24 22:36:32 +01:00
ENTRY( o s _ h p m c )
2009-01-03 06:35:40 +00:00
.os_hpmc :
2005-04-16 15:20:36 -07:00
/ *
* registers m o d i f i e d :
*
* Using c a l l e e s a v e s r e g i s t e r s w i t h o u t s a v i n g t h e m . T h e
* original v a l u e s a r e i n t h e p i m d u m p i f w e n e e d t h e m .
*
* r2 ( r p ) r e t u r n p o i n t e r
* r3 a d d r e s s o f P D C E _ P R O C
* r4 s c r a t c h
* r5 s c r a t c h
* r2 3 ( a r g 3 ) p r o c e d u r e a r g
* r2 4 ( a r g 2 ) p r o c e d u r e a r g
* r2 5 ( a r g 1 ) p r o c e d u r e a r g
* r2 6 ( a r g 0 ) p r o c e d u r e a r g
* r3 0 ( s p ) s t a c k p o i n t e r
*
* registers r e a d :
*
* r2 6 c o n t a i n s a d d r e s s o f P D C E _ P R O C o n e n t r y
* r2 8 ( r e t 0 ) r e t u r n v a l u e f r o m p r o c e d u r e
* /
copy a r g 0 , % r3 / * s a v e a d d r e s s o f P D C E _ P R O C * /
/ *
* disable n e s t e d H P M C s
*
* Increment o s _ h p m c c h e c k s u m t o i n v a l i d a t e i t .
* Do t h i s b e f o r e t u r n i n g t h e P S W M b i t o f f .
* /
mfctl % c r14 , % r4
ldw 5 2 ( % r4 ) ,% r5
addi 1 ,% r5 ,% r5
stw % r5 ,5 2 ( % r4 )
/* MP_FIXME: synchronize all processors. */
/* Setup stack pointer. */
load3 2 P A ( h p m c _ s t a c k ) ,s p
ldo 1 2 8 ( s p ) ,s p / * l e a v e r o o m f o r a r g u m e n t s * /
/ *
* Most P D C r o u t i n e s r e q u i r e t h a t t h e M b i t b e o f f .
* So t u r n o n t h e Q b i t a n d t u r n o f f t h e M b i t .
* /
ldo 8 ( % r0 ) ,% r4 / * P S W Q o n , P S W M o f f * /
mtctl % r4 ,i p s w
mtctl % r0 ,p c s q
mtctl % r0 ,p c s q
load3 2 P A ( o s _ h p m c _ 1 ) ,% r4
mtctl % r4 ,p c o q
ldo 4 ( % r4 ) ,% r4
mtctl % r4 ,p c o q
rfi
nop
os_hpmc_1 :
/* Call PDC_PIM to get HPMC pim info */
/ *
* Note t h a t o n s o m e n e w e r b o x e s , P D C _ P I M m u s t b e c a l l e d
* before P D C _ I O i f y o u w a n t I O t o b e r e s e t . P D C _ P I M s e t s
* a f l a g t h a t P D C _ I O e x a m i n e s .
* /
ldo P D C _ P I M ( % r0 ) , a r g 0
ldo P D C _ P I M _ H P M C ( % r0 ) ,a r g 1 / * T r a n s f e r H P M C d a t a * /
load3 2 P A ( h p m c _ r a d d r ) ,a r g 2
load3 2 P A ( h p m c _ p i m _ d a t a ) ,a r g 3
load3 2 H P M C _ P I M _ D A T A _ S I Z E ,% r4
stw % r4 ,- 5 2 ( s p )
ldil L % P A ( o s _ h p m c _ 2 ) , r p
bv ( r3 ) / * c a l l p d c e _ p r o c * /
ldo R % P A ( o s _ h p m c _ 2 ) ( r p ) , r p
os_hpmc_2 :
comib,< > 0 ,r e t 0 , o s _ h p m c _ f a i l
/* Reset IO by calling the hversion dependent PDC_IO routine */
ldo P D C _ I O ( % r0 ) ,a r g 0
ldo 0 ( % r0 ) ,a r g 1 / * l o g I O e r r o r s * /
ldo 0 ( % r0 ) ,a r g 2 / * r e s e r v e d * /
ldo 0 ( % r0 ) ,a r g 3 / * r e s e r v e d * /
stw % r0 ,- 5 2 ( s p ) / * r e s e r v e d * /
ldil L % P A ( o s _ h p m c _ 3 ) ,r p
bv ( % r3 ) / * c a l l p d c e _ p r o c * /
ldo R % P A ( o s _ h p m c _ 3 ) ( r p ) ,r p
os_hpmc_3 :
/* FIXME? Check for errors from PDC_IO (-1 might be OK) */
/ *
* Initialize t h e I O D C c o n s o l e d e v i c e ( H P A ,S P A , p a t h e t c .
* are s t o r e d o n p a g e 0 .
* /
/ *
* Load I O D C i n t o h p m c _ i o d c _ b u f b y c a l l i n g P D C _ I O D C .
* Note t h a t P D C _ I O D C h a n d l e s f l u s h i n g t h e a p p r o p r i a t e
* data a n d i n s t r u c t i o n c a c h e l i n e s .
* /
ldo P D C _ I O D C ( % r0 ) ,a r g 0
ldo P D C _ I O D C _ R E A D ( % r0 ) ,a r g 1
load3 2 P A ( h p m c _ r a d d r ) ,a r g 2
ldw B O O T _ C O N S O L E _ H P A _ O F F S E T ( % r0 ) ,a r g 3 / * c o n s o l e h p a * /
ldo P D C _ I O D C _ R I _ I N I T ( % r0 ) ,% r4
stw % r4 ,- 5 2 ( s p )
load3 2 P A ( h p m c _ i o d c _ b u f ) ,% r4
stw % r4 ,- 5 6 ( s p )
load3 2 H P M C _ I O D C _ B U F _ S I Z E ,% r4
stw % r4 ,- 6 0 ( s p )
ldil L % P A ( o s _ h p m c _ 4 ) ,r p
bv ( % r3 ) / * c a l l p d c e _ p r o c * /
ldo R % P A ( o s _ h p m c _ 4 ) ( r p ) ,r p
os_hpmc_4 :
comib,< > 0 ,r e t 0 ,o s _ h p m c _ f a i l
/* Call the entry init (just loaded by PDC_IODC) */
ldw B O O T _ C O N S O L E _ H P A _ O F F S E T ( % r0 ) ,a r g 0 / * c o n s o l e h p a * /
ldo E N T R Y _ I N I T _ M O D _ D E V ( % r0 ) , a r g 1
ldw B O O T _ C O N S O L E _ S P A _ O F F S E T ( % r0 ) ,a r g 2 / * c o n s o l e s p a * /
depi 0 ,3 1 ,1 1 ,a r g 2 / * c l e a r b i t s 2 1 - 3 1 * /
ldo B O O T _ C O N S O L E _ P A T H _ O F F S E T ( % r0 ) ,a r g 3 / * c o n s o l e p a t h * /
load3 2 P A ( h p m c _ r a d d r ) ,% r4
stw % r4 , - 5 2 ( s p )
stw % r0 , - 5 6 ( s p ) / * H V * /
stw % r0 , - 6 0 ( s p ) / * H V * /
stw % r0 , - 6 4 ( s p ) / * H V * /
stw % r0 , - 6 8 ( s p ) / * l a n g , m u s t b e z e r o * /
load3 2 P A ( h p m c _ i o d c _ b u f ) ,% r5
ldil L % P A ( o s _ h p m c _ 5 ) ,r p
bv ( % r5 )
ldo R % P A ( o s _ h p m c _ 5 ) ( r p ) ,r p
os_hpmc_5 :
comib,< > 0 ,r e t 0 ,o s _ h p m c _ f a i l
/* Prepare to call intr_save */
/ *
* Load k e r n e l p a g e d i r e c t o r y ( l o a d i n t o u s e r a l s o , s i n c e
* we d o n ' t i n t e n d t o e v e r r e t u r n t o u s e r l a n d a n y w a y )
* /
load3 2 P A ( s w a p p e r _ p g _ d i r ) ,% r4
mtctl % r4 ,% c r24 / * I n i t i a l i z e k e r n e l r o o t p o i n t e r * /
mtctl % r4 ,% c r25 / * I n i t i a l i z e u s e r r o o t p o i n t e r * /
/* Clear sr4-sr7 */
mtsp % r0 , % s r4
mtsp % r0 , % s r5
mtsp % r0 , % s r6
mtsp % r0 , % s r7
tovirt_ r1 % r30 / * m a k e s p v i r t u a l * /
rsm 8 ,% r0 / * C l e a r Q b i t * /
ldi 1 ,% r8 / * S e t t r a p c o d e t o " 1 " f o r H P M C * /
load3 2 P A ( i n t r _ s a v e ) ,% r1
be 0 ( % s r7 ,% r1 )
nop
os_hpmc_fail :
/ *
* Reset t h e s y s t e m
*
* Some s y s t e m s m a y l o c k u p f r o m a b r o a d c a s t r e s e t , s o t r y t h e
* hversion P D C _ B R O A D C A S T _ R E S E T ( ) f i r s t .
* MP_FIXME : reset a l l p r o c e s s o r s i f m o r e t h a n o n e c e n t r a l b u s .
* /
/* PDC_BROADCAST_RESET() */
ldo P D C _ B R O A D C A S T _ R E S E T ( % r0 ) ,a r g 0
ldo 0 ( % r0 ) ,a r g 1 / * d o r e s e t * /
ldil L % P A ( o s _ h p m c _ 6 ) ,r p
bv ( % r3 ) / * c a l l p d c e _ p r o c * /
ldo R % P A ( o s _ h p m c _ 6 ) ( r p ) ,r p
os_hpmc_6 :
/ *
* possible r e t u r n v a l u e s :
* - 1 non- e x i s t e n t p r o c e d u r e
* - 2 non- e x i s t e n t o p t i o n
* - 1 6 unaligned s t a c k
*
* If c a l l r e t u r n e d , d o a b r o a d c a s t r e s e t .
* /
ldil L % 0 x f f f c00 0 0 ,% r4 / * I O _ B R O A D C A S T * /
ldo 5 ( % r0 ) ,% r5
stw % r5 ,4 8 ( % r4 ) / * C M D _ R E S E T t o I O _ C O M M A N D o f f s e t * /
b .
nop
2007-01-24 22:36:32 +01:00
ENDPROC( o s _ h p m c )
2009-01-03 06:35:40 +00:00
.os_hpmc_end :
2005-04-16 15:20:36 -07:00
nop
2009-01-03 06:35:40 +00:00
.data
.align 4
.export os_hpmc_size
os_hpmc_size :
.word .os_hpmc_end - .os_hpmc