afs-linux-s390-updates-20010305
authorAdam Thornton <adam@sinenomine.net>
Mon, 5 Mar 2001 16:34:32 +0000 (16:34 +0000)
committerDerrick Brashear <shadow@dementia.org>
Mon, 5 Mar 2001 16:34:32 +0000 (16:34 +0000)
Updates for Linux s/390 AFS port

src/config/Makefile.s390_linux22
src/libafs/MakefileProto.LINUX
src/lwp/Makefile
src/lwp/lwp.c
src/lwp/preempt.c
src/lwp/process.c
src/lwp/process.s

index a8ee3b6..2c213bc 100644 (file)
@@ -15,10 +15,11 @@ LINUX_VERS = 2.2.16
 #
 # compilation and link editor flags
 DBG=-g
-OPTMZ=-O2
-PAM_CFLAGS = -O2 -Dlinux -DLINUX_PAM -fPIC
+OPTMZ=-O
+#PAM_CFLAGS = -O2 -Dlinux -DLINUX_PAM -fPIC
+PAM_CFLAGS= -O -Dlinux -DLINUX_PAM -fPIC
 # Put -O2 here to _ensure_ all Makefiles pick it up.
-XCFLAGS= -O2
+XCFLAGS= -O -g
 MT_CFLAGS=-DAFS_PTHREAD_ENV -pthread -D_REENTRANT ${XCFLAGS}
 XLDFLAGS=
 SHARE_LDFLAGS = -shared -Xlinker -x
index b274a32..b3d3e9f 100644 (file)
@@ -43,8 +43,7 @@ CCFLAGS =   -O2 -fomit-frame-pointer \
 DEFINES = -D__KERNEL__  -DCPU=586 -DKERNEL -D_KERNEL -DMODULE ${SMP_DEF}
 <s390_linux22 s390_linux24>
 CCFLAGS =   -O2 -fomit-frame-pointer -fno-strength-reduce \
-       -fno-strict-aliasing -fsigned-char -pipe \
-       -fno-builtin
+       -fno-strict-aliasing -fsigned-char 
 DEFINES = -D__KERNEL__  -D__s390__ -DKERNEL -D_KERNEL -DMODULE ${SMP_DEF}
 <sparc_linux22 sparc_linux24>
 LD = ld -m elf32_sparc
index 5d3c72c..4111dc4 100644 (file)
@@ -66,6 +66,10 @@ process.o    : process.s process.c
                                        $(CC) -c -I${SRCDIR}include -KPIC -G0  process.s;; \
                                sgi_61 | sgi_62 | sgi_63 ) \
                                        $(CC) -c ${XCFLAGS} -I${SRCDIR}include -KPIC -G0  process.s;; \
+                               s390*) \
+                                       /lib/cpp -P -I${SRCDIR}include process.s >process.ss; \
+                                       ${AS} -ahlns process.ss -o process.o >process.lst; \
+                                       rm process.ss ;; \
                                hp* | *_linux* | sgi_64 | sgi_65) \
                                        ${CC} ${CFLAGS} -c process.c;; \
                                ncrx86_*) \
index 2c8358e..a70dfa6 100644 (file)
@@ -38,6 +38,8 @@ extern char* getenv();
 #ifdef AFS_OSF_ENV
 extern void *malloc(int size);
 extern void *realloc(void *ptr, int size);
+#endif
+#if defined(AFS_OSF_ENV) || defined(AFS_LINUX20_ENV)
 extern int PRE_Block;  /* from preempt.c */
 #else
 extern char PRE_Block; /* from preempt.c */
@@ -56,6 +58,14 @@ extern char PRE_Block;       /* from preempt.c */
 
 #ifdef __hp9000s800
 #define MINFRAME 128
+#define STACK_ALIGN 8
+#else
+#ifdef __s390__
+#define MINFRAME    96
+#define STACK_ALIGN 8
+#else
+#define STACK_ALIGN 4
+#endif
 #endif
 
 /* Debugging macro */
@@ -269,11 +279,7 @@ int LWP_CreateProcess(ep, stacksize, priority, parm, name, pid)
        if (stacksize < MINSTACK)
            stacksize = 1000;
        else
