This is the mail archive of the newlib@sources.redhat.com mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Fwd: crt0.S: How to submit updates, what else to change etc.?]


Nick Clifton wrote:

Hi Toralf,



Just subscribed to this list...



Welcome to the wonderful world of newlib.




1. Where do I submit newlib patches?



To the newlib mailing list. (ie the one you are talking on now).


[ and so on ]

I thought I might as well give you an early version of the patch - see attachment. Hardly tested at all, and I don't know this assembler too well, so I've probably made some silly mistakes, but it should give an idea of what I'm trying to do.

- Toralf

--- ./newlib-1.12.0/newlib/libc/sys/arm/crt0.S.stackARM	Mon Nov 18 17:30:55 2002
+++ ./newlib-1.12.0/newlib/libc/sys/arm/crt0.S	Tue Mar 30 14:46:04 2004
@@ -43,7 +43,27 @@
 				/*  and small frames */
 #else
 	/*  Set up the stack pointer to a fixed value */
+	/*  Changes by toralf:
+	    - Allow linker script to provide stack via __stack symbol - see
+	      .Lstack defintion
+	    - Go through the individual modes, and set up sp for each of them.
+	      Loosely based on init.s from ARM/Motorola
+	      example code. */
+	ldr	r3, .Lstack
+	cmp	r3, #0
+	bne	.LC23
 	ldr	r3, .LC0
+.LC23:	
+	msr     CPSR_c, #0xD3	/* SVC mode, interrupts disabled */
+	mov 	sp, r3
+	sub	r3, r3, #6144	/* 6144 byte stack, like in example code */
+	msr     CPSR_c, #0xD2	/* IRQ mode, interrupts disabled */
+	mov	sp, r3
+	sub	r3, r3, #6144   /* Same as for SVC. Larger than example code */
+	msr     CPSR_c, #0xD1	/* FIRQ mode, interrupts disabled */
+	mov 	sp, r3
+	sub	r3, r3, #128
+	msr     CPSR_c, #0xD0	/* User mode, interrupts disabled */
 	mov 	sp, r3
 	/* Setup a default stack-limit in-case the code has been
 	   compiled with "-mapcs-stack-check".  Hard-wiring this value
@@ -78,6 +98,16 @@
 	
 	bl	FUNCTION (memset)
 #if !defined (ARM_RDP_MONITOR) && !defined (ARM_RDI_MONITOR)
+/* Changes by toralf: Taken from libgloss/m68k/crt0.S
+ * initialize target specific stuff. Only execute these
+ * functions it they exist.
+ */
+	ldr	r3, .Lswinit
+	cmp	r3, #0
+	blne	r3
+	ldr	r3, .Lhwinit
+	cmp	r3, #0
+	blne	r3
 	mov	r0, #0		/*  no arguments  */
 	mov	r1, #0		/*  no argv either */
 #else
@@ -233,8 +263,14 @@
 #ifdef __pe__
 	.word	0x800000
 #else
-/*	.word	0x80000	*/		/* Top of RAM on the PIE board.  */
+	.word	0x80000			/* Top of RAM on the PIE board.  */
 #endif
+.Lstack:
+	.word	__stack
+.Lhwinit:	
+	.word	FUNCTION (hardware_init_hook)
+.Lswinit:
+	.word	FUNCTION (software_init_hook)
 #endif
 #endif
 .LC1:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]