Hi folks, I've had a very quick look at this pthreads stuff - attached is a preliminary patch to enable pthread support for microblaze. I've built it against the user/threaddemos, and it seems to work (well it produces some output and doesn't crash the kernel, so that's good enough for me right now!). (Greg - would you please apply these to your local tree for inclusion in the next uClinux-dist?) Installation: ------------- From the uClinux-dist directory: (1) extract the tar.gz $ tar -xzf microblaze-pthreads.tar.gz (2) apply the patch $ patch -p0 < microblaze-pthreads.patch (3) delete the old uClibc config: $ rm uClibc/.config (4) make menuconfig, then simply exit and save. (5) make clean; make dep; make In the user/vendor configuration under misc. applications there is a threaddemo option, enable that if you want to test it. Badri - you should look at the Makefiles in the user/threaddemos directory to get ideas on how to build threaded applications. Cheers, John
Index: uClibc/extra/Configs/Config.microblaze
===================================================================
RCS file: /var/cvs/uClinux-dist/uClibc/extra/Configs/Config.microblaze,v
retrieving revision 1.1.1.1
diff -u -b -B -w -p -r1.1.1.1 Config.microblaze
--- uClibc/extra/Configs/Config.microblaze 2003/09/02 05:13:59 1.1.1.1
+++ uClibc/extra/Configs/Config.microblaze 2003/12/01 01:25:48
@@ -30,7 +30,7 @@ config ARCH_HAS_NO_FPU
config ARCH_HAS_C_SYMBOL_PREFIX
bool
- default y
+ default n
config HAVE_NO_PIC
bool
Index: uClibc/extra/Configs/Config.microblaze.default
===================================================================
RCS file: /var/cvs/uClinux-dist/uClibc/extra/Configs/Config.microblaze.default,v
retrieving revision 1.1.1.1
diff -u -b -B -w -p -r1.1.1.1 Config.microblaze.default
--- uClibc/extra/Configs/Config.microblaze.default 2003/09/02 05:13:59 1.1.1.1
+++ uClibc/extra/Configs/Config.microblaze.default 2003/12/01 01:25:48
@@ -8,7 +8,7 @@
HAVE_ELF=y
ARCH_HAS_NO_MMU=y
ARCH_HAS_NO_FPU=y
-ARCH_HAS_C_SYMBOL_PREFIX=y
+# ARCH_HAS_C_SYMBOL_PREFIX=y
HAVE_NO_PIC=y
CROSS="mb-"
UCLIBC_HAS_FLOATS=y
@@ -18,12 +18,12 @@ WARNINGS="-Wall"
KERNEL_SOURCE="/home/jwilliam/uClinux-dist/linux-2.4.x"
UCLIBC_UCLINUX_BROKEN_MUNMAP=y
EXCLUDE_BRK=y
-C_SYMBOL_PREFIX="_"
+C_SYMBOL_PREFIX=""
#
# General Library Settings
#
-# UCLIBC_HAS_THREADS is not set
+UCLIBC_HAS_THREADS=y
UCLIBC_HAS_LFS=y
MALLOC=y
# MALLOC_930716 is not set
Index: uClibc/libc/sysdeps/linux/microblaze/__longjmp.S
===================================================================
RCS file: /var/cvs/uClinux-dist/uClibc/libc/sysdeps/linux/microblaze/__longjmp.S,v
retrieving revision 1.1.1.1
diff -u -b -B -w -p -r1.1.1.1 __longjmp.S
--- uClibc/libc/sysdeps/linux/microblaze/__longjmp.S 2003/09/02 05:14:27 1.1.1.1
+++ uClibc/libc/sysdeps/linux/microblaze/__longjmp.S 2003/12/01 01:25:51
@@ -23,19 +23,21 @@ C_ENTRY(__longjmp):
/* load registers from memory to r5 (arg0)*/
lwi r1, r5, 0
lwi r15, r5, 4
- lwi r18, r5, 8
- lwi r19, r5, 12
- lwi r20, r5, 16
- lwi r21, r5, 20
- lwi r22, r5, 24
- lwi r23, r5, 28
- lwi r24, r5, 32
- lwi r25, r5, 36
- lwi r26, r5, 40
- lwi r27, r5, 44
- lwi r28, r5, 48
- lwi r29, r5, 52
- lwi r30, r5, 56
+ lwi r2, r5, 8
+ lwi r13, r5, 12
+ lwi r18, r5, 16
+ lwi r19, r5, 20
+ lwi r20, r5, 24
+ lwi r21, r5, 28
+ lwi r22, r5, 32
+ lwi r23, r5, 36
+ lwi r24, r5, 40
+ lwi r25, r5, 44
+ lwi r26, r5, 48
+ lwi r27, r5, 52
+ lwi r28, r5, 56
+ lwi r29, r5, 60
+ lwi r30, r5, 64
addi r3, r0, 1 // return val
rtsd r15, 8 // normal return
Index: uClibc/libc/sysdeps/linux/microblaze/clone.c
===================================================================
RCS file: /var/cvs/uClinux-dist/uClibc/libc/sysdeps/linux/microblaze/clone.c,v
retrieving revision 1.1.1.1
diff -u -b -B -w -p -r1.1.1.1 clone.c
--- uClibc/libc/sysdeps/linux/microblaze/clone.c 2003/09/02 05:14:28 1.1.1.1
+++ uClibc/libc/sysdeps/linux/microblaze/clone.c 2003/12/01 01:25:51
@@ -31,7 +31,7 @@ clone (int (*fn)(void *arg), void *child
arg0 = flags;
arg1 = (unsigned long)child_stack;
syscall = __NR_clone;
- asm volatile ("bralid r17, trap;nop;"
+ asm volatile ("bralid r17, 0x08;nop;"
: "=r" (rval), "=r" (syscall)
: "1" (syscall), "r" (arg0), "r" (arg1)
: SYSCALL_CLOBBERS);
@@ -41,7 +41,7 @@ clone (int (*fn)(void *arg), void *child
{
arg0 = (*fn) (arg);
syscall = __NR_exit;
- asm volatile ("bralid r17, trap;nop;"
+ asm volatile ("bralid r17, 0x08;nop;"
: "=r" (rval), "=r" (syscall)
: "1" (syscall), "r" (arg0)
: SYSCALL_CLOBBERS);
Index: uClibc/libc/sysdeps/linux/microblaze/setjmp.S
===================================================================
RCS file: /var/cvs/uClinux-dist/uClibc/libc/sysdeps/linux/microblaze/setjmp.S,v
retrieving revision 1.1.1.1
diff -u -b -B -w -p -r1.1.1.1 setjmp.S
--- uClibc/libc/sysdeps/linux/microblaze/setjmp.S 2003/05/23 00:38:20 1.1.1.1
+++ uClibc/libc/sysdeps/linux/microblaze/setjmp.S 2003/12/01 01:25:51
@@ -33,19 +33,22 @@ C_SYMBOL_NAME(__sigsetjmp):
/* Save registers relative to r5 (arg0)*/
swi r1, r5, 0 /* stack pointer */
swi r15, r5, 4 /* link register */
- swi r18, r5, 8 /* assembler temp */
- swi r19, r5, 12 /* now call-preserved regs */
- swi r20, r5, 16
- swi r21, r5, 20
- swi r22, r5, 24
- swi r23, r5, 28
- swi r24, r5, 32
- swi r25, r5, 36
- swi r26, r5, 40
- swi r27, r5, 44
- swi r28, r5, 48
- swi r29, r5, 52
- swi r30, r5, 56
+ swi r2, r5, 8 /* SDA and SDA2 ptrs */
+ swi r13, r5, 12
+ swi r18, r5, 16 /* assembler temp */
+ swi r19, r5, 20 /* now call-preserved regs */
+ swi r20, r5, 24
+ swi r21, r5, 28
+ swi r22, r5, 32
+ swi r23, r5, 36
+ swi r24, r5, 40
+ swi r25, r5, 44
+ swi r26, r5, 48
+ swi r27, r5, 52
+ swi r28, r5, 56
+ swi r29, r5, 60
+ swi r30, r5, 64
+ swi r31, r5, 68
/* Make a tail call to __sigjmp_save; it takes the same args. */
braid C_SYMBOL_NAME(__sigjmp_save)
Index: uClibc/libc/sysdeps/linux/microblaze/syscall.c
===================================================================
RCS file: /var/cvs/uClinux-dist/uClibc/libc/sysdeps/linux/microblaze/syscall.c,v
retrieving revision 1.1.1.2
diff -u -b -B -w -p -r1.1.1.2 syscall.c
--- uClibc/libc/sysdeps/linux/microblaze/syscall.c 2003/09/02 05:14:28 1.1.1.2
+++ uClibc/libc/sysdeps/linux/microblaze/syscall.c 2003/12/01 01:25:51
@@ -36,16 +36,10 @@ syscall (long num, arg_t a1, arg_t a2, a
register unsigned long ret asm (SYSCALL_RET);
unsigned long ret_sav;
- *((unsigned long *)0xFFFF4004) = (unsigned int)('+');
- asm ("brlid r17, 08x; nop;"
+ asm ("bralid r17, 0x08; nop;"
: "=r" (ret)
: "r" (syscall), "r" (a), "r" (b), "r" (c), "r" (d), "r" (e), "r" (f)
: SYSCALL_CLOBBERS);
- ret_sav=ret;
- *((unsigned long *)0xFFFF4004) = (unsigned int)('-');
-
-
-
__syscall_return (long, ret);
}
Index: uClibc/libc/sysdeps/linux/microblaze/bits/setjmp.h
===================================================================
RCS file: /var/cvs/uClinux-dist/uClibc/libc/sysdeps/linux/microblaze/bits/setjmp.h,v
retrieving revision 1.1.1.1
diff -u -b -B -w -p -r1.1.1.1 setjmp.h
--- uClibc/libc/sysdeps/linux/microblaze/bits/setjmp.h 2003/05/23 00:38:20 1.1.1.1
+++ uClibc/libc/sysdeps/linux/microblaze/bits/setjmp.h 2003/12/01 01:25:51
@@ -25,12 +25,16 @@ typedef struct
/* Link pointer. */
void *__lp;
- /* Callee-saved registers r18-r30. */
- int __regs[13];
+ /* SDA pointers */
+ void *__SDA;
+ void *__SDA2;
+
+ /* Callee-saved registers r18-r31. */
+ int __regs[14];
} __jmp_buf[1];
#endif
-#define JB_SIZE (4 * 15)
+#define JB_SIZE (4 * 18)
/* Test if longjmp to JMPBUF would unwind the frame
containing a local variable at ADDRESS. */
Index: uClibc/libc/sysdeps/linux/microblaze/sys/ptrace.h
===================================================================
RCS file: /var/cvs/uClinux-dist/uClibc/libc/sysdeps/linux/microblaze/sys/ptrace.h,v
retrieving revision 1.1.1.1
diff -u -b -B -w -p -r1.1.1.1 ptrace.h
--- uClibc/libc/sysdeps/linux/microblaze/sys/ptrace.h 2003/05/23 00:38:20 1.1.1.1
+++ uClibc/libc/sysdeps/linux/microblaze/sys/ptrace.h 2003/12/01 01:25:51
@@ -1,5 +1,5 @@
/* `ptrace' debugger support interface. Linux/microblaze version.
- Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -65,12 +65,16 @@ enum __ptrace_request
PTRACE_KILL = 8,
#define PT_KILL PTRACE_KILL
+ /* Single step the process. */
+ PTRACE_SINGLESTEP = 9,
+#define PT_STEP PTRACE_SINGLESTEP
+
/* Attach to a process that is already running. */
- PTRACE_ATTACH = 0x10,
+ PTRACE_ATTACH = 16,
#define PT_ATTACH PTRACE_ATTACH
/* Detach from a process attached to with PTRACE_ATTACH. */
- PTRACE_DETACH = 0x11,
+ PTRACE_DETACH = 17,
#define PT_DETACH PTRACE_DETACH
/* Continue and stop at the next (return from) syscall. */
Index: vendors/Insight/XC2V1K_Microblaze/config.uClibc
===================================================================
RCS file: /var/cvs/uClinux-dist/vendors/Insight/XC2V1K_Microblaze/config.uClibc,v
retrieving revision 1.1.1.2
diff -u -b -B -w -p -r1.1.1.2 config.uClibc
--- vendors/Insight/XC2V1K_Microblaze/config.uClibc 2003/09/02 05:26:10 1.1.1.2
+++ vendors/Insight/XC2V1K_Microblaze/config.uClibc 2003/12/01 01:42:33
@@ -8,7 +8,7 @@
HAVE_ELF=y
ARCH_HAS_NO_MMU=y
ARCH_HAS_NO_FPU=y
-ARCH_HAS_C_SYMBOL_PREFIX=y
+# ARCH_HAS_C_SYMBOL_PREFIX is not set
HAVE_NO_PIC=y
CROSS="mb-"
UCLIBC_HAS_FLOATS=y
@@ -18,14 +18,14 @@ WARNINGS="-Wall"
KERNEL_SOURCE="$(ROOTDIR)/$(LINUXDIR)"
UCLIBC_UCLINUX_BROKEN_MUNMAP=y
EXCLUDE_BRK=y
-C_SYMBOL_PREFIX="_"
+C_SYMBOL_PREFIX=""
HAVE_DOT_CONFIG=y
#
# General Library Settings
#
# UCLIBC_CTOR_DTOR is not set
-# UCLIBC_HAS_THREADS is not set
+UCLIBC_HAS_THREADS=y
UCLIBC_HAS_LFS=y
MALLOC=y
# MALLOC_930716 is not set
Attachment:
microblaze-pthreads.tar.gz
Description: GNU Zip compressed data