-#ifdef __hp9000s800
-           stacksize = 8 * ((stacksize+7) / 8);
-#else
-           stacksize = 4 * ((stacksize+3) / 4);
-#endif
+           stacksize = STACK_ALIGN * ((stacksize+STACK_ALIGN-1) / STACK_ALIGN);
 #ifdef AFS_AIX32_ENV
        if (!stackptr) {
            /*
@@ -347,10 +353,15 @@ int LWP_CreateProcess(ep, stacksize, priority, parm, name, pid)
                    stackptr+stacksize-0x40); /* lomgjmp does something
                                                 with %fp + 0x38 */
 #else
+#if defined(AFS_S390_LINUX20_ENV)
+       savecontext(Create_Process_Part2, &temp2->context,
+                   stackptr+stacksize-MINFRAME);
+#else /* !AFS_S390_LINUX20_ENV */
        savecontext(Create_Process_Part2, &temp2->context,
                    stackptr+stacksize-sizeof(void *));
-#endif
-#endif
+#endif /* AFS_S390_LINUX20_ENV */
+#endif /* AFS_SPARC64_LINUX20_ENV || AFS_SPARC_LINUX20_ENV */
+#endif /* AFS_SGI62_ENV */
 #endif
        /* End of gross hack */
 
@@ -397,11 +408,7 @@ int LWP_CreateProcess2(ep, stacksize, priority, parm, name, pid)
        if (stacksize < MINSTACK)
            stacksize = 1000;
        else
-#ifdef __hp9000s800
-           stacksize = 8 * ((stacksize+7) / 8);
-#else
-           stacksize = 4 * ((stacksize+3) / 4);
-#endif
+           stacksize = STACK_ALIGN * ((stacksize+STACK_ALIGN-1) / STACK_ALIGN);
        if ((stackptr = (char *) malloc(stacksize)) == NULL) {
            Set_LWP_RC();
            return LWP_ENOMEM;
@@ -422,8 +429,12 @@ int LWP_CreateProcess2(ep, stacksize, priority, parm, name, pid)
 #ifdef __hp9000s800
        savecontext(Create_Process_Part2, &temp2->context, stackptr+MINFRAME);
 #else
+#if defined(AFS_S390_LINUX20_ENV)
+       savecontext(Create_Process_Part2, &temp2->context, stackptr+stacksize-MINFRAME);
+#else
        savecontext(Create_Process_Part2, &temp2->context, stackptr+stacksize-sizeof(void *));
 #endif
+#endif
        /* End of gross hack */
 
        Set_LWP_RC();
@@ -482,11 +493,16 @@ int LWP_DestroyProcess(pid)               /* destroy a lightweight process */
            savecontext(Dispatcher, &(temp -> context),
                        &(LWPANCHOR.dsptchstack[(sizeof LWPANCHOR.dsptchstack)-0x40]));
 #else
+#if defined(AFS_S390_LINUX20_ENV)
+           savecontext(Dispatcher, &(temp -> context),
+                       &(LWPANCHOR.dsptchstack[(sizeof LWPANCHOR.dsptchstack)-MINFRAME]));
+#else
            savecontext(Dispatcher, &(temp -> context),
                        &(LWPANCHOR.dsptchstack[(sizeof LWPANCHOR.dsptchstack)-sizeof(void *)]));
 #endif
 #endif
 #endif
+#endif
        }
        return LWP_SUCCESS;
     } else
index 3b8971c..e2bcc61 100644 (file)
@@ -26,7 +26,7 @@ int PRE_Block = 0;
 #include "lwp.h"
 #include "preempt.h"
 
-#ifdef AFS_OSF_ENV
+#if defined(AFS_OSF_ENV) || defined(AFS_S390_LINUX20_ENV)
 int PRE_Block = 0;             /* used in lwp.c and process.s */
 #else
 char PRE_Block = 0;            /* used in lwp.c and process.s */
index 2618ad2..56c020a 100644 (file)
@@ -13,7 +13,7 @@
 #include <assert.h>
 #include "lwp.h"
 
-#ifdef  AFS_OSF_ENV
+#if defined(AFS_OSF_ENV) || defined(AFS_S390_LINUX20_ENV)
 extern int PRE_Block;              /* used in lwp.c and process.s */
 #else
 extern char PRE_Block;             /* used in lwp.c and process.s */
@@ -35,6 +35,9 @@ extern char PRE_Block;             /* used in lwp.c and process.s */
 #define LWP_SP 0
 #elif   defined(AFS_I386_LINUX20_ENV)
 #define LWP_SP 4
