Source-Changes-HG archive

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

[src/trunk]: src/sys/arch More inlined ASM.



details:   https://anonhg.NetBSD.org/src/rev/1ea71f3c837d
branches:  trunk
changeset: 460675:1ea71f3c837d
user:      maxv <maxv%NetBSD.org@localhost>
date:      Wed Oct 30 17:06:57 2019 +0000

description:
More inlined ASM.

diffstat:

 sys/arch/amd64/amd64/cpufunc.S |   46 +-----------------
 sys/arch/i386/i386/cpufunc.S   |   52 +-------------------
 sys/arch/x86/include/cpufunc.h |  106 +++++++++++++++++++++++++++++++++++++---
 3 files changed, 101 insertions(+), 103 deletions(-)

diffs (275 lines):

diff -r 17d8eeae0671 -r 1ea71f3c837d sys/arch/amd64/amd64/cpufunc.S
--- a/sys/arch/amd64/amd64/cpufunc.S    Wed Oct 30 16:32:04 2019 +0000
+++ b/sys/arch/amd64/amd64/cpufunc.S    Wed Oct 30 17:06:57 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpufunc.S,v 1.45 2019/09/07 18:56:01 maxv Exp $        */
+/*     $NetBSD: cpufunc.S,v 1.46 2019/10/30 17:06:57 maxv Exp $        */
 
 /*
  * Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc.
@@ -313,16 +313,6 @@
        ret
 END(x86_mwait)
 
-ENTRY(fnsave)
-       fnsave  (%rdi)
-       ret
-END(fnsave)
-
-ENTRY(frstor)
-       frstor  (%rdi)
-       ret
-END(frstor)
-
 ENTRY(stts)
        movq    %cr0, %rax
        orq     $CR0_TS, %rax
@@ -330,46 +320,12 @@
        ret
 END(stts)
 
-ENTRY(fxsave)
-       fxsave  (%rdi)
-       ret
-END(fxsave)
-
-ENTRY(fxrstor)
-       fxrstor (%rdi)
-       ret
-END(fxrstor)
-
 ENTRY(fldummy)
        ffree   %st(7)
        fldz
        ret
 END(fldummy)
 
-ENTRY(xsave)
-       movq    %rsi, %rax
-       movq    %rsi, %rdx
-       shrq    $32, %rdx
-       xsave   (%rdi)
-       ret
-END(xsave)
-
-ENTRY(xsaveopt)
-       movq    %rsi, %rax
-       movq    %rsi, %rdx
-       shrq    $32, %rdx
-       xsaveopt        (%rdi)
-       ret
-END(xsaveopt)
-
-ENTRY(xrstor)
-       movq    %rsi, %rax
-       movq    %rsi, %rdx
-       shrq    $32, %rdx
-       xrstor  (%rdi)
-       ret
-END(xrstor)
-
 ENTRY(inb)
        movq    %rdi, %rdx
        xorq    %rax, %rax
diff -r 17d8eeae0671 -r 1ea71f3c837d sys/arch/i386/i386/cpufunc.S
--- a/sys/arch/i386/i386/cpufunc.S      Wed Oct 30 16:32:04 2019 +0000
+++ b/sys/arch/i386/i386/cpufunc.S      Wed Oct 30 17:06:57 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpufunc.S,v 1.35 2019/09/07 18:33:16 maxv Exp $        */
+/*     $NetBSD: cpufunc.S,v 1.36 2019/10/30 17:06:57 maxv Exp $        */
 
 /*-
  * Copyright (c) 1998, 2007 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 #include <sys/errno.h>
 
 #include <machine/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: cpufunc.S,v 1.35 2019/09/07 18:33:16 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpufunc.S,v 1.36 2019/10/30 17:06:57 maxv Exp $");
 
 #include "opt_xen.h"
 
@@ -224,18 +224,6 @@
        ret
 END(x86_mwait)  
 
-ENTRY(fnsave)
-       movl    4(%esp), %eax
-       fnsave  (%eax)
-       ret
-END(fnsave)
-
-ENTRY(frstor)
-       movl    4(%esp), %eax
-       frstor  (%eax)
-       ret
-END(frstor)
-
 ENTRY(stts)
        movl    %cr0, %eax
        testl   $CR0_TS, %eax
@@ -246,42 +234,6 @@
        ret
 END(stts)
 
-ENTRY(fxsave)
-       movl    4(%esp), %eax
-       fxsave  (%eax)
-       ret
-END(fxsave)
-
-ENTRY(fxrstor)
-       movl    4(%esp), %eax
-       fxrstor (%eax)
-       ret
-END(fxrstor)
-
-ENTRY(xsave)
-       movl    4(%esp), %ecx
-       movl    8(%esp), %eax   /* feature mask bits */
-       movl    12(%esp), %edx
-       xsave   (%ecx)
-       ret
-END(xsave)
-
-ENTRY(xsaveopt)
-       movl    4(%esp), %ecx
-       movl    8(%esp), %eax   /* feature mask bits */
-       movl    12(%esp), %edx
-       xsaveopt        (%ecx)
-       ret
-END(xsaveopt)
-
-ENTRY(xrstor)
-       movl    4(%esp), %ecx
-       movl    8(%esp), %eax   /* feature mask bits */
-       movl    12(%esp), %edx
-       xrstor  (%ecx)
-       ret
-END(xrstor)
-
 ENTRY(fldummy)
        ffree   %st(7)
        fldz
