Subject: Re: ACPI vs. a "legacy free" notebook... :/
To: None <hubert.feyrer@informatik.fh-regensburg.de>
From: Takayoshi Kochi <kochi@netbsd.org>
List: port-i386
Date: 04/27/2003 21:29:23
----Next_Part(Sun_Apr_27_21:29:23_2003_616)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

From: Takayoshi Kochi <kochi@netbsd.org>
Subject: Re: ACPI vs. a "legacy free" notebook... :/
Date: Sun, 27 Apr 2003 21:26:59 +0900 (JST)

> I wrote a small support code for this reset method, attached
> to this mail.

Oops, I forgot to attach...

Takayoshi Kochi

----Next_Part(Sun_Apr_27_21:29:23_2003_616)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="acpireset.diff"

--- sys/arch/i386/i386/machdep.c.orig	Sun Apr 27 17:03:57 2003
+++ sys/arch/i386/i386/machdep.c	Sun Apr 27 17:26:33 2003
@@ -2192,6 +2192,10 @@
 	outb(IO_RTC, NVRAM_RESET);
 	outb(IO_RTC+1, NVRAM_RESET_RST);
 
+#if NACPI > 0
+	acpi_cpu_reset();
+	/* if reset via acpi is not supported, continue. */
+#endif
 	/*
 	 * The keyboard controller has 4 random output pins, one of which is
 	 * connected to the RESET pin on the CPU in many PCs.  We tell the
--- sys/dev/acpi/acpi.c.orig	Sun Apr 27 17:08:48 2003
+++ sys/dev/acpi/acpi.c	Sun Apr 27 20:22:57 2003
@@ -332,6 +332,37 @@
 	if (acpi_dbgr & ACPI_DBGR_RUNNING)
 		acpi_osd_debugger();
 #endif
+
+#if 1
+	if (AcpiGbl_FADT->ResetRegSup &&
+	    ACPI_VALID_ADDRESS(AcpiGbl_FADT->ResetRegister.Address)) {
+		printf("%s: resetting via acpi supported at ",
+		    sc->sc_dev.dv_xname);
+		switch (AcpiGbl_FADT->ResetRegister.AddressSpaceId) {
+		case ACPI_ADR_SPACE_SYSTEM_MEMORY:
+			printf("memory %p, %d, %d",
+			     (void *)(unsigned long)AcpiGbl_FADT->ResetRegister.Address,
+			     AcpiGbl_FADT->ResetRegister.RegisterBitWidth,
+			     AcpiGbl_FADT->ResetRegister.RegisterBitOffset);
+			break;
+		case ACPI_ADR_SPACE_SYSTEM_IO:
+			printf("port %p, %d, %d",
+			     (void *)(unsigned long)AcpiGbl_FADT->ResetRegister.Address,
+			     AcpiGbl_FADT->ResetRegister.RegisterBitWidth,
+			     AcpiGbl_FADT->ResetRegister.RegisterBitOffset);
+			break;
+		case ACPI_ADR_SPACE_PCI_CONFIG:
+			printf("pci %p, %d, %d",
+			     (void *)(unsigned long)AcpiGbl_FADT->ResetRegister.Address,
+			     AcpiGbl_FADT->ResetRegister.RegisterBitWidth,
+			     AcpiGbl_FADT->ResetRegister.RegisterBitOffset);
+			break;
+		default:
+			printf("unknown");
+		}
+		printf(" value 0x%02x\n", AcpiGbl_FADT->ResetValue);
+	}
+#endif
 }
 
 /*
@@ -1296,3 +1327,21 @@
 	return rv;
 }
 #endif /* ACPI_PCI_FIXUP || ACPI_ACTIVATE_DEV */
+
+#if 1
+void
+acpi_cpu_reset()
+{
+	if (!AcpiGbl_FADT->ResetRegSup ||
+	    !(ACPI_VALID_ADDRESS(AcpiGbl_FADT->ResetRegister.Address)))
+		return;
+
+	printf("Resetting via ACPI...\n");
+	delay(500000);
+	AcpiHwLowLevelWrite(8, AcpiGbl_FADT->ResetValue,
+			    &AcpiGbl_FADT->ResetRegister, 0);
+
+	/* go into tight loop as specified in ACPI 2.0b 4.7.3.6 */
+	for (;;);
+}
+#endif
--- sys/dev/acpi/acpivar.h.orig	Fri Apr 18 01:41:48 2003
+++ sys/dev/acpi/acpivar.h	Sun Apr 27 17:28:21 2003
@@ -284,3 +284,4 @@
 ACPI_STATUS	acpi_acquire_global_lock(UINT32 *);
 void		acpi_release_global_lock(UINT32);
 int		acpi_is_global_locked(void);
+void		acpi_cpu_reset(void);

----Next_Part(Sun_Apr_27_21:29:23_2003_616)----