2009-01-07 23:14:39 +08:00
/ *
2009-09-24 14:11:24 +00:00
* BF5 6 1 c o r e B b o o t s t r a p f i l e
2009-01-07 23:14:39 +08:00
*
2009-09-24 14:11:24 +00:00
* Copyright 2 0 0 7 - 2 0 0 9 A n a l o g D e v i c e s I n c .
* Philippe G e r u m < r p m @xenomai.org>
2009-01-07 23:14:39 +08:00
*
2009-09-24 14:11:24 +00:00
* Licensed u n d e r t h e G P L - 2 o r l a t e r .
2009-01-07 23:14:39 +08:00
* /
# 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 / b l a c k f i n . h >
# include < a s m / a s m - o f f s e t s . h >
2009-12-28 11:13:51 +00:00
# include < a s m / t r a c e . h >
2009-01-07 23:14:39 +08:00
_ _ INIT
/* Lay the initial stack into the L1 scratch area of Core B */
# define I N I T I A L _ S T A C K ( C O R E B _ L 1 _ S C R A T C H _ S T A R T + L 1 _ S C R A T C H _ L E N G T H - 1 2 )
ENTRY( _ c o r e b _ t r a m p o l i n e _ s t a r t )
/* Set the SYSCFG register */
R0 = 0 x36 ;
SYSCFG = R 0 ; /*Enable Cycle Counter and Nesting Of Interrupts(3rd Bit)*/
R0 = 0 ;
/*Clear Out All the data and pointer Registers*/
R1 = R 0 ;
R2 = R 0 ;
R3 = R 0 ;
R4 = R 0 ;
R5 = R 0 ;
R6 = R 0 ;
R7 = R 0 ;
P0 = R 0 ;
P1 = R 0 ;
P2 = R 0 ;
P3 = R 0 ;
P4 = R 0 ;
P5 = R 0 ;
LC0 = r0 ;
LC1 = r0 ;
L0 = r0 ;
L1 = r0 ;
L2 = r0 ;
L3 = r0 ;
/* Clear Out All the DAG Registers*/
B0 = r0 ;
B1 = r0 ;
B2 = r0 ;
B3 = r0 ;
I0 = r0 ;
I1 = r0 ;
I2 = r0 ;
I3 = r0 ;
M0 = r0 ;
M1 = r0 ;
M2 = r0 ;
M3 = r0 ;
2009-12-28 11:13:51 +00:00
trace_ b u f f e r _ i n i t ( p0 ,r0 ) ;
2009-01-07 23:14:39 +08:00
/* Turn off the icache */
p0 . l = L O ( I M E M _ C O N T R O L ) ;
p0 . h = H I ( I M E M _ C O N T R O L ) ;
R1 = [ p0 ] ;
R0 = ~ E N I C P L B ;
R0 = R 0 & R 1 ;
2009-08-07 01:20:58 +00:00
/* Disabling of CPLBs should be proceeded by a CSYNC */
CSYNC;
2009-01-07 23:14:39 +08:00
[ p0 ] = R 0 ;
SSYNC;
/* Turn off the dcache */
p0 . l = L O ( D M E M _ C O N T R O L ) ;
p0 . h = H I ( D M E M _ C O N T R O L ) ;
R1 = [ p0 ] ;
R0 = ~ E N D C P L B ;
R0 = R 0 & R 1 ;
2009-08-07 01:20:58 +00:00
/* Disabling of CPLBs should be proceeded by a CSYNC */
CSYNC;
2009-01-07 23:14:39 +08:00
[ p0 ] = R 0 ;
SSYNC;
/* in case of double faults, save a few things */
p0 . l = _ i n i t _ r e t x _ c o r e b ;
p0 . h = _ i n i t _ r e t x _ c o r e b ;
R0 = R E T X ;
[ P0 ] = R 0 ;
# ifdef C O N F I G _ D E B U G _ D O U B L E F A U L T
/ * Only s a v e t h e s e i f w e a r e s t o r i n g t h e m ,
* This h a p p e n s h e r e , s i n c e L 1 g e t s c l o b b e r e d
* below
* /
GET_ P D A ( p0 , r0 ) ;
2009-07-22 11:56:24 +00:00
r7 = [ p0 + P D A _ D F _ R E T X ] ;
2009-01-07 23:14:39 +08:00
p1 . l = _ i n i t _ s a v e d _ r e t x _ c o r e b ;
p1 . h = _ i n i t _ s a v e d _ r e t x _ c o r e b ;
[ p1 ] = r7 ;
2009-07-22 11:56:24 +00:00
r7 = [ p0 + P D A _ D F _ D C P L B ] ;
2009-01-07 23:14:39 +08:00
p1 . l = _ i n i t _ s a v e d _ d c p l b _ f a u l t _ a d d r _ c o r e b ;
p1 . h = _ i n i t _ s a v e d _ d c p l b _ f a u l t _ a d d r _ c o r e b ;
[ p1 ] = r7 ;
2009-07-22 11:56:24 +00:00
r7 = [ p0 + P D A _ D F _ I C P L B ] ;
2009-01-07 23:14:39 +08:00
p1 . l = _ i n i t _ s a v e d _ i c p l b _ f a u l t _ a d d r _ c o r e b ;
p1 . h = _ i n i t _ s a v e d _ i c p l b _ f a u l t _ a d d r _ c o r e b ;
[ p1 ] = r7 ;
2009-07-22 11:56:24 +00:00
r7 = [ p0 + P D A _ D F _ S E Q S T A T ] ;
2009-01-07 23:14:39 +08:00
p1 . l = _ i n i t _ s a v e d _ s e q s t a t _ c o r e b ;
p1 . h = _ i n i t _ s a v e d _ s e q s t a t _ c o r e b ;
[ p1 ] = r7 ;
# endif
/* Initialize stack pointer */
sp. l = l o ( I N I T I A L _ S T A C K ) ;
sp. h = h i ( I N I T I A L _ S T A C K ) ;
fp = s p ;
usp = s p ;
/ * This s e c t i o n k e e p s t h e p r o c e s s o r i n s u p e r v i s o r m o d e
* during c o r e B s t a r t u p . B r a n c h e s t o t h e i d l e t a s k .
* /
/* EVT15 = _real_start */
p0 . l = l o ( E V T 1 5 ) ;
p0 . h = h i ( E V T 1 5 ) ;
p1 . l = _ c o r e b _ s t a r t ;
p1 . h = _ c o r e b _ s t a r t ;
[ p0 ] = p1 ;
csync;
p0 . l = l o ( I M A S K ) ;
p0 . h = h i ( I M A S K ) ;
p1 . l = I M A S K _ I V G 1 5 ;
p1 . h = 0 x0 ;
[ p0 ] = p1 ;
csync;
raise 1 5 ;
p0 . l = . L W A I T _ H E R E ;
p0 . h = . L W A I T _ H E R E ;
reti = p0 ;
# if d e f i n e d ( A N O M A L Y _ 0 5 0 0 0 2 8 1 )
nop; nop; nop;
# endif
rti;
.LWAIT_HERE :
jump . L W A I T _ H E R E ;
ENDPROC( _ c o r e b _ t r a m p o l i n e _ s t a r t )
ENTRY( _ c o r e b _ t r a m p o l i n e _ e n d )
2009-12-28 11:13:51 +00:00
.section " .text "
ENTRY( _ s e t _ s i c b _ i w r )
P0 . H = h i ( S I C B _ I W R 0 ) ;
P0 . L = l o ( S I C B _ I W R 0 ) ;
P1 . H = h i ( S I C B _ I W R 1 ) ;
P1 . L = l o ( S I C B _ I W R 1 ) ;
[ P0 ] = R 0 ;
[ P1 ] = R 1 ;
SSYNC;
RTS;
ENDPROC( _ s e t _ s i c b _ i w r )
ENTRY( _ c o r e b _ s l e e p )
sp. l = l o ( I N I T I A L _ S T A C K ) ;
sp. h = h i ( I N I T I A L _ S T A C K ) ;
fp = s p ;
usp = s p ;
call _ s e t _ s i c b _ i w r ;
CLI R 2 ;
SSYNC;
IDLE;
STI R 2 ;
R0 = I W R _ D I S A B L E _ A L L ;
R1 = I W R _ D I S A B L E _ A L L ;
call _ s e t _ s i c b _ i w r ;
p0 . h = h i ( C O R E B _ L 1 _ C O D E _ S T A R T ) ;
p0 . l = l o ( C O R E B _ L 1 _ C O D E _ S T A R T ) ;
jump ( p0 ) ;
ENDPROC( _ c o r e b _ s l e e p )
_ _ CPUINIT
2009-01-07 23:14:39 +08:00
ENTRY( _ c o r e b _ s t a r t )
[ - - sp] = r e t i ;
p0 . l = l o ( W D O G B _ C T L ) ;
p0 . h = h i ( W D O G B _ C T L ) ;
r0 = 0 x A D 6 ( z ) ;
w[ p0 ] = r0 ; /* Clear the watchdog. */
ssync;
/ *
* switch t o I D L E s t a c k .
* /
p0 . l = _ s e c o n d a r y _ s t a c k ;
p0 . h = _ s e c o n d a r y _ s t a c k ;
sp = [ p0 ] ;
usp = s p ;
fp = s p ;
2009-12-28 11:13:51 +00:00
# ifdef C O N F I G _ H O T P L U G _ C P U
p0 . l = _ h o t p l u g _ c o r e b ;
p0 . h = _ h o t p l u g _ c o r e b ;
r0 = [ p0 ] ;
cc = B I T T S T ( r0 , 0 ) ;
if c c j u m p 3 f ;
# endif
2009-01-07 23:14:39 +08:00
sp + = - 1 2 ;
call _ i n i t _ p d a
sp + = 1 2 ;
2009-12-28 11:13:51 +00:00
# ifdef C O N F I G _ H O T P L U G _ C P U
3 :
# endif
2009-01-07 23:14:39 +08:00
call _ s e c o n d a r y _ s t a r t _ k e r n e l ;
.L_exit :
jump. s . L _ e x i t ;
ENDPROC( _ c o r e b _ s t a r t )