CVS commit: src/sys/arch/macppc/macppc

2023-12-27 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Dec 28 04:43:55 UTC 2023

Modified Files:
src/sys/arch/macppc/macppc: rbus_machdep.c

Log Message:
macppc/cardbus: Belatedly catch up with battable resolution change

Fix pmap_extract() failures on models with cardslot, for direct-mapped
buffers allocated by PMAP_ALLOC_POOLPAGE().

This driver had corrupted battable[] over 11 years, since resolution of
battable was changed from 256MB to 8MB:

https://github.com/NetBSD/src/commit/413fb4c3c505a13900a9dff86f563fc58ff04005

Now, indexes for battable[] should be calculated by (va >> 23), but
rather, use oea_iobat_add() instead of directly modifying battable[].

TODO:
- Add some consistency checks to oea_iobat_add().
- Map reasonable VA space for cardbus(4), if OFW does not. Note that
  hardcoded value of 0x9000-0x9fff should be safe for now, not
  that elegant although. For macppc models, IIUC, RAM is *not* mapped to
  0x8000-0x, and VA reserved for kernel and copy{in,out} is
  0xc000-0xefff.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/macppc/macppc/rbus_machdep.c

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



CVS commit: src/sys/arch/macppc/macppc

2023-12-27 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Dec 28 04:43:55 UTC 2023

Modified Files:
src/sys/arch/macppc/macppc: rbus_machdep.c

Log Message:
macppc/cardbus: Belatedly catch up with battable resolution change

Fix pmap_extract() failures on models with cardslot, for direct-mapped
buffers allocated by PMAP_ALLOC_POOLPAGE().

This driver had corrupted battable[] over 11 years, since resolution of
battable was changed from 256MB to 8MB:

https://github.com/NetBSD/src/commit/413fb4c3c505a13900a9dff86f563fc58ff04005

Now, indexes for battable[] should be calculated by (va >> 23), but
rather, use oea_iobat_add() instead of directly modifying battable[].

TODO:
- Add some consistency checks to oea_iobat_add().
- Map reasonable VA space for cardbus(4), if OFW does not. Note that
  hardcoded value of 0x9000-0x9fff should be safe for now, not
  that elegant although. For macppc models, IIUC, RAM is *not* mapped to
  0x8000-0x, and VA reserved for kernel and copy{in,out} is
  0xc000-0xefff.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/macppc/macppc/rbus_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/macppc/macppc/rbus_machdep.c
diff -u src/sys/arch/macppc/macppc/rbus_machdep.c:1.18 src/sys/arch/macppc/macppc/rbus_machdep.c:1.19
--- src/sys/arch/macppc/macppc/rbus_machdep.c:1.18	Fri Jul  1 18:43:05 2011
+++ src/sys/arch/macppc/macppc/rbus_machdep.c	Thu Dec 28 04:43:55 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: rbus_machdep.c,v 1.18 2011/07/01 18:43:05 dyoung Exp $	*/
+/*	$NetBSD: rbus_machdep.c,v 1.19 2023/12/28 04:43:55 rin Exp $	*/
 
 /*
  * Copyright (c) 1999
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rbus_machdep.c,v 1.18 2011/07/01 18:43:05 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rbus_machdep.c,v 1.19 2023/12/28 04:43:55 rin Exp $");
 
 #include 
 #include 
@@ -92,8 +92,7 @@ rbus_pccbb_parent_mem(struct pci_attach_
 		size  = 0x1000;
 	}
 
-	battable[start >> 28].batl = BATL(start, BAT_I, BAT_PP_RW);
-	battable[start >> 28].batu = BATU(start, BAT_BL_256M, BAT_Vs);
+	oea_iobat_add(start, size);
 
 	return rbus_new_root_delegate(pa->pa_memt, start, size, 0);
 }



CVS commit: src/sys/arch/macppc/macppc

2023-05-09 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue May  9 10:49:47 UTC 2023

Modified Files:
src/sys/arch/macppc/macppc: mainbus.c

Log Message:
check for proper error value from OF_finddevice()
should fix PR57394


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/macppc/macppc/mainbus.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/macppc/macppc/mainbus.c
diff -u src/sys/arch/macppc/macppc/mainbus.c:1.25 src/sys/arch/macppc/macppc/mainbus.c:1.26
--- src/sys/arch/macppc/macppc/mainbus.c:1.25	Sat Jan 22 11:49:16 2022
+++ src/sys/arch/macppc/macppc/mainbus.c	Tue May  9 10:49:46 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: mainbus.c,v 1.25 2022/01/22 11:49:16 thorpej Exp $	*/
+/*	$NetBSD: mainbus.c,v 1.26 2023/05/09 10:49:46 macallan Exp $	*/
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.25 2022/01/22 11:49:16 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.26 2023/05/09 10:49:46 macallan Exp $");
 
 #include 
 #include 
