[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: jump at boot

> The code is actually linked to run from DRAM,
> but in the beginning it is really executed from flash
> so you must use position independent code
> /Johan

I wish i could say it worked... A gave it a try changing the 
linkerscript arch/cris/boot/compressed/decompress.ld for linking to 
flash (0x00000) instead of ram (0x40700000) but with no luck. Sure it'll 
break many things but I modified my last attached file to give 
"heartbeats" via the yellow network led on the board. It works with 
branch but not jump nor jsr. Se modified version below (at mid area).


 *  arch/cris/boot/compressed/head.S
 *  Copyright (C) 1999, 2001 Axis Communications AB
 *  Code that sets up the DRAM registers, calls the
 *  decompressor to unpack the piggybacked kernel, and jumps.

#include <linux/config.h>
#include <asm/sv_addr_ag.h>

#define RAM_INIT_MAGIC 0x56902387
	;; Exported symbols
	.globl	_input_data

;; We need to initialze DRAM registers before we start using the DRAM
	cmp.d	RAM_INIT_MAGIC, r8	; Already initialized?
	beq	dram_init_finished
#include "../../lib/dram_init.S"
	;; Initiate the PA and PB ports

	move.b   r0, [R_PORT_PA_DATA]

	move.b   r0, [R_PORT_PA_DIR]

	move.b   r0, [R_PORT_PB_DATA]

	move.b   r0, [R_PORT_PB_DIR]

	;; Setup the stack to a suitably high address.
	;; We assume 8 MB is the minimum DRAM in an eLinux
	;; product and put the sp at the top for now.

	move.d	0x40800000, sp
				; #### This JUMP will crash Etrax! JSR do the same #####.
	jump aa
aa:	move.d 0x4fffff,r0				; Frequency of led flashing  #######
bb:	bne bb
	subq 1,r0
	move.b [R_PORT_PA_READ],r0
	move.d 4,r1
	xor r1,r0					; Flash led  ########
	move.b r0,[R_PORT_PA_DATA]
	ba aa
	;; Figure out where the compressed piggyback image is
	;; in the flash (since we wont try to copy it to DRAM
	;; before unpacking). It is at _edata, but in flash.
	;; Use (_edata - basse) as offset to the current PC.

basse:	move.d	pc, r5
	and.d	0x7fffffff, r5	; strip any non-cache bit
	subq	2, r5		; compensate for the move.d pc instr
	move.d	r5, r0		; save for later - flash address of 'basse'
	add.d	_edata, r5
	sub.d	basse, r5	; r5 = flash address of '_edata'
	;; Copy text+data to DRAM
	move.d	basse, r1	; destination
	move.d	_edata, r2	; end destination
1:	move.w	[r0+], r3
	move.w	r3, [r1+]
	cmp.d	r2, r1
	bcs	1b

	move.d	r5, [_input_data] ; for the decompressor

	;; Clear the decompressors BSS (between _edata and _end)
	moveq	0, r0
	move.d	_edata, r1
	move.d	_end, r2
1:	move.w	r0, [r1+]
	cmp.d	r2, r1
	bcs	1b
	;; Do the decompression and save compressed size in _inptr

	jsr	_decompress_kernel
	;; Put start address of root partition in r9 so the kernel can use it
	;; when mounting from flash

	move.d	[_input_data], r9	; flash address of compressed kernel
	add.d	[_inptr], r9		; size of compressed kernel
	;; Enter the decompressed kernel
	move.d	RAM_INIT_MAGIC, r8	; Tell kernel that DRAM is initialized
	jump	0x40004000	; kernel is linked to this address

	.dword	0		; used by the decompressor

#include "../../lib/hw_settings.S"