Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/powerpc/ibm4xx copy{in,out}str: Tidy up inline asm's:



details:   https://anonhg.NetBSD.org/src/rev/f254d4022e79
branches:  trunk
changeset: 371725:f254d4022e79
user:      rin <rin%NetBSD.org@localhost>
date:      Mon Oct 03 23:32:27 2022 +0000

description:
copy{in,out}str: Tidy up inline asm's:
- Use %[foo], %[bar], ... instead of %0, %1, ...
- One instruction per line.
- Paragraph grouped instructions.
- Fix wrong comments.
No binary changes.

diffstat:

 sys/arch/powerpc/ibm4xx/copyinstr.c  |  50 ++++++++++++++++++++-------------
 sys/arch/powerpc/ibm4xx/copyoutstr.c |  54 ++++++++++++++++++++++--------------
 2 files changed, 63 insertions(+), 41 deletions(-)

diffs (161 lines):

diff -r 6652e4e16fc5 -r f254d4022e79 sys/arch/powerpc/ibm4xx/copyinstr.c
--- a/sys/arch/powerpc/ibm4xx/copyinstr.c       Mon Oct 03 20:15:50 2022 +0000
+++ b/sys/arch/powerpc/ibm4xx/copyinstr.c       Mon Oct 03 23:32:27 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: copyinstr.c,v 1.15 2022/09/12 08:02:44 rin Exp $       */
+/*     $NetBSD: copyinstr.c,v 1.16 2022/10/03 23:32:27 rin Exp $       */
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: copyinstr.c,v 1.15 2022/09/12 08:02:44 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: copyinstr.c,v 1.16 2022/10/03 23:32:27 rin Exp $");
 
 #include <sys/param.h>
 #include <uvm/uvm_extern.h>
@@ -72,32 +72,42 @@
 
        resid = len;
        __asm volatile(
-               "mtctr %3;"                     /* Set up counter */
-               "mfmsr %0;"                     /* Save MSR */
-               "li %1,0x20;"
-               "andc %1,%0,%1; mtmsr %1;"      /* Disable IMMU */
+               "mtctr %[resid];"               /* Set up counter */
+
+               "mfmsr %[msr];"                 /* Save MSR */
+
+               "li %[pid],0x20;"               /* Disable IMMU */
+               "andc %[pid],%[msr],%[pid];"
+               "mtmsr %[pid];"
                "isync;"
-               MFPID(%1)                       /* Save old PID */
+
+               MFPID(%[pid])                   /* Save old PID */
 
-               "1: "
-               MTPID(%4)                       /* Load user ctx */
+       "1:"    MTPID(%[ctx])                   /* Load user ctx */
                "isync;"
-               "lbz %2,0(%5); addi %5,%5,1;"   /* Load byte */
+               "lbz %[data],0(%[udaddr]);"     /* Load byte */
+               "addi %[udaddr],%[udaddr],1;"
                "sync;"
-               MTPID(%1)
+
+               MTPID(%[pid])
                "isync;"
-               "stb %2,0(%6); dcbst 0,%6; addi %6,%6,1;"
-                                               /* Store kernel byte */
-               "or. %2,%2,%2;"
+               "stb %[data],0(%[kaddr]);"      /* Store kernel byte */
+               "dcbst 0,%[kaddr];"
+               "addi %[kaddr],%[kaddr],1;"
+               "or. %[data],%[data],%[data];"
                "sync;"
-               "bdnzf 2,1b;"                   /* while(ctr-- && !zero) */
+
+               "bdnzf eq,1b;"                  /* while(ctr-- && !zero) */
 
-               MTPID(%1)                       /* Restore PID, MSR */
-               "mtmsr %0;"
+               MTPID(%[pid])                   /* Restore PID, MSR */
+               "mtmsr %[msr];"
                "isync;"
-               "mfctr %3;"                     /* Restore resid */
-               : "=&r" (msr), "=&r" (pid), "=&r" (data), "+r" (resid)
-               : "r" (ctx), "b" (udaddr), "b" (kaddr));
+
+               "mfctr %[resid];"               /* Restore resid */
+
+               : [msr] "=&r" (msr), [pid] "=&r" (pid), [data] "=&r" (data),
+                 [resid] "+r" (resid)
+               : [ctx] "r" (ctx), [udaddr] "b" (udaddr), [kaddr] "b" (kaddr));
 
        curpcb->pcb_onfault = NULL;
        if (done)