diff -r 17d8eeae0671 -r 1ea71f3c837d sys/arch/x86/include/cpufunc.h
--- a/sys/arch/x86/include/cpufunc.h    Wed Oct 30 16:32:04 2019 +0000
+++ b/sys/arch/x86/include/cpufunc.h    Wed Oct 30 17:06:57 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpufunc.h,v 1.36 2019/09/07 18:33:16 maxv Exp $        */
+/*     $NetBSD: cpufunc.h,v 1.37 2019/10/30 17:06:57 maxv Exp $        */
 
 /*
  * Copyright (c) 1998, 2007, 2019 The NetBSD Foundation, Inc.
@@ -358,15 +358,105 @@
        );
 }
 
-void   fnsave(union savefpu *);
-void   frstor(const union savefpu *);
+static inline void
+fnsave(void *addr)
+{
+       uint8_t *area = addr;
+
+       __asm volatile (
+               "fnsave %[area]"
+               : [area] "=m" (*area)
+               :
+               : "memory"
+       );
+}
+
+static inline void
+frstor(void *addr)
+{
+       const uint8_t *area = addr;
+
+       __asm volatile (
+               "frstor %[area]"
+               :
+               : [area] "m" (*area)
+               : "memory"
+       );
+}
+
+static inline void
+fxsave(void *addr)
+{
+       uint8_t *area = addr;
+
+       __asm volatile (
+               "fxsave %[area]"
+               : [area] "=m" (*area)
+               :
+               : "memory"
+       );
+}
+
+static inline void
+fxrstor(void *addr)
+{
+       const uint8_t *area = addr;
 
-void   fxsave(union savefpu *);
-void   fxrstor(const union savefpu *);
+       __asm volatile (
+               "fxrstor %[area]"
+               :
+               : [area] "m" (*area)
+               : "memory"
+       );
+}
+
+static inline void
+xsave(void *addr, uint64_t mask)
+{
+       uint8_t *area = addr;
+       uint32_t low, high;
+
+       low = mask;
+       high = mask >> 32;
+       __asm volatile (
+               "xsave  %[area]"
+               : [area] "=m" (*area)
+               : "a" (low), "d" (high)
+               : "memory"
+       );
+}
 
-void   xsave(union savefpu *, uint64_t);
-void   xsaveopt(union savefpu *, uint64_t);
-void   xrstor(const union savefpu *, uint64_t);
+static inline void
+xsaveopt(void *addr, uint64_t mask)
+{
+       uint8_t *area = addr;
+       uint32_t low, high;
+
+       low = mask;
+       high = mask >> 32;
+       __asm volatile (
+               "xsaveopt %[area]"
+               : [area] "=m" (*area)
+               : "a" (low), "d" (high)
+               : "memory"
+       );
+}
+
+static inline void
+xrstor(void *addr, uint64_t mask)
+{
+       const uint8_t *area = addr;
+       uint32_t low, high;
+
+       low = mask;
+       high = mask >> 32;
+       __asm volatile (
+               "xrstor %[area]"
+               :
+               : [area] "m" (*area), "a" (low), "d" (high)
+               : "memory"
+       );
+}
 
 /* -------------------------------------------------------------------------- */
 



Home | Main Index | Thread Index | Old Index