Module Name:    src
Committed By:   skrll
Date:           Wed Nov  3 22:02:36 UTC 2021

Modified Files:
        src/sys/stand/efiboot: boot.c efiacpi.c efifdt.c

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

acpi [{on|off}]


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/stand/efiboot/boot.c
cvs rdiff -u -r1.11 -r1.12 src/sys/stand/efiboot/efiacpi.c
cvs rdiff -u -r1.31 -r1.32 src/sys/stand/efiboot/efifdt.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/stand/efiboot/boot.c
diff -u src/sys/stand/efiboot/boot.c:1.40 src/sys/stand/efiboot/boot.c:1.41
--- src/sys/stand/efiboot/boot.c:1.40	Sun Oct 17 14:12:54 2021
+++ src/sys/stand/efiboot/boot.c	Wed Nov  3 22:02:36 2021
@@ -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 <non...@netbsd.org>
@@ -93,6 +93,7 @@ static char rndseed_path[255];
 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_version(char *);
 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 @@ command_help(char *arg)
 }
 
 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;

Index: src/sys/stand/efiboot/efiacpi.c
diff -u src/sys/stand/efiboot/efiacpi.c:1.11 src/sys/stand/efiboot/efiacpi.c:1.12
--- src/sys/stand/efiboot/efiacpi.c:1.11	Wed Oct  6 10:13:19 2021
+++ src/sys/stand/efiboot/efiacpi.c	Wed Nov  3 22:02:36 2021
@@ -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 Acpi20TableGuid = ACPI_2
 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 @@ efi_acpi_probe(void)
 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 @@ efi_acpi_smbios(void)
 
 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)
 {

Index: src/sys/stand/efiboot/efifdt.c
diff -u src/sys/stand/efiboot/efifdt.c:1.31 src/sys/stand/efiboot/efifdt.c:1.32
--- src/sys/stand/efiboot/efifdt.c:1.31	Wed Oct  6 10:15:20 2021
+++ src/sys/stand/efiboot/efifdt.c	Wed Nov  3 22:02:36 2021
@@ -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 @@ efi_fdt_gop(void)
 		/*
 		 * 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 @@ arch_prepare_boot(const char *fname, con
 
 #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;
 	}
 

Reply via email to