CVS commit: src/sys/dev/fdt

2018-10-20 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 21 05:32:39 UTC 2018

Modified Files:
src/sys/dev/fdt: fdt_intr.c

Log Message:
Fix sense of test in fdtbus_intr_disestablish.

Reported by yarl-baudig on port-arm.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/dev/fdt/fdt_intr.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/dev/fdt/fdt_intr.c
diff -u src/sys/dev/fdt/fdt_intr.c:1.18 src/sys/dev/fdt/fdt_intr.c:1.19
--- src/sys/dev/fdt/fdt_intr.c:1.18	Thu Sep  6 22:54:05 2018
+++ src/sys/dev/fdt/fdt_intr.c	Sun Oct 21 05:32:39 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_intr.c,v 1.18 2018/09/06 22:54:05 jmcneill Exp $ */
+/* $NetBSD: fdt_intr.c,v 1.19 2018/10/21 05:32:39 skrll Exp $ */
 
 /*-
  * Copyright (c) 2015-2018 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fdt_intr.c,v 1.18 2018/09/06 22:54:05 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_intr.c,v 1.19 2018/10/21 05:32:39 skrll Exp $");
 
 #include 
 #include 
@@ -184,7 +184,7 @@ fdtbus_intr_disestablish(int phandle, vo
 		}
 	}
 
-	if (ic != NULL)
+	if (ic == NULL)
 		panic("%s: interrupt handle not valid", __func__);
 
 	return ic->ic_funcs->disestablish(ic->ic_dev, cookie);



CVS commit: src/sys/stand/efiboot

2018-10-20 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 21 00:57:38 UTC 2018

Modified Files:
src/sys/stand/efiboot: version
src/sys/stand/efiboot/bootaa64: Makefile

Log Message:
Enable ACPI support.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/stand/efiboot/version
cvs rdiff -u -r1.3 -r1.4 src/sys/stand/efiboot/bootaa64/Makefile

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

Modified files:

Index: src/sys/stand/efiboot/version
diff -u src/sys/stand/efiboot/version:1.3 src/sys/stand/efiboot/version:1.4
--- src/sys/stand/efiboot/version:1.3	Sun Sep  9 17:55:22 2018
+++ src/sys/stand/efiboot/version	Sun Oct 21 00:57:38 2018
@@ -1,4 +1,4 @@
-$NetBSD: version,v 1.3 2018/09/09 17:55:22 jmcneill Exp $
+$NetBSD: version,v 1.4 2018/10/21 00:57:38 jmcneill Exp $
 
 NOTE ANY CHANGES YOU MAKE TO THE EFI BOOTLOADER HERE.  The format of this
 file is important - make sure the entries are appended on end, last item
@@ -7,3 +7,4 @@ is taken as the current.
 1.0:	Initial version.
 1.1:	Add PXE booting support.
 1.2:	Add environment variable support.
+1.3:	Add ACPI support.

Index: src/sys/stand/efiboot/bootaa64/Makefile
diff -u src/sys/stand/efiboot/bootaa64/Makefile:1.3 src/sys/stand/efiboot/bootaa64/Makefile:1.4
--- src/sys/stand/efiboot/bootaa64/Makefile:1.3	Fri Oct 12 22:08:04 2018
+++ src/sys/stand/efiboot/bootaa64/Makefile	Sun Oct 21 00:57:38 2018
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.3 2018/10/12 22:08:04 jmcneill Exp $
+# $NetBSD: Makefile,v 1.4 2018/10/21 00:57:38 jmcneill Exp $
 
 PROG=		bootaa64.efi
 OBJFMT=		binary
@@ -9,7 +9,7 @@ EXTRA_SOURCES+=	cache.S
 
 COPTS+=		-mgeneral-regs-only -fno-jump-tables
 CFLAGS+=	-DEFIBOOT_ALIGN=0x20
-#CFLAGS+=	-DEFIBOOT_ACPI
+CFLAGS+=	-DEFIBOOT_ACPI
 
 .include "${.CURDIR}/../Makefile.efiboot"
 



CVS commit: src/sys/arch

2018-10-20 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 21 00:56:44 UTC 2018

Modified Files:
src/sys/arch/evbarm/conf: files.generic64
Removed Files:
src/sys/arch/arm/amd: files.seattle seattle_platform.c

Log Message:
Remove FDT support for AMD Seattle platform. This SoC is supported in ACPI
mode.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r0 src/sys/arch/arm/amd/files.seattle
cvs rdiff -u -r1.4 -r0 src/sys/arch/arm/amd/seattle_platform.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/evbarm/conf/files.generic64

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/evbarm/conf/files.generic64
diff -u src/sys/arch/evbarm/conf/files.generic64:1.8 src/sys/arch/evbarm/conf/files.generic64:1.9
--- src/sys/arch/evbarm/conf/files.generic64:1.8	Thu Oct 18 09:01:54 2018
+++ src/sys/arch/evbarm/conf/files.generic64	Sun Oct 21 00:56:44 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: files.generic64,v 1.8 2018/10/18 09:01:54 skrll Exp $
+#	$NetBSD: files.generic64,v 1.9 2018/10/21 00:56:44 jmcneill Exp $
 #
 # A generic (aarch64) kernel configuration info
 #
@@ -11,7 +11,6 @@ include "arch/evbarm/conf/files.fdt"
 # Add other board files here
 #
 include "arch/arm/acpi/files.acpi"
-include "arch/arm/amd/files.seattle"
 include "arch/arm/broadcom/files.bcm2835"
 include "arch/arm/cavium/files.thunderx"
 include "arch/arm/nvidia/files.tegra"



CVS commit: src/sys/dev/pci

2018-10-20 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 21 00:51:12 UTC 2018

Modified Files:
src/sys/dev/pci: if_msk.c if_mskvar.h

Log Message:
Enable MSI support where available.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sys/dev/pci/if_msk.c
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/pci/if_mskvar.h

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

Modified files:

Index: src/sys/dev/pci/if_msk.c
diff -u src/sys/dev/pci/if_msk.c:1.78 src/sys/dev/pci/if_msk.c:1.79
--- src/sys/dev/pci/if_msk.c:1.78	Fri Sep 14 18:46:47 2018
+++ src/sys/dev/pci/if_msk.c	Sun Oct 21 00:51:12 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: if_msk.c,v 1.78 2018/09/14 18:46:47 jakllsch Exp $ */
+/* $NetBSD: if_msk.c,v 1.79 2018/10/21 00:51:12 jmcneill Exp $ */
 /*	$OpenBSD: if_msk.c,v 1.79 2009/10/15 17:54:56 deraadt Exp $	*/
 
 /*
@@ -52,7 +52,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_msk.c,v 1.78 2018/09/14 18:46:47 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_msk.c,v 1.79 2018/10/21 00:51:12 jmcneill Exp $");
 
 #include 
 #include 
@@ -1359,7 +1359,6 @@ mskc_attach(device_t parent, device_t se
 	struct skc_attach_args skca;
 	pci_chipset_tag_t pc = pa->pa_pc;
 	pcireg_t command, memtype;
-	pci_intr_handle_t ih;
 	const char *intrstr = NULL;
 	int rc, sk_nodenum;
 	u_int8_t hw, pmd;
@@ -1431,13 +1430,13 @@ mskc_attach(device_t parent, device_t se
 	DPRINTFN(2, ("mskc_attach: allocate interrupt\n"));
 
 	/* Allocate interrupt */
