2005-04-16 15:20:36 -07:00
/ *
* linux/ a r c h / a r m / b o o t / b o o t p / i n i t . S
*
* Copyright ( C ) 2 0 0 0 - 2 0 0 3 R u s s e l l K i n g .
*
* 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 v e r s i o n 2 a s
* published 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 .
*
* " Header" f i l e f o r s p l i t t i n g k e r n e l + i n i t r d . N o t e t h a t w e p a s s
* r0 t h r o u g h t o r3 s t r a i g h t t h r o u g h .
*
* This d e m o n s t r a t e s h o w t o a p p e n d c o d e t o t h e s t a r t o f t h e k e r n e l
* zImage, a n d b o o t t h e k e r n e l w i t h o u t c o p y i n g i t a r o u n d . T h i s
* example w o u l d b e s i m p l e r ; if we didn't have an object of unknown
* size i m m e d i a t e l y f o l l o w i n g t h e k e r n e l , w e c o u l d b u i l d t h i s i n t o
* a b i n a r y b l o b , a n d c o n c a t e n a t e t h e z I m a g e u s i n g t h e c a t c o m m a n d .
* /
.section .start , # alloc,#e x e c i n s t r
.type _ start, #f u n c t i o n
.globl _start
_start : add l r , p c , #- 0x8 @ lr = current load addr
adr r13 , d a t a
ldmia r13 ! , { r4 - r6 } @ r5 = dest, r6 = length
add r4 , r4 , l r @ r4 = initrd_start + load addr
bl m o v e @ move the initrd
/ *
* Setup t h e i n i t r d p a r a m e t e r s t o p a s s t o t h e k e r n e l . T h i s c a n o n l y b e
* passed i n v i a t h e t a g g e d l i s t .
* /
ldmia r13 , { r5 - r9 } @ get size and addr of initrd
@ r5 = ATAG_CORE
@ r6 = ATAG_INITRD2
@ r7 = initrd start
@ r8 = initrd end
@ r9 = param_struct address
ldr r10 , [ r9 , #4 ] @ get first tag
teq r10 , r5 @ is it ATAG_CORE?
/ *
* If w e d i d n ' t f i n d a v a l i d t a g l i s t , c r e a t e a d u m m y A T A G _ C O R E e n t r y .
* /
movne r10 , #0 @ terminator
movne r4 , #2 @ Size of this entry (2 words)
stmneia r9 , { r4 , r5 , r10 } @ Size, ATAG_CORE, terminator
/ *
* find t h e e n d o f t h e t a g l i s t , a n d t h e n a d d a n I N I T R D t a g o n t h e e n d .
* If t h e r e i s a l r e a d y a n I N I T R D t a g , t h e n w e i g n o r e i t ; the last INITRD
2010-01-18 16:02:48 +01:00
* tag t a k e s p r e c e d e n c e .
2005-04-16 15:20:36 -07:00
* /
taglist : ldr r10 , [ r9 , #0 ] @ tag length
teq r10 , #0 @ last tag (zero length)?
addne r9 , r9 , r10 , l s l #2
bne t a g l i s t
mov r5 , #4 @ Size of initrd tag (4 words)
stmia r9 , { r5 , r6 , r7 , r8 , r10 }
b k e r n e l _ s t a r t @ call kernel
/ *
* Move t h e b l o c k o f m e m o r y l e n g t h r6 f r o m a d d r e s s r4 t o a d d r e s s r5
* /
move : ldmia r4 ! , { r7 - r10 } @ move 32-bytes at a time
stmia r5 ! , { r7 - r10 }
ldmia r4 ! , { r7 - r10 }
stmia r5 ! , { r7 - r10 }
subs r6 , r6 , #8 * 4
bcs m o v e
mov p c , l r
.size _ start, . - _ s t a r t
2010-11-29 19:43:23 +01:00
.align
2005-04-16 15:20:36 -07:00
.type data,#o b j e c t
data : .word i n i t r d _ s t a r t @ s o u r c e i n i t r d a d d r e s s
.word initrd_phys @ destination initrd address
.word initrd_size @ initrd size
.word 0x54410001 @ r5 = ATAG_CORE
.word 0x54420005 @ r6 = ATAG_INITRD2
.word initrd_phys @ r7
.word initrd_size @ r8
.word params_phys @ r9
.size data, . - d a t a