From 87b45ed5760436016dc13f285f9f6b0d5fa5e0e4 Mon Sep 17 00:00:00 2001 From: Mitsuru IWASAKI Date: Sun, 24 Nov 2002 02:27:07 +0000 Subject: [PATCH] Add `if (!cold)' checkings for functions which is called via SYSINIT. Loading acpi.ko with kldload is disallowed, however some functions were executed unexpectedly. Approved by: re --- sys/amd64/acpica/acpi_wakeup.c | 3 +++ sys/dev/acpica/acpi.c | 20 +++++++++++++------- sys/i386/acpica/acpi_wakeup.c | 3 +++ 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/sys/amd64/acpica/acpi_wakeup.c b/sys/amd64/acpica/acpi_wakeup.c index 6dc942eafe8c..53c16a4a459f 100644 --- a/sys/amd64/acpica/acpi_wakeup.c +++ b/sys/amd64/acpica/acpi_wakeup.c @@ -301,6 +301,9 @@ static void acpi_alloc_wakeup_handler(void) { + if (!cold) + return; + if (bus_dma_tag_create(/* parent */ NULL, /* alignment */ 2, 0, /* lowaddr below 1MB */ 0x9ffff, /* highaddr */ BUS_SPACE_MAXADDR, NULL, NULL, diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c index c8f7e623db05..2a6ca655a184 100644 --- a/sys/dev/acpica/acpi.c +++ b/sys/dev/acpica/acpi.c @@ -185,8 +185,10 @@ acpi_modevent(struct module *mod, int event, void *junk) { switch(event) { case MOD_LOAD: - if (!cold) + if (!cold) { + printf("The ACPI driver cannot be loaded after boot.\n"); return(EPERM); + } break; case MOD_UNLOAD: if (!cold && power_pm_get_type() == POWER_PM_TYPE_ACPI) @@ -212,10 +214,8 @@ acpi_identify(driver_t *driver, device_t parent) ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); - if(!cold){ - printf("Don't load this driver from userland!!\n"); - return ; - } + if (!cold) + return_VOID; /* * Check that we haven't been disabled with a hint. @@ -2043,6 +2043,9 @@ acpi_set_debugging(void *junk) { char *cp; + if (!cold) + return; + AcpiDbgLayer = 0; AcpiDbgLevel = 0; if ((cp = getenv("debug.acpi.layer")) != NULL) { @@ -2110,13 +2113,16 @@ acpi_pm_func(u_long cmd, void *arg, ...) static void acpi_pm_register(void *arg) { - int error; + int error; + + if (!cold) + return; if (!resource_int_value("acpi", 0, "disabled", &error) && (error != 0)) return; - power_pm_register(POWER_PM_TYPE_ACPI, acpi_pm_func, NULL); + power_pm_register(POWER_PM_TYPE_ACPI, acpi_pm_func, NULL); } SYSINIT(power, SI_SUB_KLD, SI_ORDER_ANY, acpi_pm_register, 0); diff --git a/sys/i386/acpica/acpi_wakeup.c b/sys/i386/acpica/acpi_wakeup.c index 6dc942eafe8c..53c16a4a459f 100644 --- a/sys/i386/acpica/acpi_wakeup.c +++ b/sys/i386/acpica/acpi_wakeup.c @@ -301,6 +301,9 @@ static void acpi_alloc_wakeup_handler(void) { + if (!cold) + return; + if (bus_dma_tag_create(/* parent */ NULL, /* alignment */ 2, 0, /* lowaddr below 1MB */ 0x9ffff, /* highaddr */ BUS_SPACE_MAXADDR, NULL, NULL,