CVS commit: src/doc

2018-10-12 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Oct 13 05:53:50 UTC 2018

Modified Files:
src/doc: TODO.kaslr

Log Message:
Mark one entry as done, and another one as pointless.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/doc/TODO.kaslr

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

Modified files:

Index: src/doc/TODO.kaslr
diff -u src/doc/TODO.kaslr:1.6 src/doc/TODO.kaslr:1.7
--- src/doc/TODO.kaslr:1.6	Fri Sep  7 10:20:32 2018
+++ src/doc/TODO.kaslr	Sat Oct 13 05:53:50 2018
@@ -23,7 +23,7 @@
[DONE] - kern.proc
[DONE] - kern.proc2
- kern.file
-   - kern.file2
+   [DONE] - kern.file2
- kern.lwp
- sysctl_inpcblist
- sysctl_unpcblist
@@ -38,7 +38,7 @@
 
 [DONE] -- Randomize the direct map.
 
--- Randomize the PCPU area.
+[POINTLESS, BECAUSE CPU LEAKY] -- Randomize the PCPU area.
 
 == GENERAL ==
 



CVS commit: src/sys/arch/arm/fdt

2018-10-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Oct 13 00:15:11 UTC 2018

Modified Files:
src/sys/arch/arm/fdt: acpi_fdt.c

Log Message:
Support poweroff via PSCI


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/fdt/acpi_fdt.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/arm/fdt/acpi_fdt.c
diff -u src/sys/arch/arm/fdt/acpi_fdt.c:1.1 src/sys/arch/arm/fdt/acpi_fdt.c:1.2
--- src/sys/arch/arm/fdt/acpi_fdt.c:1.1	Fri Oct 12 22:20:48 2018
+++ src/sys/arch/arm/fdt/acpi_fdt.c	Sat Oct 13 00:15:10 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_fdt.c,v 1.1 2018/10/12 22:20:48 jmcneill Exp $ */
+/* $NetBSD: acpi_fdt.c,v 1.2 2018/10/13 00:15:10 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015-2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v 1.1 2018/10/12 22:20:48 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v 1.2 2018/10/13 00:15:10 jmcneill Exp $");
 
 #include 
 #include 
@@ -44,14 +44,22 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v
 #include 
 #include 
 
+#include 
+
 static int	acpi_fdt_match(device_t, cfdata_t, void *);
 static void	acpi_fdt_attach(device_t, device_t, void *);
 
+static void	acpi_fdt_poweroff(device_t);
+
 static const char * const compatible[] = {
 	"netbsd,acpi",
 	NULL
 };
 
+static const struct fdtbus_power_controller_func acpi_fdt_power_funcs = {
+	.poweroff = acpi_fdt_poweroff,
+};
+
 CFATTACH_DECL_NEW(acpi_fdt, 0, acpi_fdt_match, acpi_fdt_attach, NULL, NULL);
 
 static int
@@ -71,6 +79,9 @@ acpi_fdt_attach(device_t parent, device_
 	aprint_naive("\n");
 	aprint_normal(": ACPI Platform support\n");
 
+	fdtbus_register_power_controller(self, faa->faa_phandle,
+	_fdt_power_funcs);
+
 	if (!acpi_probe())
 		aprint_error_dev(self, "failed to probe ACPI\n");
 
@@ -88,3 +99,11 @@ acpi_fdt_attach(device_t parent, device_
 #endif
 	config_found_ia(self, "acpibus", , 0);
 }
+
+static void
+acpi_fdt_poweroff(device_t dev)
+{
+	delay(50);
+	if (psci_available())
+		psci_system_off();
+}



CVS commit: src/sys/arch/arm/arm

2018-10-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Oct 13 00:07:55 UTC 2018

Modified Files:
src/sys/arch/arm/arm: psci.c psci.h

Log Message:
Add function that returns true if PSCI has been initialized


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/arm/psci.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/arm/psci.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/arm/psci.c
diff -u src/sys/arch/arm/arm/psci.c:1.2 src/sys/arch/arm/arm/psci.c:1.3
--- src/sys/arch/arm/arm/psci.c:1.2	Fri Jun 15 15:59:20 2018
+++ src/sys/arch/arm/arm/psci.c	Sat Oct 13 00:07:55 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: psci.c,v 1.2 2018/06/15 15:59:20 jakllsch Exp $ */
+/* $NetBSD: psci.c,v 1.3 2018/10/13 00:07:55 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -29,7 +29,7 @@
 #include "opt_diagnostic.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: psci.c,v 1.2 2018/06/15 15:59:20 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: psci.c,v 1.3 2018/10/13 00:07:55 jmcneill Exp $");
 
 #include 
 #include 
@@ -106,6 +106,12 @@ psci_init(psci_fn fn)
 	psci_call_fn = fn;
 }
 
+bool
+psci_available(void)
+{
+	return psci_call_fn != NULL;
+}
+
 void
 psci_clearfunc(void)
 {

Index: src/sys/arch/arm/arm/psci.h
diff -u src/sys/arch/arm/arm/psci.h:1.1 src/sys/arch/arm/arm/psci.h:1.2
--- src/sys/arch/arm/arm/psci.h:1.1	Wed Jun 28 23:48:23 2017
+++ src/sys/arch/arm/arm/psci.h	Sat Oct 13 00:07:55 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: psci.h,v 1.1 2017/06/28 23:48:23 jmcneill Exp $ */
+/* $NetBSD: psci.h,v 1.2 2018/10/13 00:07:55 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -65,6 +65,11 @@ typedef int (*psci_fn)(register_t, regis
 void	psci_init(psci_fn);
 
 /*
+ * Return true if PSCI is available (psci_init has been called).
+ */
+bool	psci_available(void);
+
+/*
  * PSCI call methods, implemented in psci.S
  */
 int	psci_call_smc(register_t, register_t, register_t, register_t);



CVS commit: src/sys/arch/arm/acpi

2018-10-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Oct 13 00:08:29 UTC 2018

Modified Files:
src/sys/arch/arm/acpi: acpi_platform.c

Log Message:
Don't rely on PSCI node in FDT to reboot


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/acpi/acpi_platform.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/arm/acpi/acpi_platform.c
diff -u src/sys/arch/arm/acpi/acpi_platform.c:1.1 src/sys/arch/arm/acpi/acpi_platform.c:1.2
--- src/sys/arch/arm/acpi/acpi_platform.c:1.1	Fri Oct 12 22:20:04 2018
+++ src/sys/arch/arm/acpi/acpi_platform.c	Sat Oct 13 00:08:29 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_platform.c,v 1.1 2018/10/12 22:20:04 jmcneill Exp $ */
+/* $NetBSD: acpi_platform.c,v 1.2 2018/10/13 00:08:29 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.1 2018/10/12 22:20:04 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.2 2018/10/13 00:08:29 jmcneill Exp $");
 
 #include 
 #include 
@@ -162,6 +162,13 @@ acpi_platform_device_register(device_t s
 {
 }
 
+static void
+acpi_platform_reset(void)
+{
+	if (psci_available())
+		psci_system_reset();
+}
+
 static u_int
 acpi_platform_uart_freq(void)
 {
@@ -175,7 +182,7 @@ static const struct arm_platform acpi_pl
 	.ap_init_attach_args = acpi_platform_init_attach_args,
 	.ap_early_putchar = acpi_platform_early_putchar,
 	.ap_device_register = acpi_platform_device_register,
-	.ap_reset = psci_fdt_reset,
+	.ap_reset = acpi_platform_reset,
 	.ap_delay = gtmr_delay,
 	.ap_uart_freq = acpi_platform_uart_freq,
 };



CVS commit: src/sys/arch/evbarm/dev

2018-10-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Oct 12 23:57:00 UTC 2018

Modified Files:
src/sys/arch/evbarm/dev: plcom.c

Log Message:
Don't write FBRD/IBRD if ref clk frequency is unknown


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/arch/evbarm/dev/plcom.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/evbarm/dev/plcom.c
diff -u src/sys/arch/evbarm/dev/plcom.c:1.54 src/sys/arch/evbarm/dev/plcom.c:1.55
--- src/sys/arch/evbarm/dev/plcom.c:1.54	Fri Oct 12 22:18:38 2018
+++ src/sys/arch/evbarm/dev/plcom.c	Fri Oct 12 23:57:00 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: plcom.c,v 1.54 2018/10/12 22:18:38 jmcneill Exp $	*/
+/*	$NetBSD: plcom.c,v 1.55 2018/10/12 23:57:00 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2001 ARM Ltd
@@ -94,7 +94,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: plcom.c,v 1.54 2018/10/12 22:18:38 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: plcom.c,v 1.55 2018/10/12 23:57:00 jmcneill Exp $");
 
 #include "opt_plcom.h"
 #include "opt_ddb.h"
@@ -1537,8 +1537,10 @@ plcom_loadchannelregs(struct plcom_softc
 	switch (pi->pi_type) {
 	case PLCOM_TYPE_PL010:
 		PWRITE1(pi, PL010COM_CR, 0);
-		PWRITE1(pi, PL010COM_DLBL, sc->sc_ratel);
-		PWRITE1(pi, PL010COM_DLBH, sc->sc_rateh);
+		if (sc->sc_frequency != 0) {
+			PWRITE1(pi, PL010COM_DLBL, sc->sc_ratel);
+			PWRITE1(pi, PL010COM_DLBH, sc->sc_rateh);
+		}
 		PWRITE1(pi, PL010COM_LCR, sc->sc_lcr);
 
 		/* XXX device_unit() abuse */
