Port-sparc64 archive

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

Re: autoconf hack for broken firmware



Hi,


> I'd just check the property length and patch up ur_len as needed.

That does work and is nicer than the previous code that I had - new code
attached.

Regards,

Julian

-- 
Index: src/sys/arch/sparc64/sparc64/autoconf.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sparc64/sparc64/autoconf.c,v
retrieving revision 1.246
diff -u -r1.246 autoconf.c
--- src/sys/arch/sparc64/sparc64/autoconf.c	13 Oct 2025 04:06:13 -0000	1.246
+++ src/sys/arch/sparc64/sparc64/autoconf.c	2 Feb 2026 16:10:13 -0000
@@ -775,9 +775,43 @@
 			portid = -1;
 		ma.ma_upaid = portid;
 
-		if (prom_getprop(node, "reg", sizeof(*ma.ma_reg), 
-				 &ma.ma_nreg, &ma.ma_reg) != 0)
-			continue;
+		if (prom_getproplen(node, "reg") == 12) {
+			/*
+			 * Fix up PROM's where reg is encoded as a 64-bit and
+			 * a 32-bit value (e.g. 00000400 0fc62020 00000010),
+			 * but we want 2 x 64-bit values.
+			 */
+#define NREG32	3
+			int n;
+			int32_t *reg32p = NULL;
+
+			if (prom_getprop(node, "reg", sizeof(int32_t),
+			    &n, &reg32p) != 0)
+				continue;
+			if (n != NREG32) {
+				free(reg32p, M_DEVBUF);
+				continue;
+			}
+			ma.ma_reg = malloc(sizeof(*ma.ma_reg), M_DEVBUF,
+			    M_NOWAIT);
+			if (ma.ma_reg == NULL)
+				continue;
+			ma.ma_reg->ur_paddr = reg32p[0];
+			ma.ma_reg->ur_paddr = ma.ma_reg->ur_paddr << 32;
+			ma.ma_reg->ur_paddr |= reg32p[1];
+			ma.ma_reg->ur_len = reg32p[2];
+			ma.ma_nreg = 1;
+			free(reg32p, M_DEVBUF);
+#ifdef DEBUG
+			if (autoconf_debug & ACDB_PROBE) {
+				printf(" fixed up 64/32 reg property\n");
+			}
+#endif
+		} else
+			/* reg is encoded as we expect */
+			rv = prom_getprop(node, "reg", sizeof(*ma.ma_reg), 
+			    &ma.ma_nreg, &ma.ma_reg);
+
 #ifdef DEBUG
 		if (autoconf_debug & ACDB_PROBE) {
 			if (ma.ma_nreg)


Home | Main Index | Thread Index | Old Index