2005-04-16 15:20:36 -07:00
/ *
* Copyright ( C ) P a u l M a c k e r r a s 1 9 9 7 .
*
* This p r o g r a m i s f r e e s o f t w a r e ; you can redistribute it and/or
* modify i t u n d e r t h e t e r m s o f t h e G N U G e n e r a l P u b l i c L i c e n s e
* as p u b l i s h e d b y t h e F r e e S o f t w a r e F o u n d a t i o n ; either version
* 2 of t h e L i c e n s e , o r ( a t y o u r o p t i o n ) a n y l a t e r v e r s i o n .
*
* NOTE : this c o d e r u n s i n 3 2 b i t m o d e a n d i s p a c k a g e d a s E L F 3 2 .
* /
2005-08-08 13:24:38 +10:00
# include " p p c _ a s m . h "
2005-04-16 15:20:36 -07:00
.text
2006-01-14 15:04:06 +11:00
/* a procedure descriptor used when booting this as a COFF file */
_zimage_start_opd :
.long _ zimage_ s t a r t , 0 , 0 , 0
2005-10-28 17:46:49 -07:00
.globl _zimage_start
_zimage_start :
2006-01-14 15:04:06 +11:00
/ * Work o u t t h e o f f s e t b e t w e e n t h e a d d r e s s w e w e r e l i n k e d a t
and t h e a d d r e s s w h e r e w e ' r e r u n n i n g . * /
2005-11-17 22:09:02 +01:00
bl 1 f
2006-01-14 15:04:06 +11:00
1 : mflr r0
2005-11-17 22:09:02 +01:00
lis r9 ,1 b @ha
addi r9 ,r9 ,1 b @l
2005-10-28 17:46:48 -07:00
subf. r0 ,r9 ,r0
2006-01-14 15:04:06 +11:00
beq 3 f / * i f r u n n i n g a t s a m e a d d r e s s a s l i n k e d * /
2005-10-28 17:46:48 -07:00
2006-01-14 15:04:06 +11:00
/ * The . g o t 2 s e c t i o n c o n t a i n s a l i s t o f a d d r e s s e s , s o a d d
the a d d r e s s o f f s e t o n t o e a c h e n t r y . * /
2005-10-28 17:46:48 -07:00
lis r9 ,_ _ g o t 2 _ s t a r t @ha
addi r9 ,r9 ,_ _ g o t 2 _ s t a r t @l
lis r8 ,_ _ g o t 2 _ e n d @ha
addi r8 ,r8 ,_ _ g o t 2 _ e n d @l
subf. r8 ,r9 ,r8
2005-11-17 22:09:02 +01:00
beq 3 f
2005-10-28 17:46:48 -07:00
srwi. r8 ,r8 ,2
mtctr r8
add r9 ,r0 ,r9
2006-01-14 15:04:06 +11:00
2 : lwz r8 ,0 ( r9 )
2005-10-28 17:46:48 -07:00
add r8 ,r8 ,r0
stw r8 ,0 ( r9 )
addi r9 ,r9 ,4
2005-11-17 22:09:02 +01:00
bdnz 2 b
2005-10-28 17:46:48 -07:00
2006-01-14 15:04:06 +11:00
/* Do a cache flush for our text, in case OF didn't */
2006-03-04 13:15:40 +01:00
3 : lis r9 ,_ s t a r t @ha
addi r9 ,r9 ,_ s t a r t @l
2005-10-28 17:46:48 -07:00
add r9 ,r0 ,r9
2005-04-16 15:20:36 -07:00
lis r8 ,_ e t e x t @ha
addi r8 ,r8 ,_ e t e x t @l
2005-10-28 17:46:48 -07:00
add r8 ,r0 ,r8
2005-11-17 22:09:02 +01:00
4 : dcbf r0 ,r9
2005-04-16 15:20:36 -07:00
icbi r0 ,r9
addi r9 ,r9 ,0 x20
2006-03-04 13:15:40 +01:00
cmplw c r0 ,r9 ,r8
2005-11-17 22:09:02 +01:00
blt 4 b
2005-04-16 15:20:36 -07:00
sync
isync
2005-10-28 17:46:50 -07:00
mr r6 ,r1
2005-04-16 15:20:36 -07:00
b s t a r t