From e079f9491a79f2693df34e265f287ef229cfdf57 Mon Sep 17 00:00:00 2001 From: Nate Lawson Date: Wed, 18 Aug 2004 05:48:24 +0000 Subject: [PATCH] Remove the ACPIIO_ENABLE and ACPIIO_DISABLE ioctls as well as all callers. These ioctls attempted to enable and disable the ACPI interpreter at runtime. In practice, it is not possible to boot with ACPI and then disable it on many systems and trying to do so can cause crashes, interrupt storms, etc. Binary compatibility with userland is retained. MFC after: 2 days --- sys/dev/acpica/acpi.c | 63 +++---------------------------- sys/dev/acpica/acpiio.h | 2 - sys/dev/acpica/acpivar.h | 2 - usr.sbin/acpi/acpiconf/acpiconf.8 | 8 +--- usr.sbin/acpi/acpiconf/acpiconf.c | 27 +------------ 5 files changed, 10 insertions(+), 92 deletions(-) diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c index 7c90b3298e03..8176ef2803c5 100644 --- a/sys/dev/acpica/acpi.c +++ b/sys/dev/acpica/acpi.c @@ -625,7 +625,7 @@ acpi_child_location_str_method(device_t cbdev, device_t child, char *buf, size_t buflen) { struct acpi_device *dinfo = device_get_ivars(child); - + if (dinfo->ad_handle) snprintf(buf, buflen, "handle=%s", acpi_name(dinfo->ad_handle)); else @@ -1581,7 +1581,7 @@ acpi_ForeachPackageObject(ACPI_OBJECT *pkg, { ACPI_OBJECT *comp; int i; - + if (pkg == NULL || pkg->Type != ACPI_TYPE_PACKAGE) return (AE_BAD_PARAMETER); @@ -1636,7 +1636,7 @@ acpi_AppendBufferResource(ACPI_BUFFER *buf, ACPI_RESOURCE *res) { ACPI_RESOURCE *rp; void *newp; - + /* Initialise the buffer if necessary. */ if (buf->Pointer == NULL) { buf->Length = ACPI_INITIAL_RESOURCE_BUFFER_SIZE; @@ -1648,7 +1648,7 @@ acpi_AppendBufferResource(ACPI_BUFFER *buf, ACPI_RESOURCE *res) } if (res == NULL) return (AE_OK); - + /* * Scan the current buffer looking for the terminator. * This will either find the terminator or hit the end @@ -1687,10 +1687,10 @@ acpi_AppendBufferResource(ACPI_BUFFER *buf, ACPI_RESOURCE *res) buf->Pointer = newp; buf->Length += buf->Length; } - + /* Insert the new resource. */ bcopy(res, rp, res->Length + ACPI_RESOURCE_LENGTH_NO_DATA); - + /* And add the terminator. */ rp = ACPI_NEXT_RESOURCE(rp); rp->Id = ACPI_RSTYPE_END_TAG; @@ -2145,49 +2145,6 @@ acpi_parse_prw(ACPI_HANDLE h, struct acpi_prw_data *prw) return (error); } -/* - * Enable/Disable ACPI - */ -ACPI_STATUS -acpi_Enable(struct acpi_softc *sc) -{ - ACPI_STATUS status; - u_int32_t flags; - - ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); - - status = AE_ERROR; - flags = ACPI_NO_ADDRESS_SPACE_INIT | ACPI_NO_HARDWARE_INIT | - ACPI_NO_DEVICE_INIT | ACPI_NO_OBJECT_INIT; - - ACPI_SERIAL_BEGIN(acpi); - if (!sc->acpi_enabled) - status = AcpiEnableSubsystem(flags); - if (ACPI_SUCCESS(status)) - sc->acpi_enabled = 1; - ACPI_SERIAL_END(acpi); - - return_ACPI_STATUS (status); -} - -ACPI_STATUS -acpi_Disable(struct acpi_softc *sc) -{ - ACPI_STATUS status; - - ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); - - status = AE_ERROR; - ACPI_SERIAL_BEGIN(acpi); - if (sc->acpi_enabled) - status = AcpiDisable(); - if (ACPI_SUCCESS(status)) - sc->acpi_enabled = 0; - ACPI_SERIAL_END(acpi); - - return_ACPI_STATUS (status); -} - /* * ACPI Event Handlers */ @@ -2463,14 +2420,6 @@ acpiioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, d_thread_t *td) /* Core system ioctls. */ switch (cmd) { - case ACPIIO_ENABLE: - if (ACPI_FAILURE(acpi_Enable(sc))) - error = ENXIO; - break; - case ACPIIO_DISABLE: - if (ACPI_FAILURE(acpi_Disable(sc))) - error = ENXIO; - break; case ACPIIO_SETSLPSTATE: error = EINVAL; state = *(int *)addr; diff --git a/sys/dev/acpica/acpiio.h b/sys/dev/acpica/acpiio.h index a782dfc4cb5c..4f059e79109c 100644 --- a/sys/dev/acpica/acpiio.h +++ b/sys/dev/acpica/acpiio.h @@ -30,8 +30,6 @@ /* * Core ACPI subsystem ioctls */ -#define ACPIIO_ENABLE _IO('P', 1) -#define ACPIIO_DISABLE _IO('P', 2) #define ACPIIO_SETSLPSTATE _IOW('P', 3, int) struct acpi_battdesc { diff --git a/sys/dev/acpica/acpivar.h b/sys/dev/acpica/acpivar.h index 53b33e47695f..477f590eca0a 100644 --- a/sys/dev/acpica/acpivar.h +++ b/sys/dev/acpica/acpivar.h @@ -274,8 +274,6 @@ int acpi_wake_init(device_t dev, int type); int acpi_wake_set_enable(device_t dev, int enable); int acpi_parse_prw(ACPI_HANDLE h, struct acpi_prw_data *prw); ACPI_STATUS acpi_Startup(void); -ACPI_STATUS acpi_Enable(struct acpi_softc *sc); -ACPI_STATUS acpi_Disable(struct acpi_softc *sc); void acpi_UserNotify(const char *subsystem, ACPI_HANDLE h, uint8_t notify); struct resource *acpi_bus_alloc_gas(device_t dev, int *rid, diff --git a/usr.sbin/acpi/acpiconf/acpiconf.8 b/usr.sbin/acpi/acpiconf/acpiconf.8 index 1de3c7ddf338..b665daf3669f 100644 --- a/usr.sbin/acpi/acpiconf/acpiconf.8 +++ b/usr.sbin/acpi/acpiconf/acpiconf.8 @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 12, 2001 +.Dd August 16, 2004 .Dt ACPICONF 8 .Os .Sh NAME @@ -35,7 +35,7 @@ .Nd control ACPI power management .Sh SYNOPSIS .Nm -.Op Fl deh +.Op Fl h .Op Fl i Ar batt .Op Fl s Ar type .Sh DESCRIPTION @@ -45,10 +45,6 @@ utility allows the user control of the ACPI power management functions. The following command-line options are recognized: .Bl -tag -width ".Fl s Ar type" -.It Fl d -Disables ACPI power management. -.It Fl e -Enables ACPI power management. .It Fl h Displays a summary of available options. .It Fl i Ar batt diff --git a/usr.sbin/acpi/acpiconf/acpiconf.c b/usr.sbin/acpi/acpiconf/acpiconf.c index d9e67e407cc9..4500cbefd5b0 100644 --- a/usr.sbin/acpi/acpiconf/acpiconf.c +++ b/usr.sbin/acpi/acpiconf/acpiconf.c @@ -57,21 +57,6 @@ acpi_init() } } -#if 0 -static int -acpi_enable_disable(int enable) -{ - if (ioctl(acpifd, enable, NULL) == -1) { - if (enable == ACPIIO_ENABLE) - err(EX_IOERR, "enable failed"); - else - err(EX_IOERR, "disable failed"); - } - - return (0); -} -#endif - static int acpi_sleep(int sleep_type) { @@ -138,7 +123,7 @@ acpi_battinfo(int num) static void usage(const char* prog) { - printf("usage: %s [-deh] [-i batt] [-s 1-5]\n", prog); + printf("usage: %s [-h] [-i batt] [-s 1-5]\n", prog); exit(0); } @@ -155,19 +140,11 @@ main(int argc, char *argv[]) sleep_type = -1; acpi_init(); - while ((c = getopt(argc, argv, "dehi:s:")) != -1) { + while ((c = getopt(argc, argv, "hi:s:")) != -1) { switch (c) { case 'i': acpi_battinfo(atoi(optarg)); break; -#if 0 - case 'd': - acpi_enable_disable(ACPIIO_DISABLE); - break; - case 'e': - acpi_enable_disable(ACPIIO_ENABLE); - break; -#endif case 's': if (optarg[0] == 'S') sleep_type = optarg[1] - '0';