2008-02-08 04:19:31 -08:00
/ * Boot e n t r y p o i n t f o r M N 1 0 3 0 0 k e r n e l
*
* Copyright ( C ) 2 0 0 5 R e d H a t , I n c . A l l R i g h t s R e s e r v e d .
* Written b y D a v i d H o w e l l s ( d h o w e l l s @redhat.com)
*
* 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 c 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 ; either version
* 2 of t h e L i c e n c e , o r ( a t y o u r o p t i o n ) a n y l a t e r v e r s i o n .
* /
2009-04-25 22:11:04 -04:00
# include < l i n u x / i n i t . h >
2008-02-08 04:19:31 -08:00
# include < l i n u x / t h r e a d s . h >
# include < l i n u x / l i n k a g e . h >
# include < l i n u x / s e r i a l _ r e g . h >
# include < a s m / t h r e a d _ i n f o . 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 / f r a m e . i n c >
# include < a s m / p a r a m . h >
2009-04-10 14:33:48 +01:00
# include < u n i t / s e r i a l . h >
2008-02-08 04:19:31 -08:00
2009-04-25 22:11:04 -04:00
_ _ HEAD
2008-02-08 04:19:31 -08:00
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# bootloader e n t r y p o i n t
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
.globl _start
.type _ start,@function
_start :
# save c o m m a n d l i n e p o i n t e r
mov d0 ,a3
# preload t h e P G D p o i n t e r r e g i s t e r
mov s w a p p e r _ p g _ d i r ,d0
mov d0 ,( P T B R )
# turn o n t h e T L B s
mov M M U C T R _ I I V | M M U C T R _ D I V ,d0
mov d0 ,( M M U C T R )
mov M M U C T R _ I T E | M M U C T R _ D T E | M M U C T R _ C E ,d0
mov d0 ,( M M U C T R )
# turn o n A M 3 3 v2 e x c e p t i o n h a n d l i n g m o d e a n d s e t t h e t r a p t a b l e b a s e
movhu ( C P U P ) ,d0
or C P U P _ E X M _ A M 3 3 V 2 ,d0
movhu d0 ,( C P U P )
mov C O N F I G _ I N T E R R U P T _ V E C T O R _ B A S E ,d0
mov d0 ,( T B R )
# invalidate a n d e n a b l e b o t h o f t h e c a c h e s
mov C H C T R ,a0
clr d0
movhu d0 ,( a0 ) # t u r n o f f f i r s t
mov C H C T R _ I C I N V | C H C T R _ D C I N V ,d0
movhu d0 ,( a0 )
setlb
mov ( a0 ) ,d0
btst C H C T R _ I C B U S Y | C H C T R _ D C B U S Y ,d0 # w a i t t i l l n o t b u s y
lne
# ifndef C O N F I G _ M N 1 0 3 0 0 _ C A C H E _ D I S A B L E D
# ifdef C O N F I G _ M N 1 0 3 0 0 _ C A C H E _ W B A C K
# ifndef C O N F I G _ M N 1 0 3 0 0 _ C A C H E _ W B A C K _ N O W R A L L O C
mov C H C T R _ I C E N | C H C T R _ D C E N | C H C T R _ D C W T M D _ W R B A C K ,d0
# else
mov C H C T R _ I C E N | C H C T R _ D C E N | C H C T R _ D C W T M D _ W R B A C K | C H C T R _ D C A L M D ,d0
# endif / * C A C H E _ D I S A B L E D * /
# else
mov C H C T R _ I C E N | C H C T R _ D C E N | C H C T R _ D C W T M D _ W R T H R O U G H ,d0
# endif / * W B A C K * /
movhu d0 ,( a0 ) # e n a b l e
# endif / * N O W R A L L O C * /
# turn o n R T S o n t h e d e b u g s e r i a l p o r t i f a p p l i c a b l e
# ifdef C O N F I G _ M N 1 0 3 0 0 _ U N I T _ A S B 2 3 0 5
bset U A R T _ M C R _ R T S ,( A S B 2 3 0 5 _ D E B U G _ M C R )
# endif
# clear t h e B S S a r e a
mov _ _ b s s _ s t a r t ,a0
mov _ _ b s s _ s t o p ,a1
clr d0
bssclear :
cmp a1 ,a0
bge b s s c l e a r _ e n d
mov d0 ,( a0 )
inc4 a0
bra b s s c l e a r
bssclear_end :
# retrieve t h e p a r a m e t e r s ( i n c l u d i n g c o m m a n d l i n e ) b e f o r e w e o v e r w r i t e
# them
cmp 0 x a b a d c a f e ,d1
bne _ _ n o _ p a r a m e t e r s
__copy_parameters :
mov r e d b o o t _ c o m m a n d _ l i n e ,a0
mov a0 ,a1
add C O M M A N D _ L I N E _ S I Z E ,a1
1 :
movbu ( a3 ) ,d0
inc a3
movbu d0 ,( a0 )
inc a0
cmp a1 ,a0
blt 1 b
mov r e d b o o t _ p l a t f o r m _ n a m e ,a0
mov a0 ,a1
add C O M M A N D _ L I N E _ S I Z E ,a1
mov d2 ,a3
1 :
movbu ( a3 ) ,d0
inc a3
movbu d0 ,( a0 )
inc a0
cmp a1 ,a0
blt 1 b
__no_parameters :
# set u p t h e r e g i s t e r s w i t h r e c o g n i s a b l e r u b b i s h i n t h e m
mov i n i t _ t h r e a d _ u n i o n + T H R E A D _ S I Z E - 1 2 ,s p
mov 0 x e a01 e a e a ,d0
mov d0 ,( 4 ,s p ) # E P S W s a v e a r e a
mov 0 x e a02 e a e a ,d0
mov d0 ,( 8 ,s p ) # P C s a v e a r e a
mov 0 x e b00 6 0 e d ,d0
mov d0 ,m d r
mov 0 x e b00 6 1 e d ,d0
mov d0 ,m d r q
mov 0 x e b00 6 2 e d ,d0
mov d0 ,m c r h
mov 0 x e b00 6 3 e d ,d0
mov d0 ,m c r l
mov 0 x e b00 6 4 e d ,d0
mov d0 ,m c v f
mov 0 x e d00 6 5 e d ,a3
mov a3 ,u s p
mov 0 x e d00 e 0 e d ,e 0
mov 0 x e d00 e 1 e d ,e 1
mov 0 x e d00 e 2 e d ,e 2
mov 0 x e d00 e 3 e d ,e 3
mov 0 x e d00 e 4 e d ,e 4
mov 0 x e d00 e 5 e d ,e 5
mov 0 x e d00 e 6 e d ,e 6
mov 0 x e d00 e 7 e d ,e 7
mov 0 x e d00 d0 e d ,d0
mov 0 x e d00 d1 e d ,d1
mov 0 x e d00 d2 e d ,d2
mov 0 x e d00 d3 e d ,d3
mov 0 x e d00 a0 e d ,a0
mov 0 x e d00 a1 e d ,a1
mov 0 x e d00 a2 e d ,a2
mov 0 ,a3
# set u p t h e i n i t i a l k e r n e l s t a c k
SAVE_ A L L
mov 0 x f f f f f f f f ,d0
mov d0 ,( R E G _ O R I G _ D 0 ,f p )
# put d i f f e r e n t r e c o g n i s a b l e r u b b i s h i n t h e r e g s
mov 0 x f b00 6 0 e d ,d0
mov d0 ,m d r
mov 0 x f b00 6 1 e d ,d0
mov d0 ,m d r q
mov 0 x f b00 6 2 e d ,d0
mov d0 ,m c r h
mov 0 x f b00 6 3 e d ,d0
mov d0 ,m c r l
mov 0 x f b00 6 4 e d ,d0
mov d0 ,m c v f
mov 0 x f d00 6 5 e d ,a0
mov a0 ,u s p
mov 0 x f d00 e 0 e d ,e 0
mov 0 x f d00 e 1 e d ,e 1
mov 0 x f d00 e 2 e d ,e 2
mov 0 x f d00 e 3 e d ,e 3
mov 0 x f d00 e 4 e d ,e 4
mov 0 x f d00 e 5 e d ,e 5
mov 0 x f d00 e 6 e d ,e 6
mov 0 x f d00 e 7 e d ,e 7
mov 0 x f d00 d0 e d ,d0
mov 0 x f d00 d1 e d ,d1
mov 0 x f d00 d2 e d ,d2
mov 0 x f d00 d3 e d ,d3
mov 0 x f d00 a0 e d ,a0
mov 0 x f d00 a1 e d ,a1
mov 0 x f d00 a2 e d ,a2
# we m a y b e h o l d i n g c u r r e n t i n E 2
# ifdef C O N F I G _ M N 1 0 3 0 0 _ C U R R E N T _ I N _ E 2
mov i n i t _ t a s k ,e 2
# endif
# initialise t h e p r o c e s s o r a n d t h e u n i t
call p r o c e s s o r _ i n i t [ ] ,0
call u n i t _ i n i t [ ] ,0
# ifdef C O N F I G _ G D B S T U B
call g d b s t u b _ i n i t [ ] ,0
# ifdef C O N F I G _ G D B S T U B _ I M M E D I A T E
.globl __gdbstub_pause
__gdbstub_pause :
bra _ _ g d b s t u b _ p a u s e
# endif
# endif
jmp s t a r t _ k e r n e l
.size _ start, _ s t a r t - .
ENTRY( _ _ h e a d _ e n d )
/ *
* This i s i n i t i a l i z e d t o d i s a l l o w a l l a c c e s s t o t h e l o w 2 G r e g i o n
* - the h i g h 2 G r e g i o n i s m a n a g e d d i r e c t l y b y t h e M M U
* - range 0 x70 0 0 0 0 0 0 - 0 x7 C 0 0 0 0 0 0 a r e i n i t i a l i s e d f o r u s e b y V M A L L O C
* /
.section .bss
.balign PAGE_SIZE
ENTRY( s w a p p e r _ p g _ d i r )
.space PTRS_ P E R _ P G D * 4
/ *
* The p a g e t a b l e s a r e i n i t i a l i z e d t o o n l y 8 M B h e r e - t h e f i n a l p a g e
* tables a r e s e t u p l a t e r d e p e n d i n g o n m e m o r y s i z e .
* /
.balign PAGE_SIZE
ENTRY( e m p t y _ z e r o _ p a g e )
.space PAGE_SIZE
.balign PAGE_SIZE
ENTRY( e m p t y _ b a d _ p a g e )
.space PAGE_SIZE
.balign PAGE_SIZE
ENTRY( e m p t y _ b a d _ p t e _ t a b l e )
.space PAGE_SIZE
.balign PAGE_SIZE
ENTRY( l a r g e _ p a g e _ t a b l e )
.space PAGE_SIZE
.balign PAGE_SIZE
ENTRY( k e r n e l _ v m a l l o c _ p t e s )
.space ( ( VMALLOC_ E N D - V M A L L O C _ S T A R T ) / P A G E _ S I Z E ) * 4