Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sparc/sparc sun4v: add 32/64 bit workaround for the...



details:   https://anonhg.NetBSD.org/src/rev/5d17fc920c00
branches:  trunk
changeset: 981090:5d17fc920c00
user:      palle <palle%NetBSD.org@localhost>
date:      Sat Feb 27 18:10:46 2021 +0000

description:
sun4v: add 32/64 bit workaround for the OF_read() call, similar to the one introduced in revision 1.21

diffstat:

 sys/arch/sparc/sparc/openfirm.c |  36 +++++++++++++++++++++++++++++-------
 1 files changed, 29 insertions(+), 7 deletions(-)

diffs (71 lines):

diff -r 407f7f15ffc1 -r 5d17fc920c00 sys/arch/sparc/sparc/openfirm.c
--- a/sys/arch/sparc/sparc/openfirm.c   Sat Feb 27 18:01:29 2021 +0000
+++ b/sys/arch/sparc/sparc/openfirm.c   Sat Feb 27 18:10:46 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: openfirm.c,v 1.23 2017/03/26 12:38:24 martin Exp $     */
+/*     $NetBSD: openfirm.c,v 1.24 2021/02/27 18:10:46 palle Exp $      */
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: openfirm.c,v 1.23 2017/03/26 12:38:24 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: openfirm.c,v 1.24 2021/02/27 18:10:46 palle Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -503,6 +503,15 @@
        } args;
        int l, act = 0;
 
+#ifdef SUN4V
+#if __arch64__
+       void *oaddr = addr;
+       __cpu_simple_lock(&ofcall_lock);
+       if (len > OFBOUNCE_MAXSIZE) 
+               panic("OF_read(len = %d) exceedes bounce buffer\n", len);
+       addr = ofbounce;
+#endif 
+#endif
        args.name = ADR2CELL("read");
        args.nargs = 3;
        args.nreturns = 1;
@@ -511,18 +520,31 @@
        for (; len > 0; len -= l) {
                l = MIN(NBPG, len);
                args.len = l;
-               if (openfirmware(&args) == -1)
-                       return -1;
+               if (openfirmware(&args) == -1) {
+                       act = -1;
+                       goto OF_read_exit;
+               }
                if (args.actual > 0) {
                        act += args.actual;
                }
                if (args.actual < l) {
                        if (act)
-                               return act;
-                       else
-                               return args.actual;
+                               goto OF_read_exit;
+                       else {
+                               act = args.actual;      
+                               goto OF_read_exit;
+                       }
                }
        }
+OF_read_exit:
+#ifdef SUN4V
+#if __arch64__
+       if (act > 0) {
+               memcpy(oaddr, addr, act);       
+       }
+       __cpu_simple_unlock(&ofcall_lock);
+#endif
+#endif
        return act;
 }
 



Home | Main Index | Thread Index | Old Index