@@ -76,7 +76,13 @@ mainbus_attach(device_t parent, device_t
 	devhandle_t selfh = device_handle(self);
 
 	cpus = OF_finddevice("/cpus");
-	if (cpus != 0) {
+	/*
+	 * XXX
+	 * the canonical error value is -1 but I dimly remember some OF
+	 * variants returning 0 here, so check for both just in case.
+	 * It's not like this is a performance critical path.
+	 */
+	if ((cpus != -1) && (cpus != 0)) {
 		node = OF_child(cpus);
 		while (node != 0) {
 			ca.ca_name = "cpu";



CVS commit: src/sys/arch/macppc/macppc

2023-05-09 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue May  9 10:49:47 UTC 2023

Modified Files:
src/sys/arch/macppc/macppc: mainbus.c

Log Message:
check for proper error value from OF_finddevice()
should fix PR57394


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/macppc/macppc/mainbus.c

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



CVS commit: src/sys/arch/macppc/macppc

2023-01-11 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Jan 12 01:19:21 UTC 2023

Modified Files:
src/sys/arch/macppc/macppc: pic_u3_ht.c

Log Message:
don't attach on cascaded mpics for now - we don't really use them for anything
yet and apparently setup causes problems elsewhere, which needs investigation


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/macppc/macppc/pic_u3_ht.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/macppc/macppc/pic_u3_ht.c
diff -u src/sys/arch/macppc/macppc/pic_u3_ht.c:1.13 src/sys/arch/macppc/macppc/pic_u3_ht.c:1.14
--- src/sys/arch/macppc/macppc/pic_u3_ht.c:1.13	Wed Dec 28 06:50:23 2022
+++ src/sys/arch/macppc/macppc/pic_u3_ht.c	Thu Jan 12 01:19:21 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic_u3_ht.c,v 1.13 2022/12/28 06:50:23 macallan Exp $	*/
+/*	$NetBSD: pic_u3_ht.c,v 1.14 2023/01/12 01:19:21 macallan Exp $	*/
 /*-
  * Copyright (c) 2013 Phileas Fogg
  * All rights reserved.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic_u3_ht.c,v 1.13 2022/12/28 06:50:23 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic_u3_ht.c,v 1.14 2023/01/12 01:19:21 macallan Exp $");
 
 #include "opt_openpic.h"
 #include "opt_interrupt.h"
@@ -138,8 +138,10 @@ int init_u3_ht(void)
 
 	u4 = OF_finddevice("/u4");
 	if (u4 == -1) {
+#ifdef U3HT_CASCADE
 		u4 = OF_finddevice("/u3");
 		if (u4 == -1)
+#endif
 			return FALSE;
 	}
 



CVS commit: src/sys/arch/macppc/macppc

2023-01-11 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Jan 12 01:19:21 UTC 2023

Modified Files:
src/sys/arch/macppc/macppc: pic_u3_ht.c

Log Message:
don't attach on cascaded mpics for now - we don't really use them for anything
yet and apparently setup causes problems elsewhere, which needs investigation


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/macppc/macppc/pic_u3_ht.c

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



CVS commit: src/sys/arch/macppc/macppc

2022-12-27 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Dec 28 06:50:23 UTC 2022

Modified Files:
src/sys/arch/macppc/macppc: pic_u3_ht.c

Log Message:
support cascading:
- attach on both /u3 and /u4
- install IPI handling only if we're primary
- link to primary PIC if we're cascaded


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/macppc/macppc/pic_u3_ht.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/macppc/macppc/pic_u3_ht.c
diff -u src/sys/arch/macppc/macppc/pic_u3_ht.c:1.12 src/sys/arch/macppc/macppc/pic_u3_ht.c:1.13
--- src/sys/arch/macppc/macppc/pic_u3_ht.c:1.12	Sat Mar  6 07:29:05 2021
+++ src/sys/arch/macppc/macppc/pic_u3_ht.c	Wed Dec 28 06:50:23 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic_u3_ht.c,v 1.12 2021/03/06 07:29:05 rin Exp $	*/
+/*	$NetBSD: pic_u3_ht.c,v 1.13 2022/12/28 06:50:23 macallan Exp $	*/
 /*-
  * Copyright (c) 2013 Phileas Fogg
  * All rights reserved.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic_u3_ht.c,v 1.12 2021/03/06 07:29:05 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic_u3_ht.c,v 1.13 2022/12/28 06:50:23 macallan Exp $");
 
 #include "opt_openpic.h"
 #include "opt_interrupt.h"
@@ -79,7 +79,7 @@ struct u3_ht_ops {
 #define u3_ht_read(ptr,reg)		(ptr)->ht_read(ptr, reg)
 #define u3_ht_write(ptr,reg,val)	(ptr)->ht_write(ptr, reg, val)
 
-static struct u3_ht_ops *setup_u3_ht(uint32_t, uint32_t, int);
+static struct u3_ht_ops *setup_u3_ht(uint32_t, uint32_t, int, int);
 static int setup_u3_ht_workarounds(struct u3_ht_ops *);
 
 static void u3_ht_enable_irq(struct pic_ops *, int, int);
@@ -130,15 +130,18 @@ static void u3_ht_establish_ipi(int, int
 
 int init_u3_ht(void)
 {
-	int u4, pic;
+	int u4, pic, irq = -1;
 	uint32_t reg[2];
 	uint32_t base, len, tmp;
 	int bigendian;
 	volatile uint8_t *unin_reg;
 
 	u4 = OF_finddevice("/u4");
-	if (u4 == -1)
-		return FALSE;
+	if (u4 == -1) {
+		u4 = OF_finddevice("/u3");
+		if (u4 == -1)
+			return FALSE;
+	}
 
 	if (! of_compatible(u4, u3_compat))
 		return FALSE;
@@ -173,15 +176,21 @@ int init_u3_ht(void)
 	base = reg[0];
 	len = reg[1];
 
-	aprint_normal("found U3/U4 HT PIC at %08x\n", base);
+	if (OF_getprop(pic, "interrupts", reg, 8) > 4) {
+		/* this is a cascaded PIC */
+		irq = reg[0];
+		aprint_normal("found cascaded U3/U4 HT PIC at %08x, IRQ %d\n",
+		base, irq);
+	} else
+		aprint_normal("found U3/U4 HT PIC at %08x\n", base);
 
-	setup_u3_ht(base, len, bigendian);
+	setup_u3_ht(base, len, bigendian, irq);
 
 	return TRUE;
 }
 
 static struct u3_ht_ops *
-setup_u3_ht(uint32_t addr, uint32_t len, int bigendian)
+setup_u3_ht(uint32_t addr, uint32_t len, int bigendian, int cirq)
 {
 	struct u3_ht_ops *u3_ht;
 	struct pic_ops *pic;
@@ -264,16 +273,24 @@ setup_u3_ht(uint32_t addr, uint32_t len,
 		u3_ht_eoi(u3_ht, 0);
 	}
 
+	if (cirq > -1) {
+		/* we're subordinate to a normal openpic */
+		intr_establish_xname(cirq, IST_EDGE, IPL_HIGH,
+		pic_handle_intr, pic, "u3_ht");
+	}
 #ifdef MULTIPROCESSOR
-	ipiops.ppc_send_ipi = u3_ht_send_ipi;
-	ipiops.ppc_establish_ipi = u3_ht_establish_ipi;
-	ipiops.ppc_ipi_vector = IPI_VECTOR;
-
-	x = u3_ht_read(u3_ht, OPENPIC_IPI_VECTOR(1));
-	x &= ~(OPENPIC_IMASK | OPENPIC_PRIORITY_MASK | OPENPIC_VECTOR_MASK);
-	x |= (15 << OPENPIC_PRIORITY_SHIFT) | ipiops.ppc_ipi_vector;
-	u3_ht_write(u3_ht, OPENPIC_IPI_VECTOR(1), x);
-	u3ht0 = u3_ht;
+	else {
+		/* only handle IPIs if we're the only openpic */
+		ipiops.ppc_send_ipi = u3_ht_send_ipi;
+		ipiops.ppc_establish_ipi = u3_ht_establish_ipi;
+		ipiops.ppc_ipi_vector = IPI_VECTOR;
+
+		x = u3_ht_read(u3_ht, OPENPIC_IPI_VECTOR(1));
+		x &= ~(OPENPIC_IMASK | OPENPIC_PRIORITY_MASK | OPENPIC_VECTOR_MASK);
+		x |= (15 << OPENPIC_PRIORITY_SHIFT) | ipiops.ppc_ipi_vector;
+		u3_ht_write(u3_ht, OPENPIC_IPI_VECTOR(1), x);
+		u3ht0 = u3_ht;
+	}
 #endif /* MULTIPROCESSOR */
 
 	return u3_ht;



CVS commit: src/sys/arch/macppc/macppc

2022-12-27 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Dec 28 06:50:23 UTC 2022

Modified Files:
src/sys/arch/macppc/macppc: pic_u3_ht.c

Log Message:
support cascading:
- attach on both /u3 and /u4
- install IPI handling only if we're primary
- link to primary PIC if we're cascaded


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/macppc/macppc/pic_u3_ht.c

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



CVS commit: src/sys/arch/macppc/macppc

2022-12-27 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Dec 28 06:00:27 UTC 2022

Modified Files:
src/sys/arch/macppc/macppc: interrupts.c

Log Message:
first step towards MSI support on G5:
- allow both openpic and u3_ht to attach
- make sure openpic comes first, if we have both then u3_ht is cascaded


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/macppc/macppc/interrupts.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/macppc/macppc/interrupts.c
diff -u src/sys/arch/macppc/macppc/interrupts.c:1.8 src/sys/arch/macppc/macppc/interrupts.c:1.9
--- src/sys/arch/macppc/macppc/interrupts.c:1.8	Tue Jan 26 14:49:41 2021
+++ src/sys/arch/macppc/macppc/interrupts.c	Wed Dec 28 06:00:26 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: interrupts.c,v 1.8 2021/01/26 14:49:41 thorpej Exp $ */
+/*	$NetBSD: interrupts.c,v 1.9 2022/12/28 06:00:26 macallan Exp $ */
 
 /*-
  * Copyright (c) 2007 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: interrupts.c,v 1.8 2021/01/26 14:49:41 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: interrupts.c,v 1.9 2022/12/28 06:00:26 macallan Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -108,9 +108,25 @@ init_openpic(int pass_through)
 
 #endif /* NPIC_OPENPIC > 0 */
 
+/*
+ * look for supported interrupt controllers
+ * there are several possible cases:
+ * - Ohare and Grand Central models have the same interrupt controller, Ohare
+ *   can have a 2nd cascaded one ( Powerbook 3400c with ethernet for example )
+ * - Heathrow is more or less Ohare with all the registers doubled to allow 64
+ *   IRQs
+ * - openpic covers all OpenPICs built into various mac-io found in some G3,
+ *   all G4 and most G5 models
+ * - u3_ht is an OpenPIC built into the CPC 9x5 bridges / memory controllers
+ *   found in G5s, it's got enough quirks to require its own driver. Some
+ *   models have both openpic and u3_ht, on those openpic handles IPIs and
+ *   normal IRQs while the u3_ht is cascaded and can be used for MSI. On G5s
+ *   that have no openpic the u3_ht handles all interrupts, IPIs and MSI
+ */
 void
 init_interrupt(void)
 {
+	int ok = 0;
 
 	pic_init();
 #if NPIC_OHARE > 0
@@ -121,20 +137,23 @@ init_interrupt(void)
 	if (init_heathrow())
 		goto done;
 #endif
-#if NPIC_U3_HT > 0
-	if (init_u3_ht())
-		goto done;
-#endif
 #if NPIC_OPENPIC > 0
 	if (init_openpic(0)) {
 #ifdef MULTIPROCESSOR
 		setup_openpic_ipi();
 #endif
-		goto done;
+		ok = 1;
 	}
 #endif
-	panic("%s: no supported interrupt controller found", __func__);
+#if NPIC_U3_HT > 0
+	if (init_u3_ht())
+		ok = 1;
+#endif
+	if (ok == 0)
+	panic("%s: no supported interrupt controller found", __func__);
+#if NPIC_OHARE + NPIC_HEATHROW > 0
 done:
+#endif
 	oea_install_extint(pic_ext_intr);
 
 #ifdef MULTIPROCESSOR



CVS commit: src/sys/arch/macppc/macppc

2022-12-27 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Dec 28 06:00:27 UTC 2022

Modified Files:
src/sys/arch/macppc/macppc: interrupts.c

Log Message:
first step towards MSI support on G5:
- allow both openpic and u3_ht to attach
- make sure openpic comes first, if we have both then u3_ht is cascaded


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/macppc/macppc/interrupts.c

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



CVS commit: src/sys/arch/macppc/macppc

2022-12-17 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sun Dec 18 01:16:05 UTC 2022

Modified Files:
src/sys/arch/macppc/macppc: locore.S

Log Message:
add comment to explain why we zero SPRG0 here
NFC


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.82 src/sys/arch/macppc/macppc/locore.S

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



CVS commit: src/sys/arch/macppc/macppc

2022-12-17 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sun Dec 18 01:16:05 UTC 2022

Modified Files:
src/sys/arch/macppc/macppc: locore.S

Log Message:
add comment to explain why we zero SPRG0 here
NFC


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.82 src/sys/arch/macppc/macppc/locore.S

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/macppc/macppc/locore.S
diff -u src/sys/arch/macppc/macppc/locore.S:1.81 src/sys/arch/macppc/macppc/locore.S:1.82
--- src/sys/arch/macppc/macppc/locore.S:1.81	Sun Dec 18 01:10:57 2022
+++ src/sys/arch/macppc/macppc/locore.S	Sun Dec 18 01:16:05 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.81 2022/12/18 01:10:57 macallan Exp $	*/
+/*	$NetBSD: locore.S,v 1.82 2022/12/18 01:16:05 macallan Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -92,6 +92,11 @@ __start:
 	mr	%r13,%r6
 	mr	%r14,%r7
 
+/* 
+ * Zero SPRG0 so we can catch usage of curcpu(), which just returns SPRG0,
+ * before it is set up properly. Console output uses locks now, which need
+ * working curcpu(), and macppc sets up its console *very* early.
+ */
 #ifdef DEBUG
 	li	%r0,0
 	mtsprg0	%r0



CVS commit: src/sys/arch/macppc/macppc

2022-12-17 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sun Dec 18 01:10:58 UTC 2022

Modified Files:
src/sys/arch/macppc/macppc: locore.S

Log Message:
#ifdef DEBUG the previous change, it seems to cause trouble on qemu which
needs further investigation


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/sys/arch/macppc/macppc/locore.S

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/macppc/macppc/locore.S
diff -u src/sys/arch/macppc/macppc/locore.S:1.80 src/sys/arch/macppc/macppc/locore.S:1.81
--- src/sys/arch/macppc/macppc/locore.S:1.80	Wed Dec 14 13:04:24 2022
+++ src/sys/arch/macppc/macppc/locore.S	Sun Dec 18 01:10:57 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.80 2022/12/14 13:04:24 macallan Exp $	*/
+/*	$NetBSD: locore.S,v 1.81 2022/12/18 01:10:57 macallan Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -92,8 +92,10 @@ __start:
 	mr	%r13,%r6
 	mr	%r14,%r7
 
+#ifdef DEBUG
 	li	%r0,0
 	mtsprg0	%r0
+#endif
 
 	bl	_C_LABEL(ofwinit)		/* init OF */
 



CVS commit: src/sys/arch/macppc/macppc

2022-12-17 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sun Dec 18 01:10:58 UTC 2022

Modified Files:
src/sys/arch/macppc/macppc: locore.S

Log Message:
#ifdef DEBUG the previous change, it seems to cause trouble on qemu which
needs further investigation


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/sys/arch/macppc/macppc/locore.S

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



CVS commit: src/sys/arch/macppc/macppc

2022-12-14 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Dec 14 13:04:24 UTC 2022

Modified Files:
src/sys/arch/macppc/macppc: locore.S

Log Message:
Explicitly zero SPRG0 before doing anything else - it's used to store a pointer
to struct cpuinfo, this way we can catch attempts to use it before it's set
up properly


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sys/arch/macppc/macppc/locore.S

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



CVS commit: src/sys/arch/macppc/macppc

2022-12-14 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Dec 14 13:04:24 UTC 2022

Modified Files:
src/sys/arch/macppc/macppc: locore.S

Log Message:
Explicitly zero SPRG0 before doing anything else - it's used to store a pointer
to struct cpuinfo, this way we can catch attempts to use it before it's set
up properly


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sys/arch/macppc/macppc/locore.S

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/macppc/macppc/locore.S
diff -u src/sys/arch/macppc/macppc/locore.S:1.79 src/sys/arch/macppc/macppc/locore.S:1.80
--- src/sys/arch/macppc/macppc/locore.S:1.79	Fri Feb 26 02:18:56 2021
+++ src/sys/arch/macppc/macppc/locore.S	Wed Dec 14 13:04:24 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.79 2021/02/26 02:18:56 thorpej Exp $	*/
+/*	$NetBSD: locore.S,v 1.80 2022/12/14 13:04:24 macallan Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -92,6 +92,9 @@ __start:
 	mr	%r13,%r6
 	mr	%r14,%r7
 
+	li	%r0,0
+	mtsprg0	%r0
+
 	bl	_C_LABEL(ofwinit)		/* init OF */
 
 	li	%r0,0



CVS commit: src/sys/arch/macppc/macppc

2022-08-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Aug 13 09:34:47 UTC 2022

Modified Files:
src/sys/arch/macppc/macppc: disksubr.c

Log Message:
Do not try to create a fake MBR disklabel from the PMBR of a GPT disk.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/macppc/macppc/disksubr.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/macppc/macppc/disksubr.c
diff -u src/sys/arch/macppc/macppc/disksubr.c:1.49 src/sys/arch/macppc/macppc/disksubr.c:1.50
--- src/sys/arch/macppc/macppc/disksubr.c:1.49	Fri Mar 14 21:59:41 2014
+++ src/sys/arch/macppc/macppc/disksubr.c	Sat Aug 13 09:34:47 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: disksubr.c,v 1.49 2014/03/14 21:59:41 mrg Exp $	*/
+/*	$NetBSD: disksubr.c,v 1.50 2022/08/13 09:34:47 martin Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1988 Regents of the University of California.
@@ -106,7 +106,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.49 2014/03/14 21:59:41 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.50 2022/08/13 09:34:47 martin Exp $");
 
 #include 
 #include 
@@ -497,6 +497,8 @@ read_dos_label(dev_t dev, void (*strat)(
 	bsdp = NULL;
 	for (i = 0; i < MBR_PART_COUNT; i++, dp++) {
 		switch (dp->mbrp_type) {
+		case MBR_PTYPE_PMBR:
+			goto done;	/* do not fake anything for GPT disks */
 		case MBR_PTYPE_NETBSD:
 			bsdp = dp;
 			break;



CVS commit: src/sys/arch/macppc/macppc

2022-08-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Aug 13 09:34:47 UTC 2022

Modified Files:
src/sys/arch/macppc/macppc: disksubr.c

Log Message:
Do not try to create a fake MBR disklabel from the PMBR of a GPT disk.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/macppc/macppc/disksubr.c

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



CVS commit: src/sys/arch/macppc/macppc

2022-06-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Jun 26 09:23:32 UTC 2022

Modified Files:
src/sys/arch/macppc/macppc: machdep.c

Log Message:
cpu_reboot: use cpu_halt_others() instead of a (simple) open coded
version of it.


To generate a diff of this commit:
cvs rdiff -u -r1.174 -r1.175 src/sys/arch/macppc/macppc/machdep.c

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



CVS commit: src/sys/arch/macppc/macppc

2022-06-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Jun 26 09:23:32 UTC 2022

Modified Files:
src/sys/arch/macppc/macppc: machdep.c

Log Message:
cpu_reboot: use cpu_halt_others() instead of a (simple) open coded
version of it.


To generate a diff of this commit:
cvs rdiff -u -r1.174 -r1.175 src/sys/arch/macppc/macppc/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/macppc/macppc/machdep.c
diff -u src/sys/arch/macppc/macppc/machdep.c:1.174 src/sys/arch/macppc/macppc/machdep.c:1.175
--- src/sys/arch/macppc/macppc/machdep.c:1.174	Wed Mar 10 19:45:41 2021
+++ src/sys/arch/macppc/macppc/machdep.c	Sun Jun 26 09:23:32 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.174 2021/03/10 19:45:41 macallan Exp $	*/
+/*	$NetBSD: machdep.c,v 1.175 2022/06/26 09:23:32 martin Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.174 2021/03/10 19:45:41 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.175 2022/06/26 09:23:32 martin Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_ddb.h"
@@ -233,7 +233,7 @@ cpu_reboot(int howto, char *what)
 
 #ifdef MULTIPROCESSOR
 	/* Halt other CPU */
-	cpu_send_ipi(IPI_DST_NOTME, IPI_HALT);
+	cpu_halt_others();
 	delay(10);	/* XXX */
 #endif
 



CVS commit: src/sys/arch/macppc/macppc

2019-10-24 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Oct 24 23:06:25 UTC 2019

Modified Files:
src/sys/arch/macppc/macppc: mainbus.c

Log Message:
if we have a /cpus node, use it to find and attach all CPUs.
Now we find all CPUs on a 4x G5.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/macppc/macppc/mainbus.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/macppc/macppc/mainbus.c
diff -u src/sys/arch/macppc/macppc/mainbus.c:1.21 src/sys/arch/macppc/macppc/mainbus.c:1.22
--- src/sys/arch/macppc/macppc/mainbus.c:1.21	Sun Jun  5 17:03:16 2011
+++ src/sys/arch/macppc/macppc/mainbus.c	Thu Oct 24 23:06:25 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: mainbus.c,v 1.21 2011/06/05 17:03:16 matt Exp $	*/
+/*	$NetBSD: mainbus.c,v 1.22 2019/10/24 23:06:25 macallan Exp $	*/
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.21 2011/06/05 17:03:16 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.22 2019/10/24 23:06:25 macallan Exp $");
 
 #include 
 #include 
@@ -67,17 +67,29 @@ mainbus_attach(device_t parent, device_t
 {
 	struct ofbus_attach_args oba;
 	struct confargs ca;
-	int node, i;
+	int node, cpus, i;
 	u_int32_t reg[4];
 	char name[32];
 
 	printf("\n");
 
-	for (i = 0; i < 2; i++) {
-		ca.ca_name = "cpu";
-		ca.ca_reg = reg;
-		reg[0] = i;
-		config_found(self, , NULL);
+	cpus = OF_finddevice("/cpus");
+	if (cpus != 0) {
+		node = OF_child(cpus);
+		while (node != 0) {
+			ca.ca_name = "cpu";
+			ca.ca_reg = reg;
+			ca.ca_nreg = OF_getprop(node, "reg", reg, sizeof(reg));
+			config_found(self, , NULL);
+			node = OF_peer(node);
+		}			
+	} else {
+		for (i = 0; i < 2; i++) {
+			ca.ca_name = "cpu";
+			ca.ca_reg = reg;
+			reg[0] = i;
+			config_found(self, , NULL);
+		}
 	}
 
 	pic_finish_setup();



CVS commit: src/sys/arch/macppc/macppc

2019-10-24 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Oct 24 23:06:25 UTC 2019

Modified Files:
src/sys/arch/macppc/macppc: mainbus.c

Log Message:
if we have a /cpus node, use it to find and attach all CPUs.
Now we find all CPUs on a 4x G5.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/macppc/macppc/mainbus.c

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



Re: CVS commit: src/sys/arch/macppc/macppc

2019-10-11 Thread Sevan Janiyan



On 11/10/2019 22:56, Michael Lorenz wrote:
> first step to address PR2231

PR22316
http://gnats.netbsd.org/22316


Sevan


CVS commit: src/sys/arch/macppc/macppc

2019-10-11 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Oct 11 21:56:55 UTC 2019

Modified Files:
src/sys/arch/macppc/macppc: locore.S

Log Message:
don't zero the MSR when building with options FIRMWORKSBUGS
with this a FIRMWORKSBUGS kernel boots on my TiBook
first step to address PR2231


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/sys/arch/macppc/macppc/locore.S

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/macppc/macppc/locore.S
diff -u src/sys/arch/macppc/macppc/locore.S:1.73 src/sys/arch/macppc/macppc/locore.S:1.74
--- src/sys/arch/macppc/macppc/locore.S:1.73	Sun Jul 15 05:16:43 2018
+++ src/sys/arch/macppc/macppc/locore.S	Fri Oct 11 21:56:55 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.73 2018/07/15 05:16:43 maxv Exp $	*/
+/*	$NetBSD: locore.S,v 1.74 2019/10/11 21:56:55 macallan Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -87,7 +87,9 @@ __start:
 	bl	_C_LABEL(cpu_model_init)	/* init oeacpufeat */
 
 	li	0,0
+#ifndef FIRMWORKSBUGS
 	mtmsr	0			/* Disable FPU/MMU/exceptions */
+#endif
 #if defined(PMAP_OEA64_BRIDGE)
 	mfmsr	0			/* Clear SF and ISF bits */
 	clrldi	0,0,3



CVS commit: src/sys/arch/macppc/macppc

2019-10-11 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Oct 11 21:56:55 UTC 2019

Modified Files:
src/sys/arch/macppc/macppc: locore.S

Log Message:
don't zero the MSR when building with options FIRMWORKSBUGS
with this a FIRMWORKSBUGS kernel boots on my TiBook
first step to address PR2231


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/sys/arch/macppc/macppc/locore.S

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