| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | /* | 
					
						
							|  |  |  |  *  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. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define ASSEMBLER_MACROS_ONLY | 
					
						
							| 
									
										
										
										
											2008-10-21 17:45:58 +02:00
										 |  |  | #include <arch/sv_addr_ag.h> | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | #define RAM_INIT_MAGIC 0x56902387 | 
					
						
							| 
									
										
										
										
											2005-07-27 11:44:38 -07:00
										 |  |  | #define COMMAND_LINE_MAGIC 0x87109563 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	;; Exported symbols
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-29 23:15:19 +02:00
										 |  |  | 	.globl	input_data
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	.text | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	nop | 
					
						
							|  |  |  | 	di | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ;; We need to initialze DRAM registers before we start using the DRAM
 | 
					
						
							| 
									
										
										
										
											2008-06-29 23:15:19 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	cmp.d	RAM_INIT_MAGIC, $r8	; Already initialized?
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	beq	dram_init_finished | 
					
						
							|  |  |  | 	nop | 
					
						
							| 
									
										
										
										
											2008-06-29 23:15:19 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-21 11:44:57 +02:00
										 |  |  | #include "../../arch-v10/lib/dram_init.S" | 
					
						
							| 
									
										
										
										
											2008-06-29 23:15:19 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | dram_init_finished: | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	;; Initiate the PA and PB ports
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-29 23:15:19 +02:00
										 |  |  | 	move.b   CONFIG_ETRAX_DEF_R_PORT_PA_DATA, $r0 | 
					
						
							|  |  |  | 	move.b   $r0, [R_PORT_PA_DATA] | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-29 23:15:19 +02:00
										 |  |  | 	move.b   CONFIG_ETRAX_DEF_R_PORT_PA_DIR, $r0 | 
					
						
							|  |  |  | 	move.b   $r0, [R_PORT_PA_DIR] | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-29 23:15:19 +02:00
										 |  |  | 	move.b   CONFIG_ETRAX_DEF_R_PORT_PB_DATA, $r0 | 
					
						
							|  |  |  | 	move.b   $r0, [R_PORT_PB_DATA] | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-29 23:15:19 +02:00
										 |  |  | 	move.b   CONFIG_ETRAX_DEF_R_PORT_PB_DIR, $r0 | 
					
						
							|  |  |  | 	move.b   $r0, [R_PORT_PB_DIR] | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	;; 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.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-29 23:15:19 +02:00
										 |  |  | 	move.d	0x40800000, $sp | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	;; 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.
 | 
					
						
							| 
									
										
										
										
											2008-06-29 23:15:19 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 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'
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	;; Copy text+data to DRAM
 | 
					
						
							| 
									
										
										
										
											2008-06-29 23:15:19 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	move.d	basse, $r1	; destination
 | 
					
						
							|  |  |  | 	move.d	_edata, $r2	; end destination
 | 
					
						
							|  |  |  | 1:	move.w	[$r0+], $r3 | 
					
						
							|  |  |  | 	move.w	$r3, [$r1+] | 
					
						
							|  |  |  | 	cmp.d	$r2, $r1 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	bcs	1b | 
					
						
							|  |  |  | 	nop | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-29 23:15:19 +02:00
										 |  |  | 	move.d	$r5, [input_data] ; for the decompressor
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	;; Clear the decompressors BSS (between _edata and _end)
 | 
					
						
							| 
									
										
										
										
											2008-06-29 23:15:19 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	moveq	0, $r0 | 
					
						
							|  |  |  | 	move.d	_edata, $r1 | 
					
						
							|  |  |  | 	move.d	_end, $r2 | 
					
						
							|  |  |  | 1:	move.w	$r0, [$r1+] | 
					
						
							|  |  |  | 	cmp.d	$r2, $r1 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	bcs	1b | 
					
						
							|  |  |  | 	nop | 
					
						
							| 
									
										
										
										
											2005-07-27 11:44:38 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	;;  Save command line magic and address.
 | 
					
						
							|  |  |  | 	move.d	_cmd_line_magic, $r12 | 
					
						
							|  |  |  | 	move.d  $r10, [$r12] | 
					
						
							|  |  |  | 	move.d	_cmd_line_addr, $r12 | 
					
						
							|  |  |  | 	move.d  $r11, [$r12] | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-29 23:15:19 +02:00
										 |  |  | 	;; 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
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	;; when mounting from flash
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-29 23:15:19 +02:00
										 |  |  | 	move.d	[input_data], $r9	; flash address of compressed kernel
 | 
					
						
							|  |  |  | 	add.d	[inptr], $r9		; size of compressed kernel
 | 
					
						
							| 
									
										
										
										
											2005-07-27 11:44:38 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	;; Restore command line magic and address.
 | 
					
						
							|  |  |  | 	move.d  _cmd_line_magic, $r10 | 
					
						
							|  |  |  | 	move.d  [$r10], $r10 | 
					
						
							|  |  |  | 	move.d  _cmd_line_addr, $r11 | 
					
						
							|  |  |  | 	move.d  [$r11], $r11 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	;; Enter the decompressed kernel
 | 
					
						
							| 
									
										
										
										
											2008-06-29 23:15:19 +02:00
										 |  |  | 	move.d	RAM_INIT_MAGIC, $r8	; Tell kernel that DRAM is initialized
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	jump	0x40004000	; kernel is linked to this address
 | 
					
						
							| 
									
										
										
										
											2008-06-29 23:15:19 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	.data | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-29 23:15:19 +02:00
										 |  |  | input_data: | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	.dword	0		; used by the decompressor
 | 
					
						
							| 
									
										
										
										
											2005-07-27 11:44:38 -07:00
										 |  |  | _cmd_line_magic: | 
					
						
							|  |  |  | 	.dword 0
 | 
					
						
							|  |  |  | _cmd_line_addr: | 
					
						
							|  |  |  | 	.dword 0
 | 
					
						
							| 
									
										
										
										
											2009-04-21 11:44:57 +02:00
										 |  |  | #include "../../arch-v10/lib/hw_settings.S" |