PERFORCE change 161647 for review

Arnar Mar Sig antab at FreeBSD.org
Wed May 6 04:32:13 UTC 2009


http://perforce.freebsd.org/chv.cgi?CH=161647

Change 161647 by antab at antab_farm on 2009/05/06 04:31:26

	* Start implementing syscalls
	* Build world with -fno-omit-frame-pointer to make debugging possible

Affected files ...

.. //depot/projects/avr32/src/lib/csu/avr32/crt1.c#3 edit
.. //depot/projects/avr32/src/lib/csu/avr32/crti.S#2 edit
.. //depot/projects/avr32/src/lib/csu/avr32/crtn.S#2 edit
.. //depot/projects/avr32/src/lib/libc/avr32/SYS.h#3 edit
.. //depot/projects/avr32/src/lib/libc/avr32/sys/Ovfork.S#2 edit
.. //depot/projects/avr32/src/lib/libc/avr32/sys/brk.S#2 edit
.. //depot/projects/avr32/src/lib/libc/avr32/sys/cerror.S#2 edit
.. //depot/projects/avr32/src/lib/libc/avr32/sys/pipe.S#2 edit
.. //depot/projects/avr32/src/lib/libc/avr32/sys/ptrace.S#2 edit
.. //depot/projects/avr32/src/lib/libc/avr32/sys/sbrk.S#2 edit
.. //depot/projects/avr32/src/share/mk/bsd.cpu.mk#5 edit

Differences ...

==== //depot/projects/avr32/src/lib/csu/avr32/crt1.c#3 (text+ko) ====

@@ -39,12 +39,6 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef lint
-#ifndef __GNUC__
-#error "GCC is needed to compile this file"
-#endif
-#endif /* lint */
-
 #include <stdlib.h>
 
 #include "libc_private.h"
@@ -57,11 +51,12 @@
 extern int _DYNAMIC;
 #pragma weak _DYNAMIC
 
+typedef void (*fptr)(void);
+
 extern void _fini(void);
 extern void _init(void);
 extern int main(int, char **, char **);
-extern void _start(int, char **, char **, struct ps_strings *,
-    const struct Struct_Obj_Entry *, void (*cleanup)(void));
+extern void _start(char *ap, struct ps_strings *, ...);
 
 #ifdef GCRT
 extern void _mcleanup(void);
@@ -75,11 +70,18 @@
 struct ps_strings *__ps_strings;
 
 void
