patch-2.4.5 linux/arch/cris/boot/rescue/head.S

Next file: linux/arch/cris/boot/rescue/kimagerescue.S
Previous file: linux/arch/cris/boot/compressed/misc.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.4/linux/arch/cris/boot/rescue/head.S linux/arch/cris/boot/rescue/head.S
@@ -1,66 +1,67 @@
-	;; $Id: head.S,v 1.3 2001/02/14 16:57:25 larsv Exp $
-	;; 
-	;; Rescue code, made to reside at the beginning of the
-	;; flash-memory. when it starts, it checks a partition
-	;; table at the first sector after the rescue sector.
-	;; the partition table was generated by the product builder
-	;; script and contains offsets, lengths, types and checksums
-	;; for each partition that this code should check.
-	;;
-	;; If any of the checksums fail, we assume the flash is so
-	;; corrupt that we cant use it to boot into the ftp flash
-	;; loader, and instead we initialize the serial port to
-	;; receive a flash-loader and new flash image. we dont include
-	;; any flash code here, but just accept a certain amount of
-	;; bytes from the serial port and jump into it. the downloaded
-	;; code is put in the cache.
-	;;
-	;; The partitiontable is designed so that it is transparent to
-	;; code execution - it has a relative branch opcode in the
-	;; beginning that jumps over it. each entry contains extra
-	;; data so we can add stuff later.
-	;;
-	;; Partition table format:
-	;;
-	;;     Code transparency:
-	;; 
-	;;     2 bytes    [opcode 'nop']
-	;;     2 bytes    [opcode 'di']
-	;;     4 bytes    [opcode 'ba <offset>', 8-bit or 16-bit version]
-	;;     2 bytes    [opcode 'nop', delay slot]
-	;;
-	;;     Table validation (at +10):	
-	;; 
-	;;     2 bytes    [magic/version word for partitiontable - 0xef, 0xbe]
-	;;     2 bytes    [length of all entries plus the end marker]
-	;;     4 bytes    [checksum for the partitiontable itself]
-	;;
-	;;     Entries, each with the following format, last has offset -1:	
-	;;    
-	;;        4 bytes    [offset in bytes, from start of flash]
-	;;        4 bytes    [length in bytes of partition]
-	;;        4 bytes    [checksum, simple longword sum]
-	;;        2 bytes    [partition type]
-	;;        2 bytes    [flags, only bit 0 used, ro/rw = 1/0]
-	;;        16 bytes   [reserved for future use]
-	;;
-	;;     End marker
-	;;
-	;;        4 bytes    [-1]
-	;; 
-	;;	 10 bytes    [0, padding]
-	;; 
-	;; Bit 0 in flags signifies RW or RO. The rescue code only bothers
-	;; to check the checksum for RO partitions, since the others will
-	;; change its data without updating the checksums. A 1 in bit 0
-	;; means RO, 0 means RW. That way, it is possible to set a partition
-	;; in RO mode initially, and later mark it as RW, since you can always
-	;; write 0's to the flash.
-	;;
-	;; During the wait for serial input, the status LED will flash so the
-	;; user knows something went wrong.
-	;; 
-	;; Copyright (C) 1999 Axis Communications AB
+/* $Id: head.S,v 1.7 2001/04/18 12:05:07 bjornw Exp $
+ * 
+ * Rescue code, made to reside at the beginning of the
+ * flash-memory. when it starts, it checks a partition
+ * table at the first sector after the rescue sector.
+ * the partition table was generated by the product builder
+ * script and contains offsets, lengths, types and checksums
+ * for each partition that this code should check.
+ *
+ * If any of the checksums fail, we assume the flash is so
+ * corrupt that we cant use it to boot into the ftp flash
+ * loader, and instead we initialize the serial port to
+ * receive a flash-loader and new flash image. we dont include
+ * any flash code here, but just accept a certain amount of
+ * bytes from the serial port and jump into it. the downloaded
+ * code is put in the cache.
+ *
+ * The partitiontable is designed so that it is transparent to
+ * code execution - it has a relative branch opcode in the
+ * beginning that jumps over it. each entry contains extra
+ * data so we can add stuff later.
+ *
+ * Partition table format:
+ *
+ *     Code transparency:
+ * 
+ *     2 bytes    [opcode 'nop']
+ *     2 bytes    [opcode 'di']
+ *     4 bytes    [opcode 'ba <offset>', 8-bit or 16-bit version]
+ *     2 bytes    [opcode 'nop', delay slot]
+ *
+ *     Table validation (at +10):	
+ * 
+ *     2 bytes    [magic/version word for partitiontable - 0xef, 0xbe]
+ *     2 bytes    [length of all entries plus the end marker]
+ *     4 bytes    [checksum for the partitiontable itself]
+ *
+ *     Entries, each with the following format, last has offset -1:	
+ *    
+ *        4 bytes    [offset in bytes, from start of flash]
+ *        4 bytes    [length in bytes of partition]
+ *        4 bytes    [checksum, simple longword sum]
+ *        2 bytes    [partition type]
+ *        2 bytes    [flags, only bit 0 used, ro/rw = 1/0]
+ *        16 bytes   [reserved for future use]
+ *
+ *     End marker
+ *
+ *        4 bytes    [-1]
+ * 
+ *	 10 bytes    [0, padding]
+ * 
+ * Bit 0 in flags signifies RW or RO. The rescue code only bothers
+ * to check the checksum for RO partitions, since the others will
+ * change its data without updating the checksums. A 1 in bit 0
+ * means RO, 0 means RW. That way, it is possible to set a partition
+ * in RO mode initially, and later mark it as RW, since you can always
+ * write 0's to the flash.
+ *
+ * During the wait for serial input, the status LED will flash so the
+ * user knows something went wrong.
+ * 
+ * Copyright (C) 1999,2001 Axis Communications AB
+ */
 
 #include <linux/config.h>
 #define ASSEMBLER_MACROS_ONLY
