acpi_powerres.c (131366) | acpi_powerres.c (133622) |
---|---|
1/*- 2 * Copyright (c) 2001 Michael Smith 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2001 Michael Smith 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/dev/acpica/acpi_powerres.c 131366 2004-06-30 20:31:13Z njl $"); | 28__FBSDID("$FreeBSD: head/sys/dev/acpica/acpi_powerres.c 133622 2004-08-13 06:22:10Z njl $"); |
29 30#include "opt_acpi.h" 31#include <sys/param.h> 32#include <sys/kernel.h> 33#include <sys/malloc.h> 34#include <sys/bus.h> 35 36#include "acpi.h" --- 9 unchanged lines hidden (view full) --- 46 * 47 * Note that this only manages resources for known devices. There is an 48 * ugly case where we may turn of power to a device which is in use because 49 * we don't know that it depends on a given resource. We should perhaps 50 * try to be smarter about this, but a more complete solution would involve 51 * scanning all of the ACPI namespace to find devices we're not currently 52 * aware of, and this raises questions about whether they should be left 53 * on, turned off, etc. | 29 30#include "opt_acpi.h" 31#include <sys/param.h> 32#include <sys/kernel.h> 33#include <sys/malloc.h> 34#include <sys/bus.h> 35 36#include "acpi.h" --- 9 unchanged lines hidden (view full) --- 46 * 47 * Note that this only manages resources for known devices. There is an 48 * ugly case where we may turn of power to a device which is in use because 49 * we don't know that it depends on a given resource. We should perhaps 50 * try to be smarter about this, but a more complete solution would involve 51 * scanning all of the ACPI namespace to find devices we're not currently 52 * aware of, and this raises questions about whether they should be left 53 * on, turned off, etc. |
54 * 55 * XXX locking | |
56 */ 57 58MALLOC_DEFINE(M_ACPIPWR, "acpipwr", "ACPI power resources"); 59 60/* Hooks for the ACPI CA debugging infrastructure */ 61#define _COMPONENT ACPI_POWERRES 62ACPI_MODULE_NAME("POWERRES") 63 --- 26 unchanged lines hidden (view full) --- 90 ACPI_INTEGER ap_systemlevel; 91 ACPI_INTEGER ap_order; 92}; 93 94static TAILQ_HEAD(acpi_powerresource_list, acpi_powerresource) 95 acpi_powerresources; 96static TAILQ_HEAD(acpi_powerconsumer_list, acpi_powerconsumer) 97 acpi_powerconsumers; | 54 */ 55 56MALLOC_DEFINE(M_ACPIPWR, "acpipwr", "ACPI power resources"); 57 58/* Hooks for the ACPI CA debugging infrastructure */ 59#define _COMPONENT ACPI_POWERRES 60ACPI_MODULE_NAME("POWERRES") 61 --- 26 unchanged lines hidden (view full) --- 88 ACPI_INTEGER ap_systemlevel; 89 ACPI_INTEGER ap_order; 90}; 91 92static TAILQ_HEAD(acpi_powerresource_list, acpi_powerresource) 93 acpi_powerresources; 94static TAILQ_HEAD(acpi_powerconsumer_list, acpi_powerconsumer) 95 acpi_powerconsumers; |
96ACPI_SERIAL_DECL(powerres, "ACPI power resources"); |
|
98 99static ACPI_STATUS acpi_pwr_register_consumer(ACPI_HANDLE consumer); 100#ifdef notyet 101static ACPI_STATUS acpi_pwr_deregister_consumer(ACPI_HANDLE consumer); 102#endif /* notyet */ 103static ACPI_STATUS acpi_pwr_register_resource(ACPI_HANDLE res); 104#ifdef notyet 105static ACPI_STATUS acpi_pwr_deregister_resource(ACPI_HANDLE res); --- 26 unchanged lines hidden (view full) --- 132acpi_pwr_register_resource(ACPI_HANDLE res) 133{ 134 ACPI_STATUS status; 135 ACPI_BUFFER buf; 136 ACPI_OBJECT *obj; 137 struct acpi_powerresource *rp, *srp; 138 139 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); | 97 98static ACPI_STATUS acpi_pwr_register_consumer(ACPI_HANDLE consumer); 99#ifdef notyet 100static ACPI_STATUS acpi_pwr_deregister_consumer(ACPI_HANDLE consumer); 101#endif /* notyet */ 102static ACPI_STATUS acpi_pwr_register_resource(ACPI_HANDLE res); 103#ifdef notyet 104static ACPI_STATUS acpi_pwr_deregister_resource(ACPI_HANDLE res); --- 26 unchanged lines hidden (view full) --- 131acpi_pwr_register_resource(ACPI_HANDLE res) 132{ 133 ACPI_STATUS status; 134 ACPI_BUFFER buf; 135 ACPI_OBJECT *obj; 136 struct acpi_powerresource *rp, *srp; 137 138 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); |
139 ACPI_SERIAL_ASSERT(powerres); |
|
140 141 rp = NULL; 142 buf.Pointer = NULL; 143 144 /* Look to see if we know about this resource */ 145 if (acpi_pwr_find_resource(res) != NULL) 146 return_ACPI_STATUS (AE_OK); /* already know about it */ 147 --- 54 unchanged lines hidden (view full) --- 202 * Deregister a power resource. 203 */ 204static ACPI_STATUS 205acpi_pwr_deregister_resource(ACPI_HANDLE res) 206{ 207 struct acpi_powerresource *rp; 208 209 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); | 140 141 rp = NULL; 142 buf.Pointer = NULL; 143 144 /* Look to see if we know about this resource */ 145 if (acpi_pwr_find_resource(res) != NULL) 146 return_ACPI_STATUS (AE_OK); /* already know about it */ 147 --- 54 unchanged lines hidden (view full) --- 202 * Deregister a power resource. 203 */ 204static ACPI_STATUS 205acpi_pwr_deregister_resource(ACPI_HANDLE res) 206{ 207 struct acpi_powerresource *rp; 208 209 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); |
210 ACPI_SERIAL_ASSERT(powerres); |
|
210 211 rp = NULL; 212 213 /* Find the resource */ 214 if ((rp = acpi_pwr_find_resource(res)) == NULL) 215 return_ACPI_STATUS (AE_BAD_PARAMETER); 216 217 /* Check that there are no consumers referencing this resource */ --- 17 unchanged lines hidden (view full) --- 235 * It's OK to call this if we already know about the consumer. 236 */ 237static ACPI_STATUS 238acpi_pwr_register_consumer(ACPI_HANDLE consumer) 239{ 240 struct acpi_powerconsumer *pc; 241 242 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); | 211 212 rp = NULL; 213 214 /* Find the resource */ 215 if ((rp = acpi_pwr_find_resource(res)) == NULL) 216 return_ACPI_STATUS (AE_BAD_PARAMETER); 217 218 /* Check that there are no consumers referencing this resource */ --- 17 unchanged lines hidden (view full) --- 236 * It's OK to call this if we already know about the consumer. 237 */ 238static ACPI_STATUS 239acpi_pwr_register_consumer(ACPI_HANDLE consumer) 240{ 241 struct acpi_powerconsumer *pc; 242 243 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); |
244 ACPI_SERIAL_ASSERT(powerres); |
|
243 244 /* Check to see whether we know about this consumer already */ 245 if ((pc = acpi_pwr_find_consumer(consumer)) != NULL) 246 return_ACPI_STATUS (AE_OK); 247 248 /* Allocate a new power consumer */ 249 if ((pc = malloc(sizeof(*pc), M_ACPIPWR, M_NOWAIT)) == NULL) 250 return_ACPI_STATUS (AE_NO_MEMORY); --- 18 unchanged lines hidden (view full) --- 269 * (XXX is this correct? Check once implemented) 270 */ 271static ACPI_STATUS 272acpi_pwr_deregister_consumer(ACPI_HANDLE consumer) 273{ 274 struct acpi_powerconsumer *pc; 275 276 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); | 245 246 /* Check to see whether we know about this consumer already */ 247 if ((pc = acpi_pwr_find_consumer(consumer)) != NULL) 248 return_ACPI_STATUS (AE_OK); 249 250 /* Allocate a new power consumer */ 251 if ((pc = malloc(sizeof(*pc), M_ACPIPWR, M_NOWAIT)) == NULL) 252 return_ACPI_STATUS (AE_NO_MEMORY); --- 18 unchanged lines hidden (view full) --- 271 * (XXX is this correct? Check once implemented) 272 */ 273static ACPI_STATUS 274acpi_pwr_deregister_consumer(ACPI_HANDLE consumer) 275{ 276 struct acpi_powerconsumer *pc; 277 278 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); |
279 ACPI_SERIAL_ASSERT(powerres); |
|
277 278 /* Find the consumer */ 279 if ((pc = acpi_pwr_find_consumer(consumer)) == NULL) 280 return_ACPI_STATUS (AE_BAD_PARAMETER); 281 282 /* Make sure the consumer's not referencing anything right now */ 283 if (TAILQ_FIRST(&pc->ac_references) != NULL) 284 return_ACPI_STATUS (AE_BAD_PARAMETER); 285 286 /* Pull the consumer off the list and free it */ 287 TAILQ_REMOVE(&acpi_powerconsumers, pc, ac_link); | 280 281 /* Find the consumer */ 282 if ((pc = acpi_pwr_find_consumer(consumer)) == NULL) 283 return_ACPI_STATUS (AE_BAD_PARAMETER); 284 285 /* Make sure the consumer's not referencing anything right now */ 286 if (TAILQ_FIRST(&pc->ac_references) != NULL) 287 return_ACPI_STATUS (AE_BAD_PARAMETER); 288 289 /* Pull the consumer off the list and free it */ 290 TAILQ_REMOVE(&acpi_powerconsumers, pc, ac_link); |
291 free(pc, M_ACPIPWR); |
|
288 289 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "deregistered power consumer %s\n", 290 acpi_name(consumer))); 291 292 return_ACPI_STATUS (AE_OK); 293} 294#endif /* notyet */ 295 --- 11 unchanged lines hidden (view full) --- 307 char *method_name, *reslist_name; 308 int res_changed; 309 310 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); 311 312 /* It's never ok to switch a non-existent consumer. */ 313 if (consumer == NULL) 314 return_ACPI_STATUS (AE_NOT_FOUND); | 292 293 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "deregistered power consumer %s\n", 294 acpi_name(consumer))); 295 296 return_ACPI_STATUS (AE_OK); 297} 298#endif /* notyet */ 299 --- 11 unchanged lines hidden (view full) --- 311 char *method_name, *reslist_name; 312 int res_changed; 313 314 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); 315 316 /* It's never ok to switch a non-existent consumer. */ 317 if (consumer == NULL) 318 return_ACPI_STATUS (AE_NOT_FOUND); |
319 reslist_buffer.Pointer = NULL; 320 reslist_object = NULL; 321 ACPI_SERIAL_BEGIN(powerres); |
|
315 316 /* Find the consumer */ 317 if ((pc = acpi_pwr_find_consumer(consumer)) == NULL) { 318 if (ACPI_FAILURE(status = acpi_pwr_register_consumer(consumer))) | 322 323 /* Find the consumer */ 324 if ((pc = acpi_pwr_find_consumer(consumer)) == NULL) { 325 if (ACPI_FAILURE(status = acpi_pwr_register_consumer(consumer))) |
319 return_ACPI_STATUS (status); 320 if ((pc = acpi_pwr_find_consumer(consumer)) == NULL) { 321 return_ACPI_STATUS (AE_ERROR); /* something very wrong */ 322 } | 326 goto out; 327 if ((pc = acpi_pwr_find_consumer(consumer)) == NULL) 328 panic("acpi added power consumer but can't find it"); |
323 } 324 | 329 } 330 |
325 /* Check for valid transitions */ | 331 /* Check for valid transitions. We can only go to D0 from D3. */ 332 status = AE_BAD_PARAMETER; |
326 if (pc->ac_state == ACPI_STATE_D3 && state != ACPI_STATE_D0) | 333 if (pc->ac_state == ACPI_STATE_D3 && state != ACPI_STATE_D0) |
327 return_ACPI_STATUS (AE_BAD_PARAMETER); /* can only go to D0 from D3 */ | 334 goto out; |
328 329 /* Find transition mechanism(s) */ 330 switch (state) { 331 case ACPI_STATE_D0: 332 method_name = "_PS0"; 333 reslist_name = "_PR0"; 334 break; 335 case ACPI_STATE_D1: --- 4 unchanged lines hidden (view full) --- 340 method_name = "_PS2"; 341 reslist_name = "_PR2"; 342 break; 343 case ACPI_STATE_D3: 344 method_name = "_PS3"; 345 reslist_name = "_PR3"; 346 break; 347 default: | 335 336 /* Find transition mechanism(s) */ 337 switch (state) { 338 case ACPI_STATE_D0: 339 method_name = "_PS0"; 340 reslist_name = "_PR0"; 341 break; 342 case ACPI_STATE_D1: --- 4 unchanged lines hidden (view full) --- 347 method_name = "_PS2"; 348 reslist_name = "_PR2"; 349 break; 350 case ACPI_STATE_D3: 351 method_name = "_PS3"; 352 reslist_name = "_PR3"; 353 break; 354 default: |
348 return_ACPI_STATUS (AE_BAD_PARAMETER); | 355 goto out; |
349 } 350 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "setup to switch %s D%d -> D%d\n", 351 acpi_name(consumer), pc->ac_state, state)); 352 353 /* 354 * Verify that this state is supported, ie. one of method or 355 * reslist must be present. We need to do this before we go 356 * dereferencing resources (since we might be trying to go to 357 * a state we don't support). 358 * 359 * Note that if any states are supported, the device has to 360 * support D0 and D3. It's never an error to try to go to 361 * D0. 362 */ | 356 } 357 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "setup to switch %s D%d -> D%d\n", 358 acpi_name(consumer), pc->ac_state, state)); 359 360 /* 361 * Verify that this state is supported, ie. one of method or 362 * reslist must be present. We need to do this before we go 363 * dereferencing resources (since we might be trying to go to 364 * a state we don't support). 365 * 366 * Note that if any states are supported, the device has to 367 * support D0 and D3. It's never an error to try to go to 368 * D0. 369 */ |
363 status = AE_BAD_PARAMETER; 364 reslist_buffer.Pointer = NULL; 365 reslist_object = NULL; | |
366 if (ACPI_FAILURE(AcpiGetHandle(consumer, method_name, &method_handle))) 367 method_handle = NULL; 368 if (ACPI_FAILURE(AcpiGetHandle(consumer, reslist_name, &reslist_handle))) 369 reslist_handle = NULL; 370 if (reslist_handle == NULL && method_handle == NULL) { 371 if (state == ACPI_STATE_D0) { 372 pc->ac_state = ACPI_STATE_D0; | 370 if (ACPI_FAILURE(AcpiGetHandle(consumer, method_name, &method_handle))) 371 method_handle = NULL; 372 if (ACPI_FAILURE(AcpiGetHandle(consumer, reslist_name, &reslist_handle))) 373 reslist_handle = NULL; 374 if (reslist_handle == NULL && method_handle == NULL) { 375 if (state == ACPI_STATE_D0) { 376 pc->ac_state = ACPI_STATE_D0; |
373 return_ACPI_STATUS (AE_OK); | 377 status = AE_OK; 378 goto out; |
374 } | 379 } |
375 if (state != ACPI_STATE_D3) 376 goto bad; | 380 if (state != ACPI_STATE_D3) { 381 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, 382 "attempt to set unsupported state D%d\n", state)); 383 goto out; 384 } |
377 378 /* 379 * Turn off the resources listed in _PR0 to go to D3. If there is 380 * no _PR0 method, this object doesn't support ACPI power states. 381 */ 382 if (ACPI_FAILURE(AcpiGetHandle(consumer, "_PR0", &pr0_handle))) { 383 status = AE_NOT_FOUND; | 385 386 /* 387 * Turn off the resources listed in _PR0 to go to D3. If there is 388 * no _PR0 method, this object doesn't support ACPI power states. 389 */ 390 if (ACPI_FAILURE(AcpiGetHandle(consumer, "_PR0", &pr0_handle))) { 391 status = AE_NOT_FOUND; |
384 goto bad; | 392 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, 393 "device missing _PR0 (desired state was D%d)\n", state)); 394 goto out; |
385 } 386 reslist_buffer.Length = ACPI_ALLOCATE_BUFFER; 387 status = AcpiEvaluateObject(pr0_handle, NULL, NULL, &reslist_buffer); | 395 } 396 reslist_buffer.Length = ACPI_ALLOCATE_BUFFER; 397 status = AcpiEvaluateObject(pr0_handle, NULL, NULL, &reslist_buffer); |
388 if (ACPI_FAILURE(status)) 389 goto bad; | 398 if (ACPI_FAILURE(status)) { 399 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, 400 "can't evaluate _PR0 for device %s, state D%d\n", 401 acpi_name(consumer), state)); 402 goto out; 403 } |
390 reslist_object = (ACPI_OBJECT *)reslist_buffer.Pointer; | 404 reslist_object = (ACPI_OBJECT *)reslist_buffer.Pointer; |
391 if (reslist_object->Type != ACPI_TYPE_PACKAGE || 392 reslist_object->Package.Count == 0) 393 goto bad; | 405 if (!ACPI_PKG_VALID(reslist_object, 1)) { 406 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, 407 "invalid package object for state D%d\n", state)); 408 status = AE_TYPE; 409 goto out; 410 } |
394 AcpiOsFree(reslist_buffer.Pointer); 395 reslist_buffer.Pointer = NULL; 396 reslist_object = NULL; 397 } 398 399 /* 400 * Check that we can actually fetch the list of power resources 401 */ --- 62 unchanged lines hidden (view full) --- 464 465 /* XXX Should we return to previous state? */ 466 goto out; 467 } 468 } 469 470 /* Transition was successful */ 471 pc->ac_state = state; | 411 AcpiOsFree(reslist_buffer.Pointer); 412 reslist_buffer.Pointer = NULL; 413 reslist_object = NULL; 414 } 415 416 /* 417 * Check that we can actually fetch the list of power resources 418 */ --- 62 unchanged lines hidden (view full) --- 481 482 /* XXX Should we return to previous state? */ 483 goto out; 484 } 485 } 486 487 /* Transition was successful */ 488 pc->ac_state = state; |
472 return_ACPI_STATUS (AE_OK); | 489 status = AE_OK; |
473 | 490 |
474 bad: 475 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, 476 "attempt to set unsupported state D%d\n", state)); 477 478 out: | 491out: 492 ACPI_SERIAL_END(powerres); |
479 if (reslist_buffer.Pointer != NULL) 480 AcpiOsFree(reslist_buffer.Pointer); 481 return_ACPI_STATUS (status); 482} 483 484/* Enable or disable a power resource for wake */ 485ACPI_STATUS 486acpi_pwr_wake_enable(ACPI_HANDLE consumer, int enable) 487{ 488 ACPI_STATUS status; 489 struct acpi_powerconsumer *pc; 490 struct acpi_prw_data prw; 491 int i; 492 493 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); 494 495 if (consumer == NULL) 496 return (AE_BAD_PARAMETER); 497 | 493 if (reslist_buffer.Pointer != NULL) 494 AcpiOsFree(reslist_buffer.Pointer); 495 return_ACPI_STATUS (status); 496} 497 498/* Enable or disable a power resource for wake */ 499ACPI_STATUS 500acpi_pwr_wake_enable(ACPI_HANDLE consumer, int enable) 501{ 502 ACPI_STATUS status; 503 struct acpi_powerconsumer *pc; 504 struct acpi_prw_data prw; 505 int i; 506 507 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); 508 509 if (consumer == NULL) 510 return (AE_BAD_PARAMETER); 511 |
512 ACPI_SERIAL_BEGIN(powerres); |
|
498 if ((pc = acpi_pwr_find_consumer(consumer)) == NULL) { 499 if (ACPI_FAILURE(status = acpi_pwr_register_consumer(consumer))) | 513 if ((pc = acpi_pwr_find_consumer(consumer)) == NULL) { 514 if (ACPI_FAILURE(status = acpi_pwr_register_consumer(consumer))) |
500 return_ACPI_STATUS (status); 501 if ((pc = acpi_pwr_find_consumer(consumer)) == NULL) { 502 return_ACPI_STATUS (AE_ERROR); /* something very wrong */ 503 } | 515 goto out; 516 if ((pc = acpi_pwr_find_consumer(consumer)) == NULL) 517 panic("acpi wake added power consumer but can't find it"); |
504 } 505 | 518 } 519 |
520 status = AE_OK; |
|
506 if (acpi_parse_prw(consumer, &prw) != 0) | 521 if (acpi_parse_prw(consumer, &prw) != 0) |
507 return (AE_OK); | 522 goto out; |
508 for (i = 0; i < prw.power_res_count; i++) 509 if (enable) 510 acpi_pwr_reference_resource(&prw.power_res[i], pc); 511 else 512 acpi_pwr_dereference_resource(pc); 513 514 if (prw.power_res_count > 0) 515 acpi_pwr_switch_power(); 516 | 523 for (i = 0; i < prw.power_res_count; i++) 524 if (enable) 525 acpi_pwr_reference_resource(&prw.power_res[i], pc); 526 else 527 acpi_pwr_dereference_resource(pc); 528 529 if (prw.power_res_count > 0) 530 acpi_pwr_switch_power(); 531 |
517 return (AE_OK); | 532out: 533 ACPI_SERIAL_END(powerres); 534 return (status); |
518} 519 520/* 521 * Called to create a reference between a power consumer and a power resource 522 * identified in the object. 523 */ 524static void 525acpi_pwr_reference_resource(ACPI_OBJECT *obj, void *arg) 526{ 527 struct acpi_powerconsumer *pc = (struct acpi_powerconsumer *)arg; 528 struct acpi_powerreference *pr; 529 struct acpi_powerresource *rp; 530 ACPI_HANDLE res; 531 ACPI_STATUS status; 532 533 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); | 535} 536 537/* 538 * Called to create a reference between a power consumer and a power resource 539 * identified in the object. 540 */ 541static void 542acpi_pwr_reference_resource(ACPI_OBJECT *obj, void *arg) 543{ 544 struct acpi_powerconsumer *pc = (struct acpi_powerconsumer *)arg; 545 struct acpi_powerreference *pr; 546 struct acpi_powerresource *rp; 547 ACPI_HANDLE res; 548 ACPI_STATUS status; 549 550 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); |
551 ACPI_SERIAL_ASSERT(powerres); |
|
534 535 res = acpi_GetReference(NULL, obj); 536 if (res == NULL) { 537 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, 538 "can't create a power reference for object type %d\n", 539 obj->Type)); 540 return_VOID; 541 } --- 28 unchanged lines hidden (view full) --- 570 571static int 572acpi_pwr_dereference_resource(struct acpi_powerconsumer *pc) 573{ 574 struct acpi_powerreference *pr; 575 int changed; 576 577 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); | 552 553 res = acpi_GetReference(NULL, obj); 554 if (res == NULL) { 555 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, 556 "can't create a power reference for object type %d\n", 557 obj->Type)); 558 return_VOID; 559 } --- 28 unchanged lines hidden (view full) --- 588 589static int 590acpi_pwr_dereference_resource(struct acpi_powerconsumer *pc) 591{ 592 struct acpi_powerreference *pr; 593 int changed; 594 595 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); |
596 ACPI_SERIAL_ASSERT(powerres); |
|
578 579 changed = 0; 580 while ((pr = TAILQ_FIRST(&pc->ac_references)) != NULL) { 581 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "removing reference to %s\n", 582 acpi_name(pr->ar_resource->ap_resource))); 583 TAILQ_REMOVE(&pr->ar_resource->ap_references, pr, ar_rlink); 584 TAILQ_REMOVE(&pc->ac_references, pr, ar_clink); 585 free(pr, M_ACPIPWR); --- 12 unchanged lines hidden (view full) --- 598static ACPI_STATUS 599acpi_pwr_switch_power(void) 600{ 601 struct acpi_powerresource *rp; 602 ACPI_STATUS status; 603 int cur; 604 605 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); | 597 598 changed = 0; 599 while ((pr = TAILQ_FIRST(&pc->ac_references)) != NULL) { 600 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "removing reference to %s\n", 601 acpi_name(pr->ar_resource->ap_resource))); 602 TAILQ_REMOVE(&pr->ar_resource->ap_references, pr, ar_rlink); 603 TAILQ_REMOVE(&pc->ac_references, pr, ar_clink); 604 free(pr, M_ACPIPWR); --- 12 unchanged lines hidden (view full) --- 617static ACPI_STATUS 618acpi_pwr_switch_power(void) 619{ 620 struct acpi_powerresource *rp; 621 ACPI_STATUS status; 622 int cur; 623 624 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); |
625 ACPI_SERIAL_ASSERT(powerres); |
|
606 607 /* 608 * Sweep the list forwards turning things on. 609 */ 610 TAILQ_FOREACH(rp, &acpi_powerresources, ap_link) { 611 if (TAILQ_FIRST(&rp->ap_references) == NULL) { 612 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, 613 "%s has no references, not turning on\n", --- 82 unchanged lines hidden (view full) --- 696 * Find a power resource's control structure. 697 */ 698static struct acpi_powerresource * 699acpi_pwr_find_resource(ACPI_HANDLE res) 700{ 701 struct acpi_powerresource *rp; 702 703 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); | 626 627 /* 628 * Sweep the list forwards turning things on. 629 */ 630 TAILQ_FOREACH(rp, &acpi_powerresources, ap_link) { 631 if (TAILQ_FIRST(&rp->ap_references) == NULL) { 632 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, 633 "%s has no references, not turning on\n", --- 82 unchanged lines hidden (view full) --- 716 * Find a power resource's control structure. 717 */ 718static struct acpi_powerresource * 719acpi_pwr_find_resource(ACPI_HANDLE res) 720{ 721 struct acpi_powerresource *rp; 722 723 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); |
724 ACPI_SERIAL_ASSERT(powerres); |
|
704 705 TAILQ_FOREACH(rp, &acpi_powerresources, ap_link) { 706 if (rp->ap_resource == res) 707 break; 708 } 709 710 return_PTR (rp); 711} 712 713/* 714 * Find a power consumer's control structure. 715 */ 716static struct acpi_powerconsumer * 717acpi_pwr_find_consumer(ACPI_HANDLE consumer) 718{ 719 struct acpi_powerconsumer *pc; 720 721 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); | 725 726 TAILQ_FOREACH(rp, &acpi_powerresources, ap_link) { 727 if (rp->ap_resource == res) 728 break; 729 } 730 731 return_PTR (rp); 732} 733 734/* 735 * Find a power consumer's control structure. 736 */ 737static struct acpi_powerconsumer * 738acpi_pwr_find_consumer(ACPI_HANDLE consumer) 739{ 740 struct acpi_powerconsumer *pc; 741 742 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); |
743 ACPI_SERIAL_ASSERT(powerres); |
|
722 723 TAILQ_FOREACH(pc, &acpi_powerconsumers, ac_link) { 724 if (pc->ac_consumer == consumer) 725 break; 726 } 727 728 return_PTR (pc); 729} | 744 745 TAILQ_FOREACH(pc, &acpi_powerconsumers, ac_link) { 746 if (pc->ac_consumer == consumer) 747 break; 748 } 749 750 return_PTR (pc); 751} |