2010-05-29 07:09:12 +04:00
/ *
* Copyright 2 0 1 0 T i l e r a C o r p o r a t i o n . A l l R i g h t s R e s e r v e d .
*
* 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 i t 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
* as p u b l i s h e d b y t h e F r e e S o f t w a r e F o u n d a t i o n , v e r s i o n 2 .
*
* 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 , b u t
* WITHOUT 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 , G O O D T I T L E o r
* NON I N F R I N G E M E N T . S e e 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 f o r
* more d e t a i l s .
*
* TILE s t a r t u p c o d e .
* /
# include < l i n u x / l i n k a g e . h >
# include < l i n u x / i n i t . h >
# include < a s m / p a g e . h >
# include < a s m / p g 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 r o c e s s o r . h >
# include < a s m / a s m - o f f s e t s . h >
# include < h v / h y p e r v i s o r . h >
# include < a r c h / c h i p . h >
2010-10-15 00:23:03 +04:00
# include < a r c h / s p r _ d e f . h >
2010-05-29 07:09:12 +04:00
/ *
* This m o d u l e c o n t a i n s t h e e n t r y c o d e f o r k e r n e l i m a g e s . I t p e r f o r m s t h e
* minimal s e t u p n e e d e d t o c a l l t h e g e n e r i c C r o u t i n e s .
* /
_ _ HEAD
ENTRY( _ s t a r t )
/* Notify the hypervisor of what version of the API we want */
{
movei r1 , T I L E _ C H I P
movei r2 , T I L E _ C H I P _ R E V
}
{
moveli r0 , _ H V _ V E R S I O N
jal h v _ i n i t
}
/* Get a reasonable default ASID in r0 */
{
move r0 , z e r o
jal h v _ i n q u i r e _ a s i d
}
/* Install the default page table */
{
moveli r6 , l o 1 6 ( s w a p p e r _ p g p r o t - P A G E _ O F F S E T )
move r4 , r0 / * u s e s t a r t i n g A S I D o f r a n g e f o r t h i s p a g e t a b l e * /
}
{
moveli r0 , l o 1 6 ( s w a p p e r _ p g _ d i r - P A G E _ O F F S E T )
auli r6 , r6 , h a16 ( s w a p p e r _ p g p r o t - P A G E _ O F F S E T )
}
{
lw r2 , r6
addi r6 , r6 , 4
}
{
lw r3 , r6
auli r0 , r0 , h a16 ( s w a p p e r _ p g _ d i r - P A G E _ O F F S E T )
}
{
inv r6
move r1 , z e r o / * h i g h 3 2 b i t s o f C P A i s z e r o * /
}
{
moveli l r , l o 1 6 ( 1 f )
move r5 , z e r o
}
{
auli l r , l r , h a16 ( 1 f )
j h v _ i n s t a l l _ c o n t e x t
}
1 :
2010-10-15 00:23:03 +04:00
/* Get our processor number and save it away in SAVE_K_0. */
2010-05-29 07:09:12 +04:00
jal h v _ i n q u i r e _ t o p o l o g y
mulll_ u u r4 , r1 , r2 / * r1 = = y , r2 = = w i d t h * /
add r4 , r4 , r0 / * r0 = = x , s o r4 = = c p u = = y * w i d t h + x * /
# ifdef C O N F I G _ S M P
/ *
* Load u p o u r p e r - c p u o f f s e t . W h e n t h e f i r s t ( m a s t e r ) t i l e
* boots, t h i s v a l u e i s s t i l l z e r o , s o w e w i l l l o a d b o o t _ p c
* with s t a r t _ k e r n e l , a n d b o o t _ s p w i t h i n i t _ s t a c k + T H R E A D _ S I Z E .
* The m a s t e r t i l e i n i t i a l i z e s t h e p e r - c p u o f f s e t a r r a y , s o t h a t
* when s u b s e q u e n t ( s e c o n d a r y ) t i l e s b o o t , t h e y w i l l i n s t e a d l o a d
* from t h e i r p e r - c p u v e r s i o n s o f b o o t _ s p a n d b o o t _ p c .
* /
moveli r5 , l o 1 6 ( _ _ p e r _ c p u _ o f f s e t )
auli r5 , r5 , h a16 ( _ _ p e r _ c p u _ o f f s e t )
s2 a r5 , r4 , r5
lw r5 , r5
bnz r5 , 1 f
/ *
* Save t h e w i d t h a n d h e i g h t t o t h e s m p _ t o p o l o g y v a r i a b l e
* for l a t e r u s e .
* /
moveli r0 , l o 1 6 ( s m p _ t o p o l o g y + H V _ T O P O L O G Y _ W I D T H _ O F F S E T )
auli r0 , r0 , h a16 ( s m p _ t o p o l o g y + H V _ T O P O L O G Y _ W I D T H _ O F F S E T )
{
sw r0 , r2
addi r0 , r0 , ( H V _ T O P O L O G Y _ H E I G H T _ O F F S E T - H V _ T O P O L O G Y _ W I D T H _ O F F S E T )
}
sw r0 , r3
1 :
# else
move r5 , z e r o
# endif
/* Load and go with the correct pc and sp. */
{
addli r1 , r5 , l o 1 6 ( b o o t _ s p )
addli r0 , r5 , l o 1 6 ( b o o t _ p c )
}
{
auli r1 , r1 , h a16 ( b o o t _ s p )
auli r0 , r0 , h a16 ( b o o t _ p c )
}
lw r0 , r0
lw s p , r1
or r4 , s p , r4
2010-10-15 00:23:03 +04:00
mtspr S P R _ S Y S T E M _ S A V E _ K _ 0 , r4 / * s a v e k s p0 + c p u * /
2010-05-29 07:09:12 +04:00
addi s p , s p , - S T A C K _ T O P _ D E L T A
{
move l r , z e r o / * s t o p b a c k t r a c e s i n t h e c a l l e d f u n c t i o n * /
jr r0
}
ENDPROC( _ s t a r t )
2011-02-28 02:52:24 +03:00
_ _ PAGE_ A L I G N E D _ B S S
2010-05-29 07:09:12 +04:00
.align PAGE_SIZE
ENTRY( e m p t y _ z e r o _ p a g e )
.fill PAGE_ S I Z E ,1 ,0
END( e m p t y _ z e r o _ p a g e )
.macro PTE va, c p a , b i t s1 , n o _ o r g =0
.ifeq \ no_ o r g
.org swapper_pg_dir + HV_ L 1 _ I N D E X ( \ v a ) * H V _ P T E _ S I Z E
.endif
.word HV_PTE_PAGE | HV_ P T E _ D I R T Y | H V _ P T E _ P R E S E N T | H V _ P T E _ A C C E S S E D | \
( HV_ P T E _ M O D E _ C A C H E _ N O _ L 3 < < H V _ P T E _ I N D E X _ M O D E )
2011-03-17 21:32:06 +03:00
.word ( \ bits1 ) | ( H V _ C P A _ T O _ P F N ( \ c p a ) < < ( H V _ P T E _ I N D E X _ P F N - 3 2 ) )
2010-05-29 07:09:12 +04:00
.endm
2011-02-28 02:52:24 +03:00
_ _ PAGE_ A L I G N E D _ D A T A
2010-05-29 07:09:12 +04:00
.align PAGE_SIZE
ENTRY( s w a p p e r _ p g _ d i r )
/ *
* All d a t a p a g e s f r o m P A G E _ O F F S E T t o M E M _ U S E R _ I N T R P T a r e m a p p e d a s
* VA = P A + P A G E _ O F F S E T . W e r e m a p t h i n g s w i t h m o r e p r e c i s e a c c e s s
* permissions a n d m o r e r e s p e c t f o r s i z e o f R A M l a t e r .
* /
.set addr, 0
.rept ( MEM_ U S E R _ I N T R P T - P A G E _ O F F S E T ) > > P G D I R _ S H I F T
2011-03-17 21:32:06 +03:00
PTE a d d r + P A G E _ O F F S E T , a d d r , ( 1 < < ( H V _ P T E _ I N D E X _ R E A D A B L E - 3 2 ) ) | \
( 1 < < ( HV_ P T E _ I N D E X _ W R I T A B L E - 3 2 ) )
2010-05-29 07:09:12 +04:00
.set addr, a d d r + P G D I R _ S I Z E
.endr
/* The true text VAs are mapped as VA = PA + MEM_SV_INTRPT */
2011-03-17 21:32:06 +03:00
PTE M E M _ S V _ I N T R P T , 0 , ( 1 < < ( H V _ P T E _ I N D E X _ R E A D A B L E - 3 2 ) ) | \
( 1 < < ( HV_ P T E _ I N D E X _ E X E C U T A B L E - 3 2 ) )
2010-05-29 07:09:12 +04:00
.org swapper_pg_dir + HV_ L 1 _ S I Z E
END( s w a p p e r _ p g _ d i r )
/ *
* Isolate s w a p p e r _ p g p r o t t o i t s o w n c a c h e l i n e , s i n c e e a c h c p u
* starting u p w i l l r e a d i t u s i n g V A - i s - P A a n d l o c a l h o m i n g .
* This w o u l d o t h e r w i s e l i k e l y c o n f l i c t w i t h o t h e r d a t a o n t h e c a c h e
* line, o n c e w e h a v e s e t i t s p e r m a n e n t h o m e i n t h e p a g e t a b l e s .
* /
_ _ INITDATA
.align CHIP_ L 2 _ L I N E _ S I Z E ( )
ENTRY( s w a p p e r _ p g p r o t )
2011-03-17 21:32:06 +03:00
PTE 0 , 0 , ( 1 < < ( H V _ P T E _ I N D E X _ R E A D A B L E - 3 2 ) ) | \
( 1 < < ( HV_ P T E _ I N D E X _ W R I T A B L E - 3 2 ) ) , 1
2010-05-29 07:09:12 +04:00
.align CHIP_ L 2 _ L I N E _ S I Z E ( )
END( s w a p p e r _ p g p r o t )