@@ -69,7 +70,7 @@
 	;; The partitiontable is looked for at the first sector after the boot
 	;; sector. Sector size is 65536 bytes in all flashes we use.
 		
-#define PTABLE_START 0x10000
+#define PTABLE_START CONFIG_ETRAX_PTABLE_SECTOR
 #define PTABLE_MAGIC 0xbeef
 
 	;; The normal Etrax100 on-chip boot ROM does serial boot at 0x380000f0.
@@ -82,28 +83,28 @@
 #define CODE_START 0x40000000
 #define CODE_LENGTH 784
 
-#ifdef CONFIG_RESCUE_SER0
+#ifdef CONFIG_ETRAX_RESCUE_SER0
 #define SERXOFF R_SERIAL0_XOFF
 #define SERBAUD R_SERIAL0_BAUD
 #define SERRECC R_SERIAL0_REC_CTRL
 #define SERRDAT R_SERIAL0_REC_DATA
 #define SERSTAT R_SERIAL0_STATUS
 #endif
-#ifdef CONFIG_RESCUE_SER1
+#ifdef CONFIG_ETRAX_RESCUE_SER1
 #define SERXOFF R_SERIAL1_XOFF
 #define SERBAUD R_SERIAL1_BAUD
 #define SERRECC R_SERIAL1_REC_CTRL
 #define SERRDAT R_SERIAL1_REC_DATA
 #define SERSTAT R_SERIAL1_STATUS
 #endif
-#ifdef CONFIG_RESCUE_SER2
+#ifdef CONFIG_ETRAX_RESCUE_SER2
 #define SERXOFF R_SERIAL2_XOFF
 #define SERBAUD R_SERIAL2_BAUD
 #define SERRECC R_SERIAL2_REC_CTRL
 #define SERRDAT R_SERIAL2_REC_DATA
 #define SERSTAT R_SERIAL2_STATUS
 #endif	
-#ifdef CONFIG_RESCUE_SER3
+#ifdef CONFIG_ETRAX_RESCUE_SER3
 #define SERXOFF R_SERIAL3_XOFF
 #define SERBAUD R_SERIAL3_BAUD
 #define SERRECC R_SERIAL3_REC_CTRL
@@ -112,7 +113,8 @@
 #endif
 
 #define NOP_DI 0xf025050f
-	
+#define RAM_INIT_MAGIC 0x56902387
+		
 	.text
 	
 	;; This is the entry point of the rescue code
@@ -221,14 +223,14 @@
 	;; setup port PA and PB default initial directions and data
 	;; (so we can flash LEDs, and so that DTR and others are set)
 	
-	move.b	DEF_R_PORT_PA_DIR, r0
+	move.b	CONFIG_ETRAX_DEF_R_PORT_PA_DIR, r0
 	move.b	r0, [R_PORT_PA_DIR]
-	move.b	DEF_R_PORT_PA_DATA, r0
+	move.b	CONFIG_ETRAX_DEF_R_PORT_PA_DATA, r0
 	move.b	r0, [R_PORT_PA_DATA]
 	
-	move.b	DEF_R_PORT_PB_DIR, r0
+	move.b	CONFIG_ETRAX_DEF_R_PORT_PB_DIR, r0
 	move.b	r0, [R_PORT_PB_DIR]
-	move.b	DEF_R_PORT_PB_DATA, r0
+	move.b	CONFIG_ETRAX_DEF_R_PORT_PB_DATA, r0
 	move.b	r0, [R_PORT_PB_DATA]
 
 	;; setup the serial port at 115200 baud
@@ -250,10 +252,10 @@
 	addq	1, r1
 #ifndef CONFIG_ETRAX_NO_LEDS
 #ifdef CONFIG_ETRAX_PA_LEDS
-	move.b	DEF_R_PORT_PA_DATA, r2
+	move.b	CONFIG_ETRAX_DEF_R_PORT_PA_DATA, r2
 #endif
 #ifdef CONFIG_ETRAX_PB_LEDS
-	move.b	DEF_R_PORT_PB_DATA, r2
+	move.b	CONFIG_ETRAX_DEF_R_PORT_PB_DATA, r2
 #endif
 	move.d	(1 << CONFIG_ETRAX_LED1R) | (1 << CONFIG_ETRAX_LED2R), r0
 	btstq	16, r1
@@ -293,7 +295,8 @@
 	nop
 
 	;; jump into downloaded code
-	
+
+	move.d	RAM_INIT_MAGIC, r8	; Tell next product that DRAM is initialized
 	jump	CODE_START
 
 flash_ok:
@@ -303,7 +306,8 @@
 	bne	1f
 	nop
 	move.d	PTABLE_START, r7; otherwise use the ptable start
-1:	
+1:
+	move.d	RAM_INIT_MAGIC, r8	; Tell next product that DRAM is initialized
 	jump	r7		; boot!
 
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)