2005-04-17 02:20:36 +04:00
/ * - * - mode : asm - * -
* *
* * head. S - - T h i s f i l e c o n t a i n s t h e i n i t i a l b o o t c o d e f o r t h e
* * Linux/ 6 8 k k e r n e l .
* *
* * Copyright 1 9 9 3 b y H a m i s h M a c d o n a l d
* *
* * 6 8 0 4 0 fixes b y M i c h a e l R a u s c h
* * 6 8 0 6 0 fixes b y R o m a n H o d e k
* * MMU c l e a n u p b y R a n d y T h e l e n
* * Final M M U c l e a n u p b y R o m a n Z i p p e l
* *
* * Atari s u p p o r t b y A n d r e a s S c h w a b , u s i n g i d e a s o f R o b e r t d e V r i e s
* * and B j o e r n B r a u e l
* * VME S u p p o r t b y R i c h a r d H i r s t
* *
* * 9 4 / 1 1 / 1 4 Andreas S c h w a b : p u t k e r n e l a t P A G E S I Z E
* * 9 4 / 1 1 / 1 8 Andreas S c h w a b : r e m o v e i d e n t i t y m a p p i n g o f S T R A M f o r A t a r i
* * + + Bjoern & R o m a n : A T A R I - 6 8 0 4 0 s u p p o r t f o r t h e M e d u s a
* * 9 5 / 1 1 / 1 8 Richard H i r s t : A d d e d M V M E 1 6 6 s u p p o r t
* * 9 6 / 0 4 / 2 6 Guenther K e l l e t e r : f i x e d i d e n t i t y m a p p i n g f o r F a l c o n w i t h
* * Magnum- a n d F X - a l t e r n a t e r a m
* * 9 8 / 0 4 / 2 5 Phil B l u n d e l l : a d d e d H P 3 0 0 s u p p o r t
* * 1 9 9 8 / 0 8 / 3 0 David K i l z e r : A d d e d s u p p o r t f o r f o n t _ d e s c s t r u c t u r e s
* * for l i n u x - 2 . 1 . 1 1 5
* * 9 / 0 2 / 1 1 Richard Z i d l i c k y : a d d e d Q 4 0 s u p p o r t ( i n i t i a l v e s i o n 9 9 / 0 1 / 0 1 )
* * 2 0 0 4 / 0 5 / 1 3 Kars d e J o n g : F i n a l i s e d H P 3 0 0 s u p p o r t
* *
* * This f i l e i s s u b j e c t t o t h e t e r m s a n d c o n d i t i o n s o f t h e G N U G e n e r a l P u b l i c
* * License. S e e t h e f i l e R E A D M E . l e g a l i n t h e m a i n d i r e c t o r y o f t h i s a r c h i v e
* * for m o r e d e t a i l s .
* *
* /
/ *
* Linux s t a r t u p c o d e .
*
* At t h i s p o i n t , t h e b o o t l o a d e r h a s :
* Disabled i n t e r r u p t s
* Disabled c a c h e s
* Put u s i n s u p e r v i s o r s t a t e .
*
* The k e r n e l s e t u p c o d e t a k e s t h e f o l l o w i n g s t e p s :
* . Raise i n t e r r u p t l e v e l
* . Set u p i n i t i a l k e r n e l m e m o r y m a p p i n g .
* . This s e t s u p a m a p p i n g o f t h e 4 M o f m e m o r y t h e k e r n e l i s l o c a t e d i n .
* . It a l s o d o e s a m a p p i n g o f a n y i n i t i a l m a c h i n e s p e c i f i c a r e a s .
* . Enable t h e M M U
* . Enable c a c h e m e m o r i e s
* . Jump t o k e r n e l s t a r t u p
*
* Much o f t h e f i l e r e s t r u c t u r i n g w a s t o a c c o m p l i s h :
* 1 ) Remove r e g i s t e r d e p e n d e n c y t h r o u g h - o u t t h e f i l e .
* 2 ) Increase u s e o f s u b r o u t i n e s t o p e r f o r m f u n c t i o n s
* 3 ) Increase r e a d a b i l i t y o f t h e c o d e
*
* Of c o u r s e , r e a d a b i l i t y i s a s u b j e c t i v e i s s u e , s o i t w i l l n e v e r b e
* argued t h a t t h a t g o a l w a s a c c o m p l i s h e d . I t w a s m e r e l y a g o a l .
* A k e y w a y t o h e l p m a k e c o d e m o r e r e a d a b l e i s t o g i v e g o o d
* documentation. S o , t h e f i r s t t h i n g y o u w i l l f i n d i s e x a u s t i v e
* write- u p s o n t h e s t r u c t u r e o f t h e f i l e , a n d t h e f e a t u r e s o f t h e
* functional s u b r o u t i n e s .
*
* General S t r u c t u r e :
* - - - - - - - - - - - - - - - - - -
* Without a d o u b t t h e s i n g l e l a r g e s t c h u n k o f h e a d . S i s s p e n t
* mapping t h e k e r n e l a n d I / O p h y s i c a l s p a c e i n t o t h e l o g i c a l r a n g e
* for t h e k e r n e l .
* There a r e n e w s u b r o u t i n e s a n d d a t a s t r u c t u r e s t o m a k e M M U
* support c l e a n e r a n d e a s i e r t o u n d e r s t a n d .
* First, y o u w i l l f i n d a r o u t i n e c a l l " m m u _ m a p " w h i c h m a p s
* a l o g i c a l t o a p h y s i c a l r e g i o n f o r s o m e l e n g t h g i v e n a c a c h e
* type o n b e h a l f o f t h e c a l l e r . T h i s r o u t i n e m a k e s w r i t i n g t h e
* actual p e r - m a c h i n e s p e c i f i c c o d e v e r y s i m p l e .
* A c e n t r a l p a r t o f t h e c o d e , b u t n o t a s u b r o u t i n e i n i t s e l f ,
* is t h e m m u _ i n i t c o d e w h i c h i s b r o k e n d o w n i n t o m a p p i n g t h e k e r n e l
* ( the s a m e f o r a l l m a c h i n e s ) a n d m a p p i n g m a c h i n e - s p e c i f i c I / O
* regions.
* Also, t h e r e w i l l b e a d e s c r i p t i o n o f e n g a g i n g t h e M M U a n d
* caches.
* You w i l l n o t i c e t h a t t h e r e i s a c h u n k o f c o d e w h i c h
* can e m i t t h e e n t i r e M M U m a p p i n g o f t h e m a c h i n e . T h i s i s p r e s e n t
* only i n d e b u g m o d e s a n d c a n b e v e r y h e l p f u l .
* Further, t h e r e i s a n e w c o n s o l e d r i v e r i n h e a d . S t h a t i s
* also o n l y e n g a g e d i n d e b u g m o d e . C u r r e n t l y , i t ' s o n l y s u p p o r t e d
* on t h e M a c i n t o s h c l a s s o f m a c h i n e s . H o w e v e r , i t i s h o p e d t h a t
* others w i l l p l u g - i n s u p p o r t f o r s p e c i f i c m a c h i n e s .
*
* # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
*
* mmu_ m a p
* - - - - - - -
* mmu_ m a p w a s w r i t t e n f o r t w o k e y r e a s o n s . F i r s t , i t w a s c l e a r
* that i t w a s v e r y d i f f i c u l t t o r e a d t h e p r e v i o u s c o d e f o r m a p p i n g
* regions o f m e m o r y . S e c o n d , t h e M a c i n t o s h r e q u i r e d s u c h e x t e n s i v e
* memory a l l o c a t i o n s t h a t i t d i d n ' t m a k e s e n s e t o p r o p a g a t e t h e
* existing c o d e a n y f u r t h e r .
* mmu_ m a p r e q u i r e s s o m e p a r a m e t e r s :
*
* mmu_ m a p ( l o g i c a l , p h y s i c a l , l e n g t h , c a c h e _ t y p e )
*
* While t h i s e s s e n t i a l l y d e s c r i b e s t h e f u n c t i o n i n t h e a b s t r a c t , y o u ' l l
* find m o r e i n d e p t h d e s c r i p t i o n o f o t h e r p a r a m e t e r s a t t h e i m p l e m e n t a t i o n s i t e .
*
* mmu_ g e t _ r o o t _ t a b l e _ e n t r y
* - - - - - - - - - - - - - - - - - - - - - - - -
* mmu_ g e t _ p t r _ t a b l e _ e n t r y
* - - - - - - - - - - - - - - - - - - - - - - -
* mmu_ g e t _ p a g e _ t a b l e _ e n t r y
* - - - - - - - - - - - - - - - - - - - - - - - -
*
* These r o u t i n e s a r e u s e d b y o t h e r m m u r o u t i n e s t o g e t a p o i n t e r i n t o
* a t a b l e , i f n e c e s s a r y a n e w t a b l e i s a l l o c a t e d . T h e s e r o u t i n e s a r e w o r k i n g
* basically l i k e p m d _ a l l o c ( ) a n d p t e _ a l l o c ( ) i n < a s m / p g t a b l e . h > . T h e r o o t
* table n e e d s o f c o u r s e o n l y t o b e a l l o c a t e d o n c e i n m m u _ g e t _ r o o t _ t a b l e _ e n t r y ,
* so t h a t h e r e a l s o s o m e m m u s p e c i f i c i n i t i a l i z a t i o n i s d o n e . T h e s e c o n d p a g e
* at t h e s t a r t o f t h e k e r n e l ( t h e f i r s t p a g e i s u n m a p p e d l a t e r ) i s u s e d f o r
* the k e r n e l _ p g _ d i r . I t m u s t b e a t a p o s i t i o n k n o w n a t l i n k t i m e ( a s i t ' s u s e d
* to i n i t i a l i z e t h e i n i t t a s k s t r u c t ) a n d s i n c e i t n e e d s s p e c i a l c a c h e
* settings, i t ' s t h e e a s i e s t t o u s e t h i s p a g e , t h e r e s t o f t h e p a g e i s u s e d
* for f u r t h e r p o i n t e r t a b l e s .
* mmu_ g e t _ p a g e _ t a b l e _ e n t r y a l l o c a t e s a l w a y s a w h o l e p a g e f o r p a g e t a b l e s , t h i s
* means 1 0 2 4 p a g e s a n d s o 4 M B o f m e m o r y c a n b e m a p p e d . I t d o e s n ' t m a k e s e n s e
* to m a n a g e p a g e t a b l e s i n s m a l l e r p i e c e s a s n e a r l y a l l m a p p i n g s h a v e t h a t
* size.
*
* # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
*
*
* # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
*
* mmu_ e n g a g e
* - - - - - - - - - -
* Thanks t o a s m a l l h e l p i n g r o u t i n e e n a b l i n g t h e m m u g o t q u i t e s i m p l e
* and t h e r e i s o n l y o n e w a y l e f t . m m u _ e n g a g e m a k e s a c o m p l e t e a n e w m a p p i n g
* that o n l y i n c l u d e s t h e a b s o l u t e n e c e s s a r y t o b e a b l e t o j u m p t o t h e f i n a l
* postion a n d t o r e s t o r e t h e o r i g i n a l m a p p i n g .
* As t h i s c o d e d o e s n ' t n e e d a t r a n s p a r e n t t r a n s l a t i o n r e g i s t e r a n y m o r e t h i s
* means a l l r e g i s t e r s a r e f r e e t o b e u s e d b y m a c h i n e s t h a t n e e d s t h e m f o r
* other p u r p o s e s .
*
* # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
*
* mmu_ p r i n t
* - - - - - - - - -
* This a l g o r i t h m w i l l p r i n t o u t t h e p a g e t a b l e s o f t h e s y s t e m a s
* appropriate f o r a n 0 3 0 o r a n 0 4 0 . T h i s i s u s e f u l f o r d e b u g g i n g p u r p o s e s
* and a s s u c h i s e n c l o s e d i n #i f d e f M M U _ P R I N T / # e n d i f c l a u s e s .
*
* # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
*
* console_ i n i t
* - - - - - - - - - - - -
* The c o n s o l e i s a l s o a b l e t o b e t u r n e d o f f . T h e c o n s o l e i n h e a d . S
* is s p e c i f i c a l l y f o r d e b u g g i n g a n d c a n b e v e r y u s e f u l . I t i s s u r r o u n d e d b y
* # ifdef C O N S O L E / #e n d i f c l a u s e s s o i t d o e s n ' t h a v e t o s h i p i n k n o w n - g o o d
* kernels. I t ' s b a s i c a l g o r i t h m i s t o d e t e r m i n e t h e s i z e o f t h e s c r e e n
* ( in h e i g h t / w i d t h a n d b i t d e p t h ) a n d t h e n u s e t h a t i n f o r m a t i o n f o r
* displaying a n 8 x8 f o n t o r a n 8 x16 ( w i d t h x h e i g h t ) . I p r e f e r t h e 8 x8 f o r
* debugging s o I c a n s e e m o r e g o o d d a t a . B u t i t w a s t r i v i a l t o a d d s u p p o r t
* for b o t h f o n t s , s o I i n c l u d e d i t .
* Also, t h e a l g o r i t h m f o r p l o t t i n g p i x e l s i s a b s t r a c t e d s o t h a t i n
* theory o t h e r p l a t f o r m s c o u l d a d d s u p p o r t f o r d i f f e r e n t k i n d s o f f r a m e
* buffers. T h i s c o u l d b e v e r y u s e f u l .
*
* console_ p u t _ p e n g u i n
* - - - - - - - - - - - - - - - - - - -
* An i m p o r t a n t p a r t o f a n y L i n u x b r i n g u p i s t h e p e n g u i n a n d t h e r e ' s
* nothing l i k e g e t t i n g t h e P e n g u i n o n t h e s c r e e n ! T h i s a l g o r i t h m w i l l w o r k
* on a n y m a c h i n e f o r w h i c h t h e r e i s a c o n s o l e _ p l o t _ p i x e l .
*
* console_ s c r o l l
* - - - - - - - - - - - - - -
* My h o p e i s t h a t t h e s c r o l l a l g o r i t h m d o e s t h e r i g h t t h i n g o n t h e
* various p l a t f o r m s , b u t i t w o u l d n ' t b e h a r d t o a d d t h e t e s t c o n d i t i o n s
* and n e w c o d e i f i t d o e s n ' t .
*
* console_ p u t c
* - - - - - - - - - - - - -
*
* # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
*
* Register u s a g e h a s g r e a t l y s i m p l i f i e d w i t h i n h e a d . S . E v e r y s u b r o u t i n e
* saves a n d r e s t o r e s a l l r e g i s t e r s t h a t i t m o d i f i e s ( e x c e p t i t r e t u r n s a
* value i n t h e r e o f c o u r s e ) . S o t h e o n l y r e g i s t e r t h a t n e e d s t o b e i n i t i a l i z e d
* is t h e s t a c k p o i n t e r .
* All o t h e r i n i t c o d e a n d d a t a i s n o w p l a c e d i n t h e i n i t s e c t i o n , s o i t w i l l
* be a u t o m a t i c a l l y f r e e d a t t h e e n d o f t h e k e r n e l i n i t i a l i z a t i o n .
*
* # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
*
* options
* - - - - - - -
* There a r e m a n y o p t i o n s a v a i l a b l e i n a b u i l d o f t h i s f i l e . I ' v e
* taken t h e t i m e t o d e s c r i b e t h e m h e r e t o s a v e y o u t h e t i m e o f s e a r c h i n g
* for t h e m a n d t r y i n g t o u n d e r s t a n d w h a t t h e y m e a n .
*
* CONFIG_xxx : These a r e t h e o b v i o u s m a c h i n e c o n f i g u r a t i o n d e f i n e s c r e a t e d
* during c o n f i g u r a t i o n . T h e s e a r e d e f i n e d i n i n c l u d e / l i n u x / a u t o c o n f . h .
*
* CONSOLE : There i s s u p p o r t f o r h e a d . S c o n s o l e i n t h i s f i l e . T h i s
* console c a n t a l k t o a M a c f r a m e b u f f e r , b u t c o u l d e a s i l y b e e x t r a p o l a t e d
* to e x t e n d i t t o s u p p o r t o t h e r p l a t f o r m s .
*
* TEST_MMU : This i s a t e s t h a r n e s s f o r r u n n i n g o n a n y g i v e n m a c h i n e b u t
* getting a n M M U d u m p f o r a n o t h e r c l a s s o f m a c h i n e . T h e c l a s s e s o f m a c h i n e s
* that c a n b e t e s t e d a r e a n y o f t h e m a k e s ( A t a r i , A m i g a , M a c , V M E , e t c . )
* and a n y o f t h e m o d e l s ( 0 3 0 , 0 4 0 , 0 6 0 , e t c . ) .
*
* NOTE : TEST_ M M U i s N O T p e r m a n e n t ! I t i s s c h e d u l e d t o b e r e m o v e d
* When h e a d . S b o o t s o n A t a r i , A m i g a , M a c i n t o s h , a n d V M E
* machines. A t t h a t p o i n t t h e u n d e r l y i n g l o g i c w i l l b e
* believed t o b e s o l i d e n o u g h t o b e t r u s t e d , a n d T E S T _ M M U
* can b e d r o p p e d . D o n o t e t h a t t h a t w i l l c l e a n u p t h e
* head. S c o d e s i g n i f i c a n t l y a s l a r g e b l o c k s o f #i f / # e l s e
* clauses c a n b e r e m o v e d .
*
* MMU_NOCACHE_KERNEL : On t h e M a c i n t o s h p l a t f o r m t h e r e w a s a n i n q u i r y i n t o
* determing w h y d e v i c e s d o n ' t a p p e a r t o w o r k . A t e s t c a s e w a s t o r e m o v e
* the c a c h e a b i l i t y o f t h e k e r n e l b i t s .
*
* MMU_PRINT : There i s a r o u t i n e b u i l t i n t o h e a d . S t h a t c a n d i s p l a y t h e
* MMU d a t a s t r u c t u r e s . I t o u t p u t s i t s r e s u l t t h r o u g h t h e s e r i a l _ p u t c
* interface. S o w h e r e e v e r t h a t w i n d s u p d r i v i n g d a t a , t h a t ' s w h e r e t h e
* mmu s t r u c t w i l l a p p e a r . O n t h e M a c i n t o s h t h a t ' s t y p i c a l l y t h e c o n s o l e .
*
* SERIAL_DEBUG : There a r e a s e r i e s o f p u t c ( ) m a c r o s t a t e m e n t s
* scattered t h r o u g h o u t t h e c o d e t o g i v e p r o g r e s s o f s t a t u s t o t h e
* person s i t t i n g a t t h e c o n s o l e . T h i s c o n s t a n t d e t e r m i n e s w h e t h e r t h o s e
* are u s e d .
*
* DEBUG : This i s t h e s t a n d a r d D E B U G f l a g t h a t c a n b e s e t f o r b u i l d i n g
* the k e r n e l . I t h a s t h e e f f e c t a d d i n g a d d i t i o n a l t e s t s i n t o
* the c o d e .
*
* FONT_6x11 :
* FONT_8x8 :
* FONT_8x16 :
* In t h e o r y t h e s e c o u l d b e d e t e r m i n e d a t r u n t i m e o r h a n d e d
* over b y t h e b o o t e r . B u t , l e t ' s b e r e a l , i t ' s a f i n e h a r d
* coded v a l u e . ( B u t , y o u w i l l n o t i c e t h e c o d e i s r u n - t i m e
* flexible! ) A p o i n t e r t o t h e f o n t ' s s t r u c t f o n t _ d e s c
* is k e p t l o c a l l y i n L c o n s o l e _ f o n t . I t i s u s e d t o d e t e r m i n e
* font s i z e i n f o r m a t i o n d y n a m i c a l l y .
*
* Atari c o n s t a n t s :
* USE_PRINTER : Use t h e p r i n t e r p o r t f o r s e r i a l d e b u g .
* USE_SCC_B : Use t h e S C C p o r t A ( S e r i a l 2 ) f o r s e r i a l d e b u g .
* USE_SCC_A : Use t h e S C C p o r t B ( M o d e m 2 ) f o r s e r i a l d e b u g .
* USE_MFP : Use t h e S T - M F P p o r t ( M o d e m 1 ) f o r s e r i a l d e b u g .
*
* Macintosh c o n s t a n t s :
* MAC_SERIAL_DEBUG : Turns o n s e r i a l d e b u g o u t p u t f o r t h e M a c i n t o s h .
* MAC_USE_SCC_A : Use t h e S C C p o r t A ( m o d e m ) f o r s e r i a l d e b u g .
* MAC_USE_SCC_B : Use t h e S C C p o r t B ( p r i n t e r ) f o r s e r i a l d e b u g ( d e f a u l t ) .
* /
# 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 o o t i n f o . h >
# include < a s m / s e t u p . h >
# include < a s m / e n t r y . h >
# include < a s m / p g t a b l e . h >
# include < a s m / p a g e . h >
2005-09-09 22:57:26 +04:00
# include < a s m / a s m - o f f s e t s . h >
2005-04-17 02:20:36 +04:00
# ifdef C O N F I G _ M A C
# include < a s m / m a c h w . h >
/ *
* Macintosh c o n s o l e s u p p o r t
* /
2006-01-12 12:06:40 +03:00
# ifdef C O N F I G _ F R A M E B U F F E R _ C O N S O L E
2005-04-17 02:20:36 +04:00
# define C O N S O L E
# define C O N S O L E _ P E N G U I N
2006-01-12 12:06:40 +03:00
# endif
2005-04-17 02:20:36 +04:00
/ *
* Macintosh s e r i a l d e b u g s u p p o r t ; outputs boot info to the printer
* and/ o r m o d e m s e r i a l p o r t s
* /
# undef M A C _ S E R I A L _ D E B U G
/ *
* Macintosh s e r i a l d e b u g p o r t s e l e c t i o n ; define one or both;
* requires M A C _ S E R I A L _ D E B U G t o b e d e f i n e d
* /
# define M A C _ U S E _ S C C _ A / * M a c i n t o s h m o d e m s e r i a l p o r t * /
# define M A C _ U S E _ S C C _ B / * M a c i n t o s h p r i n t e r s e r i a l p o r t * /
# endif / * C O N F I G _ M A C * /
# undef M M U _ P R I N T
# undef M M U _ N O C A C H E _ K E R N E L
# define S E R I A L _ D E B U G
# undef D E B U G
/ *
* For t h e h e a d . S c o n s o l e , t h e r e a r e t h r e e s u p p o r t e d f o n t s , 6 x11 , 8 x16 a n d 8 x8 .
* The 8 x8 f o n t i s h a r d e r t o r e a d b u t f i t s m o r e o n t h e s c r e e n .
* /
# define F O N T _ 8 x8 / * d e f a u l t * /
/* #define FONT_8x16 */ /* 2nd choice */
/* #define FONT_6x11 */ /* 3rd choice */
.globl kernel_pg_dir
.globl availmem
.globl m68k_pgtable_cachemode
.globl m68k_supervisor_cachemode
# ifdef C O N F I G _ M V M E 1 6 x
.globl mvme_bdid
# endif
# ifdef C O N F I G _ Q 4 0
.globl q40_mem_cptr
# endif
CPUTYPE_ 0 4 0 = 1 / * i n d i c a t e s a n 0 4 0 * /
CPUTYPE_ 0 6 0 = 2 / * i n d i c a t e s a n 0 6 0 * /
CPUTYPE_ 0 4 6 0 = 3 / * i f e i t h e r a b o v e a r e s e t , t h i s i s s e t * /
CPUTYPE_ 0 2 0 = 4 / * i n d i c a t e s a n 0 2 0 * /
/* Translation control register */
TC_ E N A B L E = 0 x80 0 0
TC_ P A G E 8 K = 0 x40 0 0
TC_ P A G E 4 K = 0 x00 0 0
/* Transparent translation registers */
TTR_ E N A B L E = 0 x80 0 0 / * e n a b l e t r a n s p a r e n t t r a n s l a t i o n * /
TTR_ A N Y M O D E = 0 x40 0 0 / * u s e r a n d k e r n e l m o d e a c c e s s * /
TTR_ K E R N E L M O D E = 0 x20 0 0 / * o n l y k e r n e l m o d e a c c e s s * /
TTR_ U S E R M O D E = 0 x00 0 0 / * o n l y u s e r m o d e a c c e s s * /
TTR_ C I = 0 x04 0 0 / * i n h i b i t c a c h e * /
TTR_ R W = 0 x02 0 0 / * r e a d / w r i t e m o d e * /
TTR_ R W M = 0 x01 0 0 / * r e a d / w r i t e m a s k * /
TTR_ F C B 2 = 0 x00 4 0 / * f u n c t i o n c o d e b a s e b i t 2 * /
TTR_ F C B 1 = 0 x00 2 0 / * f u n c t i o n c o d e b a s e b i t 1 * /
TTR_ F C B 0 = 0 x00 1 0 / * f u n c t i o n c o d e b a s e b i t 0 * /
TTR_ F C M 2 = 0 x00 0 4 / * f u n c t i o n c o d e m a s k b i t 2 * /
TTR_ F C M 1 = 0 x00 0 2 / * f u n c t i o n c o d e m a s k b i t 1 * /
TTR_ F C M 0 = 0 x00 0 1 / * f u n c t i o n c o d e m a s k b i t 0 * /
/* Cache Control registers */
CC6 _ E N A B L E _ D = 0 x80 0 0 0 0 0 0 / * e n a b l e d a t a c a c h e ( 6 8 0 [ 4 6 ] 0 ) * /
CC6 _ F R E E Z E _ D = 0 x40 0 0 0 0 0 0 / * f r e e z e d a t a c a c h e ( 6 8 0 6 0 ) * /
CC6 _ E N A B L E _ S B = 0 x20 0 0 0 0 0 0 / * e n a b l e s t o r e b u f f e r ( 6 8 0 6 0 ) * /
CC6 _ P U S H _ D P I = 0 x10 0 0 0 0 0 0 / * d i s a b l e C P U S H i n v a l i d a t i o n ( 6 8 0 6 0 ) * /
CC6 _ H A L F _ D = 0 x08 0 0 0 0 0 0 / * h a l f - c a c h e m o d e f o r d a t a c a c h e ( 6 8 0 6 0 ) * /
CC6 _ E N A B L E _ B = 0 x00 8 0 0 0 0 0 / * e n a b l e b r a n c h c a c h e ( 6 8 0 6 0 ) * /
CC6 _ C L R A _ B = 0 x00 4 0 0 0 0 0 / * c l e a r a l l e n t r i e s i n b r a n c h c a c h e ( 6 8 0 6 0 ) * /
CC6 _ C L R U _ B = 0 x00 2 0 0 0 0 0 / * c l e a r u s e r e n t r i e s i n b r a n c h c a c h e ( 6 8 0 6 0 ) * /
CC6 _ E N A B L E _ I = 0 x00 0 0 8 0 0 0 / * e n a b l e i n s t r u c t i o n c a c h e ( 6 8 0 [ 4 6 ] 0 ) * /
CC6 _ F R E E Z E _ I = 0 x00 0 0 4 0 0 0 / * f r e e z e i n s t r u c t i o n c a c h e ( 6 8 0 6 0 ) * /
CC6 _ H A L F _ I = 0 x00 0 0 2 0 0 0 / * h a l f - c a c h e m o d e f o r i n s t r u c t i o n c a c h e ( 6 8 0 6 0 ) * /
CC3 _ A L L O C _ W R I T E = 0 x00 0 0 2 0 0 0 / * w r i t e a l l o c a t e m o d e ( 6 8 0 3 0 ) * /
CC3 _ E N A B L E _ D B = 0 x00 0 0 1 0 0 0 / * e n a b l e d a t a b u r s t ( 6 8 0 3 0 ) * /
CC3 _ C L R _ D = 0 x00 0 0 0 8 0 0 / * c l e a r d a t a c a c h e ( 6 8 0 3 0 ) * /
CC3 _ C L R E _ D = 0 x00 0 0 0 4 0 0 / * c l e a r e n t r y i n d a t a c a c h e ( 6 8 0 3 0 ) * /
CC3 _ F R E E Z E _ D = 0 x00 0 0 0 2 0 0 / * f r e e z e d a t a c a c h e ( 6 8 0 3 0 ) * /
CC3 _ E N A B L E _ D = 0 x00 0 0 0 1 0 0 / * e n a b l e d a t a c a c h e ( 6 8 0 3 0 ) * /
CC3 _ E N A B L E _ I B = 0 x00 0 0 0 0 1 0 / * e n a b l e i n s t r u c t i o n b u r s t ( 6 8 0 3 0 ) * /
CC3 _ C L R _ I = 0 x00 0 0 0 0 0 8 / * c l e a r i n s t r u c t i o n c a c h e ( 6 8 0 3 0 ) * /
CC3 _ C L R E _ I = 0 x00 0 0 0 0 0 4 / * c l e a r e n t r y i n i n s t r u c t i o n c a c h e ( 6 8 0 3 0 ) * /
CC3 _ F R E E Z E _ I = 0 x00 0 0 0 0 0 2 / * f r e e z e i n s t r u c t i o n c a c h e ( 6 8 0 3 0 ) * /
CC3 _ E N A B L E _ I = 0 x00 0 0 0 0 0 1 / * e n a b l e i n s t r u c t i o n c a c h e ( 6 8 0 3 0 ) * /
/* Miscellaneous definitions */
PAGESIZE = 4 0 9 6
PAGESHIFT = 1 2
ROOT_ T A B L E _ S I Z E = 1 2 8
PTR_ T A B L E _ S I Z E = 1 2 8
PAGE_ T A B L E _ S I Z E = 6 4
ROOT_ I N D E X _ S H I F T = 2 5
PTR_ I N D E X _ S H I F T = 1 8
PAGE_ I N D E X _ S H I F T = 1 2
# ifdef D E B U G
/* When debugging use readable names for labels */
# ifdef _ _ S T D C _ _
# define L ( n a m e ) . h e a d . S . ## n a m e
# else
# define L ( n a m e ) . h e a d . S . / * * / n a m e
# endif
# else
# ifdef _ _ S T D C _ _
# define L ( n a m e ) . L ## n a m e
# else
# define L ( n a m e ) . L / * * / n a m e
# endif
# endif
/* The __INITDATA stuff is a no-op when ftrace or kgdb are turned on */
# ifndef _ _ I N I T D A T A
# define _ _ I N I T D A T A . d a t a
# define _ _ F I N I T . p r e v i o u s
# endif
/ * Several m a c r o s t o m a k e t h e w r i t i n g o f s u b r o u t i n e s e a s i e r :
* - func_ s t a r t m a r k s t h e b e g i n n i n g o f t h e r o u t i n e w h i c h s e t u p s t h e f r a m e
* register a n d s a v e s t h e r e g i s t e r s , i t a l s o d e f i n e s a n o t h e r m a c r o
* to a u t o m a t i c a l l y r e s t o r e t h e r e g i s t e r s a g a i n .
* - func_ r e t u r n m a r k s t h e e n d o f t h e r o u t i n e a n d s i m p l y c a l l s t h e p r e p a r e d
* macro t o r e s t o r e r e g i s t e r s a n d j u m p b a c k t o t h e c a l l e r .
* - func_ d e f i n e g e n e r a t e s a n o t h e r m a c r o t o a u t o m a t i c a l l y p u t a r g u m e n t s
* onto t h e s t a c k c a l l t h e s u b r o u t i n e a n d c l e a n u p t h e s t a c k a g a i n .
* /
/ * Within s u b r o u t i n e s t h e s e m a c r o s c a n b e u s e d t o a c c e s s t h e a r g u m e n t s
* on t h e s t a c k . W i t h S T A C K s o m e a l l o c a t e d m e m o r y o n t h e s t a c k c a n b e
* accessed a n d A R G 0 p o i n t s t o t h e r e t u r n a d d r e s s ( u s e d b y m m u _ e n g a g e ) .
* /
# define S T A C K % a6 @(stackstart)
# define A R G 0 % a6 @(4)
# define A R G 1 % a6 @(8)
# define A R G 2 % a6 @(12)
# define A R G 3 % a6 @(16)
# define A R G 4 % a6 @(20)
.macro func_start name,s a v e r e g s ,s t a c k =0
L( \ n a m e ) :
linkw % a6 ,#- \ s t a c k
moveml \ s a v e r e g s ,% s p @-
.set stackstart,- \ s t a c k
.macro func_ r e t u r n _ \ n a m e
moveml % s p @+,\saveregs
unlk % a6
rts
.endm
.endm
.macro func_return name
func_ r e t u r n _ \ n a m e
.endm
.macro func_call name
jbsr L ( \ n a m e )
.endm
.macro move_stack nr,a r g 1 ,a r g 2 ,a r g 3 ,a r g 4
.if \ nr
move_ s t a c k " ( \ n r - 1 ) " ,\ a r g 2 ,\ a r g 3 ,\ a r g 4
movel \ a r g 1 ,% s p @-
.endif
.endm
.macro func_define name,n r =0
.macro \ name a r g 1 ,a r g 2 ,a r g 3 ,a r g 4
move_ s t a c k \ n r ,\ a r g 1 ,\ a r g 2 ,\ a r g 3 ,\ a r g 4
func_ c a l l \ n a m e
.if \ nr
lea % s p @(\nr*4),%sp
.endif
.endm
.endm
func_ d e f i n e m m u _ m a p ,4
func_ d e f i n e m m u _ m a p _ t t ,4
func_ d e f i n e m m u _ f i x u p _ p a g e _ m m u _ c a c h e ,1
func_ d e f i n e m m u _ t e m p _ m a p ,2
func_ d e f i n e m m u _ e n g a g e
func_ d e f i n e m m u _ g e t _ r o o t _ t a b l e _ e n t r y ,1
func_ d e f i n e m m u _ g e t _ p t r _ t a b l e _ e n t r y ,2
func_ d e f i n e m m u _ g e t _ p a g e _ t a b l e _ e n t r y ,2
func_ d e f i n e m m u _ p r i n t
func_ d e f i n e g e t _ n e w _ p a g e
# if d e f i n e d ( C O N F I G _ H P 3 0 0 ) | | d e f i n e d ( C O N F I G _ A P O L L O )
func_ d e f i n e s e t _ l e d s
# endif
.macro mmu_map_eq arg1 ,a r g 2 ,a r g 3
mmu_ m a p \ a r g 1 ,\ a r g 1 ,\ a r g 2 ,\ a r g 3
.endm
.macro get_bi_record record
pea \ r e c o r d
func_ c a l l g e t _ b i _ r e c o r d
addql #4 ,% s p
.endm
func_ d e f i n e s e r i a l _ p u t c ,1
func_ d e f i n e c o n s o l e _ p u t c ,1
func_ d e f i n e c o n s o l e _ i n i t
func_ d e f i n e c o n s o l e _ p u t _ s t a t s
func_ d e f i n e c o n s o l e _ p u t _ p e n g u i n
func_ d e f i n e c o n s o l e _ p l o t _ p i x e l ,3
func_ d e f i n e c o n s o l e _ s c r o l l
.macro putc ch
# if d e f i n e d ( C O N S O L E ) | | d e f i n e d ( S E R I A L _ D E B U G )
pea \ c h
# endif
# ifdef C O N S O L E
func_ c a l l c o n s o l e _ p u t c
# endif
# ifdef S E R I A L _ D E B U G
func_ c a l l s e r i a l _ p u t c
# endif
# if d e f i n e d ( C O N S O L E ) | | d e f i n e d ( S E R I A L _ D E B U G )
addql #4 ,% s p
# endif
.endm
.macro dputc ch
# ifdef D E B U G
putc \ c h
# endif
.endm
func_ d e f i n e p u t n ,1
.macro dputn nr
# ifdef D E B U G
putn \ n r
# endif
.endm
.macro puts string
# if d e f i n e d ( C O N S O L E ) | | d e f i n e d ( S E R I A L _ D E B U G )
_ _ INITDATA
.Lstr \ @:
.string " \ string"
_ _ FINIT
pea % p c @(.Lstr\@)
func_ c a l l p u t s
addql #4 ,% s p
# endif
.endm
.macro dputs string
# ifdef D E B U G
puts " \ s t r i n g "
# endif
.endm
# define i s _ n o t _ a m i g a ( l a b ) c m p l & M A C H _ A M I G A ,% p c @(m68k_machtype); jne lab
# define i s _ n o t _ a t a r i ( l a b ) c m p l & M A C H _ A T A R I ,% p c @(m68k_machtype); jne lab
# define i s _ n o t _ m a c ( l a b ) c m p l & M A C H _ M A C ,% p c @(m68k_machtype); jne lab
# define i s _ n o t _ m v m e 1 4 7 ( l a b ) c m p l & M A C H _ M V M E 1 4 7 ,% p c @(m68k_machtype); jne lab
# define i s _ n o t _ m v m e 1 6 x ( l a b ) c m p l & M A C H _ M V M E 1 6 x ,% p c @(m68k_machtype); jne lab
# define i s _ n o t _ b v m e 6 0 0 0 ( l a b ) c m p l & M A C H _ B V M E 6 0 0 0 ,% p c @(m68k_machtype); jne lab
# define i s _ m v m e 1 4 7 ( l a b ) c m p l & M A C H _ M V M E 1 4 7 ,% p c @(m68k_machtype); jeq lab
# define i s _ m v m e 1 6 x ( l a b ) c m p l & M A C H _ M V M E 1 6 x ,% p c @(m68k_machtype); jeq lab
# define i s _ b v m e 6 0 0 0 ( l a b ) c m p l & M A C H _ B V M E 6 0 0 0 ,% p c @(m68k_machtype); jeq lab
# define i s _ n o t _ h p30 0 ( l a b ) c m p l & M A C H _ H P 3 0 0 ,% p c @(m68k_machtype); jne lab
# define i s _ n o t _ a p o l l o ( l a b ) c m p l & M A C H _ A P O L L O ,% p c @(m68k_machtype); jne lab
# define i s _ n o t _ q40 ( l a b ) c m p l & M A C H _ Q 4 0 ,% p c @(m68k_machtype); jne lab
# define i s _ n o t _ s u n 3 x ( l a b ) c m p l & M A C H _ S U N 3 X ,% p c @(m68k_machtype); jne lab
# define h a s n t _ l e d s ( l a b ) c m p l & M A C H _ H P 3 0 0 ,% p c @(m68k_machtype); \
jeq 4 2 f ; \
cmpl & M A C H _ A P O L L O ,% p c @(m68k_machtype); \
jne l a b ;\
42 : \
# define i s _ 0 4 0 _ o r _ 0 6 0 ( l a b ) b t s t & C P U T Y P E _ 0 4 6 0 ,% p c @(L(cputype)+3); jne lab
# define i s _ n o t _ 0 4 0 _ o r _ 0 6 0 ( l a b ) b t s t & C P U T Y P E _ 0 4 6 0 ,% p c @(L(cputype)+3); jeq lab
# define i s _ 0 4 0 ( l a b ) b t s t & C P U T Y P E _ 0 4 0 ,% p c @(L(cputype)+3); jne lab
# define i s _ 0 6 0 ( l a b ) b t s t & C P U T Y P E _ 0 6 0 ,% p c @(L(cputype)+3); jne lab
# define i s _ n o t _ 0 6 0 ( l a b ) b t s t & C P U T Y P E _ 0 6 0 ,% p c @(L(cputype)+3); jeq lab
# define i s _ 0 2 0 ( l a b ) b t s t & C P U T Y P E _ 0 2 0 ,% p c @(L(cputype)+3); jne lab
# define i s _ n o t _ 0 2 0 ( l a b ) b t s t & C P U T Y P E _ 0 2 0 ,% p c @(L(cputype)+3); jeq lab
/ * On t h e H P 3 0 0 w e u s e t h e o n - b o a r d L E D s f o r d e b u g o u t p u t b e f o r e
the c o n s o l e i s r u n n i n g . W r i t i n g a 1 b i t t u r n s t h e c o r r e s p o n d i n g L E D
_ off_ - o n t h e 3 4 0 b i t 7 i s t o w a r d s t h e b a c k p a n e l o f t h e m a c h i n e . * /
.macro leds mask
# if d e f i n e d ( C O N F I G _ H P 3 0 0 ) | | d e f i n e d ( C O N F I G _ A P O L L O )
hasnt_ l e d s ( . L l e d \ @)
pea \ m a s k
func_ c a l l s e t _ l e d s
addql #4 ,% s p
.Lled \ @:
# endif
.endm
2007-07-20 07:33:08 +04:00
.section " .text .head " , " ax"
2005-04-17 02:20:36 +04:00
ENTRY( _ s t e x t )
/ *
* Version n u m b e r s o f t h e b o o t i n f o i n t e r f a c e
* The a r e a f r o m _ s t e x t t o _ s t a r t w i l l l a t e r b e u s e d a s k e r n e l p o i n t e r t a b l e
* /
bras 1 f / * J u m p o v e r b o o t i n f o v e r s i o n n u m b e r s * /
.long BOOTINFOV_MAGIC
.long MACH_ A M I G A , A M I G A _ B O O T I _ V E R S I O N
.long MACH_ A T A R I , A T A R I _ B O O T I _ V E R S I O N
.long MACH_ M V M E 1 4 7 , M V M E 1 4 7 _ B O O T I _ V E R S I O N
.long MACH_ M V M E 1 6 x , M V M E 1 6 x _ B O O T I _ V E R S I O N
.long MACH_ B V M E 6 0 0 0 , B V M E 6 0 0 0 _ B O O T I _ V E R S I O N
.long MACH_ M A C , M A C _ B O O T I _ V E R S I O N
.long MACH_ Q 4 0 , Q 4 0 _ B O O T I _ V E R S I O N
.long MACH_ H P 3 0 0 , H P 3 0 0 _ B O O T I _ V E R S I O N
.long 0
1 : jra _ _ s t a r t
.equ kernel_ p g _ d i r ,_ s t e x t
.equ . , _ stext+ P A G E S I Z E
ENTRY( _ s t a r t )
jra _ _ s t a r t
_ _ INIT
ENTRY( _ _ s t a r t )
/ *
* Setup i n i t i a l s t a c k p o i n t e r
* /
lea % p c @(_stext),%sp
/ *
* Record t h e C P U a n d m a c h i n e t y p e .
* /
get_ b i _ r e c o r d B I _ M A C H T Y P E
lea % p c @(m68k_machtype),%a1
movel % a0 @,%a1@
get_ b i _ r e c o r d B I _ F P U T Y P E
lea % p c @(m68k_fputype),%a1
movel % a0 @,%a1@
get_ b i _ r e c o r d B I _ M M U T Y P E
lea % p c @(m68k_mmutype),%a1
movel % a0 @,%a1@
get_ b i _ r e c o r d B I _ C P U T Y P E
lea % p c @(m68k_cputype),%a1
movel % a0 @,%a1@
leds 0 x1
# ifdef C O N F I G _ M A C
/ *
* For M a c i n t o s h , w e n e e d t o d e t e r m i n e t h e d i s p l a y p a r a m e t e r s e a r l y ( a t l e a s t
* while d e b u g g i n g i t ) .
* /
is_ n o t _ m a c ( L ( t e s t _ n o t m a c ) )
get_ b i _ r e c o r d B I _ M A C _ V A D D R
lea % p c @(L(mac_videobase)),%a1
movel % a0 @,%a1@
get_ b i _ r e c o r d B I _ M A C _ V D E P T H
lea % p c @(L(mac_videodepth)),%a1
movel % a0 @,%a1@
get_ b i _ r e c o r d B I _ M A C _ V D I M
lea % p c @(L(mac_dimensions)),%a1
movel % a0 @,%a1@
get_ b i _ r e c o r d B I _ M A C _ V R O W
lea % p c @(L(mac_rowbytes)),%a1
movel % a0 @,%a1@
# ifdef M A C _ S E R I A L _ D E B U G
get_ b i _ r e c o r d B I _ M A C _ S C C B A S E
lea % p c @(L(mac_sccbase)),%a1
movel % a0 @,%a1@
# endif / * M A C _ S E R I A L _ D E B U G * /
# if 0
/ *
* Clear t h e s c r e e n
* /
lea % p c @(L(mac_videobase)),%a0
movel % a0 @,%a1
lea % p c @(L(mac_dimensions)),%a0
movel % a0 @,%d1
swap % d1 / * #r o w s i s h i g h b y t e s * /
andl #0xFFFF ,% d1 / * r o w s * /
subl #10 ,% d1
lea % p c @(L(mac_rowbytes)),%a0
loopy2 :
movel % a0 @,%d0
subql #1 ,% d0
loopx2 :
moveb #0x55 , % a1 @+
dbra % d0 ,l o o p x2
dbra % d1 ,l o o p y 2
# endif
L( t e s t _ n o t m a c ) :
# endif / * C O N F I G _ M A C * /
/ *
* There a r e u l t i m a t e l y t w o p i e c e s o f i n f o r m a t i o n w e w a n t f o r a l l k i n d s o f
* processors C p u T y p e a n d C a c h e B i t s . T h e C P U T Y P E w a s p a s s e d i n f r o m b o o t e r
* and i s c o n v e r t e d h e r e f r o m a b o o t e r t y p e d e f i n i t i o n t o a s e p a r a t e b i t
* number w h i c h a l l o w s f o r t h e s t a n d a r d i s _ 0 x0 m a c r o t e s t s .
* /
movel % p c @(m68k_cputype),%d0
/ *
* Assume i t ' s a n 0 3 0
* /
clrl % d1
/ *
* Test t h e B o o t I n f o c p u t y p e f o r 0 6 0
* /
btst #C P U B _ 68060 ,% d0
jeq 1 f
bset #C P U T Y P E _ 060 ,% d1
bset #C P U T Y P E _ 0460 ,% d1
jra 3 f
1 :
/ *
* Test t h e B o o t I n f o c p u t y p e f o r 0 4 0
* /
btst #C P U B _ 68040 ,% d0
jeq 2 f
bset #C P U T Y P E _ 040 ,% d1
bset #C P U T Y P E _ 0460 ,% d1
jra 3 f
2 :
/ *
* Test t h e B o o t I n f o c p u t y p e f o r 0 2 0
* /
btst #C P U B _ 68020 ,% d0
jeq 3 f
bset #C P U T Y P E _ 020 ,% d1
jra 3 f
3 :
/ *
* Record t h e c p u t y p e
* /
lea % p c @(L(cputype)),%a0
movel % d1 ,% a0 @
/ *
* NOTE :
*
* Now t h e m a c r o s a r e v a l i d :
* is_ 0 4 0 _ o r _ 0 6 0
* is_ n o t _ 0 4 0 _ o r _ 0 6 0
* is_ 0 4 0
* is_ 0 6 0
* is_ n o t _ 0 6 0
* /
/ *
* Determine t h e c a c h e m o d e f o r p a g e s h o l d i n g M M U t a b l e s
* and f o r s u p e r v i s o r m o d e , u n u s e d f o r ' 0 2 0 a n d ' 0 3 0
* /
clrl % d0
clrl % d1
is_ n o t _ 0 4 0 _ o r _ 0 6 0 ( L ( s a v e _ c a c h e t y p e ) )
/ *
* ' 0 4 0 or ' 0 6 0
* d1 : = c a c h e a b l e w r i t e - t h r o u g h
* NOTE : The 6 8 0 4 0 m a n u a l s t r o n g l y r e c o m m e n d s n o n - c a c h e d f o r M M U t a b l e s ,
* but w e h a v e b e e n u s i n g w r i t e - t h r o u g h s i n c e a t l e a s t 2 . 0 . 2 9 s o I
* guess i t i s O K .
* /
# ifdef C O N F I G _ 0 6 0 _ W R I T E T H R O U G H
/ *
* If t h i s i s a 6 8 0 6 0 b o a r d u s i n g d r i v e r s w i t h c a c h e c o h e r e n c y
* problems, t h e n s u p e r v i s o r m e m o r y a c c e s s e s n e e d t o b e w r i t e - t h r o u g h
* also; otherwise, we want copyback.
* /
is_ n o t _ 0 6 0 ( 1 f )
movel #_ P A G E _ C A C H E 040 W ,% d0
jra L ( s a v e _ c a c h e t y p e )
# endif / * C O N F I G _ 0 6 0 _ W R I T E T H R O U G H * /
1 :
movew #_ P A G E _ C A C H E 040 ,% d0
movel #_ P A G E _ C A C H E 040 W ,% d1
L( s a v e _ c a c h e t y p e ) :
/ * Save c a c h e m o d e f o r s u p e r v i s o r m o d e a n d p a g e t a b l e s
* /
lea % p c @(m68k_supervisor_cachemode),%a0
movel % d0 ,% a0 @
lea % p c @(m68k_pgtable_cachemode),%a0
movel % d1 ,% a0 @
/ *
* raise i n t e r r u p t l e v e l
* /
movew #0x2700 ,% s r
/ *
If r u n n i n g o n a n A t a r i , d e t e r m i n e t h e I / O b a s e o f t h e
serial p o r t a n d t e s t i f w e a r e r u n n i n g o n a M e d u s a o r H a d e s .
This t e s t i s n e c e s s a r y h e r e , b e c a u s e o n t h e H a d e s t h e s e r i a l
port i s o n l y a c c e s s i b l e i n t h e h i g h I / O m e m o r y a r e a .
The t e s t w h e t h e r i t i s a M e d u s a i s d o n e b y w r i t i n g t o t h e b y t e a t
phys. 0 x0 . T h i s s h o u l d r e s u l t i n a b u s e r r o r o n a l l o t h e r m a c h i n e s .
. . .should , but d o e s n ' t . T h e A f t e r b u r n e r04 0 f o r t h e F a l c o n h a s t h e
same b e h a v i o u r ( 0 x0 . . 0 x7 a r e n o R O M s h a d o w ) . S o w e h a v e t o d o
another t e s t t o d i s t i n g u i s h M e d u s a a n d A B 0 4 0 . T h i s i s a
read a t t e m p t f o r 0 x00 f f82 f e p h y s . t h a t s h o u l d b u s e r r o r o n a F a l c o n
( + AB0 4 0 ) , b u t i s i n t h e r a n g e w h e r e t h e M e d u s a a l w a y s a s s e r t s D T A C K .
The t e s t f o r t h e H a d e s i s d o n e b y r e a d i n g a d d r e s s 0 x b00 0 0 0 0 0 . T h i s
should g i v e a b u s e r r o r o n t h e M e d u s a .
* /
# ifdef C O N F I G _ A T A R I
is_ n o t _ a t a r i ( L ( n o t y p e t e s t ) )
/* get special machine type (Medusa/Hades/AB40) */
moveq #0 ,% d3 / * d e f a u l t i f t a g d o e s n ' t e x i s t * /
get_ b i _ r e c o r d B I _ A T A R I _ M C H _ T Y P E
tstl % d0
jbmi 1 f
movel % a0 @,%d3
lea % p c @(atari_mch_type),%a0
movel % d3 ,% a0 @
1 :
/ * On t h e H a d e s , t h e i o b a s e m u s t b e s e t u p b e f o r e o p e n i n g t h e
* serial p o r t . T h e r e a r e n o I / O r e g s a t 0 x00 f f x x x x a t a l l . * /
moveq #0 ,% d0
cmpl #A T A R I _ M A C H _ H A D E S , % d 3
jbne 1 f
movel #0xff000000 ,% d0 / * H a d e s I / O b a s e a d d r : 0 x f f00 0 0 0 0 * /
1 : lea % p c @(L(iobase)),%a0
movel % d0 ,% a0 @
L( n o t y p e t e s t ) :
# endif
# ifdef C O N F I G _ V M E
is_ m v m e 1 4 7 ( L ( g e t v m e t y p e ) )
is_ b v m e 6 0 0 0 ( L ( g e t v m e t y p e ) )
is_ n o t _ m v m e 1 6 x ( L ( g v t d o n e ) )
/ * See i f t h e l o a d e r h a s s p e c i f i e d t h e B I _ V M E _ T Y P E t a g . R e c e n t
* versions o f V M E L I L O a n d T F T P L I L O d o t h i s . W e h a v e t o d o t h i s
* early s o w e k n o w h o w t o h a n d l e c o n s o l e o u t p u t . I f t h e t a g
* doesn' t e x i s t t h e n w e u s e t h e B u g f o r o u t p u t o n M V M E 1 6 x .
* /
L( g e t v m e t y p e ) :
get_ b i _ r e c o r d B I _ V M E _ T Y P E
tstl % d0
jbmi 1 f
movel % a0 @,%d3
lea % p c @(vme_brdtype),%a0
movel % d3 ,% a0 @
1 :
# ifdef C O N F I G _ M V M E 1 6 x
is_ n o t _ m v m e 1 6 x ( L ( g v t d o n e ) )
/ * Need t o g e t t h e B R D _ I D i n f o t o d i f f e r e n t i a t e b e t w e e n 1 6 2 , 1 6 7 ,
* etc. T h i s i s a v a i l a b l e a s a B I _ V M E _ B R D I N F O t a g w i t h l a t e r
* versions o f V M E L I L O a n d T F T P L I L O , o t h e r w i s e w e c a l l t h e B u g .
* /
get_ b i _ r e c o r d B I _ V M E _ B R D I N F O
tstl % d0
jpl 1 f
/* Get pointer to board ID data from Bug */
movel % d2 ,% s p @-
trap #15
.word 0x70 /* trap 0x70 - .BRD_ID */
movel % s p @+,%a0
1 :
lea % p c @(mvme_bdid),%a1
/* Structure is 32 bytes long */
movel % a0 @+,%a1@+
movel % a0 @+,%a1@+
movel % a0 @+,%a1@+
movel % a0 @+,%a1@+
movel % a0 @+,%a1@+
movel % a0 @+,%a1@+
movel % a0 @+,%a1@+
movel % a0 @+,%a1@+
# endif
L( g v t d o n e ) :
# endif
# ifdef C O N F I G _ H P 3 0 0
is_ n o t _ h p30 0 ( L ( n o t h p ) )
/* Get the address of the UART for serial debugging */
get_ b i _ r e c o r d B I _ H P 3 0 0 _ U A R T _ A D D R
tstl % d0
jbmi 1 f
movel % a0 @,%d3
lea % p c @(L(uartbase)),%a0
movel % d3 ,% a0 @
get_ b i _ r e c o r d B I _ H P 3 0 0 _ U A R T _ S C O D E
tstl % d0
jbmi 1 f
movel % a0 @,%d3
lea % p c @(L(uart_scode)),%a0
movel % d3 ,% a0 @
1 :
L( n o t h p ) :
# endif
/ *
* Initialize s e r i a l p o r t
* /
jbsr L ( s e r i a l _ i n i t )
/ *
* Initialize c o n s o l e
* /
# ifdef C O N F I G _ M A C
is_ n o t _ m a c ( L ( n o c o n ) )
# ifdef C O N S O L E
console_ i n i t
# ifdef C O N S O L E _ P E N G U I N
console_ p u t _ p e n g u i n
# endif / * C O N S O L E _ P E N G U I N * /
console_ p u t _ s t a t s
# endif / * C O N S O L E * /
L( n o c o n ) :
# endif / * C O N F I G _ M A C * /
putc ' \ n '
putc ' A '
leds 0 x2
dputn % p c @(L(cputype))
dputn % p c @(m68k_supervisor_cachemode)
dputn % p c @(m68k_pgtable_cachemode)
dputc ' \ n '
/ *
* Save p h y s i c a l s t a r t a d d r e s s o f k e r n e l
* /
lea % p c @(L(phys_kernel_start)),%a0
lea % p c @(_stext),%a1
subl #_ s t e x t , % a 1
addl #P A G E _ O F F S E T , % a 1
movel % a1 ,% a0 @
putc ' B '
leds 0 x4
/ *
* mmu_ i n i t
*
* This b l o c k o f c o d e d o e s w h a t ' s n e c e s s a r y t o m a p i n t h e v a r i o u s k i n d s
* of m a c h i n e s f o r e x e c u t i o n o f L i n u x .
* First m a p t h e f i r s t 4 M B o f k e r n e l c o d e & d a t a
* /
mmu_ m a p #P A G E _ O F F S E T , % p c @ ( L ( p h y s _ k e r n e l _ s t a r t ) ) , # 4 * 1 0 2 4 * 1 0 2 4 ,\
% pc@(m68k_supervisor_cachemode)
putc ' C '
# ifdef C O N F I G _ A M I G A
L( m m u _ i n i t _ a m i g a ) :
is_ n o t _ a m i g a ( L ( m m u _ i n i t _ n o t _ a m i g a ) )
/ *
* mmu_ i n i t _ a m i g a
* /
putc ' D '
is_ n o t _ 0 4 0 _ o r _ 0 6 0 ( 1 f )
/ *
* 040 : Map t h e 1 6 M e g r a n g e p h y s i c a l 0 x0 u p t o l o g i c a l 0 x80 0 0 . 0 0 0 0
* /
mmu_ m a p #0x80000000 ,#0 ,#0x01000000 ,#_ P A G E _ N O C A C H E _ S
/ *
* Map t h e Z o r r o I I I I / O s p a c e w i t h t r a n s p a r e n t t r a n s l a t i o n
* for f r a m e b u f f e r m e m o r y e t c .
* /
mmu_ m a p _ t t #1 ,#0x40000000 ,#0x20000000 ,#_ P A G E _ N O C A C H E _ S
jbra L ( m m u _ i n i t _ d o n e )
1 :
/ *
* 030 : Map t h e 3 2 M e g r a n g e p h y s i c a l 0 x0 u p t o l o g i c a l 0 x80 0 0 . 0 0 0 0
* /
mmu_ m a p #0x80000000 ,#0 ,#0x02000000 ,#_ P A G E _ N O C A C H E 030
mmu_ m a p _ t t #1 ,#0x40000000 ,#0x20000000 ,#_ P A G E _ N O C A C H E 030
jbra L ( m m u _ i n i t _ d o n e )
L( m m u _ i n i t _ n o t _ a m i g a ) :
# endif
# ifdef C O N F I G _ A T A R I
L( m m u _ i n i t _ a t a r i ) :
is_ n o t _ a t a r i ( L ( m m u _ i n i t _ n o t _ a t a r i ) )
putc ' E '
/ * On t h e A t a r i , w e m a p t h e I / O r e g i o n ( p h y s . 0 x00 f f x x x x ) b y m a p p i n g
the l a s t 1 6 M B o f v i r t u a l a d d r e s s s p a c e t o t h e f i r s t 1 6 M B ( i . e .
0 xffxxxxxx - > 0 x00 x x x x x x ) . F o r t h i s , a n a d d i t i o n a l p o i n t e r t a b l e i s
needed. I / O r a n g e s a r e m a r k e d n o n - c a c h a b l e .
For t h e M e d u s a i t i s b e t t e r t o m a p t h e I / O r e g i o n t r a n s p a r e n t l y
( i. e . 0 x f f x x x x x x - > 0 x f f x x x x x x ) , b e c a u s e s o m e I / O r e g i s t e r s a r e
accessible o n l y i n t h e h i g h a r e a .
On t h e H a d e s a l l I / O r e g i s t e r s a r e o n l y a c c e s s i b l e i n t h e h i g h
area.
* /
/* I/O base addr for non-Medusa, non-Hades: 0x00000000 */
moveq #0 ,% d0
movel % p c @(atari_mch_type),%d3
cmpl #A T A R I _ M A C H _ M E D U S A , % d 3
jbeq 2 f
cmpl #A T A R I _ M A C H _ H A D E S , % d 3
jbne 1 f
2 : movel #0xff000000 ,% d0 / * M e d u s a / H a d e s b a s e a d d r : 0 x f f00 0 0 0 0 * /
1 : movel % d0 ,% d3
is_ 0 4 0 _ o r _ 0 6 0 ( L ( s p a t a68 0 4 0 ) )
/ * Map e v e r y t h i n g n o n - c a c h e a b l e , t h o u g h n o t a l l p a r t s r e a l l y
* need t o d i s a b l e c a c h e s ( c r u c i a l o n l y f o r 0 x f f80 0 0 . . 0 x f f f f f f
* ( standard I / O ) a n d 0 x f00 0 0 0 . . 0 x f3 f f f f ( I D E ) ) . T h e r e m a i n d e r
* isn' t r e a l l y u s e d , e x c e p t f o r s o m e t i m e s p e e k i n g i n t o t h e
* ROMs ( m i r r o r a t p h y s . 0 x0 ) , s o c a c h i n g i s n ' t n e c e s s a r y f o r
* this. * /
mmu_ m a p #0xff000000 ,% d3 ,#0x01000000 ,#_ P A G E _ N O C A C H E 030
jbra L ( m m u _ i n i t _ d o n e )
L( s p a t a68 0 4 0 ) :
mmu_ m a p #0xff000000 ,% d3 ,#0x01000000 ,#_ P A G E _ N O C A C H E _ S
jbra L ( m m u _ i n i t _ d o n e )
L( m m u _ i n i t _ n o t _ a t a r i ) :
# endif
# ifdef C O N F I G _ Q 4 0
is_ n o t _ q40 ( L ( n o t q40 ) )
/ *
* add t r a n s p a r e n t m a p p i n g f o r 0 x f f00 0 0 0 0 - 0 x f f f f f f f f
* non- c a c h e d s e r i a l i z e d e t c . .
* this i n c l u d e s m a s t e r c h i p , D A C , R T C a n d I S A p o r t s
* 0 xfe0 0 0 0 0 0 - 0 x f e f f f f f f i s f o r s c r e e n a n d R O M
* /
putc ' Q '
mmu_ m a p _ t t #0 ,#0xfe000000 ,#0x01000000 ,#_ P A G E _ C A C H E 040 W
mmu_ m a p _ t t #1 ,#0xff000000 ,#0x01000000 ,#_ P A G E _ N O C A C H E _ S
jbra L ( m m u _ i n i t _ d o n e )
L( n o t q40 ) :
# endif
# ifdef C O N F I G _ H P 3 0 0
is_ n o t _ h p30 0 ( L ( n o t h p30 0 ) )
/ * On t h e H P 3 0 0 , w e m a p t h e R O M , I N T I O a n d D I O r e g i o n s ( p h y s . 0 x00 x x x x x x )
* by m a p p i n g 3 2 M B ( o n 0 2 0 / 0 3 0 ) o r 1 6 M B ( o n 0 4 0 ) f r o m 0 x f0 x x x x x x - > 0 x00 x x x x x x ) .
* The R O M m a p p i n g i s n e e d e d b e c a u s e t h e L E D s a r e m a p p e d t h e r e t o o .
* /
is_ 0 4 0 ( 1 f )
/ *
* 030 : Map t h e 3 2 M e g r a n g e p h y s i c a l 0 x0 u p t o l o g i c a l 0 x f00 0 . 0 0 0 0
* /
mmu_ m a p #0xf0000000 ,#0 ,#0x02000000 ,#_ P A G E _ N O C A C H E 030
jbra L ( m m u _ i n i t _ d o n e )
1 :
/ *
* 040 : Map t h e 1 6 M e g r a n g e p h y s i c a l 0 x0 u p t o l o g i c a l 0 x f00 0 . 0 0 0 0
* /
mmu_ m a p #0xf0000000 ,#0 ,#0x01000000 ,#_ P A G E _ N O C A C H E _ S
jbra L ( m m u _ i n i t _ d o n e )
L( n o t h p30 0 ) :
# endif / * C O N F I G _ H P 3 0 0 * /
# ifdef C O N F I G _ M V M E 1 4 7
is_ n o t _ m v m e 1 4 7 ( L ( n o t 1 4 7 ) )
/ *
* On M V M E 1 4 7 w e h a v e a l r e a d y c r e a t e d k e r n e l p a g e t a b l e s f o r
* 4 MB o f R A M a t a d d r e s s 0 , s o n o w n e e d t o d o a t r a n s p a r e n t
* mapping o f t h e t o p o f m e m o r y s p a c e . M a k e i t 0 . 5 G B y t e f o r n o w ,
* so w e c a n a c c e s s o n - b o a r d i / o a r e a s .
* /
mmu_ m a p _ t t #1 ,#0xe0000000 ,#0x20000000 ,#_ P A G E _ N O C A C H E 030
jbra L ( m m u _ i n i t _ d o n e )
L( n o t 1 4 7 ) :
# endif / * C O N F I G _ M V M E 1 4 7 * /
# ifdef C O N F I G _ M V M E 1 6 x
is_ n o t _ m v m e 1 6 x ( L ( n o t 1 6 x ) )
/ *
* On M V M E 1 6 x w e h a v e a l r e a d y c r e a t e d k e r n e l p a g e t a b l e s f o r
* 4 MB o f R A M a t a d d r e s s 0 , s o n o w n e e d t o d o a t r a n s p a r e n t
* mapping o f t h e t o p o f m e m o r y s p a c e . M a k e i t 0 . 5 G B y t e f o r n o w .
* Supervisor o n l y a c c e s s , s o t r a n s p a r e n t m a p p i n g d o e s n ' t
* clash w i t h U s e r c o d e v i r t u a l a d d r e s s s p a c e .
* this c o v e r s I O d e v i c e s , P R O M a n d S R A M . T h e P R O M a n d S R A M
* mapping i s n e e d e d t o a l l o w 1 6 7 B u g t o r u n .
* IO i s i n t h e r a n g e 0 x f f f00 0 0 0 t o 0 x f f f e f f f f .
* PROM i s 0 x f f80 0 0 0 0 - > 0 x f f b f f f f f a n d S R A M i s
* 0 xffe0 0 0 0 0 - > 0 x f f e 1 f f f f .
* /
mmu_ m a p _ t t #1 ,#0xe0000000 ,#0x20000000 ,#_ P A G E _ N O C A C H E _ S
jbra L ( m m u _ i n i t _ d o n e )
L( n o t 1 6 x ) :
# endif / * C O N F I G _ M V M E 1 6 2 | C O N F I G _ M V M E 1 6 7 * /
# ifdef C O N F I G _ B V M E 6 0 0 0
is_ n o t _ b v m e 6 0 0 0 ( L ( n o t 6 0 0 0 ) )
/ *
* On B V M E 6 0 0 0 w e h a v e a l r e a d y c r e a t e d k e r n e l p a g e t a b l e s f o r
* 4 MB o f R A M a t a d d r e s s 0 , s o n o w n e e d t o d o a t r a n s p a r e n t
* mapping o f t h e t o p o f m e m o r y s p a c e . M a k e i t 0 . 5 G B y t e f o r n o w ,
* so w e c a n a c c e s s o n - b o a r d i / o a r e a s .
* Supervisor o n l y a c c e s s , s o t r a n s p a r e n t m a p p i n g d o e s n ' t
* clash w i t h U s e r c o d e v i r t u a l a d d r e s s s p a c e .
* /
mmu_ m a p _ t t #1 ,#0xe0000000 ,#0x20000000 ,#_ P A G E _ N O C A C H E _ S
jbra L ( m m u _ i n i t _ d o n e )
L( n o t 6 0 0 0 ) :
# endif / * C O N F I G _ B V M E 6 0 0 0 * /
/ *
* mmu_ i n i t _ m a c
*
* The M a c i n t o s h m a p p i n g s a r e l e s s c l e a r .
*
* Even a s o f t h i s w r i t i n g , i t i s u n c l e a r h o w t h e
* Macintosh m a p p i n g s w i l l b e d o n e . H o w e v e r , a s
* the f i r s t a u t h o r o f t h i s c o d e I ' m p r o p o s i n g t h e
* following m o d e l :
*
* Map t h e k e r n e l ( t h a t ' s a l r e a d y d o n e ) ,
* Map t h e I / O ( o n m o s t m a c h i n e s t h a t ' s t h e
* 0 x5 0 0 0 . 0 0 0 0 . . . 0 x53 0 0 . 0 0 0 0 r a n g e ,
* Map t h e v i d e o f r a m e b u f f e r u s i n g a s f e w p a g e s
* as a b s o l u t e l y ( t h i s r e q u i r e m e n t m o s t l y s t e m s f r o m
* the f a c t t h a t w h e n t h e f r a m e b u f f e r i s a t
* 0 x0 0 0 0 . 0 0 0 0 t h e n w e k n o w t h e r e i s v a l i d R A M j u s t
* above t h e s c r e e n t h a t w e d o n ' t w a n t t o w a s t e ! ) .
*
* By t h e w a y , i f t h e f r a m e b u f f e r i s a t 0 x00 0 0 . 0 0 0 0
* then t h e M a c i n t o s h i s k n o w n a s a n R B V b a s e d M a c .
*
* By t h e w a y 2 , t h e c o d e c u r r e n t l y m a p s i n a b u n c h o f
* regions. B u t I ' d l i k e t o c u t t h a t o u t . ( A n d m o v e m o s t
* of t h e m a p p i n g s u p i n t o t h e k e r n e l p r o p e r . . . o r o n l y
* map w h a t ' s n e c e s s a r y . )
* /
# ifdef C O N F I G _ M A C
L( m m u _ i n i t _ m a c ) :
is_ n o t _ m a c ( L ( m m u _ i n i t _ n o t _ m a c ) )
putc ' F '
is_ n o t _ 0 4 0 _ o r _ 0 6 0 ( 1 f )
moveq #_ P A G E _ N O C A C H E _ S , % d 3
jbra 2 f
1 :
moveq #_ P A G E _ N O C A C H E 030 ,% d3
2 :
/ *
* Mac N o t e : s c r e e n a d d r e s s o f l o g i c a l 0 x F 0 0 0 . 0 0 0 0 - > < s c r e e n p h y s i c a l >
* we s i m p l y m a p t h e 4 M B t h a t c o n t a i n s t h e v i d e o m e m
* /
movel #V I D E O M E M M A S K , % d 0
andl % p c @(L(mac_videobase)),%d0
mmu_ m a p #V I D E O M E M B A S E , % d 0 ,#V I D E O M E M S I Z E , % d 3
/* ROM from 4000 0000 to 4200 0000 (only for mac_reset()) */
mmu_ m a p _ e q #0x40000000 ,#0x02000000 ,% d3
/* IO devices (incl. serial port) from 5000 0000 to 5300 0000 */
mmu_ m a p _ e q #0x50000000 ,#0x03000000 ,% d3
/* Nubus slot space (video at 0xF0000000, rom at 0xF0F80000) */
mmu_ m a p _ t t #1 ,#0xf8000000 ,#0x08000000 ,% d3
jbra L ( m m u _ i n i t _ d o n e )
L( m m u _ i n i t _ n o t _ m a c ) :
# endif
# ifdef C O N F I G _ S U N 3 X
is_ n o t _ s u n 3 x ( L ( n o t s u n 3 x ) )
/ * oh, t h e p a i n . . W e ' r e g o n n a w a n t t h e p r o m c o d e a f t e r
* starting t h e M M U , s o w e c o p y t h e m a p p i n g s , t r a n s l a t i n g
* from 8 k - > 4 k p a g e s a s w e g o .
* /
/* copy maps from 0xfee00000 to 0xff000000 */
movel #0xfee00000 , % d0
moveq #R O O T _ I N D E X _ S H I F T , % d 1
lsrl % d1 ,% d0
mmu_ g e t _ r o o t _ t a b l e _ e n t r y % d0
movel #0xfee00000 , % d0
moveq #P T R _ I N D E X _ S H I F T , % d 1
lsrl % d1 ,% d0
andl #P T R _ T A B L E _ S I Z E - 1 , % d0
mmu_ g e t _ p t r _ t a b l e _ e n t r y % a0 ,% d0
movel #0xfee00000 , % d0
moveq #P A G E _ I N D E X _ S H I F T , % d 1
lsrl % d1 ,% d0
andl #P A G E _ T A B L E _ S I Z E - 1 , % d0
mmu_ g e t _ p a g e _ t a b l e _ e n t r y % a0 ,% d0
/* this is where the prom page table lives */
movel 0 x f e f e 0 0 d4 , % a1
movel % a1 @, %a1
movel #( ( 0x200000 > > 1 3 ) - 1 ) , % d1
1 :
movel % a1 @+, %d3
movel % d3 ,% a0 @+
addl #0x1000 ,% d3
movel % d3 ,% a0 @+
dbra % d1 ,1 b
/* setup tt1 for I/O */
mmu_ m a p _ t t #1 ,#0x40000000 ,#0x40000000 ,#_ P A G E _ N O C A C H E _ S
jbra L ( m m u _ i n i t _ d o n e )
L( n o t s u n 3 x ) :
# endif
# ifdef C O N F I G _ A P O L L O
is_ n o t _ a p o l l o ( L ( n o t a p o l l o ) )
putc ' P '
mmu_ m a p #0x80000000 ,#0 ,#0x02000000 ,#_ P A G E _ N O C A C H E 030
L( n o t a p o l l o ) :
jbra L ( m m u _ i n i t _ d o n e )
# endif
L( m m u _ i n i t _ d o n e ) :
putc ' G '
leds 0 x8
/ *
* mmu_ f i x u p
*
* On t h e 0 4 0 c l a s s m a c h i n e s , a l l p a g e s t h a t a r e u s e d f o r t h e
* mmu h a v e t o b e f i x e d u p . A c c o r d i n g t o M o t o r o l a , p a g e s h o l d i n g m m u
* tables s h o u l d b e n o n - c a c h e a b l e o n a ' 0 4 0 a n d w r i t e - t h r o u g h o n a
* ' 0 6 0 . But a n a l y s i s o f t h e r e a s o n s f o r t h i s , a n d p r a c t i c a l
* experience, s h o w e d t h a t w r i t e - t h r o u g h a l s o w o r k s o n a ' 0 4 0 .
*
* Allocated m e m o r y s o f a r g o e s f r o m k e r n e l _ e n d t o m e m o r y _ s t a r t t h a t
* is u s e d f o r a l l k i n d o f t a b l e s , f o r t h a t t h e c a c h e a t t r i b u t e s
* are n o w f i x e d .
* /
L( m m u _ f i x u p ) :
is_ n o t _ 0 4 0 _ o r _ 0 6 0 ( L ( m m u _ f i x u p _ d o n e ) )
# ifdef M M U _ N O C A C H E _ K E R N E L
jbra L ( m m u _ f i x u p _ d o n e )
# endif
/ * first f i x t h e p a g e a t t h e s t a r t o f t h e k e r n e l , t h a t
* contains a l s o k e r n e l _ p g _ d i r .
* /
movel % p c @(L(phys_kernel_start)),%d0
subl #P A G E _ O F F S E T , % d 0
lea % p c @(_stext),%a0
subl % d0 ,% a0
mmu_ f i x u p _ p a g e _ m m u _ c a c h e % a0
movel % p c @(L(kernel_end)),%a0
subl % d0 ,% a0
movel % p c @(L(memory_start)),%a1
subl % d0 ,% a1
bra 2 f
1 :
mmu_ f i x u p _ p a g e _ m m u _ c a c h e % a0
addw #P A G E S I Z E , % a 0
2 :
cmpl % a0 ,% a1
jgt 1 b
L( m m u _ f i x u p _ d o n e ) :
# ifdef M M U _ P R I N T
mmu_ p r i n t
# endif
/ *
* mmu_ e n g a g e
*
* This c h u n k o f c o d e p e r f o r m s t h e g r u e s o m e t a s k o f e n g a g i n g t h e M M U .
* The r e a s o n i t s g r u e s o m e i s b e c a u s e w h e n t h e M M U b e c o m e s e n g a g e d i t
* maps l o g i c a l a d d r e s s e s t o p h y s i c a l a d d r e s s e s . T h e P r o g r a m C o u n t e r
* register i s t h e n p a s s e d t h r o u g h t h e M M U b e f o r e t h e n e x t i n s t r u c t i o n
* is f e t c h e d ( t h e i n s t r u c t i o n f o l l o w i n g t h e e n g a g e M M U i n s t r u c t i o n ) .
* This m a y m e a n o n e o f t w o t h i n g s :
* 1 . The P r o g r a m C o u n t e r f a l l s w i t h i n t h e l o g i c a l a d d r e s s s p a c e o f
* the k e r n e l o f w h i c h t h e r e a r e t w o s u b - p o s s i b i l i t i e s :
* A. T h e P C m a p s t o t h e c o r r e c t i n s t r u c t i o n ( l o g i c a l P C = = p h y s i c a l
* code l o c a t i o n ) , o r
* B. T h e P C d o e s n o t m a p t h r o u g h a n d t h e p r o c e s s o r w i l l r e a d s o m e
* data ( o r i n s t r u c t i o n ) w h i c h i s n o t t h e l o g i c a l l y n e x t i n s t r .
* As y o u c a n i m a g i n e , A i s g o o d a n d B i s b a d .
* Alternatively,
* 2 . The P r o g r a m C o u n t e r d o e s n o t m a p t h r o u g h t h e M M U . T h e p r o c e s s o r
* will t a k e a B u s E r r o r .
* Clearly, 2 i s b a d .
* It d o e s n ' t t a k e a w i z k i d t o f i g u r e y o u w a n t 1 . A .
* This c o d e c r e a t e s t h a t p o s s i b i l i t y .
* There a r e t w o p o s s i b l e 1 . A . s t a t e s ( w e n o w i g n o r e t h e o t h e r a b o v e s t a t e s ) :
* A. T h e k e r n e l i s l o c a t e d a t p h y s i c a l m e m o r y a d d r e s s e d t h e s a m e a s
* the l o g i c a l m e m o r y f o r t h e k e r n e l , i . e . , 0 x01 0 0 0 .
* B. T h e k e r n e l i s l o c a t e d s o m e w h e r e e l s e . e . g . , 0 x04 0 0 . 0 0 0 0
*
* Under s o m e c o n d i t i o n s t h e M a c i n t o s h c a n l o o k l i k e A o r B .
* [ A f r i e n d a n d I o n c e n o t e d t h a t A p p l e h a r d w a r e e n g i n e e r s s h o u l d b e
* wacked t w i c e e a c h d a y : o n c e w h e n t h e y s h o w u p a t w o r k ( a s i n , W h a c k ! ,
* " This i s f o r t h e s c r e w y h a r d w a r e w e k n o w y o u ' r e g o i n g t o d e s i g n t o d a y . " ) ,
* and a l s o a t t h e e n d o f t h e d a y ( a s i n , W h a c k ! " I d o n ' t k n o w w h a t
* you d e s i g n e d t o d a y , b u t I ' m s u r e i t w a s n ' t g o o d . " ) . - - r s t ]
*
* This c o d e w o r k s o n t h e f o l l o w i n g p r e m i s e :
* If t h e k e r n e l s t a r t ( % d5 ) i s w i t h i n t h e f i r s t 1 6 M e g o f R A M ,
* then c r e a t e a m a p p i n g f o r t h e k e r n e l a t l o g i c a l 0 x80 0 0 . 0 0 0 0 t o
* the p h y s i c a l l o c a t i o n o f t h e p c . A n d , c r e a t e a t r a n s p a r e n t
* translation r e g i s t e r f o r t h e f i r s t 1 6 M e g . T h e n , a f t e r t h e M M U
* is e n g a g e d , t h e P C c a n b e m o v e d u p i n t o t h e 0 x80 0 0 . 0 0 0 0 r a n g e
* and t h e n t h e t r a n s p a r e n t t r a n s l a t i o n c a n b e t u r n e d o f f a n d t h e n
* the P C c a n j u m p t o t h e c o r r e c t l o g i c a l l o c a t i o n a n d i t w i l l b e
* home ( f i n a l l y ) . T h i s i s e s s e n t i a l l y t h e c o d e t h a t t h e A m i g a u s e d
* to u s e . N o w , i t ' s g e n e r a l i z e d f o r a l l p r o c e s s o r s . W h i c h m e a n s
* that a f r e s h ( b u t t e m p o r a r y ) m a p p i n g h a s t o b e c r e a t e d . T h e m a p p i n g
* is m a d e i n p a g e 0 ( a n a s o f y e t u n u s e d l o c a t i o n - - e x c e p t f o r t h e
* stack! ) . T h i s t e m p o r a r y m a p p i n g w i l l o n l y r e q u i r e 1 p o i n t e r t a b l e
* and a s i n g l e p a g e t a b l e ( i t c a n m a p 2 5 6 K ) .
*
* OK, a l t e r n a t i v e l y , i m a g i n e t h a t t h e P r o g r a m C o u n t e r i s n o t w i t h i n
* the f i r s t 1 6 M e g . T h e n , j u s t u s e T r a n s p a r e n t T r a n s l a t i o n r e g i s t e r s
* to d o t h e r i g h t t h i n g .
*
* Last, i f _ s t a r t i s a l r e a d y a t 0 x01 0 0 0 , t h e n t h e r e ' s n o t h i n g s p e c i a l
* to d o ( i n o t h e r w o r d s , i n a d e g e n e r a t e c a s e o f t h e f i r s t c a s e a b o v e ,
* do n o t h i n g ) .
*
* Let' s d o i t .
*
*
* /
putc ' H '
mmu_ e n g a g e
/ *
* After t h i s p o i n t n o n e w m e m o r y i s a l l o c a t e d a n d
* the s t a r t o f a v a i l a b l e m e m o r y i s s t o r e d i n a v a i l m e m .
* ( The b o o t m e m a l l o c a t o r r e q u i r e s n o w t h e p h y s i c a l l a d d r e s s . )
* /
movel L ( m e m o r y _ s t a r t ) ,a v a i l m e m
# ifdef C O N F I G _ A M I G A
is_ n o t _ a m i g a ( 1 f )
/* fixup the Amiga custom register location before printing */
clrl L ( c u s t o m )
1 :
# endif
# ifdef C O N F I G _ A T A R I
is_ n o t _ a t a r i ( 1 f )
/* fixup the Atari iobase register location before printing */
movel #0xff000000 ,L ( i o b a s e )
1 :
# endif
# ifdef C O N F I G _ M A C
is_ n o t _ m a c ( 1 f )
movel #~ V I D E O M E M M A S K , % d 0
andl L ( m a c _ v i d e o b a s e ) ,% d0
addl #V I D E O M E M B A S E , % d 0
movel % d0 ,L ( m a c _ v i d e o b a s e )
# if d e f i n e d ( C O N S O L E )
movel % p c @(L(phys_kernel_start)),%d0
subl #P A G E _ O F F S E T , % d 0
subl % d0 ,L ( c o n s o l e _ f o n t )
subl % d0 ,L ( c o n s o l e _ f o n t _ d a t a )
# endif
# ifdef M A C _ S E R I A L _ D E B U G
orl #0x50000000 ,L ( m a c _ s c c b a s e )
# endif
1 :
# endif
# ifdef C O N F I G _ H P 3 0 0
is_ n o t _ h p30 0 ( 1 f )
/ *
* Fix u p t h e i o b a s e r e g i s t e r t o p o i n t t o t h e n e w l o c a t i o n o f t h e L E D s .
* /
movel #0xf0000000 ,L ( i o b a s e )
/ *
* Energise t h e F P U a n d c a c h e s .
* /
is_ 0 4 0 ( 1 f )
movel #0x60 ,0 x f05 f40 0 c
jbra 2 f
/ *
* 040 : slightly d i f f e r e n t , a p p a r e n t l y .
* /
1 : movew #0 ,0 x f05 f40 0 e
movew #0x64 ,0 x f05 f40 0 e
2 :
# endif
# ifdef C O N F I G _ S U N 3 X
is_ n o t _ s u n 3 x ( 1 f )
/* enable copro */
oriw #0x4000 ,0 x61 0 0 0 0 0 0
1 :
# endif
# ifdef C O N F I G _ A P O L L O
is_ n o t _ a p o l l o ( 1 f )
/ *
* Fix u p t h e i o b a s e b e f o r e p r i n t i n g
* /
movel #0x80000000 ,L ( i o b a s e )
1 :
# endif
putc ' I '
leds 0 x10
/ *
* Enable c a c h e s
* /
is_ n o t _ 0 4 0 _ o r _ 0 6 0 ( L ( c a c h e _ n o t _ 6 8 0 4 6 0 ) )
L( c a c h e 6 8 0 4 6 0 ) :
.chip 68040
nop
cpusha % b c
nop
is_ 0 6 0 ( L ( c a c h e 6 8 0 6 0 ) )
movel #C C 6 _ E N A B L E _ D + C C 6 _ E N A B L E _ I ,% d0
/* MMU stuff works in copyback mode now, so enable the cache */
movec % d0 ,% c a c r
jra L ( c a c h e _ d o n e )
L( c a c h e 6 8 0 6 0 ) :
movel #C C 6 _ E N A B L E _ D + C C 6 _ E N A B L E _ I + C C 6 _ E N A B L E _ S B + C C 6 _ P U S H _ D P I + C C 6 _ E N A B L E _ B + C C 6 _ C L R A _ B ,% d0
/* MMU stuff works in copyback mode now, so enable the cache */
movec % d0 ,% c a c r
/* enable superscalar dispatch in PCR */
moveq #1 ,% d0
.chip 68060
movec % d0 ,% p c r
jbra L ( c a c h e _ d o n e )
L( c a c h e _ n o t _ 6 8 0 4 6 0 ) :
L( c a c h e 6 8 0 3 0 ) :
.chip 68030
movel #C C 3 _ E N A B L E _ D B + C C 3 _ C L R _ D + C C 3 _ E N A B L E _ D + C C 3 _ E N A B L E _ I B + C C 3 _ C L R _ I + C C 3 _ E N A B L E _ I ,% d0
movec % d0 ,% c a c r
jra L ( c a c h e _ d o n e )
.chip 68k
L( c a c h e _ d o n e ) :
putc ' J '
/ *
* Setup i n i t i a l s t a c k p o i n t e r
* /
lea i n i t _ t a s k ,% c u r p t r
lea 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 ,% s p
putc ' K '
subl % a6 ,% a6 / * c l e a r a6 f o r g d b * /
/ *
* The n e w 6 4 b i t p r i n t f s u p p o r t r e q u i r e s a n e a r l y e x c e p t i o n i n i t i a l i z a t i o n .
* /
jbsr b a s e _ t r a p _ i n i t
/* jump to the kernel start */
putc ' \ n '
leds 0 x55
jbsr s t a r t _ k e r n e l
/ *
* Find a t a g r e c o r d i n t h e b o o t i n f o s t r u c t u r e
* The b o o t i n f o s t r u c t u r e i s l o c a t e d r i g h t a f t e r t h e k e r n e l b s s
* Returns : d0 : size ( - 1 i f n o t f o u n d )
* a0 : data p o i n t e r ( e n d - o f - r e c o r d s i f n o t f o u n d )
* /
func_ s t a r t g e t _ b i _ r e c o r d ,% d1
movel A R G 1 ,% d0
lea % p c @(_end),%a0
1 : tstw % a0 @(BIR_TAG)
jeq 3 f
cmpw % a0 @(BIR_TAG),%d0
jeq 2 f
addw % a0 @(BIR_SIZE),%a0
jra 1 b
2 : moveq #0 ,% d0
movew % a0 @(BIR_SIZE),%d0
lea % a0 @(BIR_DATA),%a0
jra 4 f
3 : moveq #- 1 ,% d0
lea % a0 @(BIR_SIZE),%a0
4 :
func_ r e t u r n g e t _ b i _ r e c o r d
/ *
* MMU I n i t i a l i z a t i o n B e g i n s H e r e
*
* The s t r u c t u r e o f t h e M M U t a b l e s o n t h e 6 8 k m a c h i n e s
* is t h u s :
* Root T a b l e
* Logical a d d r e s s e s a r e t r a n s l a t e d t h r o u g h
* a h i e r a r c h i c a l t r a n s l a t i o n m e c h a n i s m w h e r e t h e h i g h - o r d e r
* seven b i t s o f t h e l o g i c a l a d d r e s s ( L A ) a r e u s e d a s a n
* index i n t o t h e " r o o t t a b l e . " E a c h e n t r y i n t h e r o o t
* table h a s a b i t w h i c h s p e c i f i e s i f i t ' s a v a l i d p o i n t e r t o a
* pointer t a b l e . E a c h e n t r y d e f i n e s a 3 2 K M e g r a n g e o f m e m o r y .
* If a n e n t r y i s i n v a l i d t h e n t h a t l o g i c a l r a n g e o f 3 2 M i s
* invalid a n d r e f e r e n c e s t o t h a t r a n g e o f m e m o r y ( w h e n t h e M M U
* is e n a b l e d ) w i l l f a u l t . I f t h e e n t r y i s v a l i d , t h e n i t d o e s
* one o f t w o t h i n g s . O n 0 4 0 / 0 6 0 c l a s s m a c h i n e s , i t p o i n t s t o
* a p o i n t e r t a b l e w h i c h t h e n d e s c r i b e s m o r e f i n e l y t h e m e m o r y
* within t h a t 3 2 M r a n g e . O n 0 2 0 / 0 3 0 c l a s s m a c h i n e s , a t e c h n i q u e
* called " e a r l y t e r m i n a t i n g d e s c r i p t o r s " a r e u s e d . T h i s t e c h n i q u e
* allows a n e n t i r e 3 2 M e g t o b e d e s c r i b e d b y a s i n g l e e n t r y i n t h e
* root t a b l e . T h u s , t h i s e n t r y i n t h e r o o t t a b l e , c o n t a i n s t h e
* physical a d d r e s s o f t h e m e m o r y o r I / O a t t h e l o g i c a l a d d r e s s
* which t h e e n t r y r e p r e s e n t s a n d i t a l s o c o n t a i n s t h e n e c e s s a r y
* cache b i t s f o r t h i s r e g i o n .
*
* Pointer T a b l e s
* Per t h e R o o t T a b l e , t h e r e w i l l b e o n e o r m o r e
* pointer t a b l e s . E a c h p o i n t e r t a b l e d e f i n e s a 3 2 M r a n g e .
* Not a l l o f t h e 3 2 M r a n g e n e e d b e d e f i n e d . A g a i n , t h e n e x t
* seven b i t s o f t h e l o g i c a l a d d r e s s a r e u s e d a n i n d e x i n t o
* the p o i n t e r t a b l e t o p o i n t t o p a g e t a b l e s ( i f t h e p o i n t e r
* is v a l i d ) . T h e r e w i l l u n d o u b t e d l y b e m o r e t h a n o n e
* pointer t a b l e f o r t h e k e r n e l b e c a u s e e a c h p o i n t e r t a b l e
* defines a r a n g e o f o n l y 3 2 M . V a l i d p o i n t e r t a b l e e n t r i e s
* point t o p a g e t a b l e s , o r a r e e a r l y t e r m i n a t i n g e n t r i e s
* themselves.
*
* Page T a b l e s
* Per t h e P o i n t e r T a b l e s , e a c h p a g e t a b l e e n t r y p o i n t s
* to t h e p h y s i c a l p a g e i n m e m o r y t h a t s u p p o r t s t h e l o g i c a l
* address t h a t t r a n s l a t e s t o t h e p a r t i c u l a r i n d e x .
*
* In s h o r t , t h e L o g i c a l A d d r e s s g e t s t r a n s l a t e d a s f o l l o w s :
* bits 3 1 . . 2 6 - i n d e x i n t o t h e R o o t T a b l e
* bits 2 5 . . 1 8 - i n d e x i n t o t h e P o i n t e r T a b l e
* bits 1 7 . . 1 2 - i n d e x i n t o t h e P a g e T a b l e
* bits 1 1 . . 0 - o f f s e t i n t o a p a r t i c u l a r 4 K p a g e
*
* The a l g o r i t h m s w h i c h f o l l o w s d o o n e t h i n g : t h e y a b s t r a c t
* the M M U h a r d w a r e . F o r e x a m p l e , t h e r e a r e t h r e e k i n d s o f
* cache s e t t i n g s t h a t a r e r e l e v a n t . E i t h e r , m e m o r y i s
* being m a p p e d i n w h i c h c a s e i t i s e i t h e r K e r n e l C o d e ( o r
* the R a m D i s k ) o r i t i s M M U d a t a . O n t h e 0 3 0 , t h e M M U d a t a
* option a l s o d e s c r i b e s t h e k e r n e l . O r , I / O i s b e i n g m a p p e d
* in w h i c h c a s e i t h a s i t s o w n k i n d o f c a c h e b i t s . T h e r e
* are c o n s t a n t s w h i c h a b s t r a c t t h e s e n o t i o n s f r o m t h e c o d e t h a t
* actually m a k e s t h e c a l l t o m a p s o m e r a n g e o f m e m o r y .
*
*
*
* /
# ifdef M M U _ P R I N T
/ *
* mmu_ p r i n t
*
* This a l g o r i t h m w i l l p r i n t o u t t h e c u r r e n t M M U m a p p i n g s .
*
* Input :
* % a5 p o i n t s t o t h e r o o t t a b l e . E v e r y t h i n g e l s e i s c a l c u l a t e d
* from t h i s .
* /
# define m m u _ n e x t _ v a l i d 0
# define m m u _ s t a r t _ l o g i c a l 4
# define m m u _ n e x t _ l o g i c a l 8
# define m m u _ s t a r t _ p h y s i c a l 1 2
# define m m u _ n e x t _ p h y s i c a l 1 6
# define M M U _ P R I N T _ I N V A L I D - 1
# define M M U _ P R I N T _ V A L I D 1
# define M M U _ P R I N T _ U N I N I T E D 0
# define p u t Z c ( z ,n ) j b n e 1 f ; putc z; jbra 2f; 1: putc n; 2:
func_ s t a r t m m u _ p r i n t ,% a0 - % a6 / % d0 - % d7
movel % p c @(L(kernel_pgdir_ptr)),%a5
lea % p c @(L(mmu_print_data)),%a0
movel #M M U _ P R I N T _ U N I N I T E D , % a 0 @(mmu_next_valid)
is_ n o t _ 0 4 0 _ o r _ 0 6 0 ( m m u _ 0 3 0 _ p r i n t )
mmu_040_print :
puts " \ n M M U 0 4 0 \ n "
puts " r p : "
putn % a5
putc ' \ n '
# if 0
/ *
* The f o l l o w i n g #i f / # e n d i f b l o c k i s a t i g h t a l g o r i t h m f o r d u m p i n g t h e 040
* MMU M a p i n g o r y d e t a i l . I t r e a l l y i s n ' t t h a t p r a c t i c a l u n l e s s t h e
* MMU M a p a l g o r i t h m a p p e a r s t o g o a w r y a n d y o u n e e d t o d e b u g i t a t t h e
* entry p e r e n t r y l e v e l .
* /
movel #R O O T _ T A B L E _ S I Z E , % d 5
# if 0
movel % a5 @+,%d7 | Burn an entry to skip the kernel mappings,
subql #1 ,% d5 | t h e y ( m i g h t ) w o r k
# endif
1 : tstl % d5
jbeq m m u _ p r i n t _ d o n e
subq #1 ,% d5
movel % a5 @+,%d7
btst #1 ,% d7
jbeq 1 b
2 : putn % d7
andil #0xFFFFFE00 ,% d7
movel % d7 ,% a4
movel #P T R _ T A B L E _ S I Z E , % d 4
putc ' '
3 : tstl % d4
jbeq 1 1 f
subq #1 ,% d4
movel % a4 @+,%d7
btst #1 ,% d7
jbeq 3 b
4 : putn % d7
andil #0xFFFFFF00 ,% d7
movel % d7 ,% a3
movel #P A G E _ T A B L E _ S I Z E , % d 3
5 : movel #8 ,% d2
6 : tstl % d3
jbeq 3 1 f
subq #1 ,% d3
movel % a3 @+,%d6
btst #0 ,% d6
jbeq 6 b
7 : tstl % d2
jbeq 8 f
subq #1 ,% d2
putc ' '
jbra 9 1 f
8 : putc ' \ n '
movel #8 + 1 + 8 + 1 + 1 ,% d2
9 : putc ' '
dbra % d2 ,9 b
movel #7 ,% d2
91 : putn % d6
jbra 6 b
31 : putc ' \ n '
movel #8 + 1 ,% d2
32 : putc ' '
dbra % d2 ,3 2 b
jbra 3 b
11 : putc ' \ n '
jbra 1 b
# endif / * M M U 0 4 0 D u m p i n g c o d e t h a t ' s g o r y a n d d e t a i l e d * /
lea % p c @(kernel_pg_dir),%a5
movel % a5 ,% a0 / * a0 h a s t h e a d d r e s s o f t h e r o o t t a b l e p t r * /
movel #0x00000000 ,% a4 / * l o g i c a l a d d r e s s * /
moveql #0 ,% d0
40 :
/* Increment the logical address and preserve in d5 */
movel % a4 ,% d5
addil #P A G E S I Z E < < 13 ,% d5
movel % a0 @+,%d6
btst #1 ,% d6
jbne 4 1 f
jbsr m m u _ p r i n t _ t u p l e _ i n v a l i d a t e
jbra 4 8 f
41 :
movel #0 ,% d1
andil #0xfffffe00 ,% d6
movel % d6 ,% a1
42 :
movel % a4 ,% d5
addil #P A G E S I Z E < < 6 ,% d5
movel % a1 @+,%d6
btst #1 ,% d6
jbne 4 3 f
jbsr m m u _ p r i n t _ t u p l e _ i n v a l i d a t e
jbra 4 7 f
43 :
movel #0 ,% d2
andil #0xffffff00 ,% d6
movel % d6 ,% a2
44 :
movel % a4 ,% d5
addil #P A G E S I Z E , % d 5
movel % a2 @+,%d6
btst #0 ,% d6
jbne 4 5 f
jbsr m m u _ p r i n t _ t u p l e _ i n v a l i d a t e
jbra 4 6 f
45 :
moveml % d0 - % d1 ,% s p @-
movel % a4 ,% d0
movel % d6 ,% d1
andil #0xfffff4e0 ,% d1
lea % p c @(mmu_040_print_flags),%a6
jbsr m m u _ p r i n t _ t u p l e
moveml % s p @+,%d0-%d1
46 :
movel % d5 ,% a4
addq #1 ,% d2
cmpib #64 ,% d2
jbne 4 4 b
47 :
movel % d5 ,% a4
addq #1 ,% d1
cmpib #128 ,% d1
jbne 4 2 b
48 :
movel % d5 ,% a4 / * m o v e t o t h e n e x t l o g i c a l a d d r e s s * /
addq #1 ,% d0
cmpib #128 ,% d0
jbne 4 0 b
.chip 68040
movec % d t t 1 ,% d0
movel % d0 ,% d1
andiw #0x8000 ,% d1 / * i s i t v a l i d ? * /
jbeq 1 f / * N o , b a i l o u t * /
movel % d0 ,% d1
andil #0xff000000 ,% d1 / * G e t t h e a d d r e s s * /
putn % d1
puts " = = "
putn % d1
movel % d0 ,% d6
jbsr m m u _ 0 4 0 _ p r i n t _ f l a g s _ t t
1 :
movec % d t t 0 ,% d0
movel % d0 ,% d1
andiw #0x8000 ,% d1 / * i s i t v a l i d ? * /
jbeq 1 f / * N o , b a i l o u t * /
movel % d0 ,% d1
andil #0xff000000 ,% d1 / * G e t t h e a d d r e s s * /
putn % d1
puts " = = "
putn % d1
movel % d0 ,% d6
jbsr m m u _ 0 4 0 _ p r i n t _ f l a g s _ t t
1 :
.chip 68k
jbra m m u _ p r i n t _ d o n e
mmu_040_print_flags :
btstl #10 ,% d6
putZc( ' ' ,' G ' ) / * g l o b a l b i t * /
btstl #7 ,% d6
putZc( ' ' ,' S ' ) / * s u p e r v i s o r b i t * /
mmu_040_print_flags_tt :
btstl #6 ,% d6
jbne 3 f
putc ' C '
btstl #5 ,% d6
putZc( ' w ' ,' c ' ) / * w r i t e t h r o u g h o r c o p y - b a c k * /
jbra 4 f
3 :
putc ' N '
btstl #5 ,% d6
putZc( ' s ' ,' ' ) / * s e r i a l i z e d n o n - c a c h e a b l e , o r n o n - c a c h e a b l e * /
4 :
rts
mmu_030_print_flags :
btstl #6 ,% d6
putZc( ' C ' ,' I ' ) / * w r i t e t h r o u g h o r c o p y - b a c k * /
rts
mmu_030_print :
puts " \ n M M U 0 3 0 \ n "
puts " \ n r p : "
putn % a5
putc ' \ n '
movel % a5 ,% d0
andil #0xfffffff0 ,% d0
movel % d0 ,% a0
movel #0x00000000 ,% a4 / * l o g i c a l a d d r e s s * /
movel #0 ,% d0
30 :
movel % a4 ,% d5
addil #P A G E S I Z E < < 13 ,% d5
movel % a0 @+,%d6
btst #1 ,% d6 / * i s i t a t a b l e p t r ? * /
jbne 3 1 f / * y e s * /
btst #0 ,% d6 / * i s i t e a r l y t e r m i n a t i n g ? * /
jbeq 1 f / * n o * /
jbsr m m u _ 0 3 0 _ p r i n t _ h e l p e r
jbra 3 8 f
1 :
jbsr m m u _ p r i n t _ t u p l e _ i n v a l i d a t e
jbra 3 8 f
31 :
movel #0 ,% d1
andil #0xfffffff0 ,% d6
movel % d6 ,% a1
32 :
movel % a4 ,% d5
addil #P A G E S I Z E < < 6 ,% d5
movel % a1 @+,%d6
btst #1 ,% d6 / * i s i t a t a b l e p t r ? * /
jbne 3 3 f / * y e s * /
btst #0 ,% d6 / * i s i t a p a g e d e s c r i p t o r ? * /
jbeq 1 f / * n o * /
jbsr m m u _ 0 3 0 _ p r i n t _ h e l p e r
jbra 3 7 f
1 :
jbsr m m u _ p r i n t _ t u p l e _ i n v a l i d a t e
jbra 3 7 f
33 :
movel #0 ,% d2
andil #0xfffffff0 ,% d6
movel % d6 ,% a2
34 :
movel % a4 ,% d5
addil #P A G E S I Z E , % d 5
movel % a2 @+,%d6
btst #0 ,% d6
jbne 3 5 f
jbsr m m u _ p r i n t _ t u p l e _ i n v a l i d a t e
jbra 3 6 f
35 :
jbsr m m u _ 0 3 0 _ p r i n t _ h e l p e r
36 :
movel % d5 ,% a4
addq #1 ,% d2
cmpib #64 ,% d2
jbne 3 4 b
37 :
movel % d5 ,% a4
addq #1 ,% d1
cmpib #128 ,% d1
jbne 3 2 b
38 :
movel % d5 ,% a4 / * m o v e t o t h e n e x t l o g i c a l a d d r e s s * /
addq #1 ,% d0
cmpib #128 ,% d0
jbne 3 0 b
mmu_print_done :
puts " \ n \ n "
func_ r e t u r n m m u _ p r i n t
mmu_030_print_helper :
moveml % d0 - % d1 ,% s p @-
movel % a4 ,% d0
movel % d6 ,% d1
lea % p c @(mmu_030_print_flags),%a6
jbsr m m u _ p r i n t _ t u p l e
moveml % s p @+,%d0-%d1
rts
mmu_print_tuple_invalidate :
moveml % a0 / % d7 ,% s p @-
lea % p c @(L(mmu_print_data)),%a0
tstl % a0 @(mmu_next_valid)
jbmi m m u _ p r i n t _ t u p l e _ i n v a l i d a t e _ e x i t
movel #M M U _ P R I N T _ I N V A L I D , % a 0 @(mmu_next_valid)
putn % a4
puts " ## \ n "
mmu_print_tuple_invalidate_exit :
moveml % s p @+,%a0/%d7
rts
mmu_print_tuple :
moveml % d0 - % d7 / % a0 ,% s p @-
lea % p c @(L(mmu_print_data)),%a0
tstl % a0 @(mmu_next_valid)
jble m m u _ p r i n t _ t u p l e _ p r i n t
cmpl % a0 @(mmu_next_physical),%d1
jbeq m m u _ p r i n t _ t u p l e _ i n c r e m e n t
mmu_print_tuple_print :
putn % d0
puts " - > "
putn % d1
movel % d1 ,% d6
jbsr % a6 @
mmu_print_tuple_record :
movel #M M U _ P R I N T _ V A L I D , % a 0 @(mmu_next_valid)
movel % d1 ,% a0 @(mmu_next_physical)
mmu_print_tuple_increment :
movel % d5 ,% d7
subl % a4 ,% d7
addl % d7 ,% a0 @(mmu_next_physical)
mmu_print_tuple_exit :
moveml % s p @+,%d0-%d7/%a0
rts
mmu_print_machine_cpu_types :
puts " m a c h i n e : "
is_ n o t _ a m i g a ( 1 f )
puts " a m i g a "
jbra 9 f
1 :
is_ n o t _ a t a r i ( 2 f )
puts " a t a r i "
jbra 9 f
2 :
is_ n o t _ m a c ( 3 f )
puts " m a c i n t o s h "
jbra 9 f
3 : puts " u n k n o w n "
9 : putc ' \ n '
puts " c p u t y p e : 0 "
is_ n o t _ 0 6 0 ( 1 f )
putc ' 6 '
jbra 9 f
1 :
is_ n o t _ 0 4 0 _ o r _ 0 6 0 ( 2 f )
putc ' 4 '
jbra 9 f
2 : putc ' 3 '
9 : putc ' 0 '
putc ' \ n '
rts
# endif / * M M U _ P R I N T * /
/ *
* mmu_ m a p _ t t
*
* This i s a s p e c i f i c f u n c t i o n w h i c h w o r k s o n a l l 6 8 0 x0 m a c h i n e s .
* On 0 3 0 , 0 4 0 & 0 6 0 i t w i l l a t t e m p t t o u s e T r a n s p a r e n t T r a n s l a t i o n
* registers ( t t 1 ) .
* On 0 2 0 i t w i l l c a l l t h e s t a n d a r d m m u _ m a p w h i c h w i l l u s e e a r l y
* terminating d e s c r i p t o r s .
* /
func_ s t a r t m m u _ m a p _ t t ,% d0 / % d1 / % a0 ,4
dputs " m m u _ m a p _ t t : "
dputn A R G 1
dputn A R G 2
dputn A R G 3
dputn A R G 4
dputc ' \ n '
is_ 0 2 0 ( L ( d o _ m a p ) )
/ * Extract t h e h i g h e s t b i t s e t
* /
bfffo A R G 3 { #0 ,#32 } ,% d1
cmpw #8 ,% d1
jcc L ( d o _ m a p )
/ * And g e t t h e m a s k
* /
moveq #- 1 ,% d0
lsrl % d1 ,% d0
lsrl #1 ,% d0
/ * Mask t h e a d d r e s s
* /
movel % d0 ,% d1
notl % d1
andl A R G 2 ,% d1
/ * Generate t h e u p p e r 1 6 b i t o f t h e t t r e g i s t e r
* /
lsrl #8 ,% d0
orl % d0 ,% d1
clrw % d1
is_ 0 4 0 _ o r _ 0 6 0 ( L ( m m u _ m a p _ t t _ 0 4 0 ) )
/ * set 0 3 0 s p e c i f i c b i t s ( r e a d / w r i t e a c c e s s f o r s u p e r v i s o r m o d e
* ( highest f u n c t i o n c o d e s e t , l o w e r t w o b i t s m a s k e d ) )
* /
orw #T T R _ E N A B L E + T T R _ R W M + T T R _ F C B 2 + T T R _ F C M 1 + T T R _ F C M 0 ,% d1
movel A R G 4 ,% d0
btst #6 ,% d0
jeq 1 f
orw #T T R _ C I , % d 1
1 : lea S T A C K ,% a0
dputn % d1
movel % d1 ,% a0 @
.chip 68030
tstl A R G 1
jne 1 f
pmove % a0 @,%tt0
jra 2 f
1 : pmove % a0 @,%tt1
2 : .chip 68 k
jra L ( m m u _ m a p _ t t _ d o n e )
/ * set 0 4 0 s p e c i f i c b i t s
* /
L( m m u _ m a p _ t t _ 0 4 0 ) :
orw #T T R _ E N A B L E + T T R _ K E R N E L M O D E , % d 1
orl A R G 4 ,% d1
dputn % d1
.chip 68040
tstl A R G 1
jne 1 f
movec % d1 ,% i t t 0
movec % d1 ,% d t t 0
jra 2 f
1 : movec % d1 ,% i t t 1
movec % d1 ,% d t t 1
2 : .chip 68 k
jra L ( m m u _ m a p _ t t _ d o n e )
L( d o _ m a p ) :
mmu_ m a p _ e q A R G 2 ,A R G 3 ,A R G 4
L( m m u _ m a p _ t t _ d o n e ) :
func_ r e t u r n m m u _ m a p _ t t
/ *
* mmu_ m a p
*
* This r o u t i n e w i l l m a p a r a n g e o f m e m o r y u s i n g a p o i n t e r
* table a n d a l l o c a t i n g t h e p a g e s o n t h e f l y f r o m t h e k e r n e l .
* The p o i n t e r t a b l e d o e s n o t h a v e t o b e a l r e a d y l i n k e d i n t o
* the r o o t t a b l e , t h i s r o u t i n e w i l l d o t h a t i f n e c e s s a r y .
*
* NOTE
* This r o u t i n e w i l l a s s e r t f a i l u r e a n d u s e t h e s e r i a l _ p u t c
* routines i n t h e c a s e o f a r u n - t i m e e r r o r . F o r e x a m p l e ,
* if t h e a d d r e s s i s a l r e a d y m a p p e d .
*
* NOTE- 2
* This r o u t i n e w i l l u s e e a r l y t e r m i n a t i n g d e s c r i p t o r s
* where p o s s i b l e f o r t h e 6 8 0 2 0 + 6 8 8 5 1 a n d 6 8 0 3 0 t y p e
* processors.
* /
func_ s t a r t m m u _ m a p ,% d0 - % d4 / % a0 - % a4
dputs " \ n m m u _ m a p : "
dputn A R G 1
dputn A R G 2
dputn A R G 3
dputn A R G 4
dputc ' \ n '
/ * Get l o g i c a l a d d r e s s a n d r o u n d i t d o w n t o 2 5 6 K B
* /
movel A R G 1 ,% d0
andl #- ( P A G E S I Z E * P A G E _ T A B L E _ S I Z E ) , % d 0
movel % d0 ,% a3
/ * Get t h e e n d a d d r e s s
* /
movel A R G 1 ,% a4
addl A R G 3 ,% a4
subql #1 ,% a4
/ * Get p h y s i c a l a d d r e s s a n d r o u n d i t d o w n t o 2 5 6 K B
* /
movel A R G 2 ,% d0
andl #- ( P A G E S I Z E * P A G E _ T A B L E _ S I Z E ) , % d 0
movel % d0 ,% a2
/ * Add p a g e a t t r i b u t e s t o t h e p h y s i c a l a d d r e s s
* /
movel A R G 4 ,% d0
orw #_ P A G E _ P R E S E N T + _ P A G E _ A C C E S S E D + _ P A G E _ D I R T Y , % d 0
addw % d0 ,% a2
dputn % a2
dputn % a3
dputn % a4
is_ n o t _ 0 4 0 _ o r _ 0 6 0 ( L ( m m u _ m a p _ 0 3 0 ) )
addw #_ P A G E _ G L O B A L 040 ,% a2
/ *
* MMU 0 4 0 & 0 6 0 S u p p o r t
*
* The M M U u s a g e f o r t h e 0 4 0 a n d 0 6 0 i s d i f f e r e n t e n o u g h f r o m
* the 0 3 0 a n d 6 8 8 5 1 t h a t t h e r e i s s e p a r a t e c o d e . T h i s c o m m e n t
* block d e s c r i b e s t h e d a t a s t r u c t u r e s a n d a l g o r i t h m s b u i l t b y
* this c o d e .
*
* The 0 4 0 d o e s n o t s u p p o r t e a r l y t e r m i n a t i n g d e s c r i p t o r s , a s
* the 0 3 0 d o e s . T h e r e f o r e , a t h i r d l e v e l o f t a b l e i s n e e d e d
* for t h e 0 4 0 , a n d t h a t w o u l d b e t h e p a g e t a b l e . I n L i n u x ,
* page t a b l e s a r e a l l o c a t e d d i r e c t l y f r o m t h e m e m o r y a b o v e t h e
* kernel.
*
* /
L( m m u _ m a p _ 0 4 0 ) :
/ * Calculate t h e o f f s e t i n t o t h e r o o t t a b l e
* /
movel % a3 ,% d0
moveq #R O O T _ I N D E X _ S H I F T , % d 1
lsrl % d1 ,% d0
mmu_ g e t _ r o o t _ t a b l e _ e n t r y % d0
/ * Calculate t h e o f f s e t i n t o t h e p o i n t e r t a b l e
* /
movel % a3 ,% d0
moveq #P T R _ I N D E X _ S H I F T , % d 1
lsrl % d1 ,% d0
andl #P T R _ T A B L E _ S I Z E - 1 ,% d0
mmu_ g e t _ p t r _ t a b l e _ e n t r y % a0 ,% d0
/ * Calculate t h e o f f s e t i n t o t h e p a g e t a b l e
* /
movel % a3 ,% d0
moveq #P A G E _ I N D E X _ S H I F T , % d 1
lsrl % d1 ,% d0
andl #P A G E _ T A B L E _ S I Z E - 1 ,% d0
mmu_ g e t _ p a g e _ t a b l e _ e n t r y % a0 ,% d0
/ * The p a g e t a b l e e n t r y m u s t n o t n o b e b u s y
* /
tstl % a0 @
jne L ( m m u _ m a p _ e r r o r )
/ * Do t h e m a p p i n g a n d a d v a n c e t h e p o i n t e r s
* /
movel % a2 ,% a0 @
2 :
addw #P A G E S I Z E , % a 2
addw #P A G E S I Z E , % a 3
/ * Ready w i t h m a p p i n g ?
* /
lea % a3 @(-1),%a0
cmpl % a0 ,% a4
jhi L ( m m u _ m a p _ 0 4 0 )
jra L ( m m u _ m a p _ d o n e )
L( m m u _ m a p _ 0 3 0 ) :
/ * Calculate t h e o f f s e t i n t o t h e r o o t t a b l e
* /
movel % a3 ,% d0
moveq #R O O T _ I N D E X _ S H I F T , % d 1
lsrl % d1 ,% d0
mmu_ g e t _ r o o t _ t a b l e _ e n t r y % d0
/ * Check i f l o g i c a l a d d r e s s 3 2 M B a l i g n e d ,
* so w e c a n t r y t o m a p i t o n c e
* /
movel % a3 ,% d0
andl #( P T R _ T A B L E _ S I Z E * P A G E _ T A B L E _ S I Z E * P A G E S I Z E - 1 ) & ( - R O O T _ T A B L E _ S I Z E ) ,% d0
jne 1 f
/ * Is t h e r e e n o u g h t o m a p f o r 3 2 M B a t o n c e
* /
lea % a3 @(PTR_TABLE_SIZE*PAGE_TABLE_SIZE*PAGESIZE-1),%a1
cmpl % a1 ,% a4
jcs 1 f
addql #1 ,% a1
/ * The r o o t t a b l e e n t r y m u s t n o t n o b e b u s y
* /
tstl % a0 @
jne L ( m m u _ m a p _ e r r o r )
/ * Do t h e m a p p i n g a n d a d v a n c e t h e p o i n t e r s
* /
dputs " e a r l y t e r m 1 "
dputn % a2
dputn % a3
dputn % a1
dputc ' \ n '
movel % a2 ,% a0 @
movel % a1 ,% a3
lea % a2 @(PTR_TABLE_SIZE*PAGE_TABLE_SIZE*PAGESIZE),%a2
jra L ( m m u _ m a p n e x t _ 0 3 0 )
1 :
/ * Calculate t h e o f f s e t i n t o t h e p o i n t e r t a b l e
* /
movel % a3 ,% d0
moveq #P T R _ I N D E X _ S H I F T , % d 1
lsrl % d1 ,% d0
andl #P T R _ T A B L E _ S I Z E - 1 ,% d0
mmu_ g e t _ p t r _ t a b l e _ e n t r y % a0 ,% d0
/ * The p o i n t e r t a b l e e n t r y m u s t n o t n o b e b u s y
* /
tstl % a0 @
jne L ( m m u _ m a p _ e r r o r )
/ * Do t h e m a p p i n g a n d a d v a n c e t h e p o i n t e r s
* /
dputs " e a r l y t e r m 2 "
dputn % a2
dputn % a3
dputc ' \ n '
movel % a2 ,% a0 @
addl #P A G E _ T A B L E _ S I Z E * P A G E S I Z E , % a 2
addl #P A G E _ T A B L E _ S I Z E * P A G E S I Z E , % a 3
L( m m u _ m a p n e x t _ 0 3 0 ) :
/ * Ready w i t h m a p p i n g ?
* /
lea % a3 @(-1),%a0
cmpl % a0 ,% a4
jhi L ( m m u _ m a p _ 0 3 0 )
jra L ( m m u _ m a p _ d o n e )
L( m m u _ m a p _ e r r o r ) :
dputs " m m u _ m a p e r r o r : "
dputn % a2
dputn % a3
dputc ' \ n '
L( m m u _ m a p _ d o n e ) :
func_ r e t u r n m m u _ m a p
/ *
* mmu_ f i x u p
*
* On t h e 0 4 0 c l a s s m a c h i n e s , a l l p a g e s t h a t a r e u s e d f o r t h e
* mmu h a v e t o b e f i x e d u p .
* /
func_ s t a r t m m u _ f i x u p _ p a g e _ m m u _ c a c h e ,% d0 / % a0
dputs " m m u _ f i x u p _ p a g e _ m m u _ c a c h e "
dputn A R G 1
/ * Calculate t h e o f f s e t i n t o t h e r o o t t a b l e
* /
movel A R G 1 ,% d0
moveq #R O O T _ I N D E X _ S H I F T , % d 1
lsrl % d1 ,% d0
mmu_ g e t _ r o o t _ t a b l e _ e n t r y % d0
/ * Calculate t h e o f f s e t i n t o t h e p o i n t e r t a b l e
* /
movel A R G 1 ,% d0
moveq #P T R _ I N D E X _ S H I F T , % d 1
lsrl % d1 ,% d0
andl #P T R _ T A B L E _ S I Z E - 1 ,% d0
mmu_ g e t _ p t r _ t a b l e _ e n t r y % a0 ,% d0
/ * Calculate t h e o f f s e t i n t o t h e p a g e t a b l e
* /
movel A R G 1 ,% d0
moveq #P A G E _ I N D E X _ S H I F T , % d 1
lsrl % d1 ,% d0
andl #P A G E _ T A B L E _ S I Z E - 1 ,% d0
mmu_ g e t _ p a g e _ t a b l e _ e n t r y % a0 ,% d0
movel % a0 @,%d0
andil #_ C A C H E M A S K 040 ,% d0
orl % p c @(m68k_pgtable_cachemode),%d0
movel % d0 ,% a0 @
dputc ' \ n '
func_ r e t u r n m m u _ f i x u p _ p a g e _ m m u _ c a c h e
/ *
* mmu_ t e m p _ m a p
*
* create a t e m p o r a r y m a p p i n g t o e n a b l e t h e m m u ,
* this w e d o n ' t n e e d a n y t r a n s p a r a t i o n t r a n s l a t i o n t r i c k s .
* /
func_ s t a r t m m u _ t e m p _ m a p ,% d0 / % d1 / % a0 / % a1
dputs " m m u _ t e m p _ m a p "
dputn A R G 1
dputn A R G 2
dputc ' \ n '
lea % p c @(L(temp_mmap_mem)),%a1
/ * Calculate t h e o f f s e t i n t h e r o o t t a b l e
* /
movel A R G 2 ,% d0
moveq #R O O T _ I N D E X _ S H I F T , % d 1
lsrl % d1 ,% d0
mmu_ g e t _ r o o t _ t a b l e _ e n t r y % d0
/ * Check i f t h e t a b l e i s t e m p o r a r y a l l o c a t e d , s o w e h a v e t o r e u s e i t
* /
movel % a0 @,%d0
cmpl % p c @(L(memory_start)),%d0
jcc 1 f
/ * Temporary a l l o c a t e a p t r t a b l e a n d i n s e r t i t i n t o t h e r o o t t a b l e
* /
movel % a1 @,%d0
addl #P T R _ T A B L E _ S I Z E * 4 ,% a1 @
orw #_ P A G E _ T A B L E + _ P A G E _ A C C E S S E D , % d 0
movel % d0 ,% a0 @
dputs " ( n e w ) "
1 :
dputn % d0
/ * Mask t h e r o o t t a b l e e n t r y f o r t h e p t r t a b l e
* /
andw #- R O O T _ T A B L E _ S I Z E , % d 0
movel % d0 ,% a0
/ * Calculate t h e o f f s e t i n t o t h e p o i n t e r t a b l e
* /
movel A R G 2 ,% d0
moveq #P T R _ I N D E X _ S H I F T , % d 1
lsrl % d1 ,% d0
andl #P T R _ T A B L E _ S I Z E - 1 ,% d0
lea % a0 @(%d0*4),%a0
dputn % a0
/ * Check i f a t e m p o r a r y p a g e t a b l e i s a l r e a d y a l l o c a t e d
* /
movel % a0 @,%d0
jne 1 f
/ * Temporary a l l o c a t e a p a g e t a b l e a n d i n s e r t i t i n t o t h e p t r t a b l e
* /
movel % a1 @,%d0
/ * The 5 1 2 s h o u l d b e P A G E _ T A B L E _ S I Z E * 4 , b u t t h a t v i o l a t e s t h e
alignment r e s t r i c t i o n f o r p o i n t e r t a b l e s o n t h e ' 0 [ 4 6 ] 0 . * /
addl #512 ,% a1 @
orw #_ P A G E _ T A B L E + _ P A G E _ A C C E S S E D , % d 0
movel % d0 ,% a0 @
dputs " ( n e w ) "
1 :
dputn % d0
/ * Mask t h e p t r t a b l e e n t r y f o r t h e p a g e t a b l e
* /
andw #- P T R _ T A B L E _ S I Z E , % d 0
movel % d0 ,% a0
/ * Calculate t h e o f f s e t i n t o t h e p a g e t a b l e
* /
movel A R G 2 ,% d0
moveq #P A G E _ I N D E X _ S H I F T , % d 1
lsrl % d1 ,% d0
andl #P A G E _ T A B L E _ S I Z E - 1 ,% d0
lea % a0 @(%d0*4),%a0
dputn % a0
/ * Insert t h e a d d r e s s i n t o t h e p a g e t a b l e
* /
movel A R G 1 ,% d0
andw #- P A G E S I Z E , % d 0
orw #_ P A G E _ P R E S E N T + _ P A G E _ A C C E S S E D + _ P A G E _ D I R T Y , % d 0
movel % d0 ,% a0 @
dputn % d0
dputc ' \ n '
func_ r e t u r n m m u _ t e m p _ m a p
func_ s t a r t m m u _ e n g a g e ,% d0 - % d2 / % a0 - % a3
moveq #R O O T _ T A B L E _ S I Z E - 1 ,% d0
/* Temporarily use a different root table. */
lea % p c @(L(kernel_pgdir_ptr)),%a0
movel % a0 @,%a2
movel % p c @(L(memory_start)),%a1
movel % a1 ,% a0 @
movel % a2 ,% a0
1 :
movel % a0 @+,%a1@+
dbra % d0 ,1 b
lea % p c @(L(temp_mmap_mem)),%a0
movel % a1 ,% a0 @
movew #P A G E S I Z E - 1 ,% d0
1 :
clrl % a1 @+
dbra % d0 ,1 b
lea % p c @(1b),%a0
movel #1 b ,% a1
/* Skip temp mappings if phys == virt */
cmpl % a0 ,% a1
jeq 1 f
mmu_ t e m p _ m a p % a0 ,% a0
mmu_ t e m p _ m a p % a0 ,% a1
addw #P A G E S I Z E , % a 0
addw #P A G E S I Z E , % a 1
mmu_ t e m p _ m a p % a0 ,% a0
mmu_ t e m p _ m a p % a0 ,% a1
1 :
movel % p c @(L(memory_start)),%a3
movel % p c @(L(phys_kernel_start)),%d2
is_ n o t _ 0 4 0 _ o r _ 0 6 0 ( L ( m m u _ e n g a g e _ 0 3 0 ) )
L( m m u _ e n g a g e _ 0 4 0 ) :
.chip 68040
nop
cinva % b c
nop
pflusha
nop
movec % a3 ,% s r p
movel #T C _ E N A B L E + T C _ P A G E 4 K ,% d0
movec % d0 ,% t c / * e n a b l e t h e M M U * /
jmp 1 f : l
1 : nop
movec % a2 ,% s r p
nop
cinva % b c
nop
pflusha
.chip 68k
jra L ( m m u _ e n g a g e _ c l e a n u p )
L( m m u _ e n g a g e _ 0 3 0 _ t e m p ) :
.space 12
L( m m u _ e n g a g e _ 0 3 0 ) :
.chip 68030
lea % p c @(L(mmu_engage_030_temp)),%a0
movel #0x80000002 ,% a0 @
movel % a3 ,% a0 @(4)
movel #0x0808 ,% d0
movec % d0 ,% c a c r
pmove % a0 @,%srp
pflusha
/ *
* enable,s u p e r r o o t e n a b l e ,4 0 9 6 b y t e p a g e s ,7 b i t r o o t i n d e x ,
* 7 bit p o i n t e r i n d e x , 6 b i t p a g e t a b l e i n d e x .
* /
movel #0x82c07760 ,% a0 @(8)
pmove % a0 @(8),%tc /* enable the MMU */
jmp 1 f : l
1 : movel % a2 ,% a0 @(4)
movel #0x0808 ,% d0
movec % d0 ,% c a c r
pmove % a0 @,%srp
pflusha
.chip 68k
L( m m u _ e n g a g e _ c l e a n u p ) :
subl #P A G E _ O F F S E T , % d 2
subl % d2 ,% a2
movel % a2 ,L ( k e r n e l _ p g d i r _ p t r )
subl % d2 ,% f p
subl % d2 ,% s p
subl % d2 ,A R G 0
func_ r e t u r n m m u _ e n g a g e
func_ s t a r t m m u _ g e t _ r o o t _ t a b l e _ e n t r y ,% d0 / % a1
# if 0
dputs " m m u _ g e t _ r o o t _ t a b l e _ e n t r y : "
dputn A R G 1
dputs " = "
# endif
movel % p c @(L(kernel_pgdir_ptr)),%a0
tstl % a0
jne 2 f
dputs " \ n m m u _ i n i t : "
/ * Find t h e s t a r t o f f r e e m e m o r y , g e t _ b i _ r e c o r d d o e s t h i s f o r u s ,
* as t h e b o o t i n f o s t r u c t u r e i s l o c a t e d d i r e c t l y b e h i n d t h e k e r n e l
* and a n d w e s i m p l y s e a r c h f o r t h e l a s t e n t r y .
* /
get_ b i _ r e c o r d B I _ L A S T
addw #P A G E S I Z E - 1 ,% a0
movel % a0 ,% d0
andw #- P A G E S I Z E , % d 0
dputn % d0
lea % p c @(L(memory_start)),%a0
movel % d0 ,% a0 @
lea % p c @(L(kernel_end)),%a0
movel % d0 ,% a0 @
/ * we h a v e t o r e t u r n t h e f i r s t p a g e a t _ s t e x t s i n c e t h e i n i t c o d e
* in m m / i n i t . c s i m p l y e x p e c t s k e r n e l _ p g _ d i r t h e r e , t h e r e s t o f
* page i s u s e d f o r f u r t h e r p t r t a b l e s i n g e t _ p t r _ t a b l e .
* /
lea % p c @(_stext),%a0
lea % p c @(L(mmu_cached_pointer_tables)),%a1
movel % a0 ,% a1 @
addl #R O O T _ T A B L E _ S I Z E * 4 ,% a1 @
lea % p c @(L(mmu_num_pointer_tables)),%a1
addql #1 ,% a1 @
/ * clear t h e p a g e
* /
movel % a0 ,% a1
movew #P A G E S I Z E / 4 - 1 ,% d0
1 :
clrl % a1 @+
dbra % d0 ,1 b
lea % p c @(L(kernel_pgdir_ptr)),%a1
movel % a0 ,% a1 @
dputn % a0
dputc ' \ n '
2 :
movel A R G 1 ,% d0
lea % a0 @(%d0*4),%a0
# if 0
dputn % a0
dputc ' \ n '
# endif
func_ r e t u r n m m u _ g e t _ r o o t _ t a b l e _ e n t r y
func_ s t a r t m m u _ g e t _ p t r _ t a b l e _ e n t r y ,% d0 / % a1
# if 0
dputs " m m u _ g e t _ p t r _ t a b l e _ e n t r y : "
dputn A R G 1
dputn A R G 2
dputs " = "
# endif
movel A R G 1 ,% a0
movel % a0 @,%d0
jne 2 f
/ * Keep t r a c k o f t h e n u m b e r o f p o i n t e r t a b l e s w e u s e
* /
dputs " \ n m m u _ g e t _ n e w _ p t r _ t a b l e : "
lea % p c @(L(mmu_num_pointer_tables)),%a0
movel % a0 @,%d0
addql #1 ,% a0 @
/ * See i f t h e r e i s a f r e e p o i n t e r t a b l e i n o u r c a c h e o f p o i n t e r t a b l e s
* /
lea % p c @(L(mmu_cached_pointer_tables)),%a1
andw #7 ,% d0
jne 1 f
/ * Get a n e w p o i n t e r t a b l e p a g e f r o m a b o v e t h e k e r n e l m e m o r y
* /
get_ n e w _ p a g e
movel % a0 ,% a1 @
1 :
/ * There i s a n u n u s e d p o i n t e r t a b l e i n o u r c a c h e . . . u s e i t
* /
movel % a1 @,%d0
addl #P T R _ T A B L E _ S I Z E * 4 ,% a1 @
dputn % d0
dputc ' \ n '
/ * Insert t h e n e w p o i n t e r t a b l e i n t o t h e r o o t t a b l e
* /
movel A R G 1 ,% a0
orw #_ P A G E _ T A B L E + _ P A G E _ A C C E S S E D , % d 0
movel % d0 ,% a0 @
2 :
/ * Extract t h e p o i n t e r t a b l e e n t r y
* /
andw #- P T R _ T A B L E _ S I Z E , % d 0
movel % d0 ,% a0
movel A R G 2 ,% d0
lea % a0 @(%d0*4),%a0
# if 0
dputn % a0
dputc ' \ n '
# endif
func_ r e t u r n m m u _ g e t _ p t r _ t a b l e _ e n t r y
func_ s t a r t m m u _ g e t _ p a g e _ t a b l e _ e n t r y ,% d0 / % a1
# if 0
dputs " m m u _ g e t _ p a g e _ t a b l e _ e n t r y : "
dputn A R G 1
dputn A R G 2
dputs " = "
# endif
movel A R G 1 ,% a0
movel % a0 @,%d0
jne 2 f
/ * If t h e p a g e t a b l e e n t r y d o e s n ' t e x i s t , w e a l l o c a t e a c o m p l e t e n e w
* page a n d u s e i t a s o n e c o n t i n u e s b i g p a g e t a b l e w h i c h c a n c o v e r
* 4 MB o f m e m o r y , n e a r l y a l m o s t a l l m a p p i n g s h a v e t h a t a l i g n m e n t .
* /
get_ n e w _ p a g e
addw #_ P A G E _ T A B L E + _ P A G E _ A C C E S S E D , % a 0
/ * align p o i n t e r t a b l e e n t r y f o r a p a g e o f p a g e t a b l e s
* /
movel A R G 1 ,% d0
andw #- ( P A G E S I Z E / P A G E _ T A B L E _ S I Z E ) , % d 0
movel % d0 ,% a1
/ * Insert t h e p a g e t a b l e s i n t o t h e p o i n t e r e n t r i e s
* /
moveq #P A G E S I Z E / P A G E _ T A B L E _ S I Z E / 4 - 1 ,% d0
1 :
movel % a0 ,% a1 @+
lea % a0 @(PAGE_TABLE_SIZE*4),%a0
dbra % d0 ,1 b
/ * Now w e c a n g e t t h e i n i t i a l i z e d p o i n t e r t a b l e e n t r y
* /
movel A R G 1 ,% a0
movel % a0 @,%d0
2 :
/ * Extract t h e p a g e t a b l e e n t r y
* /
andw #- P A G E _ T A B L E _ S I Z E , % d 0
movel % d0 ,% a0
movel A R G 2 ,% d0
lea % a0 @(%d0*4),%a0
# if 0
dputn % a0
dputc ' \ n '
# endif
func_ r e t u r n m m u _ g e t _ p a g e _ t a b l e _ e n t r y
/ *
* get_ n e w _ p a g e
*
* Return a n e w p a g e f r o m t h e m e m o r y s t a r t a n d c l e a r i t .
* /
func_ s t a r t g e t _ n e w _ p a g e ,% d0 / % a1
dputs " \ n g e t _ n e w _ p a g e : "
/ * allocate t h e p a g e a n d a d j u s t m e m o r y _ s t a r t
* /
lea % p c @(L(memory_start)),%a0
movel % a0 @,%a1
addl #P A G E S I Z E , % a 0 @
/ * clear t h e n e w p a g e
* /
movel % a1 ,% a0
movew #P A G E S I Z E / 4 - 1 ,% d0
1 :
clrl % a1 @+
dbra % d0 ,1 b
dputn % a0
dputc ' \ n '
func_ r e t u r n g e t _ n e w _ p a g e
/ *
* Debug o u t p u t s u p p o r t
* Atarians h a v e a c h o i c e b e t w e e n t h e p a r a l l e l p o r t , t h e s e r i a l p o r t
* from t h e M F P o r a s e r i a l p o r t o f t h e S C C
* /
# ifdef C O N F I G _ M A C
L( s c c _ i n i t a b l e _ m a c ) :
.byte 9 , 1 2 /* Reset */
.byte 4 , 0 x4 4 / * x16 , 1 s t o p b i t , n o p a r i t y * /
.byte 3 , 0 xc0 / * r e c e i v e r : 8 b p c * /
.byte 5 , 0 xe2 / * t r a n s m i t t e r : 8 b p c , a s s e r t d t r / r t s * /
.byte 9 , 0 /* no interrupts */
.byte 1 0 , 0 /* NRZ */
.byte 1 1 , 0 x5 0 / * u s e b a u d r a t e g e n e r a t o r * /
.byte 1 2 , 1 0 , 1 3 , 0 /* 9600 baud */
.byte 1 4 , 1 /* Baud rate generator enable */
.byte 3 , 0 xc1 / * e n a b l e r e c e i v e r * /
.byte 5 , 0 xea / * e n a b l e t r a n s m i t t e r * /
.byte - 1
.even
# endif
# ifdef C O N F I G _ A T A R I
/* #define USE_PRINTER */
/* #define USE_SCC_B */
/* #define USE_SCC_A */
# define U S E _ M F P
# if d e f i n e d ( U S E _ S C C _ A ) | | d e f i n e d ( U S E _ S C C _ B )
# define U S E _ S C C
/* Initialisation table for SCC */
L( s c c _ i n i t a b l e ) :
.byte 9 , 1 2 /* Reset */
.byte 4 , 0 x4 4 / * x16 , 1 s t o p b i t , n o p a r i t y * /
.byte 3 , 0 xc0 / * r e c e i v e r : 8 b p c * /
.byte 5 , 0 xe2 / * t r a n s m i t t e r : 8 b p c , a s s e r t d t r / r t s * /
.byte 9 , 0 /* no interrupts */
.byte 1 0 , 0 /* NRZ */
.byte 1 1 , 0 x5 0 / * u s e b a u d r a t e g e n e r a t o r * /
.byte 1 2 , 2 4 , 1 3 , 0 /* 9600 baud */
.byte 1 4 , 2 , 1 4 , 3 /* use master clock for BRG, enable */
.byte 3 , 0 xc1 / * e n a b l e r e c e i v e r * /
.byte 5 , 0 xea / * e n a b l e t r a n s m i t t e r * /
.byte - 1
.even
# endif
# ifdef U S E _ P R I N T E R
LPSG_ S E L E C T = 0 x f f88 0 0
LPSG_ R E A D = 0 x f f88 0 0
LPSG_ W R I T E = 0 x f f88 0 2
LPSG_ I O _ A = 1 4
LPSG_ I O _ B = 1 5
LPSG_ C O N T R O L = 7
LSTMFP_ G P I P = 0 x f f f a01
LSTMFP_ D D R = 0 x f f f a05
LSTMFP_ I E R B = 0 x f f f a09
# elif d e f i n e d ( U S E _ S C C _ B )
LSCC_ C T R L = 0 x f f8 c85
LSCC_ D A T A = 0 x f f8 c87
# elif d e f i n e d ( U S E _ S C C _ A )
LSCC_ C T R L = 0 x f f8 c81
LSCC_ D A T A = 0 x f f8 c83
# elif d e f i n e d ( U S E _ M F P )
LMFP_ U C R = 0 x f f f a29
LMFP_ T D C D R = 0 x f f f a1 d
LMFP_ T D D R = 0 x f f f a25
LMFP_ T S R = 0 x f f f a2 d
LMFP_ U D R = 0 x f f f a2 f
# endif
# endif / * C O N F I G _ A T A R I * /
/ *
* Serial p o r t o u t p u t s u p p o r t .
* /
/ *
* Initialize s e r i a l p o r t h a r d w a r e f o r 9 6 0 0 / 8 / 1
* /
func_ s t a r t s e r i a l _ i n i t ,% d0 / % d1 / % a0 / % a1
/ *
* Some o f t h e r e g i s t e r u s a g e t h a t f o l l o w s
* CONFIG_ A M I G A
* a0 = p o i n t e r t o b o o t i n f o r e c o r d
* d0 = b o o t i n f o o f f s e t
* CONFIG_ A T A R I
* a0 = a d d r e s s o f S C C
* a1 = L i o b a s e a d d r e s s / a d d r e s s o f s c c _ i n i t a b l e
* d0 = i n i t d a t a f o r s e r i a l p o r t
* CONFIG_ M A C
* a0 = a d d r e s s o f S C C
* a1 = a d d r e s s o f s c c _ i n i t a b l e _ m a c
* d0 = i n i t d a t a f o r s e r i a l p o r t
* /
# ifdef C O N F I G _ A M I G A
# define S E R I A L _ D T R 7
# define S E R I A L _ C N T R L C I A B B A S E + C _ P R A
is_ n o t _ a m i g a ( 1 f )
lea % p c @(L(custom)),%a0
movel #- Z T W O B A S E , % a 0 @
bclr #S E R I A L _ D T R , S E R I A L _ C N T R L - Z T W O B A S E
get_ b i _ r e c o r d B I _ A M I G A _ S E R P E R
movew % a0 @,CUSTOMBASE+C_SERPER-ZTWOBASE
| movew #61 ,C U S T O M B A S E + C _ S E R P E R - Z T W O B A S E
1 :
# endif
# ifdef C O N F I G _ A T A R I
is_ n o t _ a t a r i ( 4 f )
movel % p c @(L(iobase)),%a1
# if d e f i n e d ( U S E _ P R I N T E R )
bclr #0 ,% a1 @(LSTMFP_IERB)
bclr #0 ,% a1 @(LSTMFP_DDR)
moveb #L P S G _ C O N T R O L , % a 1 @(LPSG_SELECT)
moveb #0xff ,% a1 @(LPSG_WRITE)
moveb #L P S G _ I O _ B , % a 1 @(LPSG_SELECT)
clrb % a1 @(LPSG_WRITE)
moveb #L P S G _ I O _ A , % a 1 @(LPSG_SELECT)
moveb % a1 @(LPSG_READ),%d0
bset #5 ,% d0
moveb % d0 ,% a1 @(LPSG_WRITE)
# elif d e f i n e d ( U S E _ S C C )
lea % a1 @(LSCC_CTRL),%a0
lea % p c @(L(scc_initable)),%a1
2 : moveb % a1 @+,%d0
jmi 3 f
moveb % d0 ,% a0 @
moveb % a1 @+,%a0@
jra 2 b
3 : clrb % a0 @
# elif d e f i n e d ( U S E _ M F P )
bclr #1 ,% a1 @(LMFP_TSR)
moveb #0x88 ,% a1 @(LMFP_UCR)
andb #0x70 ,% a1 @(LMFP_TDCDR)
moveb #2 ,% a1 @(LMFP_TDDR)
orb #1 ,% a1 @(LMFP_TDCDR)
bset #1 ,% a1 @(LMFP_TSR)
# endif
jra L ( s e r i a l _ i n i t _ d o n e )
4 :
# endif
# ifdef C O N F I G _ M A C
is_ n o t _ m a c ( L ( s e r i a l _ i n i t _ n o t _ m a c ) )
# ifdef M A C _ S E R I A L _ D E B U G
# if ! d e f i n e d ( M A C _ U S E _ S C C _ A ) & & ! d e f i n e d ( M A C _ U S E _ S C C _ B )
# define M A C _ U S E _ S C C _ B
# endif
# define m a c _ s c c _ c h a _ b _ c t r l _ o f f s e t 0 x0
# define m a c _ s c c _ c h a _ a _ c t r l _ o f f s e t 0 x2
# define m a c _ s c c _ c h a _ b _ d a t a _ o f f s e t 0 x4
# define m a c _ s c c _ c h a _ a _ d a t a _ o f f s e t 0 x6
# ifdef M A C _ U S E _ S C C _ A
/* Initialize channel A */
movel % p c @(L(mac_sccbase)),%a0
lea % p c @(L(scc_initable_mac)),%a1
5 : moveb % a1 @+,%d0
jmi 6 f
moveb % d0 ,% a0 @(mac_scc_cha_a_ctrl_offset)
moveb % a1 @+,%a0@(mac_scc_cha_a_ctrl_offset)
jra 5 b
6 :
# endif / * M A C _ U S E _ S C C _ A * /
# ifdef M A C _ U S E _ S C C _ B
/* Initialize channel B */
# ifndef M A C _ U S E _ S C C _ A / * L o a d m a c _ s c c b a s e o n l y i f n e e d e d * /
movel % p c @(L(mac_sccbase)),%a0
# endif / * M A C _ U S E _ S C C _ A * /
lea % p c @(L(scc_initable_mac)),%a1
7 : moveb % a1 @+,%d0
jmi 8 f
moveb % d0 ,% a0 @(mac_scc_cha_b_ctrl_offset)
moveb % a1 @+,%a0@(mac_scc_cha_b_ctrl_offset)
jra 7 b
8 :
# endif / * M A C _ U S E _ S C C _ B * /
# endif / * M A C _ S E R I A L _ D E B U G * /
jra L ( s e r i a l _ i n i t _ d o n e )
L( s e r i a l _ i n i t _ n o t _ m a c ) :
# endif / * C O N F I G _ M A C * /
# ifdef C O N F I G _ Q 4 0
is_ n o t _ q40 ( 2 f )
/ * debug o u t p u t g o e s i n t o S R A M , s o w e d o n ' t d o i t u n l e s s r e q u e s t e d
- check f o r ' % L X $ ' s i g n a t u r e i n S R A M * /
lea % p c @(q40_mem_cptr),%a1
move. l #0xff020010 ,% a1 @ /* must be inited - also used by debug=mem */
move. l #0xff020000 ,% a1
cmp. b #' % ' ,% a1 @
bne 2 f / * n o d b g * /
addq. w #4 ,% a1
cmp. b #' L ' ,% a1 @
bne 2 f / * n o d b g * /
addq. w #4 ,% a1
cmp. b #' X ' ,% a1 @
bne 2 f / * n o d b g * /
addq. w #4 ,% a1
cmp. b #' $ ' ,% a1 @
bne 2 f / * n o d b g * /
/* signature OK */
lea % p c @(L(q40_do_debug)),%a1
tas % a1 @
/*nodbg: q40_do_debug is 0 by default*/
2 :
# endif
# ifdef C O N F I G _ A P O L L O
/* We count on the PROM initializing SIO1 */
# endif
# ifdef C O N F I G _ H P 3 0 0
/* We count on the boot loader initialising the UART */
# endif
L( s e r i a l _ i n i t _ d o n e ) :
func_ r e t u r n s e r i a l _ i n i t
/ *
* Output c h a r a c t e r o n s e r i a l p o r t .
* /
func_ s t a r t s e r i a l _ p u t c ,% d0 / % d1 / % a0 / % a1
movel A R G 1 ,% d0
cmpib #' \n ' ,% d0
jbne 1 f
/* A little safe recursion is good for the soul */
serial_ p u t c #' \r '
1 :
# ifdef C O N F I G _ A M I G A
is_ n o t _ a m i g a ( 2 f )
andw #0x00ff ,% d0
oriw #0x0100 ,% d0
movel % p c @(L(custom)),%a0
movew % d0 ,% a0 @(CUSTOMBASE+C_SERDAT)
1 : movew % a0 @(CUSTOMBASE+C_SERDATR),%d0
andw #0x2000 ,% d0
jeq 1 b
jra L ( s e r i a l _ p u t c _ d o n e )
2 :
# endif
# ifdef C O N F I G _ M A C
is_ n o t _ m a c ( 5 f )
# ifdef M A C _ S E R I A L _ D E B U G
# ifdef M A C _ U S E _ S C C _ A
movel % p c @(L(mac_sccbase)),%a1
3 : btst #2 ,% a1 @(mac_scc_cha_a_ctrl_offset)
jeq 3 b
moveb % d0 ,% a1 @(mac_scc_cha_a_data_offset)
# endif / * M A C _ U S E _ S C C _ A * /
# ifdef M A C _ U S E _ S C C _ B
# ifndef M A C _ U S E _ S C C _ A / * L o a d m a c _ s c c b a s e o n l y i f n e e d e d * /
movel % p c @(L(mac_sccbase)),%a1
# endif / * M A C _ U S E _ S C C _ A * /
4 : btst #2 ,% a1 @(mac_scc_cha_b_ctrl_offset)
jeq 4 b
moveb % d0 ,% a1 @(mac_scc_cha_b_data_offset)
# endif / * M A C _ U S E _ S C C _ B * /
# endif / * M A C _ S E R I A L _ D E B U G * /
jra L ( s e r i a l _ p u t c _ d o n e )
5 :
# endif / * C O N F I G _ M A C * /
# ifdef C O N F I G _ A T A R I
is_ n o t _ a t a r i ( 4 f )
movel % p c @(L(iobase)),%a1
# if d e f i n e d ( U S E _ P R I N T E R )
3 : btst #0 ,% a1 @(LSTMFP_GPIP)
jne 3 b
moveb #L P S G _ I O _ B , % a 1 @(LPSG_SELECT)
moveb % d0 ,% a1 @(LPSG_WRITE)
moveb #L P S G _ I O _ A , % a 1 @(LPSG_SELECT)
moveb % a1 @(LPSG_READ),%d0
bclr #5 ,% d0
moveb % d0 ,% a1 @(LPSG_WRITE)
nop
nop
bset #5 ,% d0
moveb % d0 ,% a1 @(LPSG_WRITE)
# elif d e f i n e d ( U S E _ S C C )
3 : btst #2 ,% a1 @(LSCC_CTRL)
jeq 3 b
moveb % d0 ,% a1 @(LSCC_DATA)
# elif d e f i n e d ( U S E _ M F P )
3 : btst #7 ,% a1 @(LMFP_TSR)
jeq 3 b
moveb % d0 ,% a1 @(LMFP_UDR)
# endif
jra L ( s e r i a l _ p u t c _ d o n e )
4 :
# endif / * C O N F I G _ A T A R I * /
# ifdef C O N F I G _ M V M E 1 4 7
is_ n o t _ m v m e 1 4 7 ( 2 f )
1 : btst #2 ,M 1 4 7 _ S C C _ C T R L _ A
jeq 1 b
moveb % d0 ,M 1 4 7 _ S C C _ D A T A _ A
jbra L ( s e r i a l _ p u t c _ d o n e )
2 :
# endif
# ifdef C O N F I G _ M V M E 1 6 x
is_ n o t _ m v m e 1 6 x ( 2 f )
/ *
* If t h e l o a d e r g a v e u s a b o a r d t y p e t h e n w e c a n u s e t h a t t o
* select a n a p p r o p r i a t e o u t p u t r o u t i n e ; otherwise we just use
* the B u g c o d e . I f w e h a e v t o u s e t h e B u g t h a t m e a n s t h e B u g
* workspace h a s t o b e v a l i d , w h i c h m e a n s t h e B u g h a s t o u s e
* the S R A M , w h i c h i s n o n - s t a n d a r d .
* /
moveml % d0 - % d7 / % a2 - % a6 ,% s p @-
movel v m e _ b r d t y p e ,% d1
jeq 1 f | N o t a g - u s e t h e B u g
cmpi #V M E _ T Y P E _ M V M E 162 ,% d1
jeq 6 f
cmpi #V M E _ T Y P E _ M V M E 172 ,% d1
jne 5 f
/* 162/172; it's an SCC */
6 : btst #2 ,M 1 6 2 _ S C C _ C T R L _ A
nop
nop
nop
jeq 6 b
moveb #8 ,M 1 6 2 _ S C C _ C T R L _ A
nop
nop
nop
moveb % d0 ,M 1 6 2 _ S C C _ C T R L _ A
jra 3 f
5 :
/* 166/167/177; it's a CD2401 */
moveb #0 ,M 1 6 7 _ C Y C A R
moveb M 1 6 7 _ C Y I E R ,% d2
moveb #0x02 ,M 1 6 7 _ C Y I E R
7 :
btst #5 ,M 1 6 7 _ P C S C C T I C R
jeq 7 b
moveb M 1 6 7 _ P C T P I A C K R ,% d1
moveb M 1 6 7 _ C Y L I C R ,% d1
jeq 8 f
moveb #0x08 ,M 1 6 7 _ C Y T E O I R
jra 7 b
8 :
moveb % d0 ,M 1 6 7 _ C Y T D R
moveb #0 ,M 1 6 7 _ C Y T E O I R
moveb % d2 ,M 1 6 7 _ C Y I E R
jra 3 f
1 :
moveb % d0 ,% s p @-
trap #15
.word 0x0020 /* TRAP 0x020 */
3 :
moveml % s p @+,%d0-%d7/%a2-%a6
jbra L ( s e r i a l _ p u t c _ d o n e )
2 :
# endif / * C O N F I G _ M V M E 1 6 x * /
# ifdef C O N F I G _ B V M E 6 0 0 0
is_ n o t _ b v m e 6 0 0 0 ( 2 f )
/ *
* The B V M E 6 0 0 0 m a c h i n e h a s a s e r i a l p o r t . . .
* /
1 : btst #2 ,B V M E _ S C C _ C T R L _ A
jeq 1 b
moveb % d0 ,B V M E _ S C C _ D A T A _ A
jbra L ( s e r i a l _ p u t c _ d o n e )
2 :
# endif
# ifdef C O N F I G _ S U N 3 X
is_ n o t _ s u n 3 x ( 2 f )
movel % d0 ,- ( % s p )
movel 0 x F E F E 0 0 1 8 ,% a1
jbsr ( % a1 )
addq #4 ,% s p
jbra L ( s e r i a l _ p u t c _ d o n e )
2 :
# endif
# ifdef C O N F I G _ Q 4 0
is_ n o t _ q40 ( 2 f )
tst. l % p c @(L(q40_do_debug)) /* only debug if requested */
beq 2 f
lea % p c @(q40_mem_cptr),%a1
move. l % a1 @,%a0
move. b % d0 ,% a0 @
addq. l #4 ,% a0
move. l % a0 ,% a1 @
jbra L ( s e r i a l _ p u t c _ d o n e )
2 :
# endif
# ifdef C O N F I G _ A P O L L O
is_ n o t _ a p o l l o ( 2 f )
movl % p c @(L(iobase)),%a1
moveb % d0 ,% a1 @(LTHRB0)
1 : moveb % a1 @(LSRB0),%d0
andb #0x4 ,% d0
beq 1 b
jbra L ( s e r i a l _ p u t c _ d o n e )
2 :
# endif
# ifdef C O N F I G _ H P 3 0 0
is_ n o t _ h p30 0 ( 3 f )
movl % p c @(L(iobase)),%a1
addl % p c @(L(uartbase)),%a1
movel % p c @(L(uart_scode)),%d1 /* Check the scode */
jmi 3 f / * U n s e t ? E x i t * /
cmpi #256 ,% d1 / * A P C I s c o d e ? * /
jeq 2 f
1 : moveb % a1 @(DCALSR),%d1 /* Output to DCA */
andb #0x20 ,% d1
beq 1 b
moveb % d0 ,% a1 @(DCADATA)
jbra L ( s e r i a l _ p u t c _ d o n e )
2 : moveb % a1 @(APCILSR),%d1 /* Output to APCI */
andb #0x20 ,% d1
beq 2 b
moveb % d0 ,% a1 @(APCIDATA)
jbra L ( s e r i a l _ p u t c _ d o n e )
3 :
# endif
2007-05-02 00:32:43 +04:00
2005-04-17 02:20:36 +04:00
L( s e r i a l _ p u t c _ d o n e ) :
func_ r e t u r n s e r i a l _ p u t c
/ *
* Output a s t r i n g .
* /
func_ s t a r t p u t s ,% d0 / % a0
movel A R G 1 ,% a0
jra 2 f
1 :
# ifdef C O N S O L E
console_ p u t c % d0
# endif
# ifdef S E R I A L _ D E B U G
serial_ p u t c % d0
# endif
2 : moveb % a0 @+,%d0
jne 1 b
func_ r e t u r n p u t s
/ *
* Output n u m b e r i n h e x n o t a t i o n .
* /
func_ s t a r t p u t n ,% d0 - % d2
putc ' '
movel A R G 1 ,% d0
moveq #7 ,% d1
1 : roll #4 ,% d0
move % d0 ,% d2
andb #0x0f ,% d2
addb #' 0 ' ,% d2
cmpb #' 9 ' ,% d2
jls 2 f
addb #' A ' - ( ' 9 ' + 1 ) ,% d2
2 :
# ifdef C O N S O L E
console_ p u t c % d2
# endif
# ifdef S E R I A L _ D E B U G
serial_ p u t c % d2
# endif
dbra % d1 ,1 b
func_ r e t u r n p u t n
# ifdef C O N F I G _ M A C
/ *
* mac_ s e r i a l _ p r i n t
*
* This r o u t i n e t a k e s i t s p a r a m e t e r s o n t h e s t a c k . I t t h e n
* turns a r o u n d a n d c a l l s t h e i n t e r n a l r o u t i n e . T h i s r o u t i n e
* is u s e d u n t i l t h e L i n u x c o n s o l e d r i v e r i n i t i a l i z e s i t s e l f .
*
* The c a l l i n g p a r a m e t e r s a r e :
* void m a c _ s e r i a l _ p r i n t ( c o n s t c h a r * s t r ) ;
*
* This r o u t i n e d o e s N O T u n d e r s t a n d v a r i a b l e a r g u m e n t s o n l y
* simple s t r i n g s !
* /
ENTRY( m a c _ s e r i a l _ p r i n t )
moveml % d0 / % a0 ,% s p @-
# if 1
move % s r ,% s p @-
ori #0x0700 ,% s r
# endif
movel % s p @(10),%a0 /* fetch parameter */
jra 2 f
1 : serial_ p u t c % d0
2 : moveb % a0 @+,%d0
jne 1 b
# if 1
move % s p @+,%sr
# endif
moveml % s p @+,%d0/%a0
rts
# endif / * C O N F I G _ M A C * /
# if d e f i n e d ( C O N F I G _ H P 3 0 0 ) | | d e f i n e d ( C O N F I G _ A P O L L O )
func_ s t a r t s e t _ l e d s ,% d0 / % a0
movel A R G 1 ,% d0
# ifdef C O N F I G _ H P 3 0 0
is_ n o t _ h p30 0 ( 1 f )
movel % p c @(L(iobase)),%a0
moveb % d0 ,% a0 @(0x1ffff)
jra 2 f
# endif
1 :
# ifdef C O N F I G _ A P O L L O
movel % p c @(L(iobase)),%a0
lsll #8 ,% d0
eorw #0xff00 ,% d0
moveb % d0 ,% a0 @(LCPUCTRL)
# endif
2 :
func_ r e t u r n s e t _ l e d s
# endif
# ifdef C O N S O L E
/ *
* For c o n t i n u i t y , s e e t h e d a t a a l i g n m e n t
* to w h i c h t h i s s t r u c t u r e i s t i e d .
* /
# define L c o n s o l e _ s t r u c t _ c u r _ c o l u m n 0
# define L c o n s o l e _ s t r u c t _ c u r _ r o w 4
# define L c o n s o l e _ s t r u c t _ n u m _ c o l u m n s 8
# define L c o n s o l e _ s t r u c t _ n u m _ r o w s 1 2
# define L c o n s o l e _ s t r u c t _ l e f t _ e d g e 1 6
# define L c o n s o l e _ s t r u c t _ p e n g u i n _ p u t c 2 0
func_ s t a r t c o n s o l e _ i n i t ,% a0 - % a4 / % d0 - % d7
/ *
* Some o f t h e r e g i s t e r u s a g e t h a t f o l l o w s
* a0 = p o i n t e r t o b o o t _ i n f o
* a1 = p o i n t e r t o s c r e e n
* a2 = p o i n t e r t o L c o n s o l e _ g l o b a l s
* d3 = p i x e l w i d t h o f s c r e e n
* d4 = p i x e l h e i g h t o f s c r e e n
* ( d3 ,d4 ) ~ = ( x ,y ) o f a p o i n t j u s t b e l o w
* and t o t h e r i g h t o f t h e s c r e e n
* NOT o n t h e s c r e e n !
* d5 = n u m b e r o f b y t e s p e r s c a n l i n e
* d6 = n u m b e r o f b y t e s o n t h e e n t i r e s c r e e n
* /
lea % p c @(L(console_globals)),%a2
movel % p c @(L(mac_videobase)),%a1
movel % p c @(L(mac_rowbytes)),%d5
movel % p c @(L(mac_dimensions)),%d3 /* -> low byte */
movel % d3 ,% d4
swap % d4 / * - > h i g h b y t e * /
andl #0xffff ,% d3 / * d3 = s c r e e n w i d t h i n p i x e l s * /
andl #0xffff ,% d4 / * d4 = s c r e e n h e i g h t i n p i x e l s * /
movel % d5 ,% d6
| subl #20 ,% d6
mulul % d4 ,% d6 / * s c a n l i n e b y t e s x n u m s c a n l i n e s * /
divul #8 ,% d6 / * w e ' l l c l e a r 8 b y t e s a t a t i m e * /
moveq #- 1 ,% d0 / * M a c _ b l a c k * /
subq #1 ,% d6
L( c o n s o l e _ c l e a r _ l o o p ) :
movel % d0 ,% a1 @+
movel % d0 ,% a1 @+
dbra % d6 ,L ( c o n s o l e _ c l e a r _ l o o p )
/* Calculate font size */
# if d e f i n e d ( F O N T _ 8 x8 ) & & d e f i n e d ( C O N F I G _ F O N T _ 8 x8 )
lea % p c @(font_vga_8x8),%a0
# elif d e f i n e d ( F O N T _ 8 x16 ) & & d e f i n e d ( C O N F I G _ F O N T _ 8 x16 )
lea % p c @(font_vga_8x16),%a0
# elif d e f i n e d ( F O N T _ 6 x11 ) & & d e f i n e d ( C O N F I G _ F O N T _ 6 x11 )
lea % p c @(font_vga_6x11),%a0
# elif d e f i n e d ( C O N F I G _ F O N T _ 8 x8 ) / * d e f a u l t * /
lea % p c @(font_vga_8x8),%a0
# else / * n o c o m p i l e d - i n f o n t * /
lea 0 ,% a0
# endif
/ *
* At t h i s p o i n t w e m a k e a s h i f t i n r e g i s t e r u s a g e
* a1 = a d d r e s s o f c o n s o l e _ f o n t p o i n t e r
* /
lea % p c @(L(console_font)),%a1
movel % a0 ,% a1 @ /* store pointer to struct fbcon_font_desc in console_font */
tstl % a0
jeq 1 f
lea % p c @(L(console_font_data)),%a4
movel % a0 @(FONT_DESC_DATA),%d0
subl #L ( c o n s o l e _ f o n t ) , % a 1
addl % a1 ,% d0
movel % d0 ,% a4 @
/ *
* Calculate g l o b a l m a x s
* Note - w e c a n u s e e i t h e r a n
* 8 x 1 6 o r 8 x 8 c h a r a c t e r f o n t
* 6 x 1 1 a l s o s u p p o r t e d
* /
/* ASSERT: a0 = contents of Lconsole_font */
movel % d3 ,% d0 / * s c r e e n w i d t h i n p i x e l s * /
divul % a0 @(FONT_DESC_WIDTH),%d0 /* d0 = max num chars per row */
movel % d4 ,% d1 / * s c r e e n h e i g h t i n p i x e l s * /
divul % a0 @(FONT_DESC_HEIGHT),%d1 /* d1 = max num rows */
movel % d0 ,% a2 @(Lconsole_struct_num_columns)
movel % d1 ,% a2 @(Lconsole_struct_num_rows)
/ *
* Clear t h e c u r r e n t r o w a n d c o l u m n
* /
clrl % a2 @(Lconsole_struct_cur_column)
clrl % a2 @(Lconsole_struct_cur_row)
clrl % a2 @(Lconsole_struct_left_edge)
/ *
* Initialization i s c o m p l e t e
* /
1 :
func_ r e t u r n c o n s o l e _ i n i t
func_ s t a r t c o n s o l e _ p u t _ s t a t s ,% a0 / % d7
/ *
* Some o f t h e r e g i s t e r u s a g e t h a t f o l l o w s
* a0 = p o i n t e r t o b o o t _ i n f o
* d7 = v a l u e o f b o o t _ i n f o f i e l d s
* /
puts " \ n M a c L i n u x \ n \ n "
# ifdef S E R I A L _ D E B U G
puts " v i d a d d r : "
putn % p c @(L(mac_videobase)) /* video addr. */
puts " \ n _ s t e x t : "
lea % p c @(_stext),%a0
putn % a0
puts " \ n b o o t i n f o : "
lea % p c @(_end),%a0
putn % a0
puts " \ n c p u i d : "
putn % p c @(L(cputype))
putc ' \ n '
# ifdef M A C _ S E R I A L _ D E B U G
putn % p c @(L(mac_sccbase))
putc ' \ n '
# endif
# if d e f i n e d ( M M U _ P R I N T )
jbsr m m u _ p r i n t _ m a c h i n e _ c p u _ t y p e s
# endif / * M M U _ P R I N T * /
# endif / * S E R I A L _ D E B U G * /
func_ r e t u r n c o n s o l e _ p u t _ s t a t s
# ifdef C O N S O L E _ P E N G U I N
func_ s t a r t c o n s o l e _ p u t _ p e n g u i n ,% a0 - % a1 / % d0 - % d7
/ *
* Get ' t h a t _ p e n g u i n ' o n t o t h e s c r e e n i n t h e u p p e r r i g h t c o r n e r
* penguin i s 6 4 x 7 4 p i x e l s , a l i g n a g a i n s t r i g h t e d g e o f s c r e e n
* /
lea % p c @(L(mac_dimensions)),%a0
movel % a0 @,%d0
andil #0xffff ,% d0
subil #64 ,% d0 / * s n u g u p a g a i n s t t h e r i g h t e d g e * /
clrl % d1 / * s t a r t a t t h e t o p * /
movel #73 ,% d7
lea % p c @(L(that_penguin)),%a1
L( c o n s o l e _ p e n g u i n _ r o w ) :
movel #31 ,% d6
L( c o n s o l e _ p e n g u i n _ p i x e l _ p a i r ) :
moveb % a1 @,%d2
lsrb #4 ,% d2
console_ p l o t _ p i x e l % d0 ,% d1 ,% d2
addq #1 ,% d0
moveb % a1 @+,%d2
console_ p l o t _ p i x e l % d0 ,% d1 ,% d2
addq #1 ,% d0
dbra % d6 ,L ( c o n s o l e _ p e n g u i n _ p i x e l _ p a i r )
subil #64 ,% d0
addq #1 ,% d1
dbra % d7 ,L ( c o n s o l e _ p e n g u i n _ r o w )
func_ r e t u r n c o n s o l e _ p u t _ p e n g u i n
/* include penguin bitmap */
L( t h a t _ p e n g u i n ) :
# include " . . / m a c / m a c _ p e n g u i n . S "
# endif
/ *
* Calculate s o u r c e a n d d e s t i n a t i o n a d d r e s s e s
* output a1 = d e s t
* a2 = s o u r c e
* /
func_ s t a r t c o n s o l e _ s c r o l l ,% a0 - % a4 / % d0 - % d7
lea % p c @(L(mac_videobase)),%a0
movel % a0 @,%a1
movel % a1 ,% a2
lea % p c @(L(mac_rowbytes)),%a0
movel % a0 @,%d5
movel % p c @(L(console_font)),%a0
tstl % a0
jeq 1 f
mulul % a0 @(FONT_DESC_HEIGHT),%d5 /* account for # scan lines per character */
addal % d5 ,% a2
/ *
* Get d i m e n s i o n s
* /
lea % p c @(L(mac_dimensions)),%a0
movel % a0 @,%d3
movel % d3 ,% d4
swap % d4
andl #0xffff ,% d3 / * d3 = s c r e e n w i d t h i n p i x e l s * /
andl #0xffff ,% d4 / * d4 = s c r e e n h e i g h t i n p i x e l s * /
/ *
* Calculate n u m b e r o f b y t e s t o m o v e
* /
lea % p c @(L(mac_rowbytes)),%a0
movel % a0 @,%d6
movel % p c @(L(console_font)),%a0
subl % a0 @(FONT_DESC_HEIGHT),%d4 /* we're not scrolling the top row! */
mulul % d4 ,% d6 / * s c a n l i n e b y t e s x n u m s c a n l i n e s * /
divul #32 ,% d6 / * w e ' l l m o v e 8 l o n g s a t a t i m e * /
subq #1 ,% d6
L( c o n s o l e _ s c r o l l _ l o o p ) :
movel % a2 @+,%a1@+
movel % a2 @+,%a1@+
movel % a2 @+,%a1@+
movel % a2 @+,%a1@+
movel % a2 @+,%a1@+
movel % a2 @+,%a1@+
movel % a2 @+,%a1@+
movel % a2 @+,%a1@+
dbra % d6 ,L ( c o n s o l e _ s c r o l l _ l o o p )
lea % p c @(L(mac_rowbytes)),%a0
movel % a0 @,%d6
movel % p c @(L(console_font)),%a0
mulul % a0 @(FONT_DESC_HEIGHT),%d6 /* scan line bytes x font height */
divul #32 ,% d6 / * w e ' l l m o v e 8 w o r d s a t a t i m e * /
subq #1 ,% d6
moveq #- 1 ,% d0
L( c o n s o l e _ s c r o l l _ c l e a r _ l o o p ) :
movel % d0 ,% a1 @+
movel % d0 ,% a1 @+
movel % d0 ,% a1 @+
movel % d0 ,% a1 @+
movel % d0 ,% a1 @+
movel % d0 ,% a1 @+
movel % d0 ,% a1 @+
movel % d0 ,% a1 @+
dbra % d6 ,L ( c o n s o l e _ s c r o l l _ c l e a r _ l o o p )
1 :
func_ r e t u r n c o n s o l e _ s c r o l l
func_ s t a r t c o n s o l e _ p u t c ,% a0 / % a1 / % d0 - % d7
is_ n o t _ m a c ( L ( c o n s o l e _ e x i t ) )
tstl % p c @(L(console_font))
jeq L ( c o n s o l e _ e x i t )
/ * Output c h a r a c t e r i n d7 o n c o n s o l e .
* /
movel A R G 1 ,% d7
cmpib #' \n ' ,% d7
jbne 1 f
/* A little safe recursion is good for the soul */
console_ p u t c #' \r '
1 :
lea % p c @(L(console_globals)),%a0
cmpib #10 ,% d7
jne L ( c o n s o l e _ n o t _ l f )
movel % a0 @(Lconsole_struct_cur_row),%d0
addil #1 ,% d0
movel % d0 ,% a0 @(Lconsole_struct_cur_row)
movel % a0 @(Lconsole_struct_num_rows),%d1
cmpl % d1 ,% d0
jcs 1 f
subil #1 ,% d0
movel % d0 ,% a0 @(Lconsole_struct_cur_row)
console_ s c r o l l
1 :
jra L ( c o n s o l e _ e x i t )
L( c o n s o l e _ n o t _ l f ) :
cmpib #13 ,% d7
jne L ( c o n s o l e _ n o t _ c r )
clrl % a0 @(Lconsole_struct_cur_column)
jra L ( c o n s o l e _ e x i t )
L( c o n s o l e _ n o t _ c r ) :
cmpib #1 ,% d7
jne L ( c o n s o l e _ n o t _ h o m e )
clrl % a0 @(Lconsole_struct_cur_row)
clrl % a0 @(Lconsole_struct_cur_column)
jra L ( c o n s o l e _ e x i t )
/ *
* At t h i s p o i n t w e k n o w t h a t t h e % d7 c h a r a c t e r i s g o i n g t o b e
* rendered o n t h e s c r e e n . R e g i s t e r u s a g e i s -
* a0 = p o i n t e r t o c o n s o l e g l o b a l s
* a1 = f o n t d a t a
* d0 = c u r s o r c o l u m n
* d1 = c u r s o r r o w t o d r a w t h e c h a r a c t e r
* d7 = c h a r a c t e r n u m b e r
* /
L( c o n s o l e _ n o t _ h o m e ) :
movel % a0 @(Lconsole_struct_cur_column),%d0
addql #1 ,% a0 @(Lconsole_struct_cur_column)
movel % a0 @(Lconsole_struct_num_columns),%d1
cmpl % d1 ,% d0
jcs 1 f
console_ p u t c #' \n ' / * r e c u r s i o n i s O K ! * /
1 :
movel % a0 @(Lconsole_struct_cur_row),%d1
/ *
* At t h i s p o i n t w e m a k e a s h i f t i n r e g i s t e r u s a g e
* a0 = a d d r e s s o f p o i n t e r t o f o n t d a t a ( f b c o n _ f o n t _ d e s c )
* /
movel % p c @(L(console_font)),%a0
movel % p c @(L(console_font_data)),%a1 /* Load fbcon_font_desc.data into a1 */
andl #0x000000ff ,% d7
/* ASSERT: a0 = contents of Lconsole_font */
mulul % a0 @(FONT_DESC_HEIGHT),%d7 /* d7 = index into font data */
addl % d7 ,% a1 / * a1 = p o i n t s t o c h a r i m a g e * /
/ *
* At t h i s p o i n t w e m a k e a s h i f t i n r e g i s t e r u s a g e
* d0 = p i x e l c o o r d i n a t e , x
* d1 = p i x e l c o o r d i n a t e , y
* d2 = ( b i t 0 ) 1 / 0 f o r w h i t e / b l a c k ( ! ) p i x e l o n s c r e e n
* d3 = f o n t s c a n l i n e d a t a ( 8 p i x e l s )
* d6 = c o u n t d o w n f o r t h e f o n t ' s p i x e l w i d t h ( 8 )
* d7 = c o u n t d o w n f o r t h e f o n t ' s p i x e l c o u n t i n h e i g h t
* /
/* ASSERT: a0 = contents of Lconsole_font */
mulul % a0 @(FONT_DESC_WIDTH),%d0
mulul % a0 @(FONT_DESC_HEIGHT),%d1
movel % a0 @(FONT_DESC_HEIGHT),%d7 /* Load fbcon_font_desc.height into d7 */
subq #1 ,% d7
L( c o n s o l e _ r e a d _ c h a r _ s c a n l i n e ) :
moveb % a1 @+,%d3
/* ASSERT: a0 = contents of Lconsole_font */
movel % a0 @(FONT_DESC_WIDTH),%d6 /* Load fbcon_font_desc.width into d6 */
subql #1 ,% d6
L( c o n s o l e _ d o _ f o n t _ s c a n l i n e ) :
lslb #1 ,% d3
scsb % d2 / * c o n v e r t 1 b i t i n t o a b y t e * /
console_ p l o t _ p i x e l % d0 ,% d1 ,% d2
addq #1 ,% d0
dbra % d6 ,L ( c o n s o l e _ d o _ f o n t _ s c a n l i n e )
/* ASSERT: a0 = contents of Lconsole_font */
subl % a0 @(FONT_DESC_WIDTH),%d0
addq #1 ,% d1
dbra % d7 ,L ( c o n s o l e _ r e a d _ c h a r _ s c a n l i n e )
L( c o n s o l e _ e x i t ) :
func_ r e t u r n c o n s o l e _ p u t c
/ *
* Input :
* d0 = x c o o r d i n a t e
* d1 = y c o o r d i n a t e
* d2 = ( b i t 0 ) 1 / 0 f o r w h i t e / b l a c k ( ! )
* All r e g i s t e r s a r e p r e s e r v e d
* /
func_ s t a r t c o n s o l e _ p l o t _ p i x e l ,% a0 - % a1 / % d0 - % d4
movel % p c @(L(mac_videobase)),%a1
movel % p c @(L(mac_videodepth)),%d3
movel A R G 1 ,% d0
movel A R G 2 ,% d1
mulul % p c @(L(mac_rowbytes)),%d1
movel A R G 3 ,% d2
/ *
* Register u s a g e :
* d0 = x c o o r d b e c o m e s b y t e o f f s e t i n t o f r a m e b u f f e r
* d1 = y c o o r d
* d2 = b l a c k o r w h i t e ( 0 / 1 )
* d3 = v i d e o d e p t h
* d4 = t e m p o f x ( d0 ) f o r m a n y b i t d e p t h s
* /
L( t e s t _ 1 b i t ) :
cmpb #1 ,% d3
jbne L ( t e s t _ 2 b i t )
movel % d0 ,% d4 / * w e n e e d t h e l o w o r d e r 3 b i t s ! * /
divul #8 ,% d0
addal % d0 ,% a1
addal % d1 ,% a1
andb #7 ,% d4
eorb #7 ,% d4 / * r e v e r s e t h e x - c o o r d i n a t e w / s c r e e n - b i t # * /
andb #1 ,% d2
jbne L ( w h i t e _ 1 )
bsetb % d4 ,% a1 @
jbra L ( c o n s o l e _ p l o t _ p i x e l _ e x i t )
L( w h i t e _ 1 ) :
bclrb % d4 ,% a1 @
jbra L ( c o n s o l e _ p l o t _ p i x e l _ e x i t )
L( t e s t _ 2 b i t ) :
cmpb #2 ,% d3
jbne L ( t e s t _ 4 b i t )
movel % d0 ,% d4 / * w e n e e d t h e l o w o r d e r 2 b i t s ! * /
divul #4 ,% d0
addal % d0 ,% a1
addal % d1 ,% a1
andb #3 ,% d4
eorb #3 ,% d4 / * r e v e r s e t h e x - c o o r d i n a t e w / s c r e e n - b i t # * /
lsll #1 ,% d4 / * ! * /
andb #1 ,% d2
jbne L ( w h i t e _ 2 )
bsetb % d4 ,% a1 @
addq #1 ,% d4
bsetb % d4 ,% a1 @
jbra L ( c o n s o l e _ p l o t _ p i x e l _ e x i t )
L( w h i t e _ 2 ) :
bclrb % d4 ,% a1 @
addq #1 ,% d4
bclrb % d4 ,% a1 @
jbra L ( c o n s o l e _ p l o t _ p i x e l _ e x i t )
L( t e s t _ 4 b i t ) :
cmpb #4 ,% d3
jbne L ( t e s t _ 8 b i t )
movel % d0 ,% d4 / * w e n e e d t h e l o w o r d e r b i t ! * /
divul #2 ,% d0
addal % d0 ,% a1
addal % d1 ,% a1
andb #1 ,% d4
eorb #1 ,% d4
lsll #2 ,% d4 / * ! * /
andb #1 ,% d2
jbne L ( w h i t e _ 4 )
bsetb % d4 ,% a1 @
addq #1 ,% d4
bsetb % d4 ,% a1 @
addq #1 ,% d4
bsetb % d4 ,% a1 @
addq #1 ,% d4
bsetb % d4 ,% a1 @
jbra L ( c o n s o l e _ p l o t _ p i x e l _ e x i t )
L( w h i t e _ 4 ) :
bclrb % d4 ,% a1 @
addq #1 ,% d4
bclrb % d4 ,% a1 @
addq #1 ,% d4
bclrb % d4 ,% a1 @
addq #1 ,% d4
bclrb % d4 ,% a1 @
jbra L ( c o n s o l e _ p l o t _ p i x e l _ e x i t )
L( t e s t _ 8 b i t ) :
cmpb #8 ,% d3
jbne L ( t e s t _ 1 6 b i t )
addal % d0 ,% a1
addal % d1 ,% a1
andb #1 ,% d2
jbne L ( w h i t e _ 8 )
moveb #0xff ,% a1 @
jbra L ( c o n s o l e _ p l o t _ p i x e l _ e x i t )
L( w h i t e _ 8 ) :
clrb % a1 @
jbra L ( c o n s o l e _ p l o t _ p i x e l _ e x i t )
L( t e s t _ 1 6 b i t ) :
cmpb #16 ,% d3
jbne L ( c o n s o l e _ p l o t _ p i x e l _ e x i t )
addal % d0 ,% a1
addal % d0 ,% a1
addal % d1 ,% a1
andb #1 ,% d2
jbne L ( w h i t e _ 1 6 )
clrw % a1 @
jbra L ( c o n s o l e _ p l o t _ p i x e l _ e x i t )
L( w h i t e _ 1 6 ) :
movew #0x0fff ,% a1 @
jbra L ( c o n s o l e _ p l o t _ p i x e l _ e x i t )
L( c o n s o l e _ p l o t _ p i x e l _ e x i t ) :
func_ r e t u r n c o n s o l e _ p l o t _ p i x e l
# endif / * C O N S O L E * /
# if 0
/ *
* This i s s o m e o l d c o d e l y i n g a r o u n d . I d o n ' t b e l i e v e
* it' s u s e d o r i m p o r t a n t a n y m o r e . M y g u e s s i s i t c o n t r i b u t e d
* to g e t t i n g t o t h i s p o i n t , b u t i t ' s d o n e f o r n o w .
* It w a s s t i l l i n t h e 2 . 1 . 7 7 h e a d . S , s o i t ' s s t i l l h e r e .
* ( And s t i l l n o t u s e d ! )
* /
L( s h o w t e s t ) :
moveml % a0 / % d7 ,% s p @-
puts " A = "
putn % a1
.long 0xf0119f15 | ptestr #5 ,% a1 @,#7,%a0
puts " D A = "
putn % a0
puts " D = "
putn % a0 @
puts " S = "
lea % p c @(L(mmu)),%a0
.long 0xf0106200 | pmove % p s r ,% a0 @
clrl % d7
movew % a0 @,%d7
putn % d7
putc ' \ n '
moveml % s p @+,%a0/%d7
rts
# endif / * 0 * /
_ _ INITDATA
.align 4
# if d e f i n e d ( C O N F I G _ A T A R I ) | | d e f i n e d ( C O N F I G _ A M I G A ) | | \
defined( C O N F I G _ H P 3 0 0 ) | | d e f i n e d ( C O N F I G _ A P O L L O )
L( c u s t o m ) :
L( i o b a s e ) :
.long 0
# endif
# if d e f i n e d ( C O N S O L E )
L( c o n s o l e _ g l o b a l s ) :
.long 0 /* cursor column */
.long 0 /* cursor row */
.long 0 /* max num columns */
.long 0 /* max num rows */
.long 0 /* left edge */
.long 0 /* mac putc */
L( c o n s o l e _ f o n t ) :
.long 0 /* pointer to console font (struct font_desc) */
L( c o n s o l e _ f o n t _ d a t a ) :
.long 0 /* pointer to console font data */
# endif / * C O N S O L E * /
# if d e f i n e d ( M M U _ P R I N T )
L( m m u _ p r i n t _ d a t a ) :
.long 0 /* valid flag */
.long 0 /* start logical */
.long 0 /* next logical */
.long 0 /* start physical */
.long 0 /* next physical */
# endif / * M M U _ P R I N T * /
L( c p u t y p e ) :
.long 0
L( m m u _ c a c h e d _ p o i n t e r _ t a b l e s ) :
.long 0
L( m m u _ n u m _ p o i n t e r _ t a b l e s ) :
.long 0
L( p h y s _ k e r n e l _ s t a r t ) :
.long 0
L( k e r n e l _ e n d ) :
.long 0
L( m e m o r y _ s t a r t ) :
.long 0
L( k e r n e l _ p g d i r _ p t r ) :
.long 0
L( t e m p _ m m a p _ m e m ) :
.long 0
# if d e f i n e d ( C O N F I G _ M V M E 1 4 7 )
M1 4 7 _ S C C _ C T R L _ A = 0 x f f f e 3 0 0 2
M1 4 7 _ S C C _ D A T A _ A = 0 x f f f e 3 0 0 3
# endif
# if d e f i n e d ( C O N F I G _ M V M E 1 6 x )
M1 6 2 _ S C C _ C T R L _ A = 0 x f f f45 0 0 5
M1 6 7 _ C Y C A R = 0 x f f f45 0 e e
M1 6 7 _ C Y I E R = 0 x f f f45 0 1 1
M1 6 7 _ C Y L I C R = 0 x f f f45 0 2 6
M1 6 7 _ C Y T E O I R = 0 x f f f45 0 8 5
M1 6 7 _ C Y T D R = 0 x f f f45 0 f8
M1 6 7 _ P C S C C T I C R = 0 x f f f42 0 1 e
M1 6 7 _ P C T P I A C K R = 0 x f f f42 0 2 5
# endif
# if d e f i n e d ( C O N F I G _ B V M E 6 0 0 0 )
BVME_ S C C _ C T R L _ A = 0 x f f b00 0 0 b
BVME_ S C C _ D A T A _ A = 0 x f f b00 0 0 f
# endif
# if d e f i n e d ( C O N F I G _ M A C )
L( m a c _ b o o t e r _ d a t a ) :
.long 0
L( m a c _ v i d e o b a s e ) :
.long 0
L( m a c _ v i d e o d e p t h ) :
.long 0
L( m a c _ d i m e n s i o n s ) :
.long 0
L( m a c _ r o w b y t e s ) :
.long 0
# ifdef M A C _ S E R I A L _ D E B U G
L( m a c _ s c c b a s e ) :
.long 0
# endif / * M A C _ S E R I A L _ D E B U G * /
# endif
# if d e f i n e d ( C O N F I G _ A P O L L O )
LSRB0 = 0 x10 4 1 2
LTHRB0 = 0 x10 4 1 6
LCPUCTRL = 0 x10 1 0 0
# endif
# if d e f i n e d ( C O N F I G _ H P 3 0 0 )
DCADATA = 0 x11
DCALSR = 0 x1 b
APCIDATA = 0 x00
APCILSR = 0 x14
L( u a r t b a s e ) :
.long 0
L( u a r t _ s c o d e ) :
.long - 1
# endif
_ _ FINIT
.data
.align 4
availmem :
.long 0
m68k_pgtable_cachemode :
.long 0
m68k_supervisor_cachemode :
.long 0
# if d e f i n e d ( C O N F I G _ M V M E 1 6 x )
mvme_bdid :
.long 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0
# endif
# if d e f i n e d ( C O N F I G _ Q 4 0 )
q40_mem_cptr :
.long 0
L( q40 _ d o _ d e b u g ) :
.long 0
# endif