+#elif   defined(AFS_S390_LINUX20_ENV)
+#define LWP_SP 9
+#define LWP_FP 5
 #elif   defined(AFS_SPARC_LINUX20_ENV)
 #define LWP_SP 0
 #define LWP_FP 1
@@ -105,7 +108,7 @@ char*       sp;
                                {
                                case 0: jmpBuffer = (jmp_buf_type *)jmp_tmp;
                                        jmpBuffer[LWP_SP] = (jmp_buf_type)sp; 
-#if defined(AFS_SPARC_LINUX20_ENV) || (defined(AFS_SPARC64_LINUX20_ENV) && defined(AFS_32BIT_USR_ENV))
+#if defined(AFS_S390_LINUX20_ENV) || defined(AFS_SPARC_LINUX20_ENV) || (defined(AFS_SPARC64_LINUX20_ENV) && defined(AFS_32BIT_USR_ENV))
                                        jmpBuffer[LWP_FP] = (jmp_buf_type)sp; 
 #endif
                                        longjmp(jmp_tmp,1);
index 4327570..899e384 100644 (file)
@@ -165,7 +165,93 @@ PRE_Block.S:
        .extern PRE_Block[ua]
 
 #endif /* RIOS */
+#if defined(AFS_S390_LINUX20_ENV)
+      /* Linux for S/390 (31 bit)
+       *
+       * Written by Neale Ferguson <Neale.Ferguson@SoftwareAG-usa.com>
+       *
+       *  additional munging by Adam Thornton <adam@sinenomine.net>
+       */
+              .file   "process.s"
+
+              .globl savecontext
+              .type  savecontext,%function
+      /*
+       * savecontext(f, area1, newsp)
+       *      int (*f)();    struct savearea *area1; char *newsp;
+       * f     - r2
+       * area1 - r3
+       * newsp - r4
+       */
+
+       /*
+        * struct savearea {
+        *      char    *topstack;
+        * }
+        */
+
+P_PRE:                   .long   PRE_Block
+P_ABORT:                     .long   abort
 
+savecontext:
+              stm     %r6,%r15,24(%r15)       /* Save our registers */
+              lr      %r1,%r15
+              ahi     %r15,-96                /* Move out of harm's way */
+              st      %r1,0(%r15)
+              bras    %r5,.L0                 /* Get A(A(PRE_Block)) */
+              .long   PRE_Block
+      .L0:
+              l       %r5,0(%r5)              /* Get A(PRE_Block) */
+              mvi     0(%r5),1                /* Set it */
+              lr      %r6,%r3                 /* Get base of savearea */
+              st      %r15,0(%r3)             /* Save stack pointer */
+              ltr     %r4,%r4                 /* If new sp is 0 */
+              jz      .L1                     /* ... don't change sp */
+              lr      %r15,%r4                /* Set new stack pointer */
+      .L1:
+              br      %r2                     /* Call the routine */
+              /* Can't get here....*/
+
+              bras    %r5,.L2
+              .long   abort
+      .L2:
+              l      %r5,0(%r5)
+              balr    %r14,%r5
+
+      .savecontext_end:
+              .size   savecontext,.savecontext_end-savecontext
+
+      /*
+       * returnto(area2)
+       *      struct savearea *area2;
+       *
+       * area2 - r2
+       */
+        .globl  returnto
+        .type   returnto,%function
+returnto:
+        l       %r15,0(%r2)             /* New frame, to get correct pointer*/
+        bras    %r5,.L3                         /* Get A(A(PRE_Block))
+      */
+                 .long          PRE_Block
+      .L3:
+              l       %r5,0(%r5)              /* Get A(PRE_Block) */
+              xc      0(4,%r5),0(%r5)         /* Clear it */
+              l       %r15,0(%r15)
+              lm      %r6,%r15,24(%r15)       /* Restore registers */
+              br      %r14                    /* Return */
+
+             /* Can't happen */
+              la      %r2,1234
+              bras    %r5,.L4
+                .long          abort
+      .L4:
+              l       %r5,0(%r5)
+              basr    %r14,%r5
+      .returnto_end:
+              .size   returnto,.returnto_end-returnto
+#endif /* AFS_S390_LINUX20_ENV */
+       
 #ifdef mc68000
 /*
 #