Path: blob/master/arch/cris/boot/compressed/head_v32.S
10818 views
/*1* Code that sets up the DRAM registers, calls the2* decompressor to unpack the piggybacked kernel, and jumps.3*4* Copyright (C) 1999 - 2006, Axis Communications AB5*/67#define ASSEMBLER_MACROS_ONLY8#include <hwregs/asm/reg_map_asm.h>9#include <mach/startup.inc>1011#define RAM_INIT_MAGIC 0x5690238712#define COMMAND_LINE_MAGIC 0x871095631314;; Exported symbols1516.globl input_data1718.text19start:20di2122;; Start clocks for used blocks.23START_CLOCKS2425;; Initialize the DRAM registers.26cmp.d RAM_INIT_MAGIC, $r8 ; Already initialized?27beq dram_init_finished28nop2930#if defined CONFIG_ETRAXFS31#include "../../arch-v32/mach-fs/dram_init.S"32#elif defined CONFIG_CRIS_MACH_ARTPEC333#include "../../arch-v32/mach-a3/dram_init.S"34#else35#error Only ETRAXFS and ARTPEC-3 supported!36#endif3738dram_init_finished:3940GIO_INIT41;; Setup the stack to a suitably high address.42;; We assume 8 MB is the minimum DRAM and put43;; the SP at the top for now.4445move.d 0x40800000, $sp4647;; Figure out where the compressed piggyback image is.48;; It is either in [NOR] flash (we don't want to copy it49;; to DRAM before unpacking), or copied to DRAM50;; by the [NAND] flash boot loader.51;; The piggyback image is at _edata, but relative to where the52;; image is actually located in memory, not where it is linked53;; (the decompressor is linked at 0x40700000+ and runs there).54;; Use (_edata - herami) as offset to the current PC.5556hereami:57lapcq ., $r5 ; get PC58and.d 0x7fffffff, $r5 ; strip any non-cache bit59move.d $r5, $r0 ; source address of 'herami'60add.d _edata, $r561sub.d hereami, $r5 ; r5 = flash address of '_edata'62move.d hereami, $r1 ; destination6364;; Copy text+data to DRAM6566move.d _edata, $r2 ; end destination671: move.w [$r0+], $r3 ; from herami+ source68move.w $r3, [$r1+] ; to hereami+ destination (linked address)69cmp.d $r2, $r1 ; finish when destination == _edata70bcs 1b71nop72move.d input_data, $r0 ; for the decompressor73move.d $r5, [$r0] ; for the decompressor7475;; Clear the decompressors BSS (between _edata and _end)7677moveq 0, $r078move.d _edata, $r179move.d _end, $r2801: move.w $r0, [$r1+]81cmp.d $r2, $r182bcs 1b83nop8485;; Save command line magic and address.86move.d _cmd_line_magic, $r087move.d $r10, [$r0]88move.d _cmd_line_addr, $r089move.d $r11, [$r0]9091;; Save boot source indicator92move.d _boot_source, $r093move.d $r12, [$r0]9495;; Do the decompression and save compressed size in _inptr9697jsr decompress_kernel98nop99100;; Restore boot source indicator101move.d _boot_source, $r12102move.d [$r12], $r12103104;; Restore command line magic and address.105move.d _cmd_line_magic, $r10106move.d [$r10], $r10107move.d _cmd_line_addr, $r11108move.d [$r11], $r11109110;; Put start address of root partition in r9 so the kernel can use it111;; when mounting from flash112move.d input_data, $r0113move.d [$r0], $r9 ; flash address of compressed kernel114move.d inptr, $r0115add.d [$r0], $r9 ; size of compressed kernel116cmp.d 0x40000000, $r9 ; image in DRAM ?117blo enter_kernel ; no, must be [NOR] flash, jump118nop ; delay slot119and.d 0x001fffff, $r9 ; assume compressed kernel was < 2M120121enter_kernel:122;; Enter the decompressed kernel123move.d RAM_INIT_MAGIC, $r8 ; Tell kernel that DRAM is initialized124jump 0x40004000 ; kernel is linked to this address125nop126127.data128129input_data:130.dword 0 ; used by the decompressor131_cmd_line_magic:132.dword 0133_cmd_line_addr:134.dword 0135_boot_source:136.dword 0137138#if defined CONFIG_ETRAXFS139#include "../../arch-v32/mach-fs/hw_settings.S"140#elif defined CONFIG_CRIS_MACH_ARTPEC3141#include "../../arch-v32/mach-a3/hw_settings.S"142#else143#error Only ETRAXFS and ARTPEC-3 supported!144#endif145146147