@@ -1552,8 +1554,10 @@ plcom_loadchannelregs(struct plcom_softc
 
 	case PLCOM_TYPE_PL011:
 		PWRITE4(pi, PL011COM_CR, 0);
-		PWRITE1(pi, PL011COM_FBRD, sc->sc_ratel);
-		PWRITE4(pi, PL011COM_IBRD, sc->sc_rateh);
+		if (sc->sc_frequency != 0) {
+			PWRITE1(pi, PL011COM_FBRD, sc->sc_ratel);
+			PWRITE4(pi, PL011COM_IBRD, sc->sc_rateh);
+		}
 		PWRITE1(pi, PL011COM_LCRH, sc->sc_lcr);
 		sc->sc_mcr_active = sc->sc_mcr;
 		CLR(sc->sc_cr, PL011_MCR(PL01X_MCR_RTS | PL01X_MCR_DTR));



CVS commit: src/sys/arch/evbarm/conf

2018-10-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Oct 12 23:26:41 UTC 2018

Modified Files:
src/sys/arch/evbarm/conf: GENERIC64

Log Message:
Add ahcisata at acpi


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/arch/evbarm/conf/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/GENERIC64
diff -u src/sys/arch/evbarm/conf/GENERIC64:1.45 src/sys/arch/evbarm/conf/GENERIC64:1.46
--- src/sys/arch/evbarm/conf/GENERIC64:1.45	Fri Oct 12 22:22:21 2018
+++ src/sys/arch/evbarm/conf/GENERIC64	Fri Oct 12 23:26:41 2018
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: GENERIC64,v 1.45 2018/10/12 22:22:21 jmcneill Exp $
+#	$NetBSD: GENERIC64,v 1.46 2018/10/12 23:26:41 jmcneill Exp $
 #
 #	GENERIC ARM (aarch64) kernel
 #
@@ -296,6 +296,7 @@ ld*		at sdmmc?
 
 # SATA
 ahcisata*	at fdt?			# AHCI SATA
+ahcisata*	at acpi?
 atabus*		at ata?
 atapibus*	at atapi?
 wd*		at atabus? drive ?



CVS commit: src/sys/dev/acpi

2018-10-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Oct 12 23:26:18 UTC 2018

Modified Files:
src/sys/dev/acpi: files.acpi
Added Files:
src/sys/dev/acpi: ahcisata_acpi.c

Log Message:
Add ahcisata at acpi glue


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/dev/acpi/ahcisata_acpi.c
cvs rdiff -u -r1.102 -r1.103 src/sys/dev/acpi/files.acpi

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/acpi/files.acpi
diff -u src/sys/dev/acpi/files.acpi:1.102 src/sys/dev/acpi/files.acpi:1.103
--- src/sys/dev/acpi/files.acpi:1.102	Fri Oct 12 21:38:10 2018
+++ src/sys/dev/acpi/files.acpi	Fri Oct 12 23:26:18 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: files.acpi,v 1.102 2018/10/12 21:38:10 jmcneill Exp $
+#	$NetBSD: files.acpi,v 1.103 2018/10/12 23:26:18 jmcneill Exp $
 
 include "dev/acpi/acpica/files.acpica"
 
@@ -229,4 +229,8 @@ file	dev/acpi/sdhc_acpi.c		sdhc_acpi
 attach	qemufwcfg at acpinodebus with qemufwcfg_acpi
 file	dev/acpi/qemufwcfg_acpi.c	qemufwcfg_acpi
 
+# AHCI SATA controller
+attach	ahcisata at acpinodebus with ahcisata_acpi
+file	dev/acpi/ahcisata_acpi.c	ahcisata_acpi
+
 include	"dev/acpi/wmi/files.wmi"

Added files:

Index: src/sys/dev/acpi/ahcisata_acpi.c
diff -u /dev/null src/sys/dev/acpi/ahcisata_acpi.c:1.1
--- /dev/null	Fri Oct 12 23:26:18 2018
+++ src/sys/dev/acpi/ahcisata_acpi.c	Fri Oct 12 23:26:18 2018
@@ -0,0 +1,116 @@
+/* $NetBSD: ahcisata_acpi.c,v 1.1 2018/10/12 23:26:18 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2018 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jared McNeill .
+ *
+ * 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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: ahcisata_acpi.c,v 1.1 2018/10/12 23:26:18 jmcneill Exp $");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+
+static int	ahcisata_acpi_match(device_t, cfdata_t, void *);
+static void	ahcisata_acpi_attach(device_t, device_t, void *);
+
+CFATTACH_DECL_NEW(ahcisata_acpi, sizeof(struct ahci_softc), ahcisata_acpi_match, ahcisata_acpi_attach, NULL, NULL);
+
+static int
+ahcisata_acpi_match(device_t parent, cfdata_t cf, void *aux)
+{
+	struct acpi_attach_args *aa = aux;
+
+	if (aa->aa_node->ad_type != ACPI_TYPE_DEVICE)
+		return 0;
+
+	return acpi_match_class(aa->aa_node->ad_handle,
+	PCI_CLASS_MASS_STORAGE,
+	PCI_SUBCLASS_MASS_STORAGE_SATA,
+	PCI_INTERFACE_SATA_AHCI10);
+}
+
+static void
+ahcisata_acpi_attach(device_t parent, device_t self, void *aux)
+{
+	struct ahci_softc * const sc = device_private(self);
+	struct acpi_attach_args *aa = aux;
+	struct acpi_resources res;
+	struct acpi_mem *mem;
+	struct acpi_irq *irq;
+	ACPI_STATUS rv;
+	void *ih;
+
+	rv = acpi_resource_parse(self, aa->aa_node->ad_handle, "_CRS",
+	, _resource_parse_ops_default);
+	if (ACPI_FAILURE(rv))
+		return;
+
+	mem = acpi_res_mem(, 0);
+	if (mem == NULL) {
+		aprint_error(": couldn't find mem resource\n");
+		goto done;
+	}
+
+	irq = acpi_res_irq(, 0);
+	if (irq == NULL) {
+		aprint_error(": couldn't find irq resource\n");
+		goto done;
+	}
+
+	sc->sc_atac.atac_dev = self;
+	sc->sc_dmat = aa->aa_dmat;
+	sc->sc_ahcit = aa->aa_memt;
+	sc->sc_ahcis = mem->ar_length;
+	if (bus_space_map(aa->aa_memt, mem->ar_base, mem->ar_length, 0, >sc_ahcih) != 0) {
+		aprint_error(": couldn't map registers\n");
+		goto done;
+	}
+
+	const int type = (irq->ar_type == ACPI_EDGE_SENSITIVE) ? IST_EDGE : IST_LEVEL;
+	ih = intr_establish(irq->ar_irq, IPL_BIO, type, ahci_intr, sc);
+	if (ih == NULL) {
+		

CVS commit: src/sys/dev/acpi

2018-10-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Oct 12 23:25:29 UTC 2018

Modified Files:
src/sys/dev/acpi: acpi_util.c acpi_util.h

Log Message:
Add helper function to match a PCI-defined class/subclass/interface
against a _CLS object.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/acpi/acpi_util.c
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/acpi/acpi_util.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/acpi/acpi_util.c
diff -u src/sys/dev/acpi/acpi_util.c:1.12 src/sys/dev/acpi/acpi_util.c:1.13
--- src/sys/dev/acpi/acpi_util.c:1.12	Fri Oct 12 21:19:11 2018
+++ src/sys/dev/acpi/acpi_util.c	Fri Oct 12 23:25:29 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: acpi_util.c,v 1.12 2018/10/12 21:19:11 jmcneill Exp $ */
+/*	$NetBSD: acpi_util.c,v 1.13 2018/10/12 23:25:29 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2003, 2007 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_util.c,v 1.12 2018/10/12 21:19:11 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_util.c,v 1.13 2018/10/12 23:25:29 jmcneill Exp $");
 
 #include 
 #include 
@@ -340,6 +340,43 @@ acpi_match_hid(ACPI_DEVICE_INFO *ad, con
 }
 
 /*
+ * Match a PCI-defined bass-class, sub-class, and programming interface
+ * against a handle's _CLS object.
+ */
+int
+acpi_match_class(ACPI_HANDLE handle, uint8_t pci_class, uint8_t pci_subclass,
+uint8_t pci_interface)
+{
+	ACPI_BUFFER buf;
+	ACPI_OBJECT *obj;
+	ACPI_STATUS rv;
+	int match = 0;
+
+	rv = acpi_eval_struct(handle, "_CLS", );
+	if (ACPI_FAILURE(rv))
+		goto done;
+
+	obj = buf.Pointer;
+	if (obj->Type != ACPI_TYPE_PACKAGE)
+		goto done;
+	if (obj->Package.Count != 3)
+		goto done;
+	if (obj->Package.Elements[0].Type != ACPI_TYPE_INTEGER ||
+	obj->Package.Elements[1].Type != ACPI_TYPE_INTEGER ||
+	obj->Package.Elements[2].Type != ACPI_TYPE_INTEGER)
+		goto done;
+
+	match = obj->Package.Elements[0].Integer.Value == pci_class &&
+		obj->Package.Elements[1].Integer.Value == pci_subclass &&
+		obj->Package.Elements[2].Integer.Value == pci_interface;
+
+done:
+	if (buf.Pointer)
+		ACPI_FREE(buf.Pointer);
+	return match;
+}
+
+/*
  * Match a device node from a handle.
  */
 struct acpi_devnode *

Index: src/sys/dev/acpi/acpi_util.h
diff -u src/sys/dev/acpi/acpi_util.h:1.5 src/sys/dev/acpi/acpi_util.h:1.6
--- src/sys/dev/acpi/acpi_util.h:1.5	Tue Jun 21 03:37:21 2011
+++ src/sys/dev/acpi/acpi_util.h	Fri Oct 12 23:25:29 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: acpi_util.h,v 1.5 2011/06/21 03:37:21 jruoho Exp $ */
+/*	$NetBSD: acpi_util.h,v 1.6 2018/10/12 23:25:29 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2003, 2007 The NetBSD Foundation, Inc.
@@ -84,6 +84,7 @@ void		 acpi_match_node_init(struct a
 
 const char	*acpi_name(ACPI_HANDLE);
 int		 acpi_match_hid(ACPI_DEVICE_INFO *, const char * const *);
+int		 acpi_match_class(ACPI_HANDLE, uint8_t, uint8_t, uint8_t);
 ACPI_HANDLE	 acpi_match_cpu_info(struct cpu_info *);
 struct cpu_info *acpi_match_cpu_handle(ACPI_HANDLE);
 



CVS commit: [pgoyette-compat] src/sys

2018-10-12 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Fri Oct 12 22:30:54 UTC 2018

Modified Files:
src/sys/compat/common [pgoyette-compat]: compat_50_mod.c compat_mod.h
rndpseudo_50.c
src/sys/compat/netbsd32 [pgoyette-compat]: netbsd32_compat_50.c
src/sys/kern [pgoyette-compat]: compat_stub.c kern_rndq.c
src/sys/sys [pgoyette-compat]: compat_stub.h

Log Message:
Use a MP-safe hook for the rnd_ioctl compat_50 calls.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.16 -r1.1.2.17 src/sys/compat/common/compat_50_mod.c
cvs rdiff -u -r1.1.42.22 -r1.1.42.23 src/sys/compat/common/compat_mod.h
cvs rdiff -u -r1.2.38.1 -r1.2.38.2 src/sys/compat/common/rndpseudo_50.c
cvs rdiff -u -r1.32.16.12 -r1.32.16.13 \
src/sys/compat/netbsd32/netbsd32_compat_50.c
cvs rdiff -u -r1.1.2.26 -r1.1.2.27 src/sys/kern/compat_stub.c
cvs rdiff -u -r1.89.16.3 -r1.89.16.4 src/sys/kern/kern_rndq.c
cvs rdiff -u -r1.1.2.38 -r1.1.2.39 src/sys/sys/compat_stub.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/compat/common/compat_50_mod.c
diff -u src/sys/compat/common/compat_50_mod.c:1.1.2.16 src/sys/compat/common/compat_50_mod.c:1.1.2.17
--- src/sys/compat/common/compat_50_mod.c:1.1.2.16	Sun Sep 23 04:31:17 2018
+++ src/sys/compat/common/compat_50_mod.c	Fri Oct 12 22:30:54 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat_50_mod.c,v 1.1.2.16 2018/09/23 04:31:17 pgoyette Exp $	*/
+/*	$NetBSD: compat_50_mod.c,v 1.1.2.17 2018/10/12 22:30:54 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: compat_50_mod.c,v 1.1.2.16 2018/09/23 04:31:17 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_50_mod.c,v 1.1.2.17 2018/10/12 22:30:54 pgoyette Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -85,6 +85,7 @@ compat_50_init(void)
 	puffs_50_init();
 	wsevent_50_init();
 	vnd_50_init();
+	rndpseudo_50_init();
 
 	return error;
 
@@ -105,6 +106,7 @@ compat_50_fini(void)
 {
 	int error = 0;
 
+	rndpseudo_50_fini();
 	vnd_50_fini();
 	wsevent_50_fini();
 	puffs_50_fini();
@@ -146,6 +148,7 @@ compat_50_fini(void)
 	puffs_50_init();
 	wsevent_50_init();
 	vnd_50_init();
+	rndpseudo_50_init();
 
 	return error;
 }

Index: src/sys/compat/common/compat_mod.h
diff -u src/sys/compat/common/compat_mod.h:1.1.42.22 src/sys/compat/common/compat_mod.h:1.1.42.23
--- src/sys/compat/common/compat_mod.h:1.1.42.22	Wed Sep 19 04:12:43 2018
+++ src/sys/compat/common/compat_mod.h	Fri Oct 12 22:30:54 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat_mod.h,v 1.1.42.22 2018/09/19 04:12:43 pgoyette Exp $	*/
+/*	$NetBSD: compat_mod.h,v 1.1.42.23 2018/10/12 22:30:54 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -72,6 +72,8 @@ void uipc_syscalls_50_init(void);
 void uipc_syscalls_50_fini(void);
 void vnd_50_init(void);
 void vnd_50_fini(void);
+void rndpseudo_50_init(void);
+void rndpseudo_50_fini(void);
 #endif
 
 #ifdef COMPAT_40

Index: src/sys/compat/common/rndpseudo_50.c
diff -u src/sys/compat/common/rndpseudo_50.c:1.2.38.1 src/sys/compat/common/rndpseudo_50.c:1.2.38.2
--- src/sys/compat/common/rndpseudo_50.c:1.2.38.1	Wed Mar 21 02:01:34 2018
+++ src/sys/compat/common/rndpseudo_50.c	Fri Oct 12 22:30:54 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: rndpseudo_50.c,v 1.2.38.1 2018/03/21 02:01:34 pgoyette Exp $	*/
+/*	$nETbsD: rndpseudo_50.c,v 1.2.38.1 2018/03/21 02:01:34 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rndpseudo_50.c,v 1.2.38.1 2018/03/21 02:01:34 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rndpseudo_50.c,v 1.2.38.2 2018/10/12 22:30:54 pgoyette Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -40,7 +40,11 @@ __KERNEL_RCSID(0, "$NetBSD: rndpseudo_50
 #include 
 
 #include 
+#include 
+#include 
+
 #include 
+#include 
 
 /*
  * Convert from rndsource_t to rndsource50_t, for the results from
@@ -116,3 +120,20 @@ compat_50_rnd_ioctl(struct file *fp, u_l
 
 	return ret;
 }
+
+MODULE_SET_HOOK(rnd_ioctl_50_hook, "rnd_50", compat_50_rnd_ioctl);
+MODULE_UNSET_HOOK(rnd_ioctl_50_hook);
+
+void
+rndpseudo_50_init(void)
+{
+
+	rnd_ioctl_50_hook_set();
+}
+
+void
+rndpseudo_50_fini(void)
+{
+
+	rnd_ioctl_50_hook_unset();
+}

Index: src/sys/compat/netbsd32/netbsd32_compat_50.c
diff -u src/sys/compat/netbsd32/netbsd32_compat_50.c:1.32.16.12 src/sys/compat/netbsd32/netbsd32_compat_50.c:1.32.16.13
--- src/sys/compat/netbsd32/netbsd32_compat_50.c:1.32.16.12	Wed Oct  3 11:59:21 2018
+++ src/sys/compat/netbsd32/netbsd32_compat_50.c	Fri Oct 12 22:30:54 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_compat_50.c,v 1.32.16.12 2018/10/03 11:59:21 pgoyette Exp $	*/
+/*	$NetBSD: netbsd32_compat_50.c,v 1.32.16.13 2018/10/12 22:30:54 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.

CVS commit: src/sys/arch/evbarm/conf

2018-10-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Oct 12 22:22:21 UTC 2018

Modified Files:
src/sys/arch/evbarm/conf: GENERIC64

Log Message:
Add basic ACPI support


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/arch/evbarm/conf/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/GENERIC64
diff -u src/sys/arch/evbarm/conf/GENERIC64:1.44 src/sys/arch/evbarm/conf/GENERIC64:1.45
--- src/sys/arch/evbarm/conf/GENERIC64:1.44	Fri Oct 12 01:28:58 2018
+++ src/sys/arch/evbarm/conf/GENERIC64	Fri Oct 12 22:22:21 2018
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: GENERIC64,v 1.44 2018/10/12 01:28:58 ryo Exp $
+#	$NetBSD: GENERIC64,v 1.45 2018/10/12 22:22:21 jmcneill Exp $
 #
 #	GENERIC ARM (aarch64) kernel
 #
@@ -96,9 +96,14 @@ options 	EXEC_ELF32
 armfdt0		at root
 simplebus*	at fdt? pass 0
 
+# ACPI support
+acpifdt*	at fdt? pass 1
+acpi*		at acpifdt?
+
 # CPUs
 cpus*		at fdt? pass 0
 cpu*		at fdt? pass 0
+cpu*		at acpi?
 
 # Performance monitors
 armpmu*		at fdt?
@@ -123,6 +128,7 @@ syscon*		at fdt? pass 1		# Generic Syste
 
 # Timer
 gtmr*		at fdt? pass 1		# ARM Generic Timer
+gtmr*		at acpi?
 armgtmr0	at gtmr?
 tegratimer*	at fdt?			# Timers
 
@@ -134,6 +140,7 @@ watchdog*	at fdt?			# Broadcom BCM283x w
 bcmicu*		at fdt? pass 1		# Broadcom BCM283x ICU
 tegralic*	at fdt? pass 1		# NVIDIA Tegra LIC
 gic*		at fdt? pass 1		# ARM GICv2
+gic*		at acpi?
 armgic0		at gic?
 gicvthree*	at fdt? pass 1		# ARM GICv3
 sunxinmi*	at fdt? pass 2		# Allwinner NMI / R_INTC
@@ -240,6 +247,7 @@ ukphy*		at mii? phy ?		# generic unknown
 # UART
 com*		at fdt?	pass 4		# UART
 plcom*		at fdt?	pass 4		# ARM PL011 UART
+plcom*		at acpi?
 
 # I2C controllers
 bsciic*		at fdt?			# Broadcom BCM283x Serial Control



CVS commit: src/sys/arch/evbarm/conf

2018-10-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Oct 12 22:21:23 UTC 2018

Modified Files:
src/sys/arch/evbarm/conf: files.generic64

Log Message:
Pull in ACPI platform support


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 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.6 src/sys/arch/evbarm/conf/files.generic64:1.7
--- src/sys/arch/evbarm/conf/files.generic64:1.6	Wed Oct  3 09:24:36 2018
+++ src/sys/arch/evbarm/conf/files.generic64	Fri Oct 12 22:21:22 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: files.generic64,v 1.6 2018/10/03 09:24:36 skrll Exp $
+#	$NetBSD: files.generic64,v 1.7 2018/10/12 22:21:22 jmcneill Exp $
 #
 
 defparam opt_arm_debug.h	EARLYCONS
@@ -10,6 +10,7 @@ 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"



CVS commit: src/sys/arch/arm/fdt

2018-10-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Oct 12 22:20:48 UTC 2018

Modified Files:
src/sys/arch/arm/fdt: files.fdt
Added Files:
src/sys/arch/arm/fdt: acpi_fdt.c

Log Message:
Add acpi @ fdt glue


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/fdt/acpi_fdt.c
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/arm/fdt/files.fdt

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/fdt/files.fdt
diff -u src/sys/arch/arm/fdt/files.fdt:1.26 src/sys/arch/arm/fdt/files.fdt:1.27
--- src/sys/arch/arm/fdt/files.fdt:1.26	Fri Sep 21 12:04:06 2018
+++ src/sys/arch/arm/fdt/files.fdt	Fri Oct 12 22:20:48 2018
@@ -1,4 +1,4 @@
-# $NetBSD: files.fdt,v 1.26 2018/09/21 12:04:06 skrll Exp $
+# $NetBSD: files.fdt,v 1.27 2018/10/12 22:20:48 jmcneill Exp $
 
 include	"dev/pckbport/files.pckbport"
 
@@ -67,3 +67,6 @@ file	dev/tprof/tprof_armv8.c			pmu_fdt &
 attach	genfb at fdt with plfb_fdt: fdt_display_timing
 file	arch/arm/fdt/plfb_fdt.c			plfb_fdt
 
+device	acpifdt: acpibus
+attach	acpifdt at fdt with acpi_fdt
+file	arch/arm/fdt/acpi_fdt.c			acpi_fdt

Added files:

Index: src/sys/arch/arm/fdt/acpi_fdt.c
diff -u /dev/null src/sys/arch/arm/fdt/acpi_fdt.c:1.1
--- /dev/null	Fri Oct 12 22:20:48 2018
+++ src/sys/arch/arm/fdt/acpi_fdt.c	Fri Oct 12 22:20:48 2018
@@ -0,0 +1,90 @@
+/* $NetBSD: acpi_fdt.c,v 1.1 2018/10/12 22:20:48 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2015-2017 Jared McNeill 
+ * 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: acpi_fdt.c,v 1.1 2018/10/12 22:20:48 jmcneill Exp $");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+static int	acpi_fdt_match(device_t, cfdata_t, void *);
+static void	acpi_fdt_attach(device_t, device_t, void *);
+
+static const char * const compatible[] = {
+	"netbsd,acpi",
+	NULL
+};
+
+CFATTACH_DECL_NEW(acpi_fdt, 0, acpi_fdt_match, acpi_fdt_attach, NULL, NULL);
+
+static int
+acpi_fdt_match(device_t parent, cfdata_t cf, void *aux)
+{
+	struct fdt_attach_args * const faa = aux;
+
+	return of_compatible(faa->faa_phandle, compatible) >= 0;
+}
+
+static void
+acpi_fdt_attach(device_t parent, device_t self, void *aux)
+{
+	struct fdt_attach_args * const faa = aux;
+	struct acpibus_attach_args aa;
+
+	aprint_naive("\n");
+	aprint_normal(": ACPI Platform support\n");
+
+	if (!acpi_probe())
+		aprint_error_dev(self, "failed to probe ACPI\n");
+
+	aa.aa_iot = 0;
+	aa.aa_memt = faa->faa_bst;
+	aa.aa_pc = NULL;
+	aa.aa_pciflags =
+	PCI_FLAGS_IO_OKAY | PCI_FLAGS_MEM_OKAY |
+	PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY | 
+	PCI_FLAGS_MWI_OKAY;
+	aa.aa_ic = 0;
+	aa.aa_dmat = faa->faa_dmat;
+#ifdef _PCI_HAVE_DMA64
+	aa.aa_dmat64 = faa->faa_dmat;
+#endif
+	config_found_ia(self, "acpibus", , 0);
+}



CVS commit: src/sys/arch/arm/acpi

2018-10-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Oct 12 22:20:04 UTC 2018

Added Files:
src/sys/arch/arm/acpi: acpi_platform.c cpu_acpi.c files.acpi gic_acpi.c
gtmr_acpi.c plcom_acpi.c

Log Message:
Add ACPI platform glue and basic device drivers (CPU, GIC, Generic Timer,
SBSA UART).


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/acpi/acpi_platform.c \
src/sys/arch/arm/acpi/cpu_acpi.c src/sys/arch/arm/acpi/files.acpi \
src/sys/arch/arm/acpi/gic_acpi.c src/sys/arch/arm/acpi/gtmr_acpi.c \
src/sys/arch/arm/acpi/plcom_acpi.c

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

Added files:

Index: src/sys/arch/arm/acpi/acpi_platform.c
diff -u /dev/null src/sys/arch/arm/acpi/acpi_platform.c:1.1
--- /dev/null	Fri Oct 12 22:20:04 2018
+++ src/sys/arch/arm/acpi/acpi_platform.c	Fri Oct 12 22:20:04 2018
@@ -0,0 +1,183 @@
+/* $NetBSD: acpi_platform.c,v 1.1 2018/10/12 22:20:04 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2018 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jared McNeill .
+ *
+ * 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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: acpi_platform.c,v 1.1 2018/10/12 22:20:04 jmcneill Exp $");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#define	SPCR_INTERFACE_TYPE_PL011	0x0003
+
+extern struct bus_space arm_generic_bs_tag;
+
+static struct plcom_instance plcom_console;
+
+static const struct pmap_devmap *
+acpi_platform_devmap(void)
+{
+	static const struct pmap_devmap devmap[] = {
+		DEVMAP_ENTRY_END
+	};
+
+	return devmap;
+}
+
+static void
+acpi_platform_bootstrap(void)
+{
+}
+
+static void
+acpi_platform_startup(void)
+{
+	ACPI_TABLE_SPCR *spcr;
+	ACPI_TABLE_FADT *fadt;
+	ACPI_TABLE_MADT *madt;
+
+	/*
+	 * Setup serial console device
+	 */
+	if (ACPI_SUCCESS(acpi_table_find(ACPI_SIG_SPCR, (void ** {
+		if (spcr->InterfaceType == SPCR_INTERFACE_TYPE_PL011 &&
+		spcr->SerialPort.SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY &&
+		spcr->SerialPort.Address != 0) {
+
+			plcom_console.pi_type = PLCOM_TYPE_PL011;
+			plcom_console.pi_flags = PLC_FLAG_32BIT_ACCESS;
+			plcom_console.pi_iot = _generic_bs_tag;
+			plcom_console.pi_iobase = spcr->SerialPort.Address;
+			plcom_console.pi_size = PL011COM_UART_SIZE;
+
+			plcomcnattach(_console, 115200 /* XXX */, 0, TTYDEF_CFLAG, -1);
+		}
+		acpi_table_unmap((ACPI_TABLE_HEADER *)spcr);
+	}
+
+	/*
+	 * Initialize PSCI 0.2+ if implemented
+	 */
+	if (ACPI_SUCCESS(acpi_table_find(ACPI_SIG_FADT, (void ** {
+		if (fadt->ArmBootFlags & ACPI_FADT_PSCI_COMPLIANT) {
+			if (fadt->ArmBootFlags & ACPI_FADT_PSCI_USE_HVC) {
+psci_init(psci_call_hvc);
+			} else {
+psci_init(psci_call_smc);
+			}
+		}
+		acpi_table_unmap((ACPI_TABLE_HEADER *)fadt);
+	}
+
+	/*
+	 * Count CPUs
+	 */
+	if (ACPI_SUCCESS(acpi_table_find(ACPI_SIG_MADT, (void ** {
+		char *end = (char *)madt + madt->Header.Length;
+		char *where = (char *)madt + sizeof(ACPI_TABLE_MADT);
+		while (where < end) {
+			ACPI_SUBTABLE_HEADER *subtable = (ACPI_SUBTABLE_HEADER *)where;
+			if (subtable->Type == ACPI_MADT_TYPE_GENERIC_INTERRUPT)
+arm_cpu_max++;
+			where += subtable->Length;
+		}
+		acpi_table_unmap((ACPI_TABLE_HEADER *)madt);
+	}
+}
+
+static void
+acpi_platform_init_attach_args(struct fdt_attach_args *faa)
+{
+	extern struct arm32_bus_dma_tag 

CVS commit: src/sys/arch/evbarm/dev

2018-10-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Oct 12 22:18:38 UTC 2018

Modified Files:
src/sys/arch/evbarm/dev: plcom.c

Log Message:
If rate or frequency are unspecified, assume "use firmware configuration" for 
clocks


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sys/arch/evbarm/dev/plcom.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/evbarm/dev/plcom.c
diff -u src/sys/arch/evbarm/dev/plcom.c:1.53 src/sys/arch/evbarm/dev/plcom.c:1.54
--- src/sys/arch/evbarm/dev/plcom.c:1.53	Tue Nov  7 07:21:13 2017
+++ src/sys/arch/evbarm/dev/plcom.c	Fri Oct 12 22:18:38 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: plcom.c,v 1.53 2017/11/07 07:21:13 skrll Exp $	*/
+/*	$NetBSD: plcom.c,v 1.54 2018/10/12 22:18:38 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2001 ARM Ltd
@@ -94,7 +94,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: plcom.c,v 1.53 2017/11/07 07:21:13 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: plcom.c,v 1.54 2018/10/12 22:18:38 jmcneill Exp $");
 
 #include "opt_plcom.h"
 #include "opt_ddb.h"
@@ -2367,18 +2367,22 @@ plcominit(struct plcom_instance *pi, int
 	case PLCOM_TYPE_PL010:
 		PWRITE1(pi, PL010COM_CR, 0);
 
-		rate = pl010comspeed(rate, frequency);
-		PWRITE1(pi, PL010COM_DLBL, (rate & 0xff));
-		PWRITE1(pi, PL010COM_DLBH, ((rate >> 8) & 0xff));
+		if (rate && frequency) {
+			rate = pl010comspeed(rate, frequency);
+			PWRITE1(pi, PL010COM_DLBL, (rate & 0xff));
+			PWRITE1(pi, PL010COM_DLBH, ((rate >> 8) & 0xff));
+		}
 		PWRITE1(pi, PL010COM_LCR, lcr);
 		PWRITE1(pi, PL010COM_CR, PL01X_CR_UARTEN);
 		break;
 	case PLCOM_TYPE_PL011:
 		PWRITE4(pi, PL011COM_CR, 0);
 
-		rate = pl011comspeed(rate, frequency);
-		PWRITE1(pi, PL011COM_FBRD, rate & ((1 << 6) - 1));
-		PWRITE4(pi, PL011COM_IBRD, rate >> 6);
+		if (rate && frequency) {
+			rate = pl011comspeed(rate, frequency);
+			PWRITE1(pi, PL011COM_FBRD, rate & ((1 << 6) - 1));
+			PWRITE4(pi, PL011COM_IBRD, rate >> 6);
+		}
 		PWRITE1(pi, PL011COM_LCRH, lcr);
 		PWRITE4(pi, PL011COM_CR,
 		PL01X_CR_UARTEN | PL011_CR_RXE | PL011_CR_TXE);



CVS commit: src/sys/arch/evbarm/include

2018-10-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Oct 12 22:15:48 UTC 2018

Added Files:
src/sys/arch/evbarm/include: acpi_machdep.h

Log Message:
Add wrapper for acpi_machdep.h


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/evbarm/include/acpi_machdep.h

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

Added files:

Index: src/sys/arch/evbarm/include/acpi_machdep.h
diff -u /dev/null src/sys/arch/evbarm/include/acpi_machdep.h:1.1
--- /dev/null	Fri Oct 12 22:15:48 2018
+++ src/sys/arch/evbarm/include/acpi_machdep.h	Fri Oct 12 22:15:48 2018
@@ -0,0 +1,3 @@
+/* $NetBSD: acpi_machdep.h,v 1.1 2018/10/12 22:15:48 jmcneill Exp $ */
+
+#include 



CVS commit: src/sys/arch/arm/acpi

2018-10-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Oct 12 22:15:04 UTC 2018

Added Files:
src/sys/arch/arm/acpi: acpi_table.c acpi_table.h

Log Message:
Add helper functions used for parsing ACPI tables before the ACPICA
subsystem can be brought online. ARM64 needs this primarily for
initializing the SBSA UART via SPCR table, reading ARM boot flags from the
FADT, counting CPUs, etc.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/acpi/acpi_table.c \
src/sys/arch/arm/acpi/acpi_table.h

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

Added files:

Index: src/sys/arch/arm/acpi/acpi_table.c
diff -u /dev/null src/sys/arch/arm/acpi/acpi_table.c:1.1
--- /dev/null	Fri Oct 12 22:15:04 2018
+++ src/sys/arch/arm/acpi/acpi_table.c	Fri Oct 12 22:15:04 2018
@@ -0,0 +1,115 @@
+/* $NetBSD: acpi_table.c,v 1.1 2018/10/12 22:15:04 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2018 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jared McNeill .
+ *
+ * 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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.
+ */
+
+/*
+ * ACPI table functions for use in early boot before ACPICA can be safely
+ * initialized.
+ */
+
+#include 
+__KERNEL_RCSID(0, "$NetBSD: acpi_table.c,v 1.1 2018/10/12 22:15:04 jmcneill Exp $");
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+#include 
+
+#include 
+
+ACPI_STATUS
+acpi_table_map(ACPI_PHYSICAL_ADDRESS pa, void **hdrp)
+{
+	ACPI_TABLE_HEADER *header;
+	ACPI_STATUS rv;
+	UINT32 length;
+
+	rv = acpi_md_OsMapMemory(pa, sizeof(*header), (void **));
+	if (ACPI_FAILURE(rv))
+		return rv;
+	length = header->Length;
+	acpi_md_OsUnmapMemory(header, sizeof(*header));
+
+	return acpi_md_OsMapMemory(pa, length, hdrp);
+}
+
+void
+acpi_table_unmap(ACPI_TABLE_HEADER *hdrp)
+{
+	acpi_md_OsUnmapMemory(hdrp, hdrp->Length);
+}
+
+ACPI_STATUS
+acpi_table_find(const char *sig, void **hdrp)
+{
+	ACPI_TABLE_RSDP *rsdp;
+	ACPI_TABLE_XSDT *xsdt;
+	ACPI_TABLE_HEADER *header;
+	ACPI_PHYSICAL_ADDRESS pa;
+	ACPI_STATUS rv;
+
+	/* RDSP contains a pointer to the XSDT */
+	pa = 0;
+	rv = acpi_md_OsMapMemory(acpi_md_OsGetRootPointer(), sizeof(*rsdp), (void **));
+	if (ACPI_FAILURE(rv))
+		return rv;
+	if (memcmp(rsdp->Signature, ACPI_SIG_RSDP, sizeof(rsdp->Signature)) == 0)
+		pa = rsdp->XsdtPhysicalAddress;
+	acpi_md_OsUnmapMemory(rsdp, sizeof(*rsdp));
+	if (pa == 0)
+		return AE_NOT_FOUND;
+
+	/* XSDT contains pointers to other tables */
+	rv = acpi_table_map(pa, (void **));
+	if (ACPI_FAILURE(rv))
+		return rv;
+	const u_int entries = (xsdt->Header.Length - sizeof(ACPI_TABLE_HEADER)) / ACPI_XSDT_ENTRY_SIZE;
+	for (u_int n = 0; n < entries; n++) {
+		rv = acpi_table_map(xsdt->TableOffsetEntry[n], (void **));
+		if (ACPI_FAILURE(rv))
+			continue;
+		if (memcmp(header->Signature, sig, sizeof(header->Signature)) == 0) {
+			acpi_table_unmap((ACPI_TABLE_HEADER *)xsdt);
+			*hdrp = header;
+			return AE_OK;
+		}
+	}
+
+	/* Not found */
+	acpi_table_unmap((ACPI_TABLE_HEADER *)xsdt);
+	return AE_NOT_FOUND;
+}
Index: src/sys/arch/arm/acpi/acpi_table.h
diff -u /dev/null src/sys/arch/arm/acpi/acpi_table.h:1.1
--- /dev/null	Fri Oct 12 22:15:04 2018
+++ src/sys/arch/arm/acpi/acpi_table.h	Fri Oct 12 22:15:04 2018
@@ -0,0 +1,39 @@
+/* $NetBSD: acpi_table.h,v 1.1 2018/10/12 22:15:04 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2018 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jared McNeill .
+ *
+ * Redistribution and use in source and binary forms, with or without

CVS commit: src/sys/arch/arm

2018-10-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Oct 12 22:12:12 UTC 2018

Added Files:
src/sys/arch/arm/acpi: acpi_machdep.c
src/sys/arch/arm/include: acpi_machdep.h

Log Message:
Add ARM MD ACPI implementation.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/acpi/acpi_machdep.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/include/acpi_machdep.h

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

Added files:

Index: src/sys/arch/arm/acpi/acpi_machdep.c
diff -u /dev/null src/sys/arch/arm/acpi/acpi_machdep.c:1.1
--- /dev/null	Fri Oct 12 22:12:12 2018
+++ src/sys/arch/arm/acpi/acpi_machdep.c	Fri Oct 12 22:12:11 2018
@@ -0,0 +1,254 @@
+/* $NetBSD: acpi_machdep.c,v 1.1 2018/10/12 22:12:11 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2018 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jared McNeill .
+ *
+ * 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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: acpi_machdep.c,v 1.1 2018/10/12 22:12:11 jmcneill Exp $");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+
+#include 
+#include 
+
+#include 
+
+#include 
+
+#include 
+
+extern struct bus_space arm_generic_bs_tag;
+
+ACPI_STATUS
+acpi_md_OsInitialize(void)
+{
+	return AE_OK;
+}
+
+ACPI_PHYSICAL_ADDRESS
+acpi_md_OsGetRootPointer(void)
+{
+	uint64_t pa;
+
+	const int chosen = OF_finddevice("/chosen");
+	if (chosen == -1)
+		return 0;
+
+	if (of_getprop_uint64(chosen, "netbsd,acpi-root-table", ) != 0)
+		return 0;
+
+	return (ACPI_PHYSICAL_ADDRESS)pa;
+}
+
+ACPI_STATUS
+acpi_md_OsInstallInterruptHandler(UINT32 irq, ACPI_OSD_HANDLER handler, void *context,
+void **cookiep, const char *xname)
+{
+	const int ipl = IPL_TTY;
+	const int type = IST_LEVEL;	/* TODO: MADT */
+
+	*cookiep = intr_establish(irq, ipl, type, (int (*)(void *))handler, context);
+
+	return *cookiep == NULL ? AE_NO_MEMORY : AE_OK;
+}
+
+void
+acpi_md_OsRemoveInterruptHandler(void *cookie)
+{
+	intr_disestablish(cookie);
+}
+
+ACPI_STATUS
+acpi_md_OsMapMemory(ACPI_PHYSICAL_ADDRESS pa, UINT32 size, void **vap)
+{
+	paddr_t spa, epa, curpa;
+	vaddr_t va, curva;
+
+	spa = trunc_page(pa);
+	epa = round_page(pa + size);
+
+	va = uvm_km_alloc(kernel_map, epa - spa, 0, UVM_KMF_VAONLY);
+	if (va == 0)
+		return AE_NO_MEMORY;
+
+	for (curpa = spa, curva = va; curpa < epa; curpa += PAGE_SIZE, curva += PAGE_SIZE)
+		pmap_kenter_pa(curva, curpa, VM_PROT_READ | VM_PROT_WRITE, 0);
+	pmap_update(pmap_kernel());
+
+	*vap = (void *)(va + (pa - spa));
+
+	return AE_OK;
+}
+
+void
+acpi_md_OsUnmapMemory(void *va, UINT32 size)
+{
+	vaddr_t ova;
+	vsize_t osz;
+
+	ova = trunc_page((vaddr_t)va);
+	osz = round_page((vaddr_t)va + size) - (vaddr_t)va;
+
+	pmap_kremove(ova, osz);
+	pmap_update(pmap_kernel());
+	uvm_km_free(kernel_map, ova, osz, UVM_KMF_VAONLY);
+}
+
+ACPI_STATUS
+acpi_md_OsGetPhysicalAddress(void *va, ACPI_PHYSICAL_ADDRESS *pap)
+{
+	paddr_t pa;
+
+	if (!pmap_extract(pmap_kernel(), (vaddr_t)va, ))
+		return AE_ERROR;
+
+	*pap = pa;
+
+	return AE_OK;
+}
+
+BOOLEAN
+acpi_md_OsReadable(void *va, UINT32 len)
+{
+	vaddr_t sva, eva;
+	pt_entry_t *pte;
+
+	sva = trunc_page((vaddr_t)va);
+	eva = round_page((vaddr_t)va + len);
+
+	if (sva < VM_MIN_KERNEL_ADDRESS)
+		return FALSE;
+
+	for (; sva < eva; sva += PAGE_SIZE) {
+		pte = kvtopte(sva);
+		if ((*pte & (LX_BLKPAG_AF|LX_BLKPAG_AP_RO)) != (LX_BLKPAG_AF|LX_BLKPAG_AP_RO))
+			return FALSE;
+	}
+
+	return TRUE;
+}
+
+BOOLEAN
+acpi_md_OsWritable(void *va, UINT32 len)
+{
+	vaddr_t sva, eva;
+	pt_entry_t *pte;
+
+	sva = 

CVS commit: src/sys/arch/evbarm/include

2018-10-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Oct 12 22:09:04 UTC 2018

Added Files:
src/sys/arch/evbarm/include: cpufunc.h

Log Message:
Add cpufunc.h wrapper


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/evbarm/include/cpufunc.h

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

Added files:

Index: src/sys/arch/evbarm/include/cpufunc.h
diff -u /dev/null src/sys/arch/evbarm/include/cpufunc.h:1.1
--- /dev/null	Fri Oct 12 22:09:04 2018
+++ src/sys/arch/evbarm/include/cpufunc.h	Fri Oct 12 22:09:04 2018
@@ -0,0 +1,7 @@
+/* $NetBSD: cpufunc.h,v 1.1 2018/10/12 22:09:04 jmcneill Exp $ */
+
+#ifdef __aarch64__
+#include 
+#else
+#include 
+#endif



CVS commit: src/sys/stand/efiboot

2018-10-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Oct 12 22:08:04 UTC 2018

Modified Files:
src/sys/stand/efiboot: Makefile.efiboot boot.c efiboot.c exec.c
src/sys/stand/efiboot/bootaa64: Makefile
Added Files:
src/sys/stand/efiboot: efiacpi.c efiacpi.h

Log Message:
Add ACPI support (enable with -DEFIBOOT_ACPI, currently disabled).

When UEFI reports that ACPI tables are available, generate a DTB with
compatible string "netbsd,generic-acpi" and pass this to the booted
kernel.

The DTB contains a /chosen property "netbsd,acpi-root-table" that contains
the physical address of the ACPI RSDP, along with a special /acpi node
with compatible string "netbsd,acpi" for the kernel to attach an acpi(4)
device driver.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/stand/efiboot/Makefile.efiboot
cvs rdiff -u -r1.9 -r1.10 src/sys/stand/efiboot/boot.c
cvs rdiff -u -r0 -r1.1 src/sys/stand/efiboot/efiacpi.c \
src/sys/stand/efiboot/efiacpi.h
cvs rdiff -u -r1.8 -r1.9 src/sys/stand/efiboot/efiboot.c
cvs rdiff -u -r1.6 -r1.7 src/sys/stand/efiboot/exec.c
cvs rdiff -u -r1.2 -r1.3 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/Makefile.efiboot
diff -u src/sys/stand/efiboot/Makefile.efiboot:1.5 src/sys/stand/efiboot/Makefile.efiboot:1.6
--- src/sys/stand/efiboot/Makefile.efiboot:1.5	Sat Sep 15 17:06:32 2018
+++ src/sys/stand/efiboot/Makefile.efiboot	Fri Oct 12 22:08:04 2018
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.efiboot,v 1.5 2018/09/15 17:06:32 jmcneill Exp $
+# $NetBSD: Makefile.efiboot,v 1.6 2018/10/12 22:08:04 jmcneill Exp $
 
 S=		${.CURDIR}/../../..
 
@@ -22,7 +22,7 @@ AFLAGS.start.S= ${${ACTIVE_CC} == "clang
 .PATH: ${EFIDIR}/gnuefi
 SOURCES=	crt0-efi-${GNUEFIARCH}.S reloc_${GNUEFIARCH}.c
 SOURCES+=	boot.c conf.c console.c dev_net.c devopen.c exec.c panic.c prompt.c
-SOURCES+=	efiboot.c efichar.c efidev.c efienv.c efigetsecs.c efifdt.c efifile.c efiblock.c efinet.c efipxe.c
+SOURCES+=	efiboot.c efichar.c efidev.c efienv.c efigetsecs.c efifdt.c efifile.c efiblock.c efinet.c efipxe.c efiacpi.c
 
 .PATH: ${S}/external/bsd/libfdt/dist
 CPPFLAGS+=	-I${S}/external/bsd/libfdt/dist

Index: src/sys/stand/efiboot/boot.c
diff -u src/sys/stand/efiboot/boot.c:1.9 src/sys/stand/efiboot/boot.c:1.10
--- src/sys/stand/efiboot/boot.c:1.9	Sun Sep  9 18:00:20 2018
+++ src/sys/stand/efiboot/boot.c	Fri Oct 12 22:08:04 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.9 2018/09/09 18:00:20 jmcneill Exp $	*/
+/*	$NetBSD: boot.c,v 1.10 2018/10/12 22:08:04 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -30,6 +30,7 @@
 #include "efiboot.h"
 #include "efiblock.h"
 #include "efifdt.h"
+#include "efiacpi.h"
 #include "efienv.h"
 
 #include 
@@ -210,6 +211,7 @@ command_version(char *arg)
 	}
 
 	efi_fdt_show();
+	efi_acpi_show();
 }
 
 void

Index: src/sys/stand/efiboot/efiboot.c
diff -u src/sys/stand/efiboot/efiboot.c:1.8 src/sys/stand/efiboot/efiboot.c:1.9
--- src/sys/stand/efiboot/efiboot.c:1.8	Sat Sep 15 17:06:32 2018
+++ src/sys/stand/efiboot/efiboot.c	Fri Oct 12 22:08:04 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: efiboot.c,v 1.8 2018/09/15 17:06:32 jmcneill Exp $ */
+/* $NetBSD: efiboot.c,v 1.9 2018/10/12 22:08:04 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -30,6 +30,7 @@
 #include "efifile.h"
 #include "efiblock.h"
 #include "efifdt.h"
+#include "efiacpi.h"
 
 #include 
 
@@ -79,6 +80,7 @@ efi_main(EFI_HANDLE imageHandle, EFI_SYS
 	Print(L"Image file: %s\n", DevicePathToStr(efi_li->FilePath));
 #endif
 
+	efi_acpi_probe();
 	efi_fdt_probe();
 	efi_file_system_probe();
 	efi_block_probe();

Index: src/sys/stand/efiboot/exec.c
diff -u src/sys/stand/efiboot/exec.c:1.6 src/sys/stand/efiboot/exec.c:1.7
--- src/sys/stand/efiboot/exec.c:1.6	Sat Sep 15 17:06:32 2018
+++ src/sys/stand/efiboot/exec.c	Fri Oct 12 22:08:04 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: exec.c,v 1.6 2018/09/15 17:06:32 jmcneill Exp $ */
+/* $NetBSD: exec.c,v 1.7 2018/10/12 22:08:04 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -28,6 +28,7 @@
 
 #include "efiboot.h"
 #include "efifdt.h"
+#include "efiacpi.h"
 
 #include 
 
@@ -152,6 +153,11 @@ exec_netbsd(const char *fname, const cha
 	close(fd);
 	load_offset = 0;
 
+#ifdef EFIBOOT_ACPI
+	if (efi_acpi_available()) {
+		efi_acpi_create_fdt();
+	} else
+#endif
 	if (dtb_addr && efi_fdt_set_data((void *)dtb_addr) != 0) {
 		printf("boot: invalid DTB data\n");
 		goto cleanup;

Index: src/sys/stand/efiboot/bootaa64/Makefile
diff -u src/sys/stand/efiboot/bootaa64/Makefile:1.2 src/sys/stand/efiboot/bootaa64/Makefile:1.3
--- src/sys/stand/efiboot/bootaa64/Makefile:1.2	Mon Aug 27 22:40:51 2018
+++ src/sys/stand/efiboot/bootaa64/Makefile	Fri Oct 12 22:08:04 2018
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.2 2018/08/27 22:40:51 jmcneill Exp $
+# $NetBSD: Makefile,v 1.3 2018/10/12 

CVS commit: src/sys/arch/arm/pic

2018-10-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Oct 12 21:46:32 UTC 2018

Modified Files:
src/sys/arch/arm/pic: pic.c picvar.h

Log Message:
Implement intr_string(9)


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/arch/arm/pic/pic.c
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/pic/picvar.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/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.44 src/sys/arch/arm/pic/pic.c:1.45
--- src/sys/arch/arm/pic/pic.c:1.44	Sun Jul 15 16:03:24 2018
+++ src/sys/arch/arm/pic/pic.c	Fri Oct 12 21:46:32 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.44 2018/07/15 16:03:24 jmcneill Exp $	*/
+/*	$NetBSD: pic.c,v 1.45 2018/10/12 21:46:32 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +33,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.44 2018/07/15 16:03:24 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.45 2018/10/12 21:46:32 jmcneill Exp $");
 
 #include 
 #include 
@@ -883,6 +883,24 @@ intr_disestablish(void *ih)
 	pic_disestablish_source(is);
 }
 
+const char *
+intr_string(intr_handle_t irq, char *buf, size_t len)
+{
+	for (size_t slot = 0; slot < PIC_MAXPICS; slot++) {
+		struct pic_softc * const pic = pic_list[slot];
+		if (pic == NULL || pic->pic_irqbase < 0)
+			continue;
+		if (pic->pic_irqbase <= irq
+		&& irq < pic->pic_irqbase + pic->pic_maxsources) {
+			struct intrsource * const is = pic->pic_sources[irq - pic->pic_irqbase];
+			snprintf(buf, len, "%s %s", pic->pic_name, is->is_source);
+			return buf;
+		}
+	}
+
+	return NULL;
+}
+
 #ifdef MULTIPROCESSOR
 int
 interrupt_distribute(void *ih, const kcpuset_t *newset, kcpuset_t *oldset)

Index: src/sys/arch/arm/pic/picvar.h
diff -u src/sys/arch/arm/pic/picvar.h:1.19 src/sys/arch/arm/pic/picvar.h:1.20
--- src/sys/arch/arm/pic/picvar.h:1.19	Sat Sep  8 11:54:26 2018
+++ src/sys/arch/arm/pic/picvar.h	Fri Oct 12 21:46:32 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: picvar.h,v 1.19 2018/09/08 11:54:26 jmcneill Exp $	*/
+/*	$NetBSD: picvar.h,v 1.20 2018/10/12 21:46:32 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -38,6 +38,8 @@
 #include 
 #endif
 
+typedef uint32_t	intr_handle_t;		/* for ACPI */
+
 int	_splraise(int);
 int	_spllower(int);
 void	splx(int);
@@ -86,6 +88,7 @@ void	pic_dispatch(struct intrsource *is,
 void	*intr_establish(int irq, int ipl, int type, int (*func)(void *),
 	void *arg);
 void	intr_disestablish(void *);
+const char *intr_string(intr_handle_t, char *, size_t);
 #ifdef MULTIPROCESSOR
 void	intr_cpu_init(struct cpu_info *);
 void	intr_ipi_send(const kcpuset_t *, u_long ipi);



CVS commit: src/sys/arch/sparc64/dev

2018-10-12 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Oct 12 21:44:32 UTC 2018

Added Files:
src/sys/arch/sparc64/dev: tadpmu.c tadpmureg.h tadpmuvar.h

Log Message:
experimental code to talk to the PMU found in Tadpole Viper laptops


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/sparc64/dev/tadpmu.c \
src/sys/arch/sparc64/dev/tadpmureg.h src/sys/arch/sparc64/dev/tadpmuvar.h

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

Added files:

Index: src/sys/arch/sparc64/dev/tadpmu.c
diff -u /dev/null src/sys/arch/sparc64/dev/tadpmu.c:1.1
--- /dev/null	Fri Oct 12 21:44:32 2018
+++ src/sys/arch/sparc64/dev/tadpmu.c	Fri Oct 12 21:44:32 2018
@@ -0,0 +1,261 @@
+/*/* $NetBSD: tadpmu.c,v 1.1 2018/10/12 21:44:32 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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.
+ */
+
+/* a driver for the PMU found in Tadpole Wiper and possibly SPARCle laptops */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+static bus_space_tag_t tadpmu_iot;
+static bus_space_handle_t tadpmu_hcmd;
+static bus_space_handle_t tadpmu_hdata;
+static struct sysmon_envsys *tadpmu_sme;
+static envsys_data_t tadpmu_sensors[5];
+
+static inline void
+tadpmu_cmd(uint8_t d)
+{
+	bus_space_write_1(tadpmu_iot, tadpmu_hcmd, 0, d);
+}
+
+static inline void
+tadpmu_wdata(uint8_t d)
+{
+	bus_space_write_1(tadpmu_iot, tadpmu_hdata, 0, d);
+}
+
+static inline uint8_t
+tadpmu_status(void)
+{
+	return bus_space_read_1(tadpmu_iot, tadpmu_hcmd, 0);
+}
+
+static inline uint8_t
+tadpmu_data(void)
+{
+	return bus_space_read_1(tadpmu_iot, tadpmu_hdata, 0);
+}
+
+static void
+tadpmu_flush(void)
+{
+	volatile uint8_t junk, d;
+	int bail = 0;
+
+	d = tadpmu_status();
+	while (d & STATUS_HAVE_DATA) {
+		junk = tadpmu_data();
+		__USE(junk);
+		delay(10);
+		bail++;
+		if (bail > 100) {
+			printf("%s: timeout waiting for data out to clear %2x\n",
+			__func__, d);
+			break;
+		}
+		d = tadpmu_status();
+	}
+	bail = 0;
+	d = tadpmu_status();
+	while (d & STATUS_SEND_DATA) {
+		bus_space_write_1(tadpmu_iot, tadpmu_hdata, 0, 0);
+		delay(10);
+		bail++;
+		if (bail > 100) {
+			printf("%s: timeout waiting for data in to clear %02x\n",
+			__func__, d);
+			break;
+		}
+		d = tadpmu_status();
+	}
+}
+
+static void
+tadpmu_send_cmd(uint8_t cmd)
+{
+	int bail = 0;
+	uint8_t d;
+
+	tadpmu_cmd(cmd);
+
+	d = tadpmu_status();
+	while ((d & STATUS_CMD_IN_PROGRESS) == 0) {
+		delay(10);
+		bail++;
+		if (bail > 100) {
+			printf("%s: timeout waiting for command to start\n",
+			__func__);
+			break;
+		}
+		d = tadpmu_status();
+	}
+}
+
+static uint8_t
+tadpmu_recv(void)
+{
+	int bail = 0;
+	uint8_t d;
+
+	d = tadpmu_status();	
+	while ((d & STATUS_HAVE_DATA) == 0) {
+		delay(10);
+		bail++;
+		if (bail > 1000) {
+			printf("%s: timeout waiting for data %02x\n", __func__, d);
+			break;
+		}
+		d = tadpmu_status();
+	}
+	return bus_space_read_1(tadpmu_iot, tadpmu_hdata, 0);
+}
+
+static void
+tadpmu_send(uint8_t v)
+{
+	int bail = 0;
+	uint8_t d;
+
+	d = tadpmu_status();	
+	while ((d & STATUS_SEND_DATA) == 0) {
+		delay(10);
+		bail++;
+		if (bail > 1000) {
+			printf("%s: timeout waiting for PMU ready %02x\n", __func__, d);
+			break;
+		}
+		d = tadpmu_status();
+	}
+
+	tadpmu_wdata(v);
+
+	while ((d & STATUS_SEND_DATA) != 0) {
+		delay(10);
+		bail++;
+		if (bail > 1000) {
+			printf("%s: timeout waiting for accept data %02x\n", __func__, d);
+			break;
+		}
+		d = tadpmu_status();
+	}
+}
+
+static void
+tadpmu_sensors_refresh(struct sysmon_envsys *sme, 

CVS commit: src/sys/arch

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

Modified Files:
src/sys/arch/aarch64/aarch64: aarch64_machdep.c
src/sys/arch/arm/arm32: arm32_machdep.c
src/sys/arch/arm/fdt: arm_fdtvar.h

Log Message:
Add optional ap_startup callback to struct arm_platform. This allows for
late (post-UVM init) initialization of platform specific stuff.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/aarch64/aarch64/aarch64_machdep.c
cvs rdiff -u -r1.120 -r1.121 src/sys/arch/arm/arm32/arm32_machdep.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/fdt/arm_fdtvar.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/aarch64/aarch64/aarch64_machdep.c
diff -u src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.12 src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.13
--- src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.12	Thu Oct  4 23:53:13 2018
+++ src/sys/arch/aarch64/aarch64/aarch64_machdep.c	Fri Oct 12 21:44:20 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: aarch64_machdep.c,v 1.12 2018/10/04 23:53:13 ryo Exp $ */
+/* $NetBSD: aarch64_machdep.c,v 1.13 2018/10/12 21:44:20 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,12 +30,13 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: aarch64_machdep.c,v 1.12 2018/10/04 23:53:13 ryo Exp $");
+__KERNEL_RCSID(1, "$NetBSD: aarch64_machdep.c,v 1.13 2018/10/12 21:44:20 jmcneill Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
 #include "opt_kernhist.h"
 #include "opt_modular.h"
+#include "opt_fdt.h"
 
 #include 
 #include 
@@ -63,6 +64,7 @@ __KERNEL_RCSID(1, "$NetBSD: aarch64_mach
 #include 
 
 #include 
+#include 
 
 #ifdef VERBOSE_INIT_ARM
 #define VPRINTF(...)	printf(__VA_ARGS__)
@@ -533,6 +535,11 @@ cpu_startup(void)
 
 	consinit();
 
+#ifdef FDT
+	if (arm_fdt_platform()->ap_startup != NULL)
+		arm_fdt_platform()->ap_startup();
+#endif
+
 	/*
 	 * Allocate a submap for physio.
 	 */

Index: src/sys/arch/arm/arm32/arm32_machdep.c
diff -u src/sys/arch/arm/arm32/arm32_machdep.c:1.120 src/sys/arch/arm/arm32/arm32_machdep.c:1.121
--- src/sys/arch/arm/arm32/arm32_machdep.c:1.120	Wed Aug 22 07:47:33 2018
+++ src/sys/arch/arm/arm32/arm32_machdep.c	Fri Oct 12 21:44:20 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: arm32_machdep.c,v 1.120 2018/08/22 07:47:33 skrll Exp $	*/
+/*	$NetBSD: arm32_machdep.c,v 1.121 2018/10/12 21:44:20 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 1994-1998 Mark Brinicombe.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: arm32_machdep.c,v 1.120 2018/08/22 07:47:33 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: arm32_machdep.c,v 1.121 2018/10/12 21:44:20 jmcneill Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_fdt.h"
@@ -285,6 +285,11 @@ cpu_startup(void)
 	 */
 	pmap_postinit();
 
+#ifdef FDT
+	if (arm_fdt_platform()->ap_startup != NULL)
+		arm_fdt_platform()->ap_startup();
+#endif
+
 	/*
 	 * Initialize error message buffer (at end of core).
 	 */

Index: src/sys/arch/arm/fdt/arm_fdtvar.h
diff -u src/sys/arch/arm/fdt/arm_fdtvar.h:1.9 src/sys/arch/arm/fdt/arm_fdtvar.h:1.10
--- src/sys/arch/arm/fdt/arm_fdtvar.h:1.9	Mon Sep 10 11:05:12 2018
+++ src/sys/arch/arm/fdt/arm_fdtvar.h	Fri Oct 12 21:44:20 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: arm_fdtvar.h,v 1.9 2018/09/10 11:05:12 ryo Exp $ */
+/* $NetBSD: arm_fdtvar.h,v 1.10 2018/10/12 21:44:20 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared D. McNeill 
@@ -38,6 +38,7 @@ struct fdt_attach_args;
 struct arm_platform {
 	const struct pmap_devmap * (*ap_devmap)(void);
 	void			(*ap_bootstrap)(void);
+	void			(*ap_startup)(void);
 	void			(*ap_init_attach_args)(struct fdt_attach_args *);
 	void			(*ap_early_putchar)(char);
 	void			(*ap_device_register)(device_t, void *);



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

2018-10-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Oct 12 21:41:34 UTC 2018

Modified Files:
src/sys/arch/aarch64/include: cpu.h

Log Message:
Add ACPI Processor Unique ID (ci_acpiid) to struct cpu_info, required by
ACPI subsystem.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/aarch64/include/cpu.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/aarch64/include/cpu.h
diff -u src/sys/arch/aarch64/include/cpu.h:1.8 src/sys/arch/aarch64/include/cpu.h:1.9
--- src/sys/arch/aarch64/include/cpu.h:1.8	Mon Sep 10 11:05:12 2018
+++ src/sys/arch/aarch64/include/cpu.h	Fri Oct 12 21:41:34 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.8 2018/09/10 11:05:12 ryo Exp $ */
+/* $NetBSD: cpu.h,v 1.9 2018/10/12 21:41:34 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -85,6 +85,9 @@ struct cpu_info {
 	u_int ci_gic_redist;	/* GICv3 redistributor index */
 	uint64_t ci_gic_sgir;	/* GICv3 SGIR target */
 
+	/* ACPI */
+	uint64_t ci_acpiid;	/* ACPI Processor Unique ID */
+
 	uint64_t ci_midr;	/* MIDR_EL1 */
 	uint64_t ci_mpidr;	/* MPIDR_EL1 */
 



CVS commit: src/sys/dev/acpi

2018-10-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Oct 12 21:38:10 UTC 2018

Modified Files:
src/sys/dev/acpi: files.acpi

Log Message:
Add attributes for attaching acpi(4) child devices based on SDT, GTDT, and MADT 
subtables.


To generate a diff of this commit:
cvs rdiff -u -r1.101 -r1.102 src/sys/dev/acpi/files.acpi

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/acpi/files.acpi
diff -u src/sys/dev/acpi/files.acpi:1.101 src/sys/dev/acpi/files.acpi:1.102
--- src/sys/dev/acpi/files.acpi:1.101	Thu Mar  1 06:00:49 2018
+++ src/sys/dev/acpi/files.acpi	Fri Oct 12 21:38:10 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: files.acpi,v 1.101 2018/03/01 06:00:49 maya Exp $
+#	$NetBSD: files.acpi,v 1.102 2018/10/12 21:38:10 jmcneill Exp $
 
 include "dev/acpi/acpica/files.acpica"
 
@@ -13,8 +13,11 @@ define	acpinodebus { }
 define	acpiecdtbus { }
 define	acpihpetbus { }
 define	acpiwdrtbus { }
+define	acpisdtbus { }
+define	acpigtdtbus { }
+define	acpimadtbus { }
 
-device	acpi: acpica, acpiapmbus, acpinodebus, acpiecdtbus, acpihpetbus, acpiwdrtbus, sysmon_power, sysmon_taskq
+device	acpi: acpica, acpiapmbus, acpinodebus, acpiecdtbus, acpisdtbus, acpigtdtbus, acpimadtbus, acpihpetbus, acpiwdrtbus, sysmon_power, sysmon_taskq
 attach	acpi at acpibus
 file	dev/acpi/acpi.c			acpi
 file	dev/acpi/acpi_debug.c		acpi



CVS commit: src/sys/dev/acpi/acpica

2018-10-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Oct 12 21:36:24 UTC 2018

Modified Files:
src/sys/dev/acpi/acpica: acpi_func.h

Log Message:
Implement ACPI_FLUSH_CPU_CACHE on aarch64.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/acpi/acpica/acpi_func.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/acpi/acpica/acpi_func.h
diff -u src/sys/dev/acpi/acpica/acpi_func.h:1.5 src/sys/dev/acpi/acpica/acpi_func.h:1.6
--- src/sys/dev/acpi/acpica/acpi_func.h:1.5	Thu Apr 19 21:50:08 2018
+++ src/sys/dev/acpi/acpica/acpi_func.h	Fri Oct 12 21:36:24 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: acpi_func.h,v 1.5 2018/04/19 21:50:08 christos Exp $	*/
+/*	$NetBSD: acpi_func.h,v 1.6 2018/10/12 21:36:24 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2000 Michael Smith
@@ -83,10 +83,12 @@ acpi_release_global_lock(uint32_t *lock)
 /*
  * XXX: Should be in a MD header.
  */
-#ifndef __ia64__
-#define	ACPI_FLUSH_CPU_CACHE()	wbinvd()
+#if defined(__ia64__)
+#define	ACPI_FLUSH_CPU_CACHE()	/* XXX: ia64_fc()? */
+#elif defined(__aarch64__)
+#define	ACPI_FLUSH_CPU_CACHE()	cpu_dcache_wbinv_all()
 #else
-#define ACPI_FLUSH_CPU_CACHE()	/* XXX: ia64_fc()? */
+#define	ACPI_FLUSH_CPU_CACHE()	wbinvd()
 #endif
 
 #endif /* !_SYS_DEV_ACPI_ACPICA_ACPI_FUNC_H */



CVS commit: src/sys/dev/acpi

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

Modified Files:
src/sys/dev/acpi: acpi.c acpivar.h

Log Message:
Add helper functions for walking GTDT subtables.


To generate a diff of this commit:
cvs rdiff -u -r1.272 -r1.273 src/sys/dev/acpi/acpi.c
cvs rdiff -u -r1.75 -r1.76 src/sys/dev/acpi/acpivar.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/acpi/acpi.c
diff -u src/sys/dev/acpi/acpi.c:1.272 src/sys/dev/acpi/acpi.c:1.273
--- src/sys/dev/acpi/acpi.c:1.272	Thu Oct 11 22:58:36 2018
+++ src/sys/dev/acpi/acpi.c	Fri Oct 12 21:20:54 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: acpi.c,v 1.272 2018/10/11 22:58:36 jmcneill Exp $	*/
+/*	$NetBSD: acpi.c,v 1.273 2018/10/12 21:20:54 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2003, 2007 The NetBSD Foundation, Inc.
@@ -100,7 +100,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.272 2018/10/11 22:58:36 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.273 2018/10/12 21:20:54 jmcneill Exp $");
 
 #include "pci.h"
 #include "opt_acpi.h"
@@ -148,6 +148,7 @@ static uint64_t		 acpi_root_pointer;
 extern kmutex_t		 acpi_interrupt_list_mtx;
 static ACPI_HANDLE	 acpi_scopes[4];
 ACPI_TABLE_HEADER	*madt_header;
+ACPI_TABLE_HEADER	*gtdt_header;
 
 /*
  * This structure provides a context for the ACPI
@@ -1708,6 +1709,28 @@ acpi_madt_unmap(void)
 	madt_header = NULL;
 }
 
+ACPI_STATUS
+acpi_gtdt_map(void)
+{
+	ACPI_STATUS  rv;
+
+	if (gtdt_header != NULL)
+		return AE_ALREADY_EXISTS;
+
+	rv = AcpiGetTable(ACPI_SIG_GTDT, 1, _header);
+
+	if (ACPI_FAILURE(rv))
+		return rv;
+
+	return AE_OK;
+}
+
+void
+acpi_gtdt_unmap(void)
+{
+	gtdt_header = NULL;
+}
+
 /*
  * XXX: Refactor to be a generic function that walks tables.
  */
@@ -1731,6 +1754,26 @@ acpi_madt_walk(ACPI_STATUS (*func)(ACPI_
 	}
 }
 
+void
+acpi_gtdt_walk(ACPI_STATUS (*func)(ACPI_GTDT_HEADER *, void *), void *aux)
+{
+	ACPI_GTDT_HEADER *hdrp;
+	char *gtdtend, *where;
+
+	gtdtend = (char *)gtdt_header + gtdt_header->Length;
+	where = (char *)gtdt_header + sizeof (ACPI_TABLE_GTDT);
+
+	while (where < gtdtend) {
+
+		hdrp = (ACPI_GTDT_HEADER *)where;
+
+		if (ACPI_FAILURE(func(hdrp, aux)))
+			break;
+
+		where += hdrp->Length;
+	}
+}
+
 /*
  * Miscellaneous.
  */

Index: src/sys/dev/acpi/acpivar.h
diff -u src/sys/dev/acpi/acpivar.h:1.75 src/sys/dev/acpi/acpivar.h:1.76
--- src/sys/dev/acpi/acpivar.h:1.75	Sat May  5 17:16:23 2018
+++ src/sys/dev/acpi/acpivar.h	Fri Oct 12 21:20:54 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: acpivar.h,v 1.75 2018/05/05 17:16:23 christos Exp $	*/
+/*	$NetBSD: acpivar.h,v 1.76 2018/10/12 21:20:54 jmcneill Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -351,6 +351,14 @@ void			acpi_madt_walk(ACPI_STATUS (*)(AC
    void *), void *);
 
 /*
+ * GTDT.
+ */
+ACPI_STATUS		acpi_gtdt_map(void);
+void			acpi_gtdt_unmap(void);
+void			acpi_gtdt_walk(ACPI_STATUS (*)(ACPI_GTDT_HEADER *,
+   void *), void *);
+
+/*
  * Quirk handling.
  */
 struct acpi_quirk {



CVS commit: src/sys/dev/acpi

2018-10-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Oct 12 21:19:11 UTC 2018

Modified Files:
src/sys/dev/acpi: acpi_util.c

Log Message:
Pull in sys/cpu.h for struct cpu_info and CPU_INFO_ITERATOR.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/acpi/acpi_util.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/acpi/acpi_util.c
diff -u src/sys/dev/acpi/acpi_util.c:1.11 src/sys/dev/acpi/acpi_util.c:1.12
--- src/sys/dev/acpi/acpi_util.c:1.11	Tue Mar 20 12:14:52 2018
+++ src/sys/dev/acpi/acpi_util.c	Fri Oct 12 21:19:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: acpi_util.c,v 1.11 2018/03/20 12:14:52 bouyer Exp $ */
+/*	$NetBSD: acpi_util.c,v 1.12 2018/10/12 21:19:11 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2003, 2007 The NetBSD Foundation, Inc.
@@ -65,10 +65,11 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_util.c,v 1.11 2018/03/20 12:14:52 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_util.c,v 1.12 2018/10/12 21:19:11 jmcneill Exp $");
 
 #include 
 #include 
+#include 
 
 #include 
 #include 



CVS commit: src/external/bsd/nsd/dist

2018-10-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Oct 12 18:02:59 UTC 2018

Removed Files:
src/external/bsd/nsd/dist: o

Log Message:
remove accidental commit debris.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r0 src/external/bsd/nsd/dist/o

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



CVS commit: [pgoyette-compat] src/sys/sys

2018-10-12 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Fri Oct 12 10:28:29 UTC 2018

Modified Files:
src/sys/sys [pgoyette-compat]: module_hook.h

Log Message:
Use private-namespace variable ``__hooked'' instead of ``hooked''


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.6 -r1.1.2.7 src/sys/sys/module_hook.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/sys/module_hook.h
diff -u src/sys/sys/module_hook.h:1.1.2.6 src/sys/sys/module_hook.h:1.1.2.7
--- src/sys/sys/module_hook.h:1.1.2.6	Thu Oct  4 02:24:26 2018
+++ src/sys/sys/module_hook.h	Fri Oct 12 10:28:29 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: module_hook.h,v 1.1.2.6 2018/10/04 02:24:26 pgoyette Exp $	*/
+/* $NetBSD: module_hook.h,v 1.1.2.7 2018/10/12 10:28:29 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -173,18 +173,18 @@ hook ## _ ## which ## _call decl;
 int\
 hook ## _ ## which ## _call decl\
 {\
-	bool hooked;		\
+	bool __hooked;		\
 	int __hook_error, __hook_s;\
 \
 	__hook_s = pserialize_read_enter();			\
-	hooked = hook.hooked;	\
-	if (hooked) {		\
+	__hooked = hook.hooked;	\
+	if (__hooked) {		\
 		membar_consumer();\
 		localcount_acquire();			\
 	}			\
 	pserialize_read_exit(__hook_s);\
 \
-	if (hooked) {		\
+	if (__hooked) {		\
 		__hook_error = (*hook.which)args;		\
 		localcount_release(, ,		\
 		);	\



CVS commit: src/external/bsd/nsd

2018-10-12 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Oct 12 09:43:59 UTC 2018

Modified Files:
src/external/bsd/nsd: Makefile.inc

Log Message:
Fix obvious typo: add missing equal sign.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/nsd/Makefile.inc

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

Modified files:

Index: src/external/bsd/nsd/Makefile.inc
diff -u src/external/bsd/nsd/Makefile.inc:1.4 src/external/bsd/nsd/Makefile.inc:1.5
--- src/external/bsd/nsd/Makefile.inc:1.4	Fri Feb  9 17:13:27 2018
+++ src/external/bsd/nsd/Makefile.inc	Fri Oct 12 09:43:59 2018
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.4 2018/02/09 17:13:27 christos Exp $
+# $NetBSD: Makefile.inc,v 1.5 2018/10/12 09:43:59 hannken Exp $
 
 .include 
 
@@ -15,7 +15,7 @@ CPPFLAGS+=  -DINET6
 .endif
 
 .if ${HAVE_OPENSSL} < 11
-CPPFLAGS+=	-DOPENSSL_API_COMPAT 0x1010L
+CPPFLAGS+=	-DOPENSSL_API_COMPAT=0x1010L
 .endif
 
 DPLIBS+= event ${NETBSDSRCDIR}/external/bsd/libevent/lib/libevent