-	if (pci_intr_map(pa, )) {
+	if (pci_intr_alloc(pa, >sk_pihp, NULL, 0)) {
 		aprint_error(": couldn't map interrupt\n");
 		goto fail_1;
 	}
 
-	intrstr = pci_intr_string(pc, ih, intrbuf, sizeof(intrbuf));
-	sc->sk_intrhand = pci_intr_establish_xname(pc, ih, IPL_NET, msk_intr,
+	intrstr = pci_intr_string(pc, sc->sk_pihp[0], intrbuf, sizeof(intrbuf));
+	sc->sk_intrhand = pci_intr_establish_xname(pc, sc->sk_pihp[0], IPL_NET, msk_intr,
 	sc, device_xname(sc->sk_dev));
 	if (sc->sk_intrhand == NULL) {
 		aprint_error(": couldn't establish interrupt");
@@ -1745,6 +1744,11 @@ mskc_detach(device_t self, int flags)
 		sc->sk_intrhand = NULL;
 	}
 
+	if (sc->sk_pihp != NULL) {
+		pci_intr_release(sc->sk_pc, sc->sk_pihp, 1);
+		sc->sk_pihp = NULL;
+	}
+
 	rv = config_detach_children(self, flags);
 	if (rv != 0)
 		return (rv);

Index: src/sys/dev/pci/if_mskvar.h
diff -u src/sys/dev/pci/if_mskvar.h:1.19 src/sys/dev/pci/if_mskvar.h:1.20
--- src/sys/dev/pci/if_mskvar.h:1.19	Fri Sep 14 18:46:47 2018
+++ src/sys/dev/pci/if_mskvar.h	Sun Oct 21 00:51:12 2018
@@ -1,5 +1,5 @@
 /*	$OpenBSD: if_mskvar.h,v 1.3 2006/12/28 16:34:42 kettenis Exp $	*/
-/*	$NetBSD: if_mskvar.h,v 1.19 2018/09/14 18:46:47 jakllsch Exp $	*/
+/*	$NetBSD: if_mskvar.h,v 1.20 2018/10/21 00:51:12 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -193,6 +193,7 @@ struct sk_softc {
 	bus_space_tag_t		sk_btag;	/* bus space tag */
 	bus_size_t		sk_bsize;	/* bus space size */
 	void			*sk_intrhand;	/* irq handler handle */
+	pci_intr_handle_t	*sk_pihp;
 	pci_chipset_tag_t	sk_pc;
 	u_int8_t		sk_fibertype;
 	u_int8_t		sk_type;



CVS commit: src/sys/arch

2018-10-20 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 21 00:42:06 UTC 2018

Modified Files:
src/sys/arch/arm/acpi: acpi_pci_machdep.c gic_acpi.c
src/sys/arch/arm/cortex: files.cortex
src/sys/arch/arm/fdt: acpi_fdt.c
src/sys/arch/arm/include: pci_machdep.h
src/sys/arch/evbarm/conf: files.evbarm std.generic64
Added Files:
src/sys/arch/arm/cortex: gic_v2m.c gic_v2m.h
src/sys/arch/arm/pci: files.pci pci_msi_machdep.c pci_msi_machdep.h

Log Message:
Add support for PCI MSI using ARM GICv2m.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/acpi/acpi_pci_machdep.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/acpi/gic_acpi.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/cortex/files.cortex
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/cortex/gic_v2m.c \
src/sys/arch/arm/cortex/gic_v2m.h
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/fdt/acpi_fdt.c
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/include/pci_machdep.h
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/pci/files.pci \
src/sys/arch/arm/pci/pci_msi_machdep.c \
src/sys/arch/arm/pci/pci_msi_machdep.h
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/evbarm/conf/files.evbarm
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/evbarm/conf/std.generic64

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/arm/acpi/acpi_pci_machdep.c
diff -u src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.2 src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.3
--- src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.2	Fri Oct 19 11:40:27 2018
+++ src/sys/arch/arm/acpi/acpi_pci_machdep.c	Sun Oct 21 00:42:05 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci_machdep.c,v 1.2 2018/10/19 11:40:27 jmcneill Exp $ */
+/* $NetBSD: acpi_pci_machdep.c,v 1.3 2018/10/21 00:42:05 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_pci_machdep.c,v 1.2 2018/10/19 11:40:27 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_pci_machdep.c,v 1.3 2018/10/21 00:42:05 jmcneill Exp $");
 
 #include 
 #include 
@@ -57,8 +57,7 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_pci_mac
 
 #include 
 
-#define	IH_INDEX_MASK			0x
-#define	IH_MPSAFE			0x8000
+#include 
 
 struct acpi_pci_prt {
 	u_intprt_bus;
@@ -331,7 +330,13 @@ done:
 static const char *
 acpi_pci_md_intr_string(void *v, pci_intr_handle_t ih, char *buf, size_t len)
 {
-	snprintf(buf, len, "irq %d", (int)(ih & IH_INDEX_MASK));
+	const int irq = __SHIFTOUT(ih, ARM_PCI_INTR_IRQ);
+
+	if (ih & ARM_PCI_INTR_MSI)
+		snprintf(buf, len, "irq %d (MSI)", irq);
+	else
+		snprintf(buf, len, "irq %d", irq);
+
 	return buf;
 }
 
@@ -347,9 +352,9 @@ acpi_pci_md_intr_setattr(void *v, pci_in
 	switch (attr) {
 	case PCI_INTR_MPSAFE:
 		if (data)
-			*ih |= IH_MPSAFE;
+			*ih |= ARM_PCI_INTR_MPSAFE;
 		else
-			*ih &= ~IH_MPSAFE;
+			*ih &= ~ARM_PCI_INTR_MPSAFE;
 		return 0;
 	default:
 		return ENODEV;
@@ -360,8 +365,13 @@ static void *
 acpi_pci_md_intr_establish(void *v, pci_intr_handle_t ih, int ipl,
 int (*callback)(void *), void *arg)
 {
-	const int irq = ih & IH_INDEX_MASK;
-	const int mpsafe = (ih & IH_MPSAFE) ? IST_MPSAFE : 0;
+	struct acpi_pci_context * const ap = v;
+
+	if (ih & ARM_PCI_INTR_MSI)
+		return arm_pci_msi_intr_establish(>ap_pc, ih, ipl, callback, arg);
+
+	const int irq = (int)__SHIFTOUT(ih, ARM_PCI_INTR_IRQ);
+	const int mpsafe = (ih & ARM_PCI_INTR_MPSAFE) ? IST_MPSAFE : 0;
 
 	return intr_establish(irq, ipl, IST_LEVEL | mpsafe, callback, arg);
 }

Index: src/sys/arch/arm/acpi/gic_acpi.c
diff -u src/sys/arch/arm/acpi/gic_acpi.c:1.1 src/sys/arch/arm/acpi/gic_acpi.c:1.2
--- src/sys/arch/arm/acpi/gic_acpi.c:1.1	Fri Oct 12 22:20:04 2018
+++ src/sys/arch/arm/acpi/gic_acpi.c	Sun Oct 21 00:42:05 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: gic_acpi.c,v 1.1 2018/10/12 22:20:04 jmcneill Exp $ */
+/* $NetBSD: gic_acpi.c,v 1.2 2018/10/21 00:42:05 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,30 +30,36 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gic_acpi.c,v 1.1 2018/10/12 22:20:04 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gic_acpi.c,v 1.2 2018/10/21 00:42:05 jmcneill Exp $");
 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
 
 #include 
+#include 
+#include 
 #include 
 
 #include 
 
-#define	GICD_SIZE	0x1000
-#define	GICC_SIZE	0x1000
+#define	GICD_SIZE		0x1000
+#define	GICC_SIZE		0x1000
+#define	GICMSIFRAME_SIZE	0x1000
 
 extern struct bus_space arm_generic_bs_tag;
+extern struct pic_softc *pic_list[];
 
 static int	gic_acpi_match(device_t, cfdata_t, void *);
 static void	gic_acpi_attach(device_t, device_t, void *);
 
 static ACPI_STATUS gic_acpi_find_gicc(ACPI_SUBTABLE_HEADER *, void *);
+static ACPI_STATUS gic_acpi_find_msi_frame(ACPI_SUBTABLE_HEADER *, void *);
 
 CFATTACH_DECL_NEW(gic_acpi, 0, gic_acpi_match, gic_acpi_attach, NULL, NULL);
 
@@ -85,6 

CVS commit: src/tools

2018-10-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Oct 21 00:26:24 UTC 2018

Modified Files:
src/tools: Makefile.gnuhost

Log Message:
detect clang instead of bundling it with Darwin


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/tools/Makefile.gnuhost

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

Modified files:

Index: src/tools/Makefile.gnuhost
diff -u src/tools/Makefile.gnuhost:1.49 src/tools/Makefile.gnuhost:1.50
--- src/tools/Makefile.gnuhost:1.49	Sun Oct 14 06:23:32 2018
+++ src/tools/Makefile.gnuhost	Sat Oct 20 20:26:24 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.gnuhost,v 1.49 2018/10/14 10:23:32 martin Exp $
+#	$NetBSD: Makefile.gnuhost,v 1.50 2018/10/21 00:26:24 christos Exp $
 #
 # Rules used when building a GNU host package.  Expects MODULE to be set.
 #
@@ -19,7 +19,8 @@
 
 # Disable use of pre-compiled headers on Darwin.
 BUILD_OSTYPE!= uname -s
-.if ${BUILD_OSTYPE} == "Darwin"
+HOST_COMPILER_CLANG != if ${HOST_CC} --version | grep -q -s clang; then echo yes; else echo no; fi
+.if ${HOST_COMPILER_CLANG} == "yes"
 HOST_CFLAGS+=-O2 -no-cpp-precomp
 .endif
 



CVS commit: [jdolecek-ncqfixes] src/sys/dev/ata

2018-10-20 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sat Oct 20 21:08:23 UTC 2018

Modified Files:
src/sys/dev/ata [jdolecek-ncqfixes]: satapmp_subr.c

Log Message:
hold lock during drive reset (new locking protocol)

erase xfer before each reuse for read/write port commands


To generate a diff of this commit:
cvs rdiff -u -r1.14.2.1 -r1.14.2.2 src/sys/dev/ata/satapmp_subr.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/dev/ata/satapmp_subr.c
diff -u src/sys/dev/ata/satapmp_subr.c:1.14.2.1 src/sys/dev/ata/satapmp_subr.c:1.14.2.2
--- src/sys/dev/ata/satapmp_subr.c:1.14.2.1	Sat Sep 22 09:22:59 2018
+++ src/sys/dev/ata/satapmp_subr.c	Sat Oct 20 21:08:23 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: satapmp_subr.c,v 1.14.2.1 2018/09/22 09:22:59 jdolecek Exp $	*/
+/*	$NetBSD: satapmp_subr.c,v 1.14.2.2 2018/10/20 21:08:23 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 2012 Manuel Bouyer.  All rights reserved.
@@ -25,7 +25,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: satapmp_subr.c,v 1.14.2.1 2018/09/22 09:22:59 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: satapmp_subr.c,v 1.14.2.2 2018/10/20 21:08:23 jdolecek Exp $");
 
 #include 
 #include 
@@ -62,6 +62,7 @@ satapmp_read_8(struct ata_channel *chp, 
 	KASSERT(drvp->drive == PMP_PORT_CTL);
 	ata_channel_lock_owned(chp);
 
+	memset(xfer, 0, sizeof(*xfer));
 	xfer->c_ata_c.r_command = PMPC_READ_PORT;
 	xfer->c_ata_c.r_features = reg;
 	xfer->c_ata_c.r_device = port;
@@ -133,6 +134,7 @@ satapmp_write_8(struct ata_channel *chp,
 	KASSERT(drvp->drive == PMP_PORT_CTL);
 	ata_channel_lock_owned(chp);
 
+	memset(xfer, 0, sizeof(*xfer));
 	xfer->c_ata_c.r_command = PMPC_WRITE_PORT;
 	xfer->c_ata_c.r_features = reg;
 	xfer->c_ata_c.r_device = port;
@@ -261,10 +263,10 @@ satapmp_rescan(struct ata_channel *chp, 
 			device_xname(chp->atabus), i);
 			continue;
 		}
-		ata_channel_unlock(chp);
+
+		ata_channel_lock_owned(chp);
 		chp->ch_atac->atac_bustype_ata->ata_reset_drive(
 		>ch_drive[i], AT_WAIT, );
-		ata_channel_lock(chp);
 
 		sata_interpret_sig(chp, i, sig);
 	}



CVS commit: src/sys/kern

2018-10-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Oct 20 14:09:47 UTC 2018

Modified Files:
src/sys/kern: kern_malloc.c

Log Message:
Do not assume size_t == unsigned long


To generate a diff of this commit:
cvs rdiff -u -r1.153 -r1.154 src/sys/kern/kern_malloc.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/kern/kern_malloc.c
diff -u src/sys/kern/kern_malloc.c:1.153 src/sys/kern/kern_malloc.c:1.154
--- src/sys/kern/kern_malloc.c:1.153	Wed Aug 22 14:12:30 2018
+++ src/sys/kern/kern_malloc.c	Sat Oct 20 14:09:47 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_malloc.c,v 1.153 2018/08/22 14:12:30 christos Exp $	*/
+/*	$NetBSD: kern_malloc.c,v 1.154 2018/10/20 14:09:47 martin Exp $	*/
 
 /*
  * Copyright (c) 1987, 1991, 1993
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_malloc.c,v 1.153 2018/08/22 14:12:30 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_malloc.c,v 1.154 2018/10/20 14:09:47 martin Exp $");
 
 #include 
 #include 
@@ -101,12 +101,13 @@ struct malloc_header {
 } __aligned(ALIGNBYTES + 1);
 
 void *
-kern_malloc(unsigned long size, int flags)
+kern_malloc(unsigned long reqsize, int flags)
 {
 	const int kmflags = (flags & M_NOWAIT) ? KM_NOSLEEP : KM_SLEEP;
 #ifdef KASAN
-	const size_t origsize = size;
+	const size_t origsize = reqsize;
 #endif
+	size_t size = reqsize;
 	size_t allocsize, hdroffset;
 	struct malloc_header *mh;
 	void *p;



CVS commit: src/share/man/man5

2018-10-20 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sat Oct 20 08:47:03 UTC 2018

Modified Files:
src/share/man/man5: rc.conf.5

Log Message:
Remove trailing whitespace. Fix a macro.


To generate a diff of this commit:
cvs rdiff -u -r1.178 -r1.179 src/share/man/man5/rc.conf.5

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

Modified files:

Index: src/share/man/man5/rc.conf.5
diff -u src/share/man/man5/rc.conf.5:1.178 src/share/man/man5/rc.conf.5:1.179
--- src/share/man/man5/rc.conf.5:1.178	Fri Oct 19 14:11:12 2018
+++ src/share/man/man5/rc.conf.5	Sat Oct 20 08:47:03 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: rc.conf.5,v 1.178 2018/10/19 14:11:12 martin Exp $
+.\"	$NetBSD: rc.conf.5,v 1.179 2018/10/20 08:47:03 wiz Exp $
 .\"
 .\" Copyright (c) 1996 Matthew R. Green
 .\" All rights reserved.
@@ -358,15 +358,15 @@ Useful if swapping onto RAIDframe device
 or
 .Dq "manual" .
 Before removing block-type swap devices, it is wise to unmount tmpfs filesystems to avoid having to swap their contents back into RAM.
-By default 
+By default
 .Dq ( "auto" )
 all tmpfs filesystems that contain no device nodes are unmounted.
-Set to 
+Set to
 .Dq "manual"
 to explicitly specify which filesystems to unmount before removing swap.
 .It Sy swapoff_umount_fs
 A space-separated list of absolute paths to tmpfs mount points.
-If 
+If
 .Sy swapoff_umount
 is set to
 .Dq "manual" ,
@@ -1314,7 +1314,7 @@ in
 Passes
 .Sy ypserv_flags .
 The
-.FL d
+.Fl d
 flag causes it to use DNS for lookups in
 .Pa /etc/hosts
 that fail.



CVS commit: src/distrib/utils/embedded/conf

2018-10-20 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Oct 20 08:26:10 UTC 2018

Modified Files:
src/distrib/utils/embedded/conf: armv7.conf

Log Message:
Whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/distrib/utils/embedded/conf/armv7.conf

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

Modified files:

Index: src/distrib/utils/embedded/conf/armv7.conf
diff -u src/distrib/utils/embedded/conf/armv7.conf:1.24 src/distrib/utils/embedded/conf/armv7.conf:1.25
--- src/distrib/utils/embedded/conf/armv7.conf:1.24	Sat Oct 20 08:24:11 2018
+++ src/distrib/utils/embedded/conf/armv7.conf	Sat Oct 20 08:26:10 2018
@@ -1,4 +1,4 @@
-# $NetBSD: armv7.conf,v 1.24 2018/10/20 08:24:11 skrll Exp $
+# $NetBSD: armv7.conf,v 1.25 2018/10/20 08:26:10 skrll Exp $
 # ARMv7 customization script used by mkimage
 #
 board=armv7
@@ -67,7 +67,7 @@ EOF
 echo " $f"
 cp "${firmwaredir}/${f}" .
 			done
-	)
+		)
 
 	fi
 



CVS commit: src/distrib/utils/embedded/conf

2018-10-20 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Oct 20 08:24:11 UTC 2018

Modified Files:
src/distrib/utils/embedded/conf: armv7.conf

Log Message:
a bit of sorting


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/distrib/utils/embedded/conf/armv7.conf

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

Modified files:

Index: src/distrib/utils/embedded/conf/armv7.conf
diff -u src/distrib/utils/embedded/conf/armv7.conf:1.23 src/distrib/utils/embedded/conf/armv7.conf:1.24
--- src/distrib/utils/embedded/conf/armv7.conf:1.23	Mon Dec 11 11:38:14 2017
+++ src/distrib/utils/embedded/conf/armv7.conf	Sat Oct 20 08:24:11 2018
@@ -1,4 +1,4 @@
-# $NetBSD: armv7.conf,v 1.23 2017/12/11 11:38:14 jmcneill Exp $
+# $NetBSD: armv7.conf,v 1.24 2018/10/20 08:24:11 skrll Exp $
 # ARMv7 customization script used by mkimage
 #
 board=armv7
@@ -7,11 +7,11 @@ resize=true
 
 . ${DIR}/conf/evbarm.conf
 
+kernels_amlogic="ODROID-C1"
 kernels_beagle="BEAGLEBOARD BEAGLEBONE"
 kernels_rpi="RPI2"
-kernels_amlogic="ODROID-C1"
-kernels_tegra="TEGRA"
 kernels_sunxi="SUNXI"
+kernels_tegra="TEGRA"
 
 make_label() {
 	make_label_evbarm
@@ -152,11 +152,11 @@ populate() {
 	done
 
 	# board specific configuration
+	populate_amlogic
 	populate_beagle
 	populate_rpi
-	populate_amlogic
-	populate_tegra
 	populate_sunxi
+	populate_tegra
 
 	# common configuration
 	populate_common



CVS commit: [pgoyette-compat] src

2018-10-20 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Sat Oct 20 06:58:47 UTC 2018

Modified Files:
src/bin/sh [pgoyette-compat]: alias.c eval.c mkinit.sh shell.h show.c
src/common/lib/libc/string [pgoyette-compat]: memmem.c
src/common/lib/libprop [pgoyette-compat]: prop_kern.c
src/crypto/dist/ipsec-tools [pgoyette-compat]: NEWS README
src/crypto/dist/ipsec-tools/src/libipsec [pgoyette-compat]: Makefile.am
src/crypto/dist/ipsec-tools/src/racoon [pgoyette-compat]: isakmp_frag.c
logger.c racoon.conf.5
src/crypto/dist/ipsec-tools/src/setkey [pgoyette-compat]: Makefile.am
extern.h parse.y setkey.c token.l
src/crypto/external/bsd/openssh/dist [pgoyette-compat]: log.c
monitor_wrap.c packet.c serverloop.c
src/crypto/external/bsd/openssl/dist/test [pgoyette-compat]: hmactest.c
src/crypto/external/bsd/openssl/dist/test/testutil [pgoyette-compat]:
format_output.c main.c output.h tests.c
src/crypto/external/bsd/openssl/include/openssl [pgoyette-compat]:
opensslconf.h
src/crypto/external/bsd/openssl/lib/libcrypto [pgoyette-compat]:
Makefile crypto.map man.inc
src/crypto/external/bsd/openssl/lib/libcrypto/arch/arm 
[pgoyette-compat]:
arm_asm.h
src/crypto/external/bsd/openssl/lib/libssl [pgoyette-compat]: Makefile
src/distrib/alpha/instkernel/ramdisk [pgoyette-compat]: list
src/distrib/amd64/ramdisks/common [pgoyette-compat]: list.ramdisk
src/distrib/amd64/uefi-installimage [pgoyette-compat]:
Makefile.bootimage
src/distrib/common/bootimage [pgoyette-compat]: Makefile.bootimage
src/distrib/sets [pgoyette-compat]: Makefile
src/distrib/sets/lists/base [pgoyette-compat]: ad.aarch64 md.amd64
md.i386 mi
src/distrib/sets/lists/comp [pgoyette-compat]: ad.m68k mi
src/distrib/sets/lists/debug [pgoyette-compat]: ad.aarch64 md.amd64
md.i386 mi
src/distrib/sets/lists/man [pgoyette-compat]: mi
src/distrib/sparc64/instfs [pgoyette-compat]: list
src/distrib/utils/embedded/conf [pgoyette-compat]: evbarm.conf
src/distrib/utils/embedded/files [pgoyette-compat]: resize_disklabel
src/distrib/utils/x_gzip [pgoyette-compat]: Makefile
src/doc [pgoyette-compat]: 3RDPARTY CHANGES TODO.kaslr
src/etc [pgoyette-compat]: Makefile security
src/etc/defaults [pgoyette-compat]: rc.conf
src/etc/etc.aarch64 [pgoyette-compat]: MAKEDEV.conf
src/etc/etc.evbarm [pgoyette-compat]: MAKEDEV.conf
src/etc/mtree [pgoyette-compat]: NetBSD.dist.base
src/etc/rc.d [pgoyette-compat]: cleartmp resize_root swap1
src/external/bsd/acpica/bin/iasl [pgoyette-compat]: Makefile
src/external/bsd/bind/dist/lib/isc/unix [pgoyette-compat]: socket.c
src/external/bsd/file/dist [pgoyette-compat]: AUTHORS COPYING ChangeLog
Makefile.in NEWS README aclocal.m4 compile config.guess config.h.in
config.sub configure configure.ac depcomp install-sh ltmain.sh
missing
src/external/bsd/file/dist/doc [pgoyette-compat]: Makefile.in file.1
libmagic.3 magic.5
src/external/bsd/file/dist/magic [pgoyette-compat]: Header Makefile.am
Makefile.in
src/external/bsd/file/dist/magic/magdir [pgoyette-compat]: amigaos
animation archive audio cad cafebabe coff compress console database
dbpf dump elf fsav hitachi-sh images intel java jpeg linux make
measure msdos msooxml msvc pdf sgi sniffer wsdl
src/external/bsd/file/dist/python [pgoyette-compat]: Makefile.am
Makefile.in magic.py setup.py
src/external/bsd/file/dist/src [pgoyette-compat]: Makefile.am
Makefile.in apprentice.c apptype.c ascmagic.c asprintf.c cdf.c
cdf.h cdf_time.c compress.c der.c dprintf.c elfclass.h encoding.c
file.c file.h fmtcheck.c fsmagic.c funcs.c getopt_long.c is_tar.c
magic.c magic.h.in mygetopt.h print.c readcdf.c readelf.c readelf.h
seccomp.c softmagic.c vasprintf.c
src/external/bsd/file/dist/tests [pgoyette-compat]: Makefile.am
Makefile.in
src/external/bsd/file/include [pgoyette-compat]: config.h
src/external/bsd/file/lib [pgoyette-compat]: Makefile
src/external/bsd/nsd [pgoyette-compat]: Makefile.inc
src/external/bsd/ntp/dist/ntpd [pgoyette-compat]: ntpd.c
src/external/bsd/openresolv/dist [pgoyette-compat]: dnsmasq.in libc.in
named.in resolvconf.in unbound.in
src/external/cddl/dtracetoolkit/dist [pgoyette-compat]: iosnoop
src/external/public-domain/tz/dist [pgoyette-compat]: CONTRIBUTING
Makefile NEWS README TZDATA_VERSION africa antarctica asia
australasia backward backzone etcetera europe factory

CVS commit: src/sys/arch/arm

2018-10-20 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Oct 20 06:35:34 UTC 2018

Modified Files:
src/sys/arch/arm/altera: cycv_platform.c
src/sys/arch/arm/arm: cpufunc.c
src/sys/arch/arm/arm32: arm32_kvminit.c
src/sys/arch/arm/include: cpufunc.h

Log Message:
Clean up around cpu_ttb and fix a bunch of builds


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/altera/cycv_platform.c
cvs rdiff -u -r1.174 -r1.175 src/sys/arch/arm/arm/cpufunc.c
cvs rdiff -u -r1.46 -r1.47 src/sys/arch/arm/arm32/arm32_kvminit.c
cvs rdiff -u -r1.80 -r1.81 src/sys/arch/arm/include/cpufunc.h

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/arm/altera/cycv_platform.c
diff -u src/sys/arch/arm/altera/cycv_platform.c:1.3 src/sys/arch/arm/altera/cycv_platform.c:1.4
--- src/sys/arch/arm/altera/cycv_platform.c:1.3	Thu Oct 18 09:01:52 2018
+++ src/sys/arch/arm/altera/cycv_platform.c	Sat Oct 20 06:35:34 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: cycv_platform.c,v 1.3 2018/10/18 09:01:52 skrll Exp $ */
+/* $NetBSD: cycv_platform.c,v 1.4 2018/10/20 06:35:34 skrll Exp $ */
 
 /* This file is in the public domain. */
 
@@ -6,7 +6,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cycv_platform.c,v 1.3 2018/10/18 09:01:52 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cycv_platform.c,v 1.4 2018/10/20 06:35:34 skrll Exp $");
 
 #define	_ARM32_BUS_DMA_PRIVATE
 #include 
@@ -79,8 +79,6 @@ cycv_mpstart(void)
 	 * it was unmapped by u-boot in favor of the SDRAM. Plus the dtb is
 	 * stored very low in RAM so we can't re-map the Boot ROM easily.
 	 */
-	extern vaddr_t cpu_ttb;
-
 	pmap_map_chunk(cpu_ttb, CYCV_SDRAM_VBASE, CYCV_SDRAM_BASE, L1_S_SIZE,
 	VM_PROT_READ|VM_PROT_WRITE, PMAP_NOCACHE);
 	*(volatile uint32_t *) CYCV_SDRAM_VBASE =

Index: src/sys/arch/arm/arm/cpufunc.c
diff -u src/sys/arch/arm/arm/cpufunc.c:1.174 src/sys/arch/arm/arm/cpufunc.c:1.175
--- src/sys/arch/arm/arm/cpufunc.c:1.174	Thu Oct 18 09:01:52 2018
+++ src/sys/arch/arm/arm/cpufunc.c	Sat Oct 20 06:35:34 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.c,v 1.174 2018/10/18 09:01:52 skrll Exp $	*/
+/*	$NetBSD: cpufunc.c,v 1.175 2018/10/20 06:35:34 skrll Exp $	*/
 
 /*
  * arm7tdmi support code Copyright (c) 2001 John Fremlin
@@ -49,7 +49,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.174 2018/10/18 09:01:52 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.175 2018/10/20 06:35:34 skrll Exp $");
 
 #include "opt_arm_start.h"
 #include "opt_compat_netbsd.h"
@@ -118,6 +118,9 @@ struct	arm_cache_info arm_scache;
 u_int	arm_dcache_align;
 u_int	arm_dcache_align_mask;
 
+// Define a TTB value that can never be used.
+uint32_t cpu_ttb = ~0;
+
 /* 1 == use cpu_sleep(), 0 == don't */
 int cpu_do_powersave;
 
@@ -3561,8 +3564,6 @@ cpu_earlydevice_va_p(void)
 		return false;
 
 	/* Don't access cpu_ttb unless the mmu is enabled */
-	extern uint32_t cpu_ttb;
-
 	const bool cpul1pt_p =
 	((armreg_ttbr_read() & -L1_TABLE_SIZE) == cpu_ttb) ||
 	((armreg_ttbr1_read() & -L1_TABLE_SIZE) == cpu_ttb);

Index: src/sys/arch/arm/arm32/arm32_kvminit.c
diff -u src/sys/arch/arm/arm32/arm32_kvminit.c:1.46 src/sys/arch/arm/arm32/arm32_kvminit.c:1.47
--- src/sys/arch/arm/arm32/arm32_kvminit.c:1.46	Thu Oct 18 09:01:52 2018
+++ src/sys/arch/arm/arm32/arm32_kvminit.c	Sat Oct 20 06:35:34 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: arm32_kvminit.c,v 1.46 2018/10/18 09:01:52 skrll Exp $	*/
+/*	$NetBSD: arm32_kvminit.c,v 1.47 2018/10/20 06:35:34 skrll Exp $	*/
 
 /*
  * Copyright (c) 2002, 2003, 2005  Genetec Corporation.  All rights reserved.
@@ -127,7 +127,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: arm32_kvminit.c,v 1.46 2018/10/18 09:01:52 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: arm32_kvminit.c,v 1.47 2018/10/20 06:35:34 skrll Exp $");
 
 #include 
 #include 
@@ -423,9 +423,6 @@ valloc_pages(struct bootmem_info *bmi, p
 		memset((void *)pv->pv_va, 0, nbytes);
 }
 
-// Define a TTB value that can never be used.
-uint32_t cpu_ttb = ~0;
-
 void
 arm32_kernel_vm_init(vaddr_t kernel_vm_base, vaddr_t vectors, vaddr_t iovbase,
 	const struct pmap_devmap *devmap, bool mapallmem_p)
@@ -970,7 +967,6 @@ arm32_kernel_vm_init(vaddr_t kernel_vm_b
 	/* Switch tables */
 	VPRINTF("switching to new L1 page table @%#lx...\n", l1pt_pa);
 
-	extern uint32_t cpu_ttb;
 	cpu_ttb = l1pt_pa;
 
 	cpu_domains(DOMAIN_DEFAULT);

Index: src/sys/arch/arm/include/cpufunc.h
diff -u src/sys/arch/arm/include/cpufunc.h:1.80 src/sys/arch/arm/include/cpufunc.h:1.81
--- src/sys/arch/arm/include/cpufunc.h:1.80	Wed Aug 29 11:29:27 2018
+++ src/sys/arch/arm/include/cpufunc.h	Sat Oct 20 06:35:34 2018
@@ -413,6 +413,8 @@ extern u_int arm_dcache_align_mask;
 extern struct arm_cache_info arm_pcache;
 extern struct arm_cache_info arm_scache;
 
+extern uint32_t cpu_ttb;
+
 #endif	/* _GUMP */
 
 #endif	/* _KERNEL */

CVS commit: src/sys/arch/sparc64

2018-10-20 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sat Oct 20 06:25:46 UTC 2018

Modified Files:
src/sys/arch/sparc64/conf: files.sparc64
Added Files:
src/sys/arch/sparc64/dev: jbus-i2c.c

Log Message:
support for jbus-i2c found in US-IIIi machines
this needs help from schizo to access its registers, which is suboptimal and
should go away. So, for now this is for documentation purposes only.


To generate a diff of this commit:
cvs rdiff -u -r1.155 -r1.156 src/sys/arch/sparc64/conf/files.sparc64
cvs rdiff -u -r0 -r1.1 src/sys/arch/sparc64/dev/jbus-i2c.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/sparc64/conf/files.sparc64
diff -u src/sys/arch/sparc64/conf/files.sparc64:1.155 src/sys/arch/sparc64/conf/files.sparc64:1.156
--- src/sys/arch/sparc64/conf/files.sparc64:1.155	Sat Oct 13 20:11:48 2018
+++ src/sys/arch/sparc64/conf/files.sparc64	Sat Oct 20 06:25:46 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: files.sparc64,v 1.155 2018/10/13 20:11:48 macallan Exp $
+#	$NetBSD: files.sparc64,v 1.156 2018/10/20 06:25:46 macallan Exp $
 
 # @(#)files.sparc64	8.1 (Berkeley) 7/19/93
 # sparc64-specific configuration info
@@ -45,6 +45,10 @@ file	arch/sparc64/dev/pyro.c			pyro
 file	arch/sparc64/dev/vpci.c			vpci
 file	arch/sparc64/dev/pci_machdep.c		psycho | schizo | pyro | vpci
 
+device jbusi2c: i2cexec, i2c_bitbang, i2cbus
+attach jbusi2c at mainbus
+file	arch/sparc64/dev/jbus-i2c.c		jbusi2c
+
 define  central {}
 device	central: central
 attach	central at mainbus

Added files:

Index: src/sys/arch/sparc64/dev/jbus-i2c.c
diff -u /dev/null src/sys/arch/sparc64/dev/jbus-i2c.c:1.1
--- /dev/null	Sat Oct 20 06:25:46 2018
+++ src/sys/arch/sparc64/dev/jbus-i2c.c	Sat Oct 20 06:25:46 2018
@@ -0,0 +1,266 @@
+/*	$NetBSD: jbus-i2c.c,v 1.1 2018/10/20 06:25:46 macallan Exp $	*/
+
+/*
+ * Copyright (c) 2018 Michael Lorenz
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+__KERNEL_RCSID(0, "$NetBSD: jbus-i2c.c,v 1.1 2018/10/20 06:25:46 macallan Exp $");
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define DPRINTF printf
+
+/* I2C glue */
+static int jbusi2c_i2c_acquire_bus(void *, int);
+static void jbusi2c_i2c_release_bus(void *, int);
+static int jbusi2c_i2c_send_start(void *, int);
+static int jbusi2c_i2c_send_stop(void *, int);
+static int jbusi2c_i2c_initiate_xfer(void *, i2c_addr_t, int);
+static int jbusi2c_i2c_read_byte(void *, uint8_t *, int);
+static int jbusi2c_i2c_write_byte(void *, uint8_t, int);
+
+/* I2C bitbang glue */
+static void jbusi2c_i2cbb_set_bits(void *, uint32_t);
+static void jbusi2c_i2cbb_set_dir(void *, uint32_t);
+static uint32_t jbusi2c_i2cbb_read(void *);
+
+static const struct i2c_bitbang_ops jbusi2c_i2cbb_ops = {
+	jbusi2c_i2cbb_set_bits,
+	jbusi2c_i2cbb_set_dir,
+	jbusi2c_i2cbb_read,
+	{
+		2,	/* bit 1 is data */
+		1,	/* bit 0 is clock */
+		3,	/* direction register for both out */
+		1	/* data in, clock out */
+	}
+};
+
+static	int	jbusi2c_match(device_t, cfdata_t, void *);
+static	void	jbusi2c_attach(device_t, device_t, void *);
+
+struct jbusi2c_softc {
+	device_t sc_dev;
+	struct i2c_controller sc_i2c;
+	kmutex_t sc_i2c_lock;
+	int sc_node;
+};
+
+static void jbusi2c_setup_i2c(struct jbusi2c_softc *);
+
+CFATTACH_DECL_NEW(jbusi2c, sizeof(struct jbusi2c_softc),
+jbusi2c_match, jbusi2c_attach, NULL, NULL);
+
+extern struct schizo_softc *schizo0;
+
+int
+jbusi2c_match(device_t parent, cfdata_t match, void *aux)
+{
+	struct mainbus_attach_args *ma = aux;
+	char *str;
+
+	if (strcmp(ma->ma_name, "i2c") != 0)
+		

CVS commit: src/sys/arch/aarch64/aarch64

2018-10-20 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Sat Oct 20 06:18:18 UTC 2018

Modified Files:
src/sys/arch/aarch64/aarch64: aarch64_machdep.c

Log Message:
changes of r1.14 was incomplete. use bootconfig.dram[] to resolve valid memory 
range.
pmap(1) failed to access kvm on some environment.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/aarch64/aarch64/aarch64_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/aarch64/aarch64/aarch64_machdep.c
diff -u src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.15 src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.16
--- src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.15	Sun Oct 14 14:31:05 2018
+++ src/sys/arch/aarch64/aarch64/aarch64_machdep.c	Sat Oct 20 06:18:18 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: aarch64_machdep.c,v 1.15 2018/10/14 14:31:05 skrll Exp $ */
+/* $NetBSD: aarch64_machdep.c,v 1.16 2018/10/20 06:18:18 ryo Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: aarch64_machdep.c,v 1.15 2018/10/14 14:31:05 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: aarch64_machdep.c,v 1.16 2018/10/20 06:18:18 ryo Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -228,16 +228,36 @@ initarm_common(vaddr_t kvm_base, vsize_t
 	paddr_t kernstart_phys __unused = KERN_VTOPHYS(kernstart);
 	paddr_t kernend_phys __unused = KERN_VTOPHYS(kernend);
 
-	/* XXX */
+	/* XXX: arm/arm32/bus_dma.c refers physical_{start,end} */
 	physical_start = bootconfig.dram[0].address;
 	physical_end = physical_start + ptoa(bootconfig.dram[0].pages);
 
+	/*
+	 * msgbuf is allocated from the bottom of any one of memory blocks
+	 * to avoid corruption due to bootloader or changing kernel layout.
+	 */
+	paddr_t msgbufaddr = 0;
+	for (i = 0; i < bootconfig.dramblocks; i++) {
+		/* this block has enough space for msgbuf? */
+		if (bootconfig.dram[i].pages < atop(round_page(MSGBUFSIZE)))
+			continue;
+
+		/* allocate msgbuf from the bottom of this block */
+		bootconfig.dram[i].pages -= atop(round_page(MSGBUFSIZE));
+		msgbufaddr = bootconfig.dram[i].address +
+		ptoa(bootconfig.dram[i].pages);
+		break;
+	}
+	KASSERT(msgbufaddr != 0);	/* no space for msgbuf */
+	initmsgbuf((void *)AARCH64_PA_TO_KVA(msgbufaddr), MSGBUFSIZE);
+
 	VPRINTF(
 	"--\n"
 	"kern_vtopdiff = 0x%016lx\n"
 	"physical_start= 0x%016lx\n"
 	"kernel_start_phys = 0x%016lx\n"
 	"kernel_end_phys   = 0x%016lx\n"
+	"msgbuf= 0x%016lx\n"
 	"physical_end  = 0x%016lx\n"
 	"VM_MIN_KERNEL_ADDRESS = 0x%016lx\n"
 	"kernel_start_l2   = 0x%016lx\n"
@@ -258,6 +278,7 @@ initarm_common(vaddr_t kvm_base, vsize_t
 	physical_start,
 	kernstart_phys,
 	kernend_phys,
+	msgbufaddr,
 	physical_end,
 	VM_MIN_KERNEL_ADDRESS,
 	kernstart_l2,
@@ -273,14 +294,6 @@ initarm_common(vaddr_t kvm_base, vsize_t
 	VM_KERNEL_IO_ADDRESS,
 	VM_MAX_KERNEL_ADDRESS);
 
-	/*
-	 * msgbuf is always allocated from bottom of 1st memory block.
-	 * against corruption by bootloader, or changing kernel layout.
-	 */
-	physical_end -= round_page(MSGBUFSIZE);
-	bootconfig.dram[0].pages -= atop(round_page(MSGBUFSIZE));
-	initmsgbuf((void *)AARCH64_PA_TO_KVA(physical_end), MSGBUFSIZE);
-
 #ifdef DDB
 	db_machdep_init();
 #endif
@@ -505,23 +518,35 @@ module_init_md(void)
 }
 #endif /* MODULAR */
 
+static bool
+in_dram_p(paddr_t pa, psize_t size)
+{
+	int i;
+
+	for (i = 0; i < bootconfig.dramblocks; i++) {
+		paddr_t s, e;
+		s = bootconfig.dram[i].address;
+		e = bootconfig.dram[i].address + ptoa(bootconfig.dram[i].pages);
+		if ((s <= pa) && ((pa + size) <= e))
+			return true;
+	}
+	return false;
+}
+
 bool
 mm_md_direct_mapped_phys(paddr_t pa, vaddr_t *vap)
 {
-	/* XXX */
-	if (physical_start <= pa && pa < physical_end) {
+	if (in_dram_p(pa, 0)) {
 		*vap = AARCH64_PA_TO_KVA(pa);
 		return true;
 	}
-
 	return false;
 }
 
 int
 mm_md_physacc(paddr_t pa, vm_prot_t prot)
 {
-	/* XXX */
-	if (physical_start <= pa && pa < physical_end)
+	if (in_dram_p(pa, 0))
 		return 0;
 
 	return kauth_authorize_machdep(kauth_cred_get(),
@@ -554,8 +579,12 @@ mm_md_kernacc(void *ptr, vm_prot_t prot,
 		if ((v < data_start) && (prot & VM_PROT_WRITE))
 			return EFAULT;
 	} else if (IN_RANGE(v, AARCH64_KSEG_START, AARCH64_KSEG_END)) {
+		/*
+		 * if defined PMAP_MAP_POOLPAGE, direct mapped address (KSEG)
+		 * will be appeared as kvm(3) address.
+		 */
 		paddr_t pa = AARCH64_KVA_TO_PA(v);
-		if (IN_RANGE(pa, physical_start, physical_end)) {
+		if (in_dram_p(pa, 0)) {
 			*handled = true;
 			if (IN_RANGE(pa, kernstart_phys,
 			kernstart_phys + rosize) &&