2005-04-17 02:20:36 +04:00
/ * $ Id : head. S ,v 1 . 8 7 2 0 0 2 / 0 2 / 0 9 1 9 : 4 9 : 3 1 d a v e m E x p $
* head. S : I n i t i a l b o o t c o d e f o r t h e S p a r c64 p o r t o f L i n u x .
*
* Copyright ( C ) 1 9 9 6 ,1 9 9 7 D a v i d S . M i l l e r ( d a v e m @caip.rutgers.edu)
* Copyright ( C ) 1 9 9 6 D a v i d S i t s k y ( D a v i d . S i t s k y @anu.edu.au)
* Copyright ( C ) 1 9 9 7 ,1 9 9 8 J a k u b J e l i n e k ( j j @sunsite.mff.cuni.cz)
* Copyright ( C ) 1 9 9 7 M i g u e l d e I c a z a ( m i g u e l @nuclecu.unam.mx)
* /
# include < l i n u x / c o n f i g . h >
# include < l i n u x / v e r s i o n . h >
# include < l i n u x / e r r n o . h >
# include < a s m / t h r e a d _ i n f o . h >
# include < a s m / a s i . h >
# include < a s m / p s t a t e . h >
# include < a s m / p t r a c e . h >
# include < a s m / s p i t f i r e . h >
# include < a s m / p a g e . h >
# include < a s m / p g t a b l e . h >
# include < a s m / e r r n o . h >
# include < a s m / s i g n a l . h >
# include < a s m / p r o c e s s o r . h >
# include < a s m / l s u . h >
# include < a s m / d c r . h >
# include < a s m / d c u . h >
# include < a s m / h e a d . h >
# include < a s m / t t a b l e . h >
# include < a s m / m m u . h >
/ * This s e c t i o n f r o m f r o m _ s t a r t t o s p a r c64 _ b o o t _ e n d s h o u l d f i t i n t o
2005-10-12 23:22:46 +04:00
* 0 x0 0 0 0 0 0 0 0 0 0 4 0 4 0 0 0 t o 0 x00 0 0 0 0 0 0 0 0 4 0 8 0 0 0 .
2005-04-17 02:20:36 +04:00
* /
.text
.globl start, _ s t a r t , s t e x t , _ s t e x t
_start :
start :
_stext :
stext :
! 0 x0 0 0 0 0 0 0 0 0 0 4 0 4 0 0 0
b s p a r c64 _ b o o t
flushw / * F l u s h r e g i s t e r f i l e . * /
/ * This s t u f f h a s t o b e i n s y n c w i t h S I L O a n d o t h e r p o t e n t i a l b o o t l o a d e r s
* Fields s h o u l d b e k e p t u p w a r d c o m p a t i b l e a n d w h e n e v e r a n y c h a n g e i s m a d e ,
* HdrS v e r s i o n s h o u l d b e i n c r e m e n t e d .
* /
.global root_ f l a g s , r a m _ f l a g s , r o o t _ d e v
.global sparc_ r a m d i s k _ i m a g e , s p a r c _ r a m d i s k _ s i z e
.global sparc_ramdisk_image64
.ascii " HdrS"
.word LINUX_VERSION_CODE
/ * History :
*
* 0 x0 3 0 0 : S u p p o r t s b e i n g l o c a t e d a t o t h e r t h a n 0 x40 0 0
* 0 x0 2 0 2 : S u p p o r t s k e r n e l p a r a m s s t r i n g
* 0 x0 2 0 1 : S u p p o r t s r e b o o t _ c o m m a n d
* /
.half 0x0301 /* HdrS version */
root_flags :
.half 1
root_dev :
.half 0
ram_flags :
.half 0
sparc_ramdisk_image :
.word 0
sparc_ramdisk_size :
.word 0
.xword reboot_command
.xword bootstr_info
sparc_ramdisk_image64 :
.xword 0
.word _end
[SPARC64]: Rewrite bootup sequence.
Instead of all of this cpu-specific code to remap the kernel
to the correct location, use portable firmware calls to do
this instead.
What we do now is the following in position independant
assembler:
chosen_node = prom_finddevice("/chosen");
prom_mmu_ihandle_cache = prom_getint(chosen_node, "mmu");
vaddr = 4MB_ALIGN(current_text_addr());
prom_translate(vaddr, &paddr_high, &paddr_low, &mode);
prom_boot_mapping_mode = mode;
prom_boot_mapping_phys_high = paddr_high;
prom_boot_mapping_phys_low = paddr_low;
prom_map(-1, 8 * 1024 * 1024, KERNBASE, paddr_low);
and that replaces the massive amount of by-hand TLB probing and
programming we used to do here.
The new code should also handle properly the case where the kernel
is mapped at the correct address already (think: future kexec
support).
Consequently, the bulk of remap_kernel() dies as does the entirety
of arch/sparc64/prom/map.S
We try to share some strings in the PROM library with the ones used
at bootup, and while we're here mark input strings to oplib.h routines
with "const" when appropriate.
There are many more simplifications now possible. For one thing, we
can consolidate the two copies we now have of a lot of cpu setup code
sitting in head.S and trampoline.S.
This is a significant step towards CONFIG_DEBUG_PAGEALLOC support.
Signed-off-by: David S. Miller <davem@davemloft.net>
2005-09-23 07:11:33 +04:00
/* PROM cif handler code address is in %o4. */
sparc64_boot :
1 : rd % p c , % g 7
set 1 b , % g 1
cmp % g 1 , % g 7
be,p n % x c c , s p a r c64 _ b o o t _ a f t e r _ r e m a p
mov % o 4 , % l 7
/ * We n e e d t o r e m a p t h e k e r n e l . U s e p o s i t i o n i n d e p e n d a n t
* code t o r e m a p u s t o K E R N B A S E .
2005-04-17 02:20:36 +04:00
*
[SPARC64]: Rewrite bootup sequence.
Instead of all of this cpu-specific code to remap the kernel
to the correct location, use portable firmware calls to do
this instead.
What we do now is the following in position independant
assembler:
chosen_node = prom_finddevice("/chosen");
prom_mmu_ihandle_cache = prom_getint(chosen_node, "mmu");
vaddr = 4MB_ALIGN(current_text_addr());
prom_translate(vaddr, &paddr_high, &paddr_low, &mode);
prom_boot_mapping_mode = mode;
prom_boot_mapping_phys_high = paddr_high;
prom_boot_mapping_phys_low = paddr_low;
prom_map(-1, 8 * 1024 * 1024, KERNBASE, paddr_low);
and that replaces the massive amount of by-hand TLB probing and
programming we used to do here.
The new code should also handle properly the case where the kernel
is mapped at the correct address already (think: future kexec
support).
Consequently, the bulk of remap_kernel() dies as does the entirety
of arch/sparc64/prom/map.S
We try to share some strings in the PROM library with the ones used
at bootup, and while we're here mark input strings to oplib.h routines
with "const" when appropriate.
There are many more simplifications now possible. For one thing, we
can consolidate the two copies we now have of a lot of cpu setup code
sitting in head.S and trampoline.S.
This is a significant step towards CONFIG_DEBUG_PAGEALLOC support.
Signed-off-by: David S. Miller <davem@davemloft.net>
2005-09-23 07:11:33 +04:00
* SILO c a n i n v o k e u s w i t h 3 2 - b i t a d d r e s s m a s k i n g e n a b l e d ,
* so m a k e s u r e t h a t ' s c l e a r .
2005-04-17 02:20:36 +04:00
* /
[SPARC64]: Rewrite bootup sequence.
Instead of all of this cpu-specific code to remap the kernel
to the correct location, use portable firmware calls to do
this instead.
What we do now is the following in position independant
assembler:
chosen_node = prom_finddevice("/chosen");
prom_mmu_ihandle_cache = prom_getint(chosen_node, "mmu");
vaddr = 4MB_ALIGN(current_text_addr());
prom_translate(vaddr, &paddr_high, &paddr_low, &mode);
prom_boot_mapping_mode = mode;
prom_boot_mapping_phys_high = paddr_high;
prom_boot_mapping_phys_low = paddr_low;
prom_map(-1, 8 * 1024 * 1024, KERNBASE, paddr_low);
and that replaces the massive amount of by-hand TLB probing and
programming we used to do here.
The new code should also handle properly the case where the kernel
is mapped at the correct address already (think: future kexec
support).
Consequently, the bulk of remap_kernel() dies as does the entirety
of arch/sparc64/prom/map.S
We try to share some strings in the PROM library with the ones used
at bootup, and while we're here mark input strings to oplib.h routines
with "const" when appropriate.
There are many more simplifications now possible. For one thing, we
can consolidate the two copies we now have of a lot of cpu setup code
sitting in head.S and trampoline.S.
This is a significant step towards CONFIG_DEBUG_PAGEALLOC support.
Signed-off-by: David S. Miller <davem@davemloft.net>
2005-09-23 07:11:33 +04:00
rdpr % p s t a t e , % g 1
andn % g 1 , P S T A T E _ A M , % g 1
wrpr % g 1 , 0 x0 , % p s t a t e
ba,a ,p t % x c c , 1 f
.globl prom_ f i n d d e v _ n a m e , p r o m _ c h o s e n _ p a t h
.globl prom_ g e t p r o p _ n a m e , p r o m _ m m u _ n a m e
.globl prom_ c a l l m e t h o d _ n a m e , p r o m _ t r a n s l a t e _ n a m e
.globl prom_ m a p _ n a m e , p r o m _ u n m a p _ n a m e , p r o m _ m m u _ i h a n d l e _ c a c h e
.globl prom_ b o o t _ m a p p e d _ p c , p r o m _ b o o t _ m a p p i n g _ m o d e
.globl prom_ b o o t _ m a p p i n g _ p h y s _ h i g h , p r o m _ b o o t _ m a p p i n g _ p h y s _ l o w
prom_finddev_name :
.asciz " finddevice"
prom_chosen_path :
.asciz " / chosen"
prom_getprop_name :
.asciz " getprop"
prom_mmu_name :
.asciz " mmu"
prom_callmethod_name :
.asciz " call- m e t h o d "
prom_translate_name :
.asciz " translate"
prom_map_name :
.asciz " map"
prom_unmap_name :
.asciz " unmap"
.align 4
prom_mmu_ihandle_cache :
.word 0
prom_boot_mapped_pc :
.word 0
prom_boot_mapping_mode :
.word 0
.align 8
prom_boot_mapping_phys_high :
.xword 0
prom_boot_mapping_phys_low :
.xword 0
1 :
rd % p c , % l 0
mov ( 1 b - p r o m _ f i n d d e v _ n a m e ) , % l 1
mov ( 1 b - p r o m _ c h o s e n _ p a t h ) , % l 2
mov ( 1 b - p r o m _ b o o t _ m a p p e d _ p c ) , % l 3
sub % l 0 , % l 1 , % l 1
sub % l 0 , % l 2 , % l 2
sub % l 0 , % l 3 , % l 3
stw % l 0 , [ % l 3 ]
sub % s p , ( 1 9 2 + 1 2 8 ) , % s p
/* chosen_node = prom_finddevice("/chosen") */
stx % l 1 , [ % s p + 2 0 4 7 + 1 2 8 + 0 x00 ] ! s e r v i c e , " f i n d d e v i c e "
mov 1 , % l 3
stx % l 3 , [ % s p + 2 0 4 7 + 1 2 8 + 0 x08 ] ! n u m _ a r g s , 1
stx % l 3 , [ % s p + 2 0 4 7 + 1 2 8 + 0 x10 ] ! n u m _ r e t s , 1
stx % l 2 , [ % s p + 2 0 4 7 + 1 2 8 + 0 x18 ] ! a r g 1 , " / c h o s e n "
stx % g 0 , [ % s p + 2 0 4 7 + 1 2 8 + 0 x20 ] ! r e t 1
call % l 7
add % s p , ( 2 0 4 7 + 1 2 8 ) , % o 0 ! a r g u m e n t a r r a y
ldx [ % s p + 2 0 4 7 + 1 2 8 + 0 x20 ] , % l 4 ! c h o s e n d e v i c e n o d e
mov ( 1 b - p r o m _ g e t p r o p _ n a m e ) , % l 1
mov ( 1 b - p r o m _ m m u _ n a m e ) , % l 2
mov ( 1 b - p r o m _ m m u _ i h a n d l e _ c a c h e ) , % l 5
sub % l 0 , % l 1 , % l 1
sub % l 0 , % l 2 , % l 2
sub % l 0 , % l 5 , % l 5
/* prom_mmu_ihandle_cache = prom_getint(chosen_node, "mmu") */
stx % l 1 , [ % s p + 2 0 4 7 + 1 2 8 + 0 x00 ] ! s e r v i c e , " g e t p r o p "
mov 4 , % l 3
stx % l 3 , [ % s p + 2 0 4 7 + 1 2 8 + 0 x08 ] ! n u m _ a r g s , 4
mov 1 , % l 3
stx % l 3 , [ % s p + 2 0 4 7 + 1 2 8 + 0 x10 ] ! n u m _ r e t s , 1
stx % l 4 , [ % s p + 2 0 4 7 + 1 2 8 + 0 x18 ] ! a r g 1 , c h o s e n _ n o d e
stx % l 2 , [ % s p + 2 0 4 7 + 1 2 8 + 0 x20 ] ! a r g 2 , " m m u "
stx % l 5 , [ % s p + 2 0 4 7 + 1 2 8 + 0 x28 ] ! a r g 3 , & p r o m _ m m u _ i h a n d l e _ c a c h e
mov 4 , % l 3
stx % l 3 , [ % s p + 2 0 4 7 + 1 2 8 + 0 x30 ] ! a r g 4 , s i z e o f ( a r g 3 )
stx % g 0 , [ % s p + 2 0 4 7 + 1 2 8 + 0 x38 ] ! r e t 1
call % l 7
add % s p , ( 2 0 4 7 + 1 2 8 ) , % o 0 ! a r g u m e n t a r r a y
mov ( 1 b - p r o m _ c a l l m e t h o d _ n a m e ) , % l 1
mov ( 1 b - p r o m _ t r a n s l a t e _ n a m e ) , % l 2
sub % l 0 , % l 1 , % l 1
sub % l 0 , % l 2 , % l 2
lduw [ % l 5 ] , % l 5 ! p r o m _ m m u _ i h a n d l e _ c a c h e
stx % l 1 , [ % s p + 2 0 4 7 + 1 2 8 + 0 x00 ] ! s e r v i c e , " c a l l - m e t h o d "
mov 3 , % l 3
stx % l 3 , [ % s p + 2 0 4 7 + 1 2 8 + 0 x08 ] ! n u m _ a r g s , 3
mov 5 , % l 3
stx % l 3 , [ % s p + 2 0 4 7 + 1 2 8 + 0 x10 ] ! n u m _ r e t s , 5
stx % l 2 , [ % s p + 2 0 4 7 + 1 2 8 + 0 x18 ] ! a r g 1 : " t r a n s l a t e "
stx % l 5 , [ % s p + 2 0 4 7 + 1 2 8 + 0 x20 ] ! a r g 2 : p r o m _ m m u _ i h a n d l e _ c a c h e
2005-10-12 02:45:16 +04:00
/* PAGE align */
srlx % l 0 , 1 3 , % l 3
sllx % l 3 , 1 3 , % l 3
[SPARC64]: Rewrite bootup sequence.
Instead of all of this cpu-specific code to remap the kernel
to the correct location, use portable firmware calls to do
this instead.
What we do now is the following in position independant
assembler:
chosen_node = prom_finddevice("/chosen");
prom_mmu_ihandle_cache = prom_getint(chosen_node, "mmu");
vaddr = 4MB_ALIGN(current_text_addr());
prom_translate(vaddr, &paddr_high, &paddr_low, &mode);
prom_boot_mapping_mode = mode;
prom_boot_mapping_phys_high = paddr_high;
prom_boot_mapping_phys_low = paddr_low;
prom_map(-1, 8 * 1024 * 1024, KERNBASE, paddr_low);
and that replaces the massive amount of by-hand TLB probing and
programming we used to do here.
The new code should also handle properly the case where the kernel
is mapped at the correct address already (think: future kexec
support).
Consequently, the bulk of remap_kernel() dies as does the entirety
of arch/sparc64/prom/map.S
We try to share some strings in the PROM library with the ones used
at bootup, and while we're here mark input strings to oplib.h routines
with "const" when appropriate.
There are many more simplifications now possible. For one thing, we
can consolidate the two copies we now have of a lot of cpu setup code
sitting in head.S and trampoline.S.
This is a significant step towards CONFIG_DEBUG_PAGEALLOC support.
Signed-off-by: David S. Miller <davem@davemloft.net>
2005-09-23 07:11:33 +04:00
stx % l 3 , [ % s p + 2 0 4 7 + 1 2 8 + 0 x28 ] ! a r g 3 : v a d d r , o u r P C
stx % g 0 , [ % s p + 2 0 4 7 + 1 2 8 + 0 x30 ] ! r e s1
stx % g 0 , [ % s p + 2 0 4 7 + 1 2 8 + 0 x38 ] ! r e s2
stx % g 0 , [ % s p + 2 0 4 7 + 1 2 8 + 0 x40 ] ! r e s3
stx % g 0 , [ % s p + 2 0 4 7 + 1 2 8 + 0 x48 ] ! r e s4
stx % g 0 , [ % s p + 2 0 4 7 + 1 2 8 + 0 x50 ] ! r e s5
call % l 7
add % s p , ( 2 0 4 7 + 1 2 8 ) , % o 0 ! a r g u m e n t a r r a y
ldx [ % s p + 2 0 4 7 + 1 2 8 + 0 x40 ] , % l 1 ! t r a n s l a t i o n m o d e
mov ( 1 b - p r o m _ b o o t _ m a p p i n g _ m o d e ) , % l 4
sub % l 0 , % l 4 , % l 4
stw % l 1 , [ % l 4 ]
mov ( 1 b - p r o m _ b o o t _ m a p p i n g _ p h y s _ h i g h ) , % l 4
sub % l 0 , % l 4 , % l 4
ldx [ % s p + 2 0 4 7 + 1 2 8 + 0 x48 ] , % l 2 ! p h y s a d d r h i g h
stx % l 2 , [ % l 4 + 0 x0 ]
ldx [ % s p + 2 0 4 7 + 1 2 8 + 0 x50 ] , % l 3 ! p h y s a d d r l o w
2005-10-12 02:45:16 +04:00
/* 4MB align */
srlx % l 3 , 2 2 , % l 3
sllx % l 3 , 2 2 , % l 3
[SPARC64]: Rewrite bootup sequence.
Instead of all of this cpu-specific code to remap the kernel
to the correct location, use portable firmware calls to do
this instead.
What we do now is the following in position independant
assembler:
chosen_node = prom_finddevice("/chosen");
prom_mmu_ihandle_cache = prom_getint(chosen_node, "mmu");
vaddr = 4MB_ALIGN(current_text_addr());
prom_translate(vaddr, &paddr_high, &paddr_low, &mode);
prom_boot_mapping_mode = mode;
prom_boot_mapping_phys_high = paddr_high;
prom_boot_mapping_phys_low = paddr_low;
prom_map(-1, 8 * 1024 * 1024, KERNBASE, paddr_low);
and that replaces the massive amount of by-hand TLB probing and
programming we used to do here.
The new code should also handle properly the case where the kernel
is mapped at the correct address already (think: future kexec
support).
Consequently, the bulk of remap_kernel() dies as does the entirety
of arch/sparc64/prom/map.S
We try to share some strings in the PROM library with the ones used
at bootup, and while we're here mark input strings to oplib.h routines
with "const" when appropriate.
There are many more simplifications now possible. For one thing, we
can consolidate the two copies we now have of a lot of cpu setup code
sitting in head.S and trampoline.S.
This is a significant step towards CONFIG_DEBUG_PAGEALLOC support.
Signed-off-by: David S. Miller <davem@davemloft.net>
2005-09-23 07:11:33 +04:00
stx % l 3 , [ % l 4 + 0 x8 ]
/* Leave service as-is, "call-method" */
mov 7 , % l 3
stx % l 3 , [ % s p + 2 0 4 7 + 1 2 8 + 0 x08 ] ! n u m _ a r g s , 7
mov 1 , % l 3
2005-09-23 07:31:29 +04:00
stx % l 3 , [ % s p + 2 0 4 7 + 1 2 8 + 0 x10 ] ! n u m _ r e t s , 1
[SPARC64]: Rewrite bootup sequence.
Instead of all of this cpu-specific code to remap the kernel
to the correct location, use portable firmware calls to do
this instead.
What we do now is the following in position independant
assembler:
chosen_node = prom_finddevice("/chosen");
prom_mmu_ihandle_cache = prom_getint(chosen_node, "mmu");
vaddr = 4MB_ALIGN(current_text_addr());
prom_translate(vaddr, &paddr_high, &paddr_low, &mode);
prom_boot_mapping_mode = mode;
prom_boot_mapping_phys_high = paddr_high;
prom_boot_mapping_phys_low = paddr_low;
prom_map(-1, 8 * 1024 * 1024, KERNBASE, paddr_low);
and that replaces the massive amount of by-hand TLB probing and
programming we used to do here.
The new code should also handle properly the case where the kernel
is mapped at the correct address already (think: future kexec
support).
Consequently, the bulk of remap_kernel() dies as does the entirety
of arch/sparc64/prom/map.S
We try to share some strings in the PROM library with the ones used
at bootup, and while we're here mark input strings to oplib.h routines
with "const" when appropriate.
There are many more simplifications now possible. For one thing, we
can consolidate the two copies we now have of a lot of cpu setup code
sitting in head.S and trampoline.S.
This is a significant step towards CONFIG_DEBUG_PAGEALLOC support.
Signed-off-by: David S. Miller <davem@davemloft.net>
2005-09-23 07:11:33 +04:00
mov ( 1 b - p r o m _ m a p _ n a m e ) , % l 3
sub % l 0 , % l 3 , % l 3
stx % l 3 , [ % s p + 2 0 4 7 + 1 2 8 + 0 x18 ] ! a r g 1 : " m a p "
/* Leave arg2 as-is, prom_mmu_ihandle_cache */
mov - 1 , % l 3
stx % l 3 , [ % s p + 2 0 4 7 + 1 2 8 + 0 x28 ] ! a r g 3 : m o d e ( - 1 d e f a u l t )
sethi % h i ( 8 * 1 0 2 4 * 1 0 2 4 ) , % l 3
stx % l 3 , [ % s p + 2 0 4 7 + 1 2 8 + 0 x30 ] ! a r g 4 : s i z e ( 8 M B )
sethi % h i ( K E R N B A S E ) , % l 3
stx % l 3 , [ % s p + 2 0 4 7 + 1 2 8 + 0 x38 ] ! a r g 5 : v a d d r ( K E R N B A S E )
stx % g 0 , [ % s p + 2 0 4 7 + 1 2 8 + 0 x40 ] ! a r g 6 : e m p t y
mov ( 1 b - p r o m _ b o o t _ m a p p i n g _ p h y s _ l o w ) , % l 3
sub % l 0 , % l 3 , % l 3
ldx [ % l 3 ] , % l 3
stx % l 3 , [ % s p + 2 0 4 7 + 1 2 8 + 0 x48 ] ! a r g 7 : p h y s a d d r
call % l 7
add % s p , ( 2 0 4 7 + 1 2 8 ) , % o 0 ! a r g u m e n t a r r a y
add % s p , ( 1 9 2 + 1 2 8 ) , % s p
sparc64_boot_after_remap :
2005-04-17 02:20:36 +04:00
BRANCH_ I F _ C H E E T A H _ B A S E ( g 1 ,g 7 ,c h e e t a h _ b o o t )
BRANCH_ I F _ C H E E T A H _ P L U S _ O R _ F O L L O W O N ( g 1 ,g 7 ,c h e e t a h _ p l u s _ b o o t )
ba,p t % x c c , s p i t f i r e _ b o o t
nop
cheetah_plus_boot :
/* Preserve OBP chosen DCU and DCR register settings. */
ba,p t % x c c , c h e e t a h _ g e n e r i c _ b o o t
nop
cheetah_boot :
mov D C R _ B P E | D C R _ R P E | D C R _ S I | D C R _ I F P O E | D C R _ M S , % g 1
wr % g 1 , % a s r18
sethi % u h i ( D C U _ M E | D C U _ R E | D C U _ H P E | D C U _ S P E | D C U _ S L | D C U _ W E ) , % g 7
or % g 7 , % u l o ( D C U _ M E | D C U _ R E | D C U _ H P E | D C U _ S P E | D C U _ S L | D C U _ W E ) , % g 7
sllx % g 7 , 3 2 , % g 7
or % g 7 , D C U _ D M | D C U _ I M | D C U _ D C | D C U _ I C , % g 7
stxa % g 7 , [ % g 0 ] A S I _ D C U _ C O N T R O L _ R E G
membar #S y n c
cheetah_generic_boot :
mov T S B _ E X T E N S I O N _ P , % g 3
stxa % g 0 , [ % g 3 ] A S I _ D M M U
stxa % g 0 , [ % g 3 ] A S I _ I M M U
membar #S y n c
mov T S B _ E X T E N S I O N _ S , % g 3
stxa % g 0 , [ % g 3 ] A S I _ D M M U
membar #S y n c
mov T S B _ E X T E N S I O N _ N , % g 3
stxa % g 0 , [ % g 3 ] A S I _ D M M U
stxa % g 0 , [ % g 3 ] A S I _ I M M U
membar #S y n c
[SPARC64]: Rewrite bootup sequence.
Instead of all of this cpu-specific code to remap the kernel
to the correct location, use portable firmware calls to do
this instead.
What we do now is the following in position independant
assembler:
chosen_node = prom_finddevice("/chosen");
prom_mmu_ihandle_cache = prom_getint(chosen_node, "mmu");
vaddr = 4MB_ALIGN(current_text_addr());
prom_translate(vaddr, &paddr_high, &paddr_low, &mode);
prom_boot_mapping_mode = mode;
prom_boot_mapping_phys_high = paddr_high;
prom_boot_mapping_phys_low = paddr_low;
prom_map(-1, 8 * 1024 * 1024, KERNBASE, paddr_low);
and that replaces the massive amount of by-hand TLB probing and
programming we used to do here.
The new code should also handle properly the case where the kernel
is mapped at the correct address already (think: future kexec
support).
Consequently, the bulk of remap_kernel() dies as does the entirety
of arch/sparc64/prom/map.S
We try to share some strings in the PROM library with the ones used
at bootup, and while we're here mark input strings to oplib.h routines
with "const" when appropriate.
There are many more simplifications now possible. For one thing, we
can consolidate the two copies we now have of a lot of cpu setup code
sitting in head.S and trampoline.S.
This is a significant step towards CONFIG_DEBUG_PAGEALLOC support.
Signed-off-by: David S. Miller <davem@davemloft.net>
2005-09-23 07:11:33 +04:00
ba,a ,p t % x c c , j u m p _ t o _ s u n 4 u _ i n i t
2005-04-17 02:20:36 +04:00
spitfire_boot :
/ * Typically P R O M h a s a l r e a d y e n a b l e d b o t h M M U ' s a n d b o t h o n - c h i p
* caches, b u t w e d o i t h e r e a n y w a y j u s t t o b e p a r a n o i d .
* /
mov ( L S U _ C O N T R O L _ I C | L S U _ C O N T R O L _ D C | L S U _ C O N T R O L _ I M | L S U _ C O N T R O L _ D M ) , % g 1
stxa % g 1 , [ % g 0 ] A S I _ L S U _ C O N T R O L
membar #S y n c
[SPARC64]: Rewrite bootup sequence.
Instead of all of this cpu-specific code to remap the kernel
to the correct location, use portable firmware calls to do
this instead.
What we do now is the following in position independant
assembler:
chosen_node = prom_finddevice("/chosen");
prom_mmu_ihandle_cache = prom_getint(chosen_node, "mmu");
vaddr = 4MB_ALIGN(current_text_addr());
prom_translate(vaddr, &paddr_high, &paddr_low, &mode);
prom_boot_mapping_mode = mode;
prom_boot_mapping_phys_high = paddr_high;
prom_boot_mapping_phys_low = paddr_low;
prom_map(-1, 8 * 1024 * 1024, KERNBASE, paddr_low);
and that replaces the massive amount of by-hand TLB probing and
programming we used to do here.
The new code should also handle properly the case where the kernel
is mapped at the correct address already (think: future kexec
support).
Consequently, the bulk of remap_kernel() dies as does the entirety
of arch/sparc64/prom/map.S
We try to share some strings in the PROM library with the ones used
at bootup, and while we're here mark input strings to oplib.h routines
with "const" when appropriate.
There are many more simplifications now possible. For one thing, we
can consolidate the two copies we now have of a lot of cpu setup code
sitting in head.S and trampoline.S.
This is a significant step towards CONFIG_DEBUG_PAGEALLOC support.
Signed-off-by: David S. Miller <davem@davemloft.net>
2005-09-23 07:11:33 +04:00
jump_to_sun4u_init :
2005-04-17 02:20:36 +04:00
/ *
* Make s u r e w e a r e i n p r i v i l e g e d m o d e , h a v e a d d r e s s m a s k i n g ,
* using t h e o r d i n a r y g l o b a l s a n d h a v e e n a b l e d f l o a t i n g
* point.
*
* Again, t y p i c a l l y P R O M h a s l e f t % p i l a t 1 3 o r s i m i l a r , a n d
* ( PSTATE_ P R I V | P S T A T E _ P E F | P S T A T E _ I E ) i n % p s t a t e .
* /
wrpr % g 0 , ( P S T A T E _ P R I V | P S T A T E _ P E F | P S T A T E _ I E ) , % p s t a t e
wr % g 0 , 0 , % f p r s
set s u n 4 u _ i n i t , % g 2
jmpl % g 2 + % g 0 , % g 0
nop
sun4u_init :
/* Set ctx 0 */
mov P R I M A R Y _ C O N T E X T , % g 7
stxa % g 0 , [ % g 7 ] A S I _ D M M U
membar #S y n c
mov S E C O N D A R Y _ C O N T E X T , % g 7
stxa % g 0 , [ % g 7 ] A S I _ D M M U
membar #S y n c
BRANCH_ I F _ A N Y _ C H E E T A H ( g 1 ,g 7 ,c h e e t a h _ t l b _ f i x u p )
ba,p t % x c c , s p i t f i r e _ t l b _ f i x u p
nop
cheetah_tlb_fixup :
mov 2 , % g 2 / * S e t T L B t y p e t o c h e e t a h + . * /
BRANCH_ I F _ C H E E T A H _ P L U S _ O R _ F O L L O W O N ( g 1 ,g 7 ,1 f )
mov 1 , % g 2 / * S e t T L B t y p e t o c h e e t a h . * /
1 : sethi % h i ( t l b _ t y p e ) , % g 1
stw % g 2 , [ % g 1 + % l o ( t l b _ t y p e ) ]
2005-10-05 02:23:20 +04:00
/* Patch copy/page operations to cheetah optimized versions. */
2005-04-17 02:20:36 +04:00
call c h e e t a h _ p a t c h _ c o p y o p s
nop
2005-08-30 22:26:15 +04:00
call c h e e t a h _ p a t c h _ c o p y _ p a g e
nop
2005-04-17 02:20:36 +04:00
call c h e e t a h _ p a t c h _ c a c h e t l b o p s
nop
ba,p t % x c c , t l b _ f i x u p _ d o n e
nop
spitfire_tlb_fixup :
/* Set TLB type to spitfire. */
mov 0 , % g 2
sethi % h i ( t l b _ t y p e ) , % g 1
stw % g 2 , [ % g 1 + % l o ( t l b _ t y p e ) ]
tlb_fixup_done :
sethi % h i ( i n i t _ t h r e a d _ u n i o n ) , % g 6
or % g 6 , % l o ( i n i t _ t h r e a d _ u n i o n ) , % g 6
ldx [ % g 6 + T I _ T A S K ] , % g 4
mov % s p , % l 6
mov % o 4 , % l 7
wr % g 0 , A S I _ P , % a s i
mov 1 , % g 1
sllx % g 1 , T H R E A D _ S H I F T , % g 1
sub % g 1 , ( S T A C K F R A M E _ S Z + S T A C K _ B I A S ) , % g 1
add % g 6 , % g 1 , % s p
mov 0 , % f p
/ * Set p e r - c p u p o i n t e r i n i t i a l l y t o z e r o , t h i s m a k e s
* the b o o t - c p u u s e t h e i n - k e r n e l - i m a g e p e r - c p u a r e a s
* before s e t u p _ p e r _ c p u _ a r e a ( ) i s i n v o k e d .
* /
clr % g 5
wrpr % g 0 , 0 , % w s t a t e
wrpr % g 0 , 0 x0 , % t l
/* Clear the bss */
sethi % h i ( _ _ b s s _ s t a r t ) , % o 0
or % o 0 , % l o ( _ _ b s s _ s t a r t ) , % o 0
sethi % h i ( _ e n d ) , % o 1
or % o 1 , % l o ( _ e n d ) , % o 1
call _ _ b z e r o
sub % o 1 , % o 0 , % o 1
mov % l 6 , % o 1 ! O p e n P R O M s t a c k
call p r o m _ i n i t
mov % l 7 , % o 0 ! O p e n P R O M c i f h a n d l e r
/* Off we go.... */
call s t a r t _ k e r n e l
nop
/* Not reached... */
2005-10-11 03:12:13 +04:00
/ * This i s m e a n t t o a l l o w t h e s h a r i n g o f t h i s c o d e b e t w e e n
* boot p r o c e s s o r i n v o c a t i o n ( v i a s e t u p _ t b a ( ) b e l o w ) a n d
* secondary p r o c e s s o r s t a r t u p ( v i a t r a m p o l i n e . S ) . T h e
* former d o e s u s e t h i s c o d e , t h e l a t t e r d o e s n o t y e t d u e
* to s o m e c o m p l e x i t i e s . T h a t s h o u l d b e f i x e d u p a t s o m e
* point.
2005-10-12 23:22:46 +04:00
*
* There u s e d t o b e e n o r m o u s c o m p l e x i t y w r t . t r a n s f e r r i n g
* over f r o m t h e f i r w m a r e ' s t r a p t a b l e t o t h e L i n u x k e r n e l ' s .
* For e x a m p l e , t h e r e w a s a c h i c k e n & e g g p r o b l e m w r t . b u i l d i n g
* the O B P p a g e t a b l e s , y e t n e e d i n g t o b e o n t h e L i n u x k e r n e l
* trap t a b l e ( t o t r a n s l a t e P A G E _ O F F S E T a d d r e s s e s ) i n o r d e r t o
* do t h a t .
*
* We n o w h a n d l e O B P t l b m i s s e s d i f f e r e n t l y , v i a l i n e a r l o o k u p s
* into t h e p r o m _ t r a n s [ ] a r r a y . S o t h a t s p e c i f i c p r o b l e m n o
* longer e x i s t s . Y e t , u n f o r t u n a t e l y t h e r e a r e s t i l l s o m e i s s u e s
* preventing t r a m p o l i n e . S f r o m u s i n g t h i s c o d e . . . h o h u m .
2005-10-11 03:12:13 +04:00
* /
.globl setup_trap_table
setup_trap_table :
save % s p , - 1 9 2 , % s p
2005-10-12 23:22:46 +04:00
/* Force interrupts to be disabled. */
2005-10-11 03:12:13 +04:00
rdpr % p s t a t e , % o 1
andn % o 1 , P S T A T E _ I E , % o 1
wrpr % o 1 , 0 x0 , % p s t a t e
wrpr % g 0 , 1 5 , % p i l
2005-04-17 02:20:36 +04:00
2005-10-12 23:22:46 +04:00
/* Make the firmware call to jump over to the Linux trap table. */
2005-10-11 03:12:13 +04:00
call p r o m _ s e t _ t r a p _ t a b l e
sethi % h i ( s p a r c64 _ t t a b l e _ t l 0 ) , % o 0
/* Start using proper page size encodings in ctx register. */
sethi % h i ( s p a r c64 _ k e r n _ p r i _ c o n t e x t ) , % g 3
ldx [ % g 3 + % l o ( s p a r c64 _ k e r n _ p r i _ c o n t e x t ) ] , % g 2
mov P R I M A R Y _ C O N T E X T , % g 1
stxa % g 2 , [ % g 1 ] A S I _ D M M U
membar #S y n c
/ * The L i n u x t r a p h a n d l e r s e x p e c t v a r i o u s t r a p g l o b a l r e g i s t e r s
* to b e s e t u p w i t h s o m e f i x e d v a l u e s . S o h e r e w e s e t t h e s e
* up v e r y c a r e f u l l y . T h e s e g l o b a l s a r e :
*
* Alternate G l o b a l s ( P S T A T E _ A G ) :
*
* % g6 - - > c u r r e n t _ t h r e a d _ i n f o ( )
*
* MMU G l o b a l s ( P S T A T E _ M G ) :
*
* % g1 - - > T L B _ S F S R
* % g2 - - > ( ( _ P A G E _ V A L I D | _ P A G E _ S Z 4 M B |
* _ PAGE_ C P | _ P A G E _ C V | _ P A G E _ P | _ P A G E _ W )
* ^ 0 xfffff8 0 0 0 0 0 0 0 0 0 0 )
* ( this % g 2 v a l u e i s u s e d f o r c o m p u t i n g t h e P A G E _ O F F S E T k e r n e l
* TLB e n t r i e s q u i c k l y , t h e v i r t u a l a d d r e s s o f t h e f a u l t X O R ' d
* with t h i s % g 2 v a l u e i s t h e P T E t o l o a d i n t o t h e T L B )
* % g3 - - > V P T E _ B A S E _ C H E E T A H o r V P T E _ B A S E _ S P I T F I R E
*
* Interrupt G l o b a l s ( P S T A T E _ I G , s e t u p b y i n i t _ i r q w o r k _ c u r c p u ( ) ) :
*
* % g6 - - > _ _ i r q _ w o r k [ s m p _ p r o c e s s o r _ i d ( ) ]
* /
2005-04-17 02:20:36 +04:00
rdpr % p s t a t e , % o 1
mov % g 6 , % o 2
2005-10-11 03:12:13 +04:00
wrpr % o 1 , P S T A T E _ A G , % p s t a t e
2005-04-17 02:20:36 +04:00
mov % o 2 , % g 6
# define K E R N _ H I G H B I T S ( ( _ P A G E _ V A L I D | _ P A G E _ S Z 4 M B ) ^ 0 x f f f f f80 0 0 0 0 0 0 0 0 0 )
# define K E R N _ L O W B I T S ( _ P A G E _ C P | _ P A G E _ C V | _ P A G E _ P | _ P A G E _ W )
2005-10-11 03:12:13 +04:00
wrpr % o 1 , P S T A T E _ M G , % p s t a t e
2005-04-17 02:20:36 +04:00
mov T S B _ R E G , % g 1
stxa % g 0 , [ % g 1 ] A S I _ D M M U
membar #S y n c
stxa % g 0 , [ % g 1 ] A S I _ I M M U
membar #S y n c
mov T L B _ S F S R , % g 1
sethi % u h i ( K E R N _ H I G H B I T S ) , % g 2
or % g 2 , % u l o ( K E R N _ H I G H B I T S ) , % g 2
sllx % g 2 , 3 2 , % g 2
or % g 2 , K E R N _ L O W B I T S , % g 2
2005-10-11 03:12:13 +04:00
BRANCH_ I F _ A N Y _ C H E E T A H ( g 3 ,g 7 ,8 f )
ba,p t % x c c , 9 f
2005-04-17 02:20:36 +04:00
nop
2005-10-11 03:12:13 +04:00
8 :
2005-04-17 02:20:36 +04:00
sethi % u h i ( V P T E _ B A S E _ C H E E T A H ) , % g 3
or % g 3 , % u l o ( V P T E _ B A S E _ C H E E T A H ) , % g 3
ba,p t % x c c , 2 f
sllx % g 3 , 3 2 , % g 3
2005-10-11 03:12:13 +04:00
9 :
2005-04-17 02:20:36 +04:00
sethi % u h i ( V P T E _ B A S E _ S P I T F I R E ) , % g 3
or % g 3 , % u l o ( V P T E _ B A S E _ S P I T F I R E ) , % g 3
sllx % g 3 , 3 2 , % g 3
2 :
clr % g 7
# undef K E R N _ H I G H B I T S
# undef K E R N _ L O W B I T S
/* Kill PROM timer */
sethi % h i ( 0 x80 0 0 0 0 0 0 ) , % o 2
sllx % o 2 , 3 2 , % o 2
wr % o 2 , 0 , % t i c k _ c m p r
BRANCH_ I F _ A N Y _ C H E E T A H ( o 2 ,o 3 ,1 f )
ba,p t % x c c , 2 f
nop
/* Disable STICK_INT interrupts. */
1 :
sethi % h i ( 0 x80 0 0 0 0 0 0 ) , % o 2
sllx % o 2 , 3 2 , % o 2
wr % o 2 , % a s r25
2 :
wrpr % g 0 , % g 0 , % w s t a t e
2005-10-11 03:12:13 +04:00
wrpr % o 1 , 0 x0 , % p s t a t e
2005-04-17 02:20:36 +04:00
call i n i t _ i r q w o r k _ c u r c p u
nop
2005-10-11 03:12:13 +04:00
/* Now we can turn interrupts back on. */
2005-04-17 02:20:36 +04:00
rdpr % p s t a t e , % o 1
or % o 1 , P S T A T E _ I E , % o 1
wrpr % o 1 , 0 , % p s t a t e
2005-10-11 03:12:13 +04:00
wrpr % g 0 , 0 x0 , % p i l
ret
restore
.globl setup_tba
setup_tba : /* i0 = is_starfire */
save % s p , - 1 9 2 , % s p
/ * The b o o t p r o c e s s o r i s t h e o n l y c p u w h i c h i n v o k e s t h i s
* routine, t h e o t h e r c p u s s e t t h i n g s u p v i a t r a m p o l i n e . S .
* So s a v e t h e O B P t r a p t a b l e a d d r e s s h e r e .
* /
rdpr % t b a , % g 7
sethi % h i ( p r o m _ t b a ) , % o 1
or % o 1 , % l o ( p r o m _ t b a ) , % o 1
stx % g 7 , [ % o 1 ]
call s e t u p _ t r a p _ t a b l e
nop
2005-04-17 02:20:36 +04:00
ret
restore
2005-10-12 23:22:46 +04:00
sparc64_boot_end :
# include " s y s t b l s . S "
# include " k t l b . S "
# include " e t r a p . S "
# include " r t r a p . S "
# include " w i n f i x u p . S "
# include " e n t r y . S "
2005-04-17 02:20:36 +04:00
/ *
2005-10-12 23:22:46 +04:00
* The f o l l o w i n g s k i p m a k e s s u r e t h e t r a p t a b l e i n t t a b l e . S i s a l i g n e d
2005-04-17 02:20:36 +04:00
* on a 3 2 K b o u n d a r y a s r e q u i r e d b y t h e v9 s p e c s f o r T B A r e g i s t e r .
* /
2005-10-12 23:22:46 +04:00
1 :
.skip 0x4000 + _ start - 1 b
2005-04-17 02:20:36 +04:00
# ifdef C O N F I G _ S B U S
/ * This i s j u s t a h a c k t o f o o l m a k e d e p e n d c o n f i g . h d i s c o v e r i n g
strategy : As t h e . S f i l e s b e l o w n e e d c o n f i g . h , b u t
make d e p e n d d o e s n o t f i n d i t f o r t h e m , w e i n c l u d e c o n f i g . h
in h e a d . S * /
# endif
! 0 x0 0 0 0 0 0 0 0 0 0 4 0 8 0 0 0
# include " t t a b l e . S "
.data
.align 8
.globl prom_ t b a , t l b _ t y p e
prom_tba : .xword 0
tlb_type : .word 0 /* Must NOT end up in BSS */
.section " .fixup " , # alloc,#e x e c i n s t r
2005-09-29 07:41:45 +04:00
.globl _ _ ret_ e f a u l t , _ _ r e t l _ e f a u l t
2005-04-17 02:20:36 +04:00
__ret_efault :
ret
restore % g 0 , - E F A U L T , % o 0
2005-09-29 07:41:45 +04:00
__retl_efault :
retl
mov - E F A U L T , % o 0