2007-07-04 09:07:18 +10:00
/ *
* PS3 b o o t w r a p p e r h v c a l l s .
*
* Copyright ( C ) 2 0 0 7 S o n y C o m p u t e r E n t e r t a i n m e n t I n c .
* Copyright 2 0 0 7 S o n y C o r p .
*
* This p r o g r a m i s f r e e s o f t w a r e ; you can redistribute it and/or modify
* it u n d e r t h e t e r m s o f t h e G N U G e n e r a l P u b l i c L i c e n s e a s p u b l i s h e d b y
* the F r e e S o f t w a r e F o u n d a t i o n ; version 2 of the License.
*
* This p r o g r a m i s d i s t r i b u t e d i n t h e h o p e t h a t i t w i l l b e u s e f u l ,
* but W I T H O U T A N Y W A R R A N T Y ; without even the implied warranty of
* MERCHANTABILITY o r F I T N E S S F O R A P A R T I C U L A R P U R P O S E . S e e t h e
* GNU G e n e r a l P u b l i c L i c e n s e f o r m o r e d e t a i l s .
*
* You s h o u l d h a v e r e c e i v e d a c o p y o f t h e G N U G e n e r a l P u b l i c L i c e n s e
* along w i t h t h i s p r o g r a m ; if not, write to the Free Software
* Foundation, I n c . , 5 9 T e m p l e P l a c e , S u i t e 3 3 0 , B o s t o n , M A 0 2 1 1 1 - 1 3 0 7 U S A
* /
# include " p p c _ a s m . h "
2007-07-21 04:37:49 -07:00
.machine " ppc6 4 "
2007-07-04 09:07:18 +10:00
/ *
* The P S 3 h y p e r v i s o r u s e s a 6 4 b i t " C " l a n g u a g e c a l l i n g c o n v e n t i o n .
* The r o u t i n e s h e r e m a r s h a l a r g u m e n t s b e t w e e n t h e 3 2 b i t w r a p p e r
* program a n d t h e 6 4 b i t h v c a l l s .
*
* wrapper l v1
* 3 2 - bit ( h ,l ) 6 4 - b i t
*
* 1 : r3 ,r4 < - > r3
* 2 : r5 ,r6 < - > r4
* 3 : r7 ,r8 < - > r5
* 4 : r9 ,r10 < - > r6
* 5 : 8 ( r1 ) ,1 2 ( r1 ) < - > r7
* 6 : 1 6 ( r1 ) ,2 0 ( r1 ) < - > r8
* 7 : 2 4 ( r1 ) ,2 8 ( r1 ) < - > r9
* 8 : 3 2 ( r1 ) ,3 6 ( r1 ) < - > r10
*
* /
.macro GLOBAL name
.section " .text "
.balign 4
.globl \ name
\ name :
.endm
.macro NO_SUPPORT name
GLOBAL \ n a m e
b p s3 _ n o _ s u p p o r t
.endm
.macro HVCALL num
li r11 , \ n u m
.long 0x44000022
extsw r3 , r3
.endm
.macro SAVE_LR offset=4
mflr r0
stw r0 , \ o f f s e t ( r1 )
.endm
.macro LOAD_LR offset=4
lwz r0 , \ o f f s e t ( r1 )
mtlr r0
.endm
.macro LOAD_64_REG target,h i g h ,l o w
sldi r11 , \ h i g h , 3 2
or \ t a r g e t , r11 , \ l o w
.endm
.macro LOAD_64_STACK target,o f f s e t
ld \ t a r g e t , \ o f f s e t ( r1 )
.endm
.macro LOAD_R3
LOAD_ 6 4 _ R E G r3 ,r3 ,r4
.endm
.macro LOAD_R4
LOAD_ 6 4 _ R E G r4 ,r5 ,r6
.endm
.macro LOAD_R5
LOAD_ 6 4 _ R E G r5 ,r7 ,r8
.endm
.macro LOAD_R6
LOAD_ 6 4 _ R E G r6 ,r9 ,r10
.endm
.macro LOAD_R7
LOAD_ 6 4 _ S T A C K r7 ,8
.endm
.macro LOAD_R8
LOAD_ 6 4 _ S T A C K r8 ,1 6
.endm
.macro LOAD_R9
LOAD_ 6 4 _ S T A C K r9 ,2 4
.endm
.macro LOAD_R10
LOAD_ 6 4 _ S T A C K r10 ,3 2
.endm
.macro LOAD_REGS_0
stwu 1 ,- 1 6 ( 1 )
stw 3 , 8 ( 1 )
.endm
.macro LOAD_REGS_5
LOAD_ R 3
LOAD_ R 4
LOAD_ R 5
LOAD_ R 6
LOAD_ R 7
.endm
.macro LOAD_REGS_6
LOAD_ R E G S _ 5
LOAD_ R 8
.endm
.macro LOAD_REGS_8
LOAD_ R E G S _ 6
LOAD_ R 9
LOAD_ R 1 0
.endm
.macro STORE_REGS_0_1
lwz r11 , 8 ( r1 )
std r4 , 0 ( r11 )
mr r4 , r3
li r3 , 0
addi r1 ,r1 ,1 6
.endm
.macro STORE_REGS_5_2
lwz r11 , 1 6 ( r1 )
std r4 , 0 ( r11 )
2008-02-09 09:52:48 +11:00
lwz r11 , 2 0 ( r1 )
2007-07-04 09:07:18 +10:00
std r5 , 0 ( r11 )
.endm
.macro STORE_REGS_6_1
lwz r11 , 2 4 ( r1 )
std r4 , 0 ( r11 )
.endm
GLOBAL l v1 _ g e t _ l o g i c a l _ p p e _ i d
SAVE_ L R
LOAD_ R E G S _ 0
HVCALL 6 9
STORE_ R E G S _ 0 _ 1
LOAD_ L R
blr
GLOBAL l v1 _ g e t _ l o g i c a l _ p a r t i t i o n _ i d
SAVE_ L R
LOAD_ R E G S _ 0
HVCALL 7 4
STORE_ R E G S _ 0 _ 1
LOAD_ L R
blr
GLOBAL l v1 _ g e t _ r e p o s i t o r y _ n o d e _ v a l u e
SAVE_ L R
LOAD_ R E G S _ 5
HVCALL 9 1
STORE_ R E G S _ 5 _ 2
LOAD_ L R
blr
GLOBAL l v1 _ p a n i c
SAVE_ L R
LOAD_ R E G S _ 8
HVCALL 2 5 5
LOAD_ L R
blr