-_start(int argc, char **argv, char **env, struct ps_strings *ps_strings,
-    const struct Struct_Obj_Entry *obj __unused, void (*cleanup)(void))
+_start(char *ap, struct ps_strings *ps_strings, ...)
 {
+	fptr cleanup;
+	int argc;
+	char **argv;
+	char **env;
 	const char *s;
 
+	//cleanup = get_rtld_cleanup();
+	argv = &ap;
+	argc = *(int *)(void *)(argv - 1);
+	env = argv + argc + 1;
 	environ = env;
 
 	if (argc > 0 && argv[0] != NULL) {
@@ -96,6 +98,7 @@
 		atexit(cleanup);
 	else
 		_init_tls();
+
 #ifdef GCRT
 	atexit(_mcleanup);
 #endif
@@ -104,7 +107,7 @@
 	monstartup(&eprol, &etext);
 #endif
 	_init();
-	exit( main(argc, argv, env) );
+	exit(main(argc, argv, env));
 }
 
 #ifdef GCRT

==== //depot/projects/avr32/src/lib/csu/avr32/crti.S#2 (text+ko) ====

@@ -2,15 +2,17 @@
 __FBSDID("$FreeBSD: $");
 
 .section .init,"ax",%progbits
-.align 4
-.globl _init
+.align 2
+.global _init
 .type _init,%function
 _init:
-	breakpoint
+	stm	--sp, r6,lr
+	/* gcc crti loads got, should we? */
 
 .section .fini,"ax",%progbits
-.align 4
-.globl _fini
+.align 2
+.global _fini
 .type _fini,%function
 _fini:
-	breakpoint
+	stm	--sp, r6,lr
+	/* gcc crti loads got, should we? */

==== //depot/projects/avr32/src/lib/csu/avr32/crtn.S#2 (text+ko) ====

@@ -2,7 +2,7 @@
 __FBSDID("$FreeBSD:  $");
 
 .section .init,"ax",%progbits
-	breakpoint
+	ldm	sp++, r6,pc
 
 .section .fini,"ax",%progbits
-	breakpoint
+	ldm	sp++, r6,pc

==== //depot/projects/avr32/src/lib/libc/avr32/SYS.h#3 (text+ko) ====

@@ -1,16 +1,18 @@
 #include <sys/syscall.h>
 #include <machine/asm.h>
 
-#define	RSYSCALL(x)													\
+#define	RSYSCALL(x)							\
 	PSEUDO(x)
 
-#define	PSEUDO(x)													\
-	ENTRY(__CONCAT(__sys_, x));										\
-	.weak _C_LABEL(x);												\
-	.set _C_LABEL(x), _C_LABEL(__CONCAT(__sys_,x));					\
-	.weak _C_LABEL(__CONCAT(_,x));									\
-	.set _C_LABEL(__CONCAT(_,x)),_C_LABEL(__CONCAT(__sys_,x));		\
-	SCALL(x);														\
-	retal	sp;														\
+#define	PSEUDO(x)							\
+	.text								;\
+	ENTRY(__CONCAT(__sys_, x))					;\
+	.weak _C_LABEL(x)						;\
+	.set _C_LABEL(x), _C_LABEL(__CONCAT(__sys_, x))			;\
+	.weak _C_LABEL(__CONCAT(_, x))					;\
+	.set _C_LABEL(__CONCAT(_, x)),_C_LABEL(__CONCAT(__sys_, x))	;\
+	SCALL(x)							;\
+	retcc	r12							;\
+	rjmp	_C_LABEL(cerror)					;\
 	END(__CONCAT(__sys_, x))
 

==== //depot/projects/avr32/src/lib/libc/avr32/sys/Ovfork.S#2 (text+ko) ====

@@ -36,10 +36,9 @@
  * r0 == pid of child in parent, r0 == pid of parent in child.
  * XXX: Finish implementing
  */
-	.text
-	.align	0
-
+.text
 ENTRY(vfork)
 	breakpoint
 	SCALL(vfork)
 	retal	sp
+END(vfork)

==== //depot/projects/avr32/src/lib/libc/avr32/sys/brk.S#2 (text+ko) ====

@@ -40,7 +40,9 @@
 
 
 /* XXX: This needs work */
+.text
 ENTRY(brk)
 	breakpoint
 	SCALL(break)
-	retal	sp
+	retal	r11
+END(brk)

==== //depot/projects/avr32/src/lib/libc/avr32/sys/cerror.S#2 (text+ko) ====

@@ -36,14 +36,17 @@
 .global	_C_LABEL(__error)
 .type	_C_LABEL(__error), %function
 
-.data
-_C_LABEL(minbrk):
-	.word	_C_LABEL(_end)
-_C_LABEL(curbrk):
-	.word	_C_LABEL(_end)
+/**
+ * r12:	errno value to safe, set when returning from SCALL()
+ */
+.text
+ENTRY(cerror)
+	stm	--sp, r6,r7,lr		/* Create call frame and save r6 */
+	mov	r7, sp			/* Set framepointer */
+	mov	r6, r12			/* Save r12 (errno) */
 
-
-ENTRY(cerror)
-	breakpoint
-	/* This need work... */
-	retal	sp
+	call	_C_LABEL(__error)	/* Call __error() to get pointer to errno */
+	st.w	r12, r6			/* Store errno */
+	mov	r12, -1			/* Return -1 */
+	ldm	sp++, r6,r7,pc		/* Return */
+END(cerror)

==== //depot/projects/avr32/src/lib/libc/avr32/sys/pipe.S#2 (text+ko) ====

@@ -28,7 +28,9 @@
 __FBSDID("$FreeBSD: $");
 #include "SYS.h"
 
+.text
 ENTRY(pipe)
 	breakpoint
 	SCALL(pipe)
 	retal	sp
+END(pipe)

==== //depot/projects/avr32/src/lib/libc/avr32/sys/ptrace.S#2 (text+ko) ====

@@ -28,7 +28,9 @@
 __FBSDID("$FreeBSD: $");
 #include "SYS.h"
 
+.text
 ENTRY(ptrace)
 	breakpoint
 	SCALL(ptrace)
 	retal	sp
+END(ptrace)

==== //depot/projects/avr32/src/lib/libc/avr32/sys/sbrk.S#2 (text+ko) ====

@@ -35,8 +35,39 @@
 _C_LABEL(__curbrk):
 	.word	_C_LABEL(_end)
 
-/* XXX: This need work */
+/*
+ * r10:	new curbrk
+ * r9:	old curbrk
+ * r8:	Pointer to curbrk
+ */
+.text
 ENTRY(sbrk)
-	breakpoint
-	SCALL(break)
-	retal	sp
+	stm	--sp, r7,lr		/* Create call frame amd save r5,r6 */
+
+	lddpc	r8, sbrk_curbrk		/* Pointer to curbrk */
+	ld.w	r9, r8			/* Load old curbrk */
+	cp.w	r12, 0			/* sbrk(0) ? */
+	breq	sbrk_return		/* yes, just return curbrk */
+
+	add	r10, r12, r9		/* Calculate new break, hold in r10 */
+	mov	r12, r10
+	SCALL(break)			/* Do syscall, r12 and r11 hold return values */
+	cp.w	r12, 0			/* Error from syscall? */
+	brne	sbrk_error		/* Yes */
+
+	st.w	r8, r10			/* Save new curbrk */
+	mov	r12, r9			/* return old curbrk */
+	ldm	sp++, r7,pc		/* return */
+
+sbrk_error:
+	call	_C_LABEL(cerror)	/* Call cerror(errno) to safe errno */
+	mov	r12, -1			/* Return -1 */
+	ldm	sp++, r7,pc		/* Return */
+
+sbrk_return:
+	mov	r12, r9			/* Return curbrk */
+	ldm	sp++, r7,pc		/* Return */
+
+sbrk_curbrk:
+	.word	_C_LABEL(__curbrk)
+END(sbrk)

==== //depot/projects/avr32/src/share/mk/bsd.cpu.mk#5 (text+ko) ====

@@ -202,6 +202,11 @@
 LD += -EB
 .endif
 
+.if ${MACHINE_ARCH} == "avr32"
+# XXX: Needed for debugging
+CFLAGS += -fno-omit-frame-pointer
+.endif
+
 .if ${MACHINE_ARCH} == "mips" 
 . if defined(TARGET_BIG_ENDIAN)
 CFLAGS += -EB


More information about the p4-projects mailing list