Back to home page

LXR

 
 

    


0001 /*
0002  *  arch/cris/boot/compressed/head.S
0003  *
0004  *  Copyright (C) 1999, 2001 Axis Communications AB
0005  *
0006  *  Code that sets up the DRAM registers, calls the
0007  *  decompressor to unpack the piggybacked kernel, and jumps.
0008  *
0009  */
0010 
0011 #define ASSEMBLER_MACROS_ONLY
0012 #include <arch/sv_addr_ag.h>
0013 
0014 #define RAM_INIT_MAGIC 0x56902387
0015 #define COMMAND_LINE_MAGIC 0x87109563
0016 
0017     ;; Exported symbols
0018 
0019     .globl  input_data
0020 
0021 
0022     .text
0023 
0024     nop
0025     di
0026 
0027 ;; We need to initialze DRAM registers before we start using the DRAM
0028 
0029     cmp.d   RAM_INIT_MAGIC, $r8 ; Already initialized?
0030     beq dram_init_finished
0031     nop
0032 
0033 #include "../../arch-v10/lib/dram_init.S"
0034 
0035 dram_init_finished:
0036 
0037     ;; Initiate the PA and PB ports
0038 
0039     move.b   CONFIG_ETRAX_DEF_R_PORT_PA_DATA, $r0
0040     move.b   $r0, [R_PORT_PA_DATA]
0041 
0042     move.b   CONFIG_ETRAX_DEF_R_PORT_PA_DIR, $r0
0043     move.b   $r0, [R_PORT_PA_DIR]
0044 
0045     move.b   CONFIG_ETRAX_DEF_R_PORT_PB_DATA, $r0
0046     move.b   $r0, [R_PORT_PB_DATA]
0047 
0048     move.b   CONFIG_ETRAX_DEF_R_PORT_PB_DIR, $r0
0049     move.b   $r0, [R_PORT_PB_DIR]
0050 
0051     ;; Setup the stack to a suitably high address.
0052     ;; We assume 8 MB is the minimum DRAM in an eLinux
0053     ;; product and put the sp at the top for now.
0054 
0055     move.d  0x40800000, $sp
0056 
0057     ;; Figure out where the compressed piggyback image is
0058     ;; in the flash (since we wont try to copy it to DRAM
0059     ;; before unpacking). It is at _edata, but in flash.
0060     ;; Use (_edata - basse) as offset to the current PC.
0061 
0062 basse:  move.d  $pc, $r5
0063     and.d   0x7fffffff, $r5 ; strip any non-cache bit
0064     subq    2, $r5      ; compensate for the move.d $pc instr
0065     move.d  $r5, $r0        ; save for later - flash address of 'basse'
0066     add.d   _edata, $r5
0067     sub.d   basse, $r5  ; $r5 = flash address of '_edata'
0068 
0069     ;; Copy text+data to DRAM
0070 
0071     move.d  basse, $r1  ; destination
0072     move.d  _edata, $r2 ; end destination
0073 1:  move.w  [$r0+], $r3
0074     move.w  $r3, [$r1+]
0075     cmp.d   $r2, $r1
0076     bcs 1b
0077     nop
0078 
0079     move.d  $r5, [input_data] ; for the decompressor
0080 
0081 
0082     ;; Clear the decompressors BSS (between _edata and _end)
0083 
0084     moveq   0, $r0
0085     move.d  _edata, $r1
0086     move.d  _end, $r2
0087 1:  move.w  $r0, [$r1+]
0088     cmp.d   $r2, $r1
0089     bcs 1b
0090     nop
0091 
0092     ;;  Save command line magic and address.
0093     move.d  _cmd_line_magic, $r12
0094     move.d  $r10, [$r12]
0095     move.d  _cmd_line_addr, $r12
0096     move.d  $r11, [$r12]
0097 
0098     ;; Do the decompression and save compressed size in inptr
0099 
0100     jsr decompress_kernel
0101 
0102     ;; Put start address of root partition in $r9 so the kernel can use it
0103     ;; when mounting from flash
0104 
0105     move.d  [input_data], $r9   ; flash address of compressed kernel
0106     add.d   [inptr], $r9        ; size of compressed kernel
0107 
0108     ;; Restore command line magic and address.
0109     move.d  _cmd_line_magic, $r10
0110     move.d  [$r10], $r10
0111     move.d  _cmd_line_addr, $r11
0112     move.d  [$r11], $r11
0113 
0114     ;; Enter the decompressed kernel
0115     move.d  RAM_INIT_MAGIC, $r8 ; Tell kernel that DRAM is initialized
0116     jump    0x40004000  ; kernel is linked to this address
0117 
0118     .data
0119 
0120 input_data:
0121     .dword  0       ; used by the decompressor
0122 _cmd_line_magic:
0123     .dword 0
0124 _cmd_line_addr:
0125     .dword 0
0126 #include "../../arch-v10/lib/hw_settings.S"