Hi,
 
I'm trying to embed a 1MB ram disc into the kernel. I have sort-of copied
the bootpimage build, producing my own .lds file. The kernel hangs when it
calls printk() for the first time in main(). I think this is because I have
got something wrong with the memory layout. But what...?
 
Anyway, is there an easy way to do this? I want to link the ramdisk with the
kernel, load it as one file, then have the kernel use the ramdisk on startup
(I can tack a loader onto the start to move it out of the way).
 
I'm learning a lot more about the kernel than I'd hoped would be necessary
and I'm all web-mailing-list-searched out!
BTW, I'm porting to an ELF board from Inhand Electronics.
 
Thanks in advance for any ideas.
 
 
/*
 *  linux/arch/arm/boot/ramdisc/ramdisc.lds
 *
 *  Copyright (C) 2000 Russell King
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */
OUTPUT_ARCH(arm)
ENTRY(kernel_start)
SECTIONS
{
  . = 0xc0007fe0;  @ allow 32 bytes for the B to the relocate code
  _text = .;
  .text : {
   _stext = .;
   _start = .;
   init.o(.start)
   . = ALIGN(32);
   kernel_start = .;
   kernel_addr = .;
   kernel.o
   . = ALIGN(32);
   kernel_end = .;
   kernel_len = kernel_end - kernel_start;
 
   initrd_start = .;
   initrd_addr = .;
   initrd_virt = .;
   rd.o
 
   . = ALIGN(32);
   initrd_end = .;
   initrd_len = initrd_end - initrd_start;
   setup_params = .;
   *(.text)
   _etext = .;
  }
 
  .stab 0 : { *(.stab) }
  .stabstr 0 : { *(.stabstr) }
  .stab.excl 0 : { *(.stab.excl) }
  .stab.exclstr 0 : { *(.stab.exclstr) }
  .stab.index 0 : { *(.stab.index) }
  .stab.indexstr 0 : { *(.stab.indexstr) }
  .comment 0 : { *(.comment) }
}
 
 
 
 *  linux/arch/arm/boot/ramdisc/init.S
 *
 *  Copyright (C) 2000 Russell King
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 *  Header file for splitting kernel + initrd.  Note that we pass
 *  r0 through to r3 straight through.
 */
  .section .start,#alloc,#execinstr
  .type _entry, #function
_entry:  adr r10, initdata
  ldr r11, initdata
  sub r11, r10, r11  @ work out exec offset
  b splitify
  .size _entry,. - _entry
 
  .type initdata, #object
initdata: .word initdata  @ compiled address of this
  .size initdata,. - initdata
 
  .text
splitify: adr r13, data
  ldmia r13!, {r4-r6}  @ move the initrd
  sub r6, r6, r4
  add r4, r4, r11  @ correction
  cmp r6, #0
@  blne move
 
  ldmia r13!, {r4-r6}  @ then the kernel
  sub r6, r6, r4
  mov r12, r5
  add r4, r4, r11  @ correction
@  bl move
 
/*
 * Setup the initrd parameters to pass to the kernel.  This can either be
 * passed in via a param_struct or a tag list.  We spot the param_struct
 * method by looking at the first word; this should either indicate a page
 * size of 4K, 16K or 32K.
 */
 
/*
 * find the end of the tag list, and then add an INITRD tag on the end.
 */
taglist:
@ initialise tag list
@  ldr r9, [r8, #0]  @ tag length
@  teq r9, #0   @ last tag?
@  addne r8, r8, r9
@  bne taglist
  ldr r8, =0xc0000100;
 
  mov r4, #20
  ldmia r13!, {r5-r7,r10}
  stmia r8!, {r4, r5, r6, r7, r10}
 
  ldmia r13, {r5-r7}  @ get size and addr of initrd
      @ r5 = ATAG_INITRD
      @ r6 = initrd start
      @ r7 = initrd end
      @ r8 = param_struct address
  sub r7, r7, r6
 
  mov r4, #16   @ length of initrd tag
  mov r9, #0   @ end of tag list terminator
  stmia r8, {r4, r5, r6, r7, r9}
  mov pc, r12   @ call kernel
 
no_taglist: add r8, r8, #16*4
  stmia r8, {r6,r7}  @ save in param_struct
  mov pc, r12   @ call kernel
 
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 move
  mov pc, lr
 
data:  .word initrd_start
  .word initrd_addr
  .word initrd_end
 
  .word kernel_start
  .word kernel_addr
  .word kernel_end
 
  .word 0x54410001  @ r5 = ATAG_CORE
  .word 0   @ r6 - flags
  .word 4096   @ r7 - pagesize
  .word 0x0100   @ r8 - rootdev
 
  .word 0x54410005  @ r5 = ATAG_INITRD
  .word initrd_virt  @ r6
  .word initrd_end  @ r7
  .word params   @ r8
 
  .type kernel_start,#object
  .type initrd_start,#object
 
 
--------------------------------------------------------------------------
Bluewater Systems Ltd - ARM Technology Specialists
 
       Sally Glass                              Bluewater Systems Ltd
Phone: +64 3 3779127                            Level 17, 119 Armagh St
Fax:   +64 3 3779135                            PO Box 13889
Email: [EMAIL PROTECTED]                    Christchurch
Web:   http://www.bluewaternz.com               New Zealand

Reply via email to