diff -r 6652e4e16fc5 -r f254d4022e79 sys/arch/powerpc/ibm4xx/copyoutstr.c
--- a/sys/arch/powerpc/ibm4xx/copyoutstr.c      Mon Oct 03 20:15:50 2022 +0000
+++ b/sys/arch/powerpc/ibm4xx/copyoutstr.c      Mon Oct 03 23:32:27 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: copyoutstr.c,v 1.15 2022/09/12 08:02:44 rin Exp $      */
+/*     $NetBSD: copyoutstr.c,v 1.16 2022/10/03 23:32:27 rin Exp $      */
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: copyoutstr.c,v 1.15 2022/09/12 08:02:44 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: copyoutstr.c,v 1.16 2022/10/03 23:32:27 rin Exp $");
 
 #include <sys/param.h>
 #include <uvm/uvm_extern.h>
@@ -72,32 +72,44 @@
 
        resid = len;
        __asm volatile(
-               "mtctr %3;"                     /* Set up counter */
-               "mfmsr %0;"                     /* Save MSR */
-               "li %1,0x20;"
-               "andc %1,%0,%1; mtmsr %1;"      /* Disable IMMU */
+               "mtctr %[resid];"               /* Set up counter */
+
+               "mfmsr %[msr];"                 /* Save MSR */
+
+               "li %[pid],0x20;"               /* Disable IMMU */
+               "andc %[pid],%[msr],%[pid];"
+               "mtmsr %[pid];"
                "isync;"
-               MFPID(%1)                       /* Save old PID */
+
+               MFPID(%[pid])                   /* Save old PID */
 
-               "1:"
-               MTPID(%1)
+       "1:"    MTPID(%[pid])
                "isync;"
-               "lbz %2,0(%6); addi %6,%6,1;"   /* Store kernel byte */
+
+               "lbz %[data],0(%[kaddr]);"      /* Load kernel byte */
+               "addi %[kaddr],%[kaddr],1;"
                "sync;"
-               MTPID(%4)                       /* Load user ctx */
+
+               MTPID(%[ctx])                   /* Load user ctx */
                "isync;"
-               "stb %2,0(%5); dcbst 0,%5; addi %5,%5,1;"
-                                               /* Load byte */
-               "or. %2,%2,%2;"
+
+               "stb %[data],0(%[udaddr]);"     /* Store byte */
+               "dcbst 0,%[udaddr];"
+               "addi %[udaddr],%[udaddr],1;"
+
+               "or. %[data],%[data],%[data];"
                "sync;"
-               "bdnzf 2,1b;"                   /* while(ctr-- && !zero) */
+               "bdnzf eq,1b;"                  /* while(ctr-- && !zero) */
+
+               MTPID(%[pid])                   /* Restore PID, MSR */
+               "mtmsr %[msr];"
+               "isync;"
 
-               MTPID(%1)                       /* Restore PID, MSR */
-               "mtmsr %0;"
-               "isync;"
-               "mfctr %3;"                     /* Restore resid */
-               : "=&r" (msr), "=&r" (pid), "=&r" (data), "+r" (resid)
-               : "r" (ctx), "b" (udaddr), "b" (kaddr));
+               "mfctr %[resid];"               /* Restore resid */
+
+               : [msr] "=&r" (msr), [pid] "=&r" (pid), [data] "=&r" (data),
+                 [resid] "+r" (resid)
+               : [ctx] "r" (ctx), [udaddr] "b" (udaddr), [kaddr] "b" (kaddr));
 
        curpcb->pcb_onfault = NULL;
        if (done)



Home | Main Index | Thread Index | Old Index