Module Name:    src
Committed By:   macallan
Date:           Thu Nov 24 00:07:49 UTC 2022

Modified Files:
        src/sys/arch/powerpc/include: ofw_machdep.h
        src/sys/arch/powerpc/oea: ofw_consinit.c
        src/sys/arch/powerpc/powerpc: ofw_machdep.c

Log Message:
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


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/powerpc/include/ofw_machdep.h
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/powerpc/oea/ofw_consinit.c
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/powerpc/powerpc/ofw_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/powerpc/include/ofw_machdep.h
diff -u src/sys/arch/powerpc/include/ofw_machdep.h:1.5 src/sys/arch/powerpc/include/ofw_machdep.h:1.6
--- src/sys/arch/powerpc/include/ofw_machdep.h:1.5	Wed Nov  2 20:38:22 2022
+++ src/sys/arch/powerpc/include/ofw_machdep.h	Thu Nov 24 00:07:49 2022
@@ -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 int ofw_chosen;		/* cached handle
 extern struct OF_translation ofw_translations[OFW_MAX_TRANSLATIONS];
 
 void	ofw_bootstrap(void);
+void 	ofprint(const char *, ...);
+
 #endif /* _KERNEL */
 
 #endif /* _POWERPC_OFW_MACHDEP_H_ */

Index: src/sys/arch/powerpc/oea/ofw_consinit.c
diff -u src/sys/arch/powerpc/oea/ofw_consinit.c:1.25 src/sys/arch/powerpc/oea/ofw_consinit.c:1.26
--- src/sys/arch/powerpc/oea/ofw_consinit.c:1.25	Sun Feb 13 12:24:24 2022
+++ src/sys/arch/powerpc/oea/ofw_consinit.c	Thu Nov 24 00:07:49 2022
@@ -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 @@ extern struct consdev consdev_zs;
 #include <dev/ic/pckbcvar.h>
 #endif
 
-extern int console_node, console_instance;
+extern int console_node;
 
 int ofkbd_ihandle = -1;
 
@@ -98,19 +98,6 @@ static void ofwoea_cnprobe_keyboard(void
 /*#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

Index: src/sys/arch/powerpc/powerpc/ofw_machdep.c
diff -u src/sys/arch/powerpc/powerpc/ofw_machdep.c:1.31 src/sys/arch/powerpc/powerpc/ofw_machdep.c:1.32
--- src/sys/arch/powerpc/powerpc/ofw_machdep.c:1.31	Wed Oct 12 20:50:43 2022
+++ src/sys/arch/powerpc/powerpc/ofw_machdep.c	Thu Nov 24 00:07:48 2022
@@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: ofw_machdep.
 #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 @@ bool	ofwbootcons_suppress;
 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 @@ ofw_bootstrap_get_memory(void)
 #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 @@ ofw_bootstrap_get_memory(void)
 #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 @@ ofw_bootstrap_get_memory(void)
 			    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_bootstrap(void)
 			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. */

Reply via email to