acpi.c (94168) | acpi.c (94936) |
---|---|
1/*- 2 * Copyright (c) 2000 Takanori Watanabe <takawata@jp.freebsd.org> 3 * Copyright (c) 2000 Mitsuru IWASAKI <iwasaki@jp.freebsd.org> 4 * Copyright (c) 2000, 2001 Michael Smith 5 * Copyright (c) 2000 BSDi 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 12 unchanged lines hidden (view full) --- 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * | 1/*- 2 * Copyright (c) 2000 Takanori Watanabe <takawata@jp.freebsd.org> 3 * Copyright (c) 2000 Mitsuru IWASAKI <iwasaki@jp.freebsd.org> 4 * Copyright (c) 2000, 2001 Michael Smith 5 * Copyright (c) 2000 BSDi 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 12 unchanged lines hidden (view full) --- 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * |
29 * $FreeBSD: head/sys/dev/acpica/acpi.c 94168 2002-04-08 06:58:17Z takawata $ | 29 * $FreeBSD: head/sys/dev/acpica/acpi.c 94936 2002-04-17 13:06:36Z mux $ |
30 */ 31 32#include "opt_acpi.h" 33#include <sys/param.h> 34#include <sys/kernel.h> 35#include <sys/proc.h> 36#include <sys/lock.h> 37#include <sys/malloc.h> --- 167 unchanged lines hidden (view full) --- 205 */ 206static void 207acpi_identify(driver_t *driver, device_t parent) 208{ 209 device_t child; 210 int error; 211 caddr_t acpi_dsdt, p; 212#ifdef ENABLE_DEBUGGER | 30 */ 31 32#include "opt_acpi.h" 33#include <sys/param.h> 34#include <sys/kernel.h> 35#include <sys/proc.h> 36#include <sys/lock.h> 37#include <sys/malloc.h> --- 167 unchanged lines hidden (view full) --- 205 */ 206static void 207acpi_identify(driver_t *driver, device_t parent) 208{ 209 device_t child; 210 int error; 211 caddr_t acpi_dsdt, p; 212#ifdef ENABLE_DEBUGGER |
213 char *debugpoint = getenv("debug.acpi.debugger"); | 213 char *debugpoint; |
214#endif 215 216 ACPI_FUNCTION_TRACE(__func__); 217 218 if(!cold){ 219 printf("Don't load this driver from userland!!\n"); 220 return ; 221 } --- 13 unchanged lines hidden (view full) --- 235 236 /* initialise the ACPI mutex */ 237 mtx_init(&acpi_mutex, "ACPI global lock", NULL, MTX_DEF); 238 239 /* 240 * Start up the ACPI CA subsystem. 241 */ 242#ifdef ENABLE_DEBUGGER | 214#endif 215 216 ACPI_FUNCTION_TRACE(__func__); 217 218 if(!cold){ 219 printf("Don't load this driver from userland!!\n"); 220 return ; 221 } --- 13 unchanged lines hidden (view full) --- 235 236 /* initialise the ACPI mutex */ 237 mtx_init(&acpi_mutex, "ACPI global lock", NULL, MTX_DEF); 238 239 /* 240 * Start up the ACPI CA subsystem. 241 */ 242#ifdef ENABLE_DEBUGGER |
243 if (debugpoint && !strcmp(debugpoint, "init")) 244 acpi_EnterDebugger(); | 243 debugpoint = getenv("debug.acpi.debugger"); 244 if (debugpoint) { 245 if (!strcmp(debugpoint, "init")) 246 acpi_EnterDebugger(); 247 freeenv(debugpoint); 248 } |
245#endif 246 if (ACPI_FAILURE(error = AcpiInitializeSubsystem())) { 247 printf("ACPI: initialisation failed: %s\n", AcpiFormatException(error)); 248 return_VOID; 249 } 250#ifdef ENABLE_DEBUGGER | 249#endif 250 if (ACPI_FAILURE(error = AcpiInitializeSubsystem())) { 251 printf("ACPI: initialisation failed: %s\n", AcpiFormatException(error)); 252 return_VOID; 253 } 254#ifdef ENABLE_DEBUGGER |
251 if (debugpoint && !strcmp(debugpoint, "tables")) 252 acpi_EnterDebugger(); | 255 debugpoint = getenv("debug.acpi.debugger"); 256 if (debugpoint) { 257 if (!strcmp(debugpoint, "tables")) 258 acpi_EnterDebugger(); 259 freeenv(debugpoint); 260 } |
253#endif 254 255 if ((acpi_dsdt = preload_search_by_type("acpi_dsdt")) != NULL) { 256 if ((p = preload_search_info(acpi_dsdt, MODINFO_ADDR)) != NULL) { 257 if (ACPI_FAILURE(error = AcpiSetDsdtTablePtr(*(void **)p))) { 258 printf("ACPI: DSDT overriding failed: %s\n", 259 AcpiFormatException(error)); 260 } else { --- 53 unchanged lines hidden (view full) --- 314acpi_attach(device_t dev) 315{ 316 struct acpi_softc *sc; 317 ACPI_STATUS status; 318 int error; 319 UINT32 flags; 320 321#ifdef ENABLE_DEBUGGER | 261#endif 262 263 if ((acpi_dsdt = preload_search_by_type("acpi_dsdt")) != NULL) { 264 if ((p = preload_search_info(acpi_dsdt, MODINFO_ADDR)) != NULL) { 265 if (ACPI_FAILURE(error = AcpiSetDsdtTablePtr(*(void **)p))) { 266 printf("ACPI: DSDT overriding failed: %s\n", 267 AcpiFormatException(error)); 268 } else { --- 53 unchanged lines hidden (view full) --- 322acpi_attach(device_t dev) 323{ 324 struct acpi_softc *sc; 325 ACPI_STATUS status; 326 int error; 327 UINT32 flags; 328 329#ifdef ENABLE_DEBUGGER |
322 char *debugpoint = getenv("debug.acpi.debugger"); | 330 char *debugpoint; |
323#endif 324 325 ACPI_FUNCTION_TRACE(__func__); 326 ACPI_LOCK; 327 sc = device_get_softc(dev); 328 bzero(sc, sizeof(*sc)); 329 sc->acpi_dev = dev; 330 331#ifdef ENABLE_DEBUGGER | 331#endif 332 333 ACPI_FUNCTION_TRACE(__func__); 334 ACPI_LOCK; 335 sc = device_get_softc(dev); 336 bzero(sc, sizeof(*sc)); 337 sc->acpi_dev = dev; 338 339#ifdef ENABLE_DEBUGGER |
332 if (debugpoint && !strcmp(debugpoint, "spaces")) 333 acpi_EnterDebugger(); | 340 debugpoint = getenv("debug.acpi.debugger"); 341 if (debugpoint) { 342 if (!strcmp(debugpoint, "spaces")) 343 acpi_EnterDebugger(); 344 freeenv(debugpoint); 345 } |
334#endif 335 336 /* 337 * Install the default address space handlers. 338 */ 339 error = ENXIO; 340 if (ACPI_FAILURE(status = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT, 341 ACPI_ADR_SPACE_SYSTEM_MEMORY, --- 25 unchanged lines hidden (view full) --- 367 * and _STA on everything, as well as dodging the final object init pass. 368 * 369 * For these devices, we set ACPI_NO_DEVICE_INIT and ACPI_NO_OBJECT_INIT). 370 * 371 * XXX We should arrange for the object init pass after we have attached all our 372 * child devices, but on many systems it works here. 373 */ 374#ifdef ENABLE_DEBUGGER | 346#endif 347 348 /* 349 * Install the default address space handlers. 350 */ 351 error = ENXIO; 352 if (ACPI_FAILURE(status = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT, 353 ACPI_ADR_SPACE_SYSTEM_MEMORY, --- 25 unchanged lines hidden (view full) --- 379 * and _STA on everything, as well as dodging the final object init pass. 380 * 381 * For these devices, we set ACPI_NO_DEVICE_INIT and ACPI_NO_OBJECT_INIT). 382 * 383 * XXX We should arrange for the object init pass after we have attached all our 384 * child devices, but on many systems it works here. 385 */ 386#ifdef ENABLE_DEBUGGER |
375 if (debugpoint && !strcmp(debugpoint, "enable")) 376 acpi_EnterDebugger(); | 387 debugpoint = getenv("debug.acpi.debugger"); 388 if (debugpoint) { 389 if (!strcmp(debugpoint, "enable")) 390 acpi_EnterDebugger(); 391 freeenv(debugpoint); 392 } |
377#endif 378 flags = 0; | 393#endif 394 flags = 0; |
379 if (getenv("debug.acpi.avoid") != NULL) | 395 if (testenv("debug.acpi.avoid")) |
380 flags = ACPI_NO_DEVICE_INIT | ACPI_NO_OBJECT_INIT; 381 if (ACPI_FAILURE(status = AcpiEnableSubsystem(flags))) { 382 device_printf(dev, "could not enable ACPI: %s\n", AcpiFormatException(status)); 383 goto out; 384 } 385 386 /* 387 * Setup our sysctl tree. --- 40 unchanged lines hidden (view full) --- 428 sc->acpi_suspend_sx = ACPI_STATE_S3; 429 430 acpi_enable_fixed_events(sc); 431 432 /* 433 * Scan the namespace and attach/initialise children. 434 */ 435#ifdef ENABLE_DEBUGGER | 396 flags = ACPI_NO_DEVICE_INIT | ACPI_NO_OBJECT_INIT; 397 if (ACPI_FAILURE(status = AcpiEnableSubsystem(flags))) { 398 device_printf(dev, "could not enable ACPI: %s\n", AcpiFormatException(status)); 399 goto out; 400 } 401 402 /* 403 * Setup our sysctl tree. --- 40 unchanged lines hidden (view full) --- 444 sc->acpi_suspend_sx = ACPI_STATE_S3; 445 446 acpi_enable_fixed_events(sc); 447 448 /* 449 * Scan the namespace and attach/initialise children. 450 */ 451#ifdef ENABLE_DEBUGGER |
436 if (debugpoint && !strcmp(debugpoint, "probe")) 437 acpi_EnterDebugger(); | 452 debugpoint = getenv("debug.acpi.debugger"); 453 if (debugpoint) { 454 if (!strcmp(debugpoint, "probe")) 455 acpi_EnterDebugger(); 456 freeenv(debugpoint); 457 } |
438#endif 439 if (!acpi_disabled("bus")) 440 acpi_probe_children(dev); 441 442 /* 443 * Register our shutdown handlers 444 */ 445 EVENTHANDLER_REGISTER(shutdown_pre_sync, acpi_shutdown_pre_sync, sc, SHUTDOWN_PRI_LAST); --- 15 unchanged lines hidden (view full) --- 461 462 /* 463 * Create the control device 464 */ 465 sc->acpi_dev_t = make_dev(&acpi_cdevsw, 0, 0, 5, 0660, "acpi"); 466 sc->acpi_dev_t->si_drv1 = sc; 467 468#ifdef ENABLE_DEBUGGER | 458#endif 459 if (!acpi_disabled("bus")) 460 acpi_probe_children(dev); 461 462 /* 463 * Register our shutdown handlers 464 */ 465 EVENTHANDLER_REGISTER(shutdown_pre_sync, acpi_shutdown_pre_sync, sc, SHUTDOWN_PRI_LAST); --- 15 unchanged lines hidden (view full) --- 481 482 /* 483 * Create the control device 484 */ 485 sc->acpi_dev_t = make_dev(&acpi_cdevsw, 0, 0, 5, 0660, "acpi"); 486 sc->acpi_dev_t->si_drv1 = sc; 487 488#ifdef ENABLE_DEBUGGER |
469 if (debugpoint && !strcmp(debugpoint, "running")) 470 acpi_EnterDebugger(); | 489 debugpoint = getenv("debug.acpi.debugger"); 490 if (debugpoint) { 491 if (!strcmp(debugpoint, "running")) 492 acpi_EnterDebugger(); 493 freeenv(debugpoint); 494 } |
471#endif 472 473#if defined(ACPI_MAX_THREADS) && ACPI_MAX_THREADS > 0 474 if ((error = acpi_task_thread_init())) { 475 goto out; 476 } 477#endif 478 --- 1066 unchanged lines hidden (view full) --- 1545 for (;;) { 1546 while ((*cp != 0) && isspace(*cp)) 1547 cp++; 1548 if (*cp == 0) 1549 break; 1550 len = 0; 1551 while ((cp[len] != 0) && !isspace(cp[len])) 1552 len++; | 495#endif 496 497#if defined(ACPI_MAX_THREADS) && ACPI_MAX_THREADS > 0 498 if ((error = acpi_task_thread_init())) { 499 goto out; 500 } 501#endif 502 --- 1066 unchanged lines hidden (view full) --- 1569 for (;;) { 1570 while ((*cp != 0) && isspace(*cp)) 1571 cp++; 1572 if (*cp == 0) 1573 break; 1574 len = 0; 1575 while ((cp[len] != 0) && !isspace(cp[len])) 1576 len++; |
1553 if (!strncmp(cp, np, len)) | 1577 if (!strncmp(cp, np, len)) { 1578 freeenv(cp); |
1554 return(1); | 1579 return(1); |
1580 } |
|
1555 cp += len; 1556 } | 1581 cp += len; 1582 } |
1583 freeenv(cp); |
|
1557 return(0); 1558} 1559 1560/* 1561 * Debugging/bug-avoidance. Disable ACPI subsystem components. 1562 */ 1563int 1564acpi_disabled(char *subsys) 1565{ 1566 char *cp; 1567 int len; 1568 1569 if ((cp = getenv("debug.acpi.disable")) == NULL) 1570 return(0); | 1584 return(0); 1585} 1586 1587/* 1588 * Debugging/bug-avoidance. Disable ACPI subsystem components. 1589 */ 1590int 1591acpi_disabled(char *subsys) 1592{ 1593 char *cp; 1594 int len; 1595 1596 if ((cp = getenv("debug.acpi.disable")) == NULL) 1597 return(0); |
1571 if (!strcmp(cp, "all")) | 1598 if (!strcmp(cp, "all")) { 1599 freeenv(cp); |
1572 return(1); | 1600 return(1); |
1601 } |
|
1573 1574 /* scan the disable list checking for a match */ 1575 for (;;) { 1576 while ((*cp != 0) && isspace(*cp)) 1577 cp++; 1578 if (*cp == 0) 1579 break; 1580 len = 0; 1581 while ((cp[len] != 0) && !isspace(cp[len])) 1582 len++; | 1602 1603 /* scan the disable list checking for a match */ 1604 for (;;) { 1605 while ((*cp != 0) && isspace(*cp)) 1606 cp++; 1607 if (*cp == 0) 1608 break; 1609 len = 0; 1610 while ((cp[len] != 0) && !isspace(cp[len])) 1611 len++; |
1583 if (!strncmp(cp, subsys, len)) | 1612 if (!strncmp(cp, subsys, len)) { 1613 freeenv(cp); |
1584 return(1); | 1614 return(1); |
1615 } |
|
1585 cp += len; 1586 } | 1616 cp += len; 1617 } |
1618 freeenv(cp); |
|
1587 return(0); 1588} 1589 1590/* 1591 * Control interface. 1592 * 1593 * We multiplex ioctls for all participating ACPI devices here. Individual 1594 * drivers wanting to be accessible via /dev/acpi should use the register/deregister --- 275 unchanged lines hidden (view full) --- 1870 } 1871 cp = ep; 1872 } 1873} 1874 1875static void 1876acpi_set_debugging(void *junk) 1877{ | 1619 return(0); 1620} 1621 1622/* 1623 * Control interface. 1624 * 1625 * We multiplex ioctls for all participating ACPI devices here. Individual 1626 * drivers wanting to be accessible via /dev/acpi should use the register/deregister --- 275 unchanged lines hidden (view full) --- 1902 } 1903 cp = ep; 1904 } 1905} 1906 1907static void 1908acpi_set_debugging(void *junk) 1909{ |
1878 char *cp; | |
1879 1880 AcpiDbgLayer = 0; 1881 AcpiDbgLevel = 0; | 1910 1911 AcpiDbgLayer = 0; 1912 AcpiDbgLevel = 0; |
1882 if ((cp = getenv("debug.acpi.layer")) != NULL) | 1913 if (testenv("debug.acpi.layer")) |
1883 acpi_parse_debug(cp, &dbg_layer[0], &AcpiDbgLayer); | 1914 acpi_parse_debug(cp, &dbg_layer[0], &AcpiDbgLayer); |
1884 if ((cp = getenv("debug.acpi.level")) != NULL) | 1915 if (testenv("debug.acpi.level")) |
1885 acpi_parse_debug(cp, &dbg_level[0], &AcpiDbgLevel); 1886 1887 printf("ACPI debug layer 0x%x debug level 0x%x\n", AcpiDbgLayer, AcpiDbgLevel); 1888} 1889SYSINIT(acpi_debugging, SI_SUB_TUNABLES, SI_ORDER_ANY, acpi_set_debugging, NULL); 1890#endif 1891 1892static int --- 56 unchanged lines hidden --- | 1916 acpi_parse_debug(cp, &dbg_level[0], &AcpiDbgLevel); 1917 1918 printf("ACPI debug layer 0x%x debug level 0x%x\n", AcpiDbgLayer, AcpiDbgLevel); 1919} 1920SYSINIT(acpi_debugging, SI_SUB_TUNABLES, SI_ORDER_ANY, acpi_set_debugging, NULL); 1921#endif 1922 1923static int --- 56 unchanged lines hidden --- |