Source-Changes-HG archive

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

[src/trunk]: src/sys/stand/efiboot Provide the ablity to ignore ACPI with an ...



details:   https://anonhg.NetBSD.org/src/rev/2d3394c5444b
branches:  trunk
changeset: 1024773:2d3394c5444b
user:      skrll <skrll%NetBSD.org@localhost>
date:      Wed Nov 03 22:02:36 2021 +0000

description:
Provide the ablity to ignore ACPI with an 'acpi' command:

acpi [{on|off}]

diffstat:

 sys/stand/efiboot/boot.c    |  21 ++++++++++++++++++++-
 sys/stand/efiboot/efiacpi.c |  24 ++++++++++++++----------
 sys/stand/efiboot/efifdt.c  |  15 ++++++++-------
 3 files changed, 42 insertions(+), 18 deletions(-)

diffs (151 lines):

diff -r 957aff53d229 -r 2d3394c5444b sys/stand/efiboot/boot.c
--- a/sys/stand/efiboot/boot.c  Wed Nov 03 21:47:35 2021 +0000
+++ b/sys/stand/efiboot/boot.c  Wed Nov 03 22:02:36 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: boot.c,v 1.40 2021/10/17 14:12:54 jmcneill Exp $       */
+/*     $NetBSD: boot.c,v 1.41 2021/11/03 22:02:36 skrll Exp $  */
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka <nonaka%netbsd.org@localhost>
@@ -93,6 +93,7 @@
 int    set_bootfile(const char *);
 int    set_bootargs(const char *);
 
+void   command_acpi(char *);
 void   command_boot(char *);
 void   command_dev(char *);
 void   command_initrd(char *);
@@ -115,6 +116,7 @@
 void   command_quit(char *);
 
 const struct boot_command commands[] = {
+       { "acpi",       command_acpi,           "acpi [{on|off}]" },
        { "boot",       command_boot,           "boot [dev:][filename] [args]\n     (ex. \"hd0a:\\netbsd.old -s\"" },
        { "dev",        command_dev,            "dev" },
 #ifdef EFIBOOT_FDT
@@ -173,6 +175,23 @@
 }
 
 void
+command_acpi(char *arg)
+{
+       if (arg && *arg) {
+               if (strcmp(arg, "on") == 0)
+                       efi_acpi_enable(1);
+               else if (strcmp(arg, "off") == 0)
+                       efi_acpi_enable(0);
+               else {
+                       command_help("");
+                       return;
+               }
+       } else {
+               printf("ACPI support is %sabled\n",
+                   efi_acpi_enabled() ? "en" : "dis");
+       }
+}
+void
 command_boot(char *arg)
 {
        char *fname = arg;
diff -r 957aff53d229 -r 2d3394c5444b sys/stand/efiboot/efiacpi.c
--- a/sys/stand/efiboot/efiacpi.c       Wed Nov 03 21:47:35 2021 +0000
+++ b/sys/stand/efiboot/efiacpi.c       Wed Nov 03 22:02:36 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: efiacpi.c,v 1.11 2021/10/06 10:13:19 jmcneill Exp $ */
+/* $NetBSD: efiacpi.c,v 1.12 2021/11/03 22:02:36 skrll Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -49,10 +49,11 @@
 static EFI_GUID Smbios3TableGuid = SMBIOS3_TABLE_GUID;
 static EFI_GUID SmbiosTableGuid = SMBIOS_TABLE_GUID;
 
-static int acpi_enable = 1;
 static void *acpi_root = NULL;
 static void *smbios_table = NULL;
 
+static int acpi_enabled = 1;
+
 int
 efi_acpi_probe(void)
 {
@@ -76,19 +77,13 @@
 int
 efi_acpi_available(void)
 {
-       return acpi_root != NULL;
+       return acpi_root != NULL && acpi_enabled;
 }
 
 int
 efi_acpi_enabled(void)
 {
-       return acpi_enable;
-}
-
-void
-efi_acpi_enable(int enable)
-{
-       acpi_enable = enable;
+       return acpi_enabled;
 }
 
 void *
@@ -105,6 +100,15 @@
 
 static char model_buf[128];
 
+void
+efi_acpi_enable(int val)
+{
+       if (acpi_root == NULL) {
+               printf("No ACPI node\n");
+       } else
+               acpi_enabled = val;
+}
+
 const char *
 efi_acpi_get_model(void)
 {
diff -r 957aff53d229 -r 2d3394c5444b sys/stand/efiboot/efifdt.c
--- a/sys/stand/efiboot/efifdt.c        Wed Nov 03 21:47:35 2021 +0000
+++ b/sys/stand/efiboot/efifdt.c        Wed Nov 03 22:02:36 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: efifdt.c,v 1.31 2021/10/06 10:15:20 jmcneill Exp $ */
+/* $NetBSD: efifdt.c,v 1.32 2021/11/03 22:02:36 skrll Exp $ */
 
 /*-
  * Copyright (c) 2019 Jason R. Thorpe
@@ -391,7 +391,7 @@
                /*
                 * In ACPI mode, use GOP as console.
                 */
-               if (efi_acpi_available() && efi_acpi_enabled()) {
+               if (efi_acpi_available()) {
                        snprintf(buf, sizeof(buf), "/chosen/framebuffer@%" PRIx64, mode->FrameBufferBase);
                        fdt_setprop_string(fdt_data, chosen, "stdout-path", buf);
                }
@@ -587,17 +587,18 @@
 
 #ifdef EFIBOOT_ACPI
        /* ACPI support only works for little endian kernels */
-       efi_acpi_enable(netbsd_elf_data == ELFDATA2LSB);
-
-       if (efi_acpi_available() && efi_acpi_enabled()) {
+       if (efi_acpi_available() && netbsd_elf_data == ELFDATA2LSB) {
                int error = efi_fdt_create_acpifdt();
                if (error != 0) {
                        return error;
                }
        } else
 #endif
-       if (dtb_addr && efi_fdt_set_data((void *)(uintptr_t)dtb_addr) != 0) {
-               printf("boot: invalid DTB data\n");
+       if (!dtb_addr || efi_fdt_set_data((void *)(uintptr_t)dtb_addr) != 0) {
+               if (!dtb_addr)
+                       printf("boot: no DTB provided\n");
+               else
+                       printf("boot: invalid DTB data\n");
                return EINVAL;
        }
 



Home | Main Index | Thread Index | Old Index