Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/arm/acpi Use SPCR to force console selection for co...



details:   https://anonhg.NetBSD.org/src/rev/a3e08ca4fbaa
branches:  trunk
changeset: 995413:a3e08ca4fbaa
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Fri Dec 21 14:50:18 2018 +0000

description:
Use SPCR to force console selection for com@acpi. This is needed because
we may use a non-standard bus_space tag (a4x) to attach the console early,
which breaks com_is_console.

diffstat:

 sys/arch/arm/acpi/acpi_platform.c |  46 +++++++++++++++++++++++++++++---------
 1 files changed, 35 insertions(+), 11 deletions(-)

diffs (78 lines):

diff -r 440d32ddb777 -r a3e08ca4fbaa sys/arch/arm/acpi/acpi_platform.c
--- a/sys/arch/arm/acpi/acpi_platform.c Fri Dec 21 11:11:40 2018 +0000
+++ b/sys/arch/arm/acpi/acpi_platform.c Fri Dec 21 14:50:18 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_platform.c,v 1.10 2018/11/28 22:29:36 jmcneill Exp $ */
+/* $NetBSD: acpi_platform.c,v 1.11 2018/12/21 14:50:18 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 #include "opt_efi.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.10 2018/11/28 22:29:36 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.11 2018/12/21 14:50:18 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -232,16 +232,12 @@
 #if NCOM > 0
        prop_dictionary_t prop = device_properties(self);
 
-       if (device_is_a(self, "com") && device_is_a(device_parent(self), "puc")) {
-               const struct puc_attach_args * const paa = aux;
+       if (device_is_a(self, "com")) {
                ACPI_TABLE_SPCR *spcr;
-               int b, d, f;
-
-               const int s = pci_get_segment(paa->pc);
-               pci_decompose_tag(paa->pc, paa->tag, &b, &d, &f);
 
                if (ACPI_FAILURE(acpi_table_find(ACPI_SIG_SPCR, (void **)&spcr)))
                        return;
+
                if (spcr->SerialPort.SpaceId != ACPI_ADR_SPACE_SYSTEM_MEMORY)
                        goto spcr_unmap;
                if (spcr->SerialPort.Address == 0)
@@ -250,9 +246,37 @@
                    spcr->InterfaceType != ACPI_DBG2_16550_SUBSET)
                        goto spcr_unmap;
 
-               if (spcr->PciSegment == s && spcr->PciBus == b &&
-                   spcr->PciDevice == d && spcr->PciFunction == f)
-                       prop_dictionary_set_bool(prop, "force_console", true);
+               if (device_is_a(device_parent(self), "puc")) {
+                       const struct puc_attach_args * const paa = aux;
+                       int b, d, f;
+
+                       const int s = pci_get_segment(paa->pc);
+                       pci_decompose_tag(paa->pc, paa->tag, &b, &d, &f);
+
+                       if (spcr->PciSegment == s && spcr->PciBus == b &&
+                           spcr->PciDevice == d && spcr->PciFunction == f)
+                               prop_dictionary_set_bool(prop, "force_console", true);
+               }
+
+               if (device_is_a(device_parent(self), "acpi")) {
+                       struct acpi_attach_args * const aa = aux;
+                       struct acpi_resources res;
+                       struct acpi_mem *mem;
+
+                       if (ACPI_FAILURE(acpi_resource_parse(self, aa->aa_node->ad_handle, "_CRS",
+                           &res, &acpi_resource_parse_ops_quiet)))
+                               goto spcr_unmap;
+
+                       mem = acpi_res_mem(&res, 0);
+                       if (mem == NULL)
+                               goto crs_cleanup;
+
+                       if (mem->ar_base == spcr->SerialPort.Address)
+                               prop_dictionary_set_bool(prop, "force_console", true);
+
+crs_cleanup:
+                       acpi_resource_cleanup(&res);
+               }
 
 spcr_unmap:
                acpi_table_unmap((ACPI_TABLE_HEADER *)spcr);



Home | Main Index | Thread Index | Old Index