2019-05-27 09:55:01 +03:00
/* SPDX-License-Identifier: GPL-2.0-or-later */
2009-12-12 09:31:36 +03:00
/ *
* arch/ p o w e r p c / b o o t / g a m e c u b e - h e a d . S
*
* Nintendo G a m e C u b e b o o t w r a p p e r e n t r y .
* Copyright ( C ) 2 0 0 4 - 2 0 0 9 T h e G a m e C u b e L i n u x T e a m
* Copyright ( C ) 2 0 0 8 ,2 0 0 9 A l b e r t H e r r a n z
* /
# include " p p c _ a s m . h "
/ *
* The e n t r y c o d e d o e s n o a s s u m p t i o n s r e g a r d i n g :
* - if t h e d a t a a n d i n s t r u c t i o n c a c h e s a r e e n a b l e d o r n o t
* - if t h e M M U i s e n a b l e d o r n o t
*
* We e n a b l e t h e c a c h e s i f n o t a l r e a d y e n a b l e d , e n a b l e t h e M M U w i t h a n
* identity m a p p i n g s c h e m e a n d j u m p t o t h e s t a r t c o d e .
* /
.text
.globl _zimage_start
_zimage_start :
/* turn the MMU off */
mfmsr 9
rlwinm 9 , 9 , 0 , ~ ( ( 1 < < 4 ) | ( 1 < < 5 ) ) / * M S R _ D R | M S R _ I R * /
bcl 2 0 , 3 1 , 1 f
1 :
mflr 8
clrlwi 8 , 8 , 3 / * c o n v e r t t o a r e a l a d d r e s s * /
addi 8 , 8 , _ m m u _ o f f - 1 b
mtsrr0 8
mtsrr1 9
rfi
_mmu_off :
/* MMU disabled */
/* setup BATs */
isync
li 8 , 0
mtspr 0 x21 0 , 8 / * I B A T 0 U * /
mtspr 0 x21 2 , 8 / * I B A T 1 U * /
mtspr 0 x21 4 , 8 / * I B A T 2 U * /
mtspr 0 x21 6 , 8 / * I B A T 3 U * /
mtspr 0 x21 8 , 8 / * D B A T 0 U * /
mtspr 0 x21 a , 8 / * D B A T 1 U * /
mtspr 0 x21 c , 8 / * D B A T 2 U * /
mtspr 0 x21 e , 8 / * D B A T 3 U * /
li 8 , 0 x01 f f / * f i r s t 1 6 M i B * /
li 9 , 0 x00 0 2 / * r w * /
mtspr 0 x21 1 , 9 / * I B A T 0 L * /
mtspr 0 x21 0 , 8 / * I B A T 0 U * /
mtspr 0 x21 9 , 9 / * D B A T 0 L * /
mtspr 0 x21 8 , 8 / * D B A T 0 U * /
lis 8 , 0 x0 c00 / * I / O m e m * /
ori 8 , 8 , 0 x3 f f / * 3 2 M i B * /
lis 9 , 0 x0 c00
ori 9 , 9 , 0 x00 2 a / * u n c a c h e d , g u a r d e d , r w * /
mtspr 0 x21 b , 9 / * D B A T 1 L * /
mtspr 0 x21 a , 8 / * D B A T 1 U * /
lis 8 , 0 x01 0 0 / * n e x t 8 M i B * /
ori 8 , 8 , 0 x00 f f / * 8 M i B * /
lis 9 , 0 x01 0 0
ori 9 , 9 , 0 x00 0 2 / * r w * /
mtspr 0 x21 5 , 9 / * I B A T 2 L * /
mtspr 0 x21 4 , 8 / * I B A T 2 U * /
mtspr 0 x21 d , 9 / * D B A T 2 L * /
mtspr 0 x21 c , 8 / * D B A T 2 U * /
/* enable and invalidate the caches if not already enabled */
mfspr 8 , 0 x3 f0 / * H I D 0 * /
andi. 0 , 8 , ( 1 < < 1 5 ) / * H I D 0 _ I C E * /
bne 1 f
ori 8 , 8 , ( 1 < < 1 5 ) | ( 1 < < 1 1 ) / * H I D 0 _ I C E | H I D 0 _ I C F I * /
1 :
andi. 0 , 8 , ( 1 < < 1 4 ) / * H I D 0 _ D C E * /
bne 1 f
ori 8 , 8 , ( 1 < < 1 4 ) | ( 1 < < 1 0 ) / * H I D 0 _ D C E | H I D 0 _ D C F I * /
1 :
mtspr 0 x3 f0 , 8 / * H I D 0 * /
isync
/* initialize arguments */
li 3 , 0
li 4 , 0
li 5 , 0
/* turn the MMU on */
bcl 2 0 , 3 1 , 1 f
1 :
mflr 8
addi 8 , 8 , _ m m u _ o n - 1 b
mfmsr 9
ori 9 , 9 , ( 1 < < 4 ) | ( 1 < < 5 ) / * M S R _ D R | M S R _ I R * /
mtsrr0 8
mtsrr1 9
sync
rfi
_mmu_on :
b _ z i m a g e _ s t a r t _ l i b