Path: blob/master/arch/cris/boot/compressed/head_v10.S
10818 views
/*1* arch/cris/boot/compressed/head.S2*3* Copyright (C) 1999, 2001 Axis Communications AB4*5* Code that sets up the DRAM registers, calls the6* decompressor to unpack the piggybacked kernel, and jumps.7*8*/910#define ASSEMBLER_MACROS_ONLY11#include <arch/sv_addr_ag.h>1213#define RAM_INIT_MAGIC 0x5690238714#define COMMAND_LINE_MAGIC 0x871095631516;; Exported symbols1718.globl input_data192021.text2223nop24di2526;; We need to initialze DRAM registers before we start using the DRAM2728cmp.d RAM_INIT_MAGIC, $r8 ; Already initialized?29beq dram_init_finished30nop3132#include "../../arch-v10/lib/dram_init.S"3334dram_init_finished:3536;; Initiate the PA and PB ports3738move.b CONFIG_ETRAX_DEF_R_PORT_PA_DATA, $r039move.b $r0, [R_PORT_PA_DATA]4041move.b CONFIG_ETRAX_DEF_R_PORT_PA_DIR, $r042move.b $r0, [R_PORT_PA_DIR]4344move.b CONFIG_ETRAX_DEF_R_PORT_PB_DATA, $r045move.b $r0, [R_PORT_PB_DATA]4647move.b CONFIG_ETRAX_DEF_R_PORT_PB_DIR, $r048move.b $r0, [R_PORT_PB_DIR]4950;; Setup the stack to a suitably high address.51;; We assume 8 MB is the minimum DRAM in an eLinux52;; product and put the sp at the top for now.5354move.d 0x40800000, $sp5556;; Figure out where the compressed piggyback image is57;; in the flash (since we wont try to copy it to DRAM58;; before unpacking). It is at _edata, but in flash.59;; Use (_edata - basse) as offset to the current PC.6061basse: move.d $pc, $r562and.d 0x7fffffff, $r5 ; strip any non-cache bit63subq 2, $r5 ; compensate for the move.d $pc instr64move.d $r5, $r0 ; save for later - flash address of 'basse'65add.d _edata, $r566sub.d basse, $r5 ; $r5 = flash address of '_edata'6768;; Copy text+data to DRAM6970move.d basse, $r1 ; destination71move.d _edata, $r2 ; end destination721: move.w [$r0+], $r373move.w $r3, [$r1+]74cmp.d $r2, $r175bcs 1b76nop7778move.d $r5, [input_data] ; for the decompressor798081;; Clear the decompressors BSS (between _edata and _end)8283moveq 0, $r084move.d _edata, $r185move.d _end, $r2861: move.w $r0, [$r1+]87cmp.d $r2, $r188bcs 1b89nop9091;; Save command line magic and address.92move.d _cmd_line_magic, $r1293move.d $r10, [$r12]94move.d _cmd_line_addr, $r1295move.d $r11, [$r12]9697;; Do the decompression and save compressed size in inptr9899jsr decompress_kernel100101;; Put start address of root partition in $r9 so the kernel can use it102;; when mounting from flash103104move.d [input_data], $r9 ; flash address of compressed kernel105add.d [inptr], $r9 ; size of compressed kernel106107;; Restore command line magic and address.108move.d _cmd_line_magic, $r10109move.d [$r10], $r10110move.d _cmd_line_addr, $r11111move.d [$r11], $r11112113;; Enter the decompressed kernel114move.d RAM_INIT_MAGIC, $r8 ; Tell kernel that DRAM is initialized115jump 0x40004000 ; kernel is linked to this address116117.data118119input_data:120.dword 0 ; used by the decompressor121_cmd_line_magic:122.dword 0123_cmd_line_addr:124.dword 0125#include "../../arch-v10/lib/hw_settings.S"126127128