Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/powerpc move ofprint() to powerpc/ofw_machdep.c and...



details:   https://anonhg.NetBSD.org/src/rev/dec018210aae
branches:  trunk
changeset: 372416:dec018210aae
user:      macallan <macallan%NetBSD.org@localhost>
date:      Thu Nov 24 00:07:48 2022 +0000

description:
move ofprint() to powerpc/ofw_machdep.c and make it official
now that console output uses locks it needs more of the kernel to function, so
for now use direct OF calls for earliest debug output

diffstat:

 sys/arch/powerpc/include/ofw_machdep.h |   4 +++-
 sys/arch/powerpc/oea/ofw_consinit.c    |  19 +++----------------
 sys/arch/powerpc/powerpc/ofw_machdep.c |  32 +++++++++++++++++++++++---------
 3 files changed, 29 insertions(+), 26 deletions(-)

diffs (165 lines):

diff -r 46b365b0ce3f -r dec018210aae sys/arch/powerpc/include/ofw_machdep.h
--- a/sys/arch/powerpc/include/ofw_machdep.h    Wed Nov 23 23:53:53 2022 +0000
+++ b/sys/arch/powerpc/include/ofw_machdep.h    Thu Nov 24 00:07:48 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ofw_machdep.h,v 1.5 2022/11/02 20:38:22 andvar Exp $ */
+/* $NetBSD: ofw_machdep.h,v 1.6 2022/11/24 00:07:49 macallan Exp $ */
 
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -60,6 +60,8 @@
 extern struct OF_translation ofw_translations[OFW_MAX_TRANSLATIONS];
 
 void   ofw_bootstrap(void);
+void   ofprint(const char *, ...);
+
 #endif /* _KERNEL */
 
 #endif /* _POWERPC_OFW_MACHDEP_H_ */
diff -r 46b365b0ce3f -r dec018210aae sys/arch/powerpc/oea/ofw_consinit.c
--- a/sys/arch/powerpc/oea/ofw_consinit.c       Wed Nov 23 23:53:53 2022 +0000
+++ b/sys/arch/powerpc/oea/ofw_consinit.c       Thu Nov 24 00:07:48 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ofw_consinit.c,v 1.25 2022/02/13 12:24:24 martin Exp $ */
+/* $NetBSD: ofw_consinit.c,v 1.26 2022/11/24 00:07:49 macallan Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ofw_consinit.c,v 1.25 2022/02/13 12:24:24 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_consinit.c,v 1.26 2022/11/24 00:07:49 macallan Exp $");
 
 #include "adb.h"
 #include "adbkbd.h"
@@ -89,7 +89,7 @@
 #include <dev/ic/pckbcvar.h>
 #endif
 
-extern int console_node, console_instance;
+extern int console_node;
 
 int ofkbd_ihandle = -1;
 
@@ -98,19 +98,6 @@
 /*#define OFDEBUG*/
 
 #ifdef OFDEBUG
-void ofprint(const char *, ...);
-
-void ofprint(const char *blah, ...)
-{
-       va_list va;
-       char buf[256];
-       int len;
-
-       va_start(va, blah);
-       len = vsnprintf(buf, sizeof(buf), blah, va);
-       va_end(va);
-       OF_write(console_instance, buf, len);
-}
 
 #define OFPRINTF ofprint
 #else
diff -r 46b365b0ce3f -r dec018210aae sys/arch/powerpc/powerpc/ofw_machdep.c
--- a/sys/arch/powerpc/powerpc/ofw_machdep.c    Wed Nov 23 23:53:53 2022 +0000
+++ b/sys/arch/powerpc/powerpc/ofw_machdep.c    Thu Nov 24 00:07:48 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ofw_machdep.c,v 1.31 2022/10/12 20:50:43 andvar Exp $  */
+/*     $NetBSD: ofw_machdep.c,v 1.32 2022/11/24 00:07:48 macallan Exp $        */
 
 /*-
  * Copyright (c) 2007, 2021 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ofw_machdep.c,v 1.31 2022/10/12 20:50:43 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_machdep.c,v 1.32 2022/11/24 00:07:48 macallan Exp $");
 
 #include <sys/param.h>
 #include <sys/buf.h>
@@ -83,7 +83,7 @@
 #include <powerpc/ofw_machdep.h>
 
 #ifdef DEBUG
-#define DPRINTF aprint_error
+#define DPRINTF ofprint
 #else
 #define DPRINTF while(0) printf
 #endif
@@ -104,6 +104,20 @@
 int    ofw_address_cells;
 int    ofw_size_cells;
 
+void ofprint(const char *blah, ...)
+{
+       va_list va;
+       char buf[256];
+       int len;
+
+       va_start(va, blah);
+       len = vsnprintf(buf, sizeof(buf), blah, va);
+       va_end(va);
+       OF_write(console_instance, buf, len);
+       /* Apple OF only does a newline on \n, so add an explicit CR */
+       OF_write(console_instance, "\r", 1);
+}
+
 static int
 ofwbootcons_cngetc(dev_t dev)
 {
@@ -227,14 +241,14 @@
 #ifndef _LP64
                if (addr > 0xFFFFFFFF || size > 0xFFFFFFFF ||
                        (addr + size) > 0xFFFFFFFF) {
-                       aprint_error("Base addr of %llx or size of %llx too"
+                       ofprint("Base addr of %llx or size of %llx too"
                            " large for 32 bit OS. Skipping.", addr, size);
                        continue;
                }
 #endif
                OFmem[memcnt].start = addr;
                OFmem[memcnt].size = size;
-               aprint_normal("mem region %d start=%"PRIx64" size=%"PRIx64"\n",
+               ofprint("mem region %d start=%"PRIx64" size=%"PRIx64"\n",
                    memcnt, addr, size);
                memcnt++;
        }
@@ -290,14 +304,14 @@
 #ifndef _LP64
                if (addr > 0xFFFFFFFF || size > 0xFFFFFFFF ||
                        (addr + size) > 0xFFFFFFFF) {
-                       aprint_verbose("Base addr of %llx or size of %llx too"
+                       ofprint("Base addr of %llx or size of %llx too"
                            " large for 32 bit OS. Skipping.", addr, size);
                        continue;
                }
 #endif
                OFavail[cnt].start = addr;
                OFavail[cnt].size = size;
-               aprint_normal("avail region %d start=%#"PRIx64" size=%#"PRIx64"\n",
+               ofprint("avail region %d start=%#"PRIx64" size=%#"PRIx64"\n",
                    cnt, addr, size);
                cnt++;
        }
@@ -318,7 +332,7 @@
                            AVAIL_THRESH) & ~AVAIL_THRESH;
                        OFavail[cnt].size =
                            OFmem[memcnt-1].size - OFavail[cnt].start;
-                       aprint_normal("WARNING: add memory segment %lx - %lx,"
+                       ofprint("WARNING: add memory segment %lx - %" PRIxPADDR ","
                            "\nWARNING: which was not recognized by "
                            "the Firmware.\n",
                            (unsigned long)OFavail[cnt].start,
@@ -468,7 +482,7 @@
                        ofw_real_mode = false;
                }
        }
-       aprint_normal("OpenFirmware running in %s-mode\n",
+       ofprint("OpenFirmware running in %s-mode\n",
            ofw_real_mode ? "real" : "virtual");
 
        /* Get #address-cells and #size-cells to fetching memory info. */



Home | Main Index | Thread Index | Old Index