3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
23 */
24
25 #include <sys/types.h>
26 #include <sys/param.h>
27 #include <sys/cmn_err.h>
28 #include <sys/promif.h>
29 #include <sys/acpi/acpi.h>
30 #include <sys/acpica.h>
31 #include <sys/sunddi.h>
32 #include <sys/ddi.h>
33 #include <sys/ddi_impldefs.h>
34 #include <sys/pci.h>
35 #include <sys/debug.h>
36 #include <sys/psm_common.h>
37 #include <sys/sunndi.h>
38 #include <sys/ksynch.h>
39
40 /* Global configurables */
41
42 char *psm_module_name; /* used to store name of psm module */
43
44 /*
45 * acpi_irq_check_elcr: when set elcr will also be consulted for building
46 * the reserved irq list. When 0 (false), the existing state of the ELCR
47 * is ignored when selecting a vector during IRQ translation, and the ELCR
48 * is programmed to the proper setting for the type of bus (level-triggered
49 * for PCI, edge-triggered for non-PCI). When non-zero (true), vectors
471 rsb.Length = ACPI_ALLOCATE_BUFFER;
472 status = AcpiGetPossibleResources(lnkobj, &rsb);
473 if (status != AE_OK) {
474 cmn_err(CE_WARN, "!psm: set_irq: _PRS failed");
475 return (ACPI_PSM_FAILURE);
476 }
477
478 /*
479 * Find an IRQ resource descriptor to use as template
480 */
481 srsp = NULL;
482 for (resp = rsb.Pointer; resp->Type != ACPI_RESOURCE_TYPE_END_TAG;
483 resp = ACPI_NEXT_RESOURCE(resp)) {
484 if ((resp->Type == ACPI_RESOURCE_TYPE_IRQ) ||
485 (resp->Type == ACPI_RESOURCE_TYPE_EXTENDED_IRQ)) {
486 ACPI_RESOURCE *endtag;
487 /*
488 * Allocate enough room for this resource entry
489 * and one end tag following it
490 */
491 srs_len = resp->Length + sizeof (*endtag);
492 srsp = kmem_zalloc(srs_len, KM_SLEEP);
493 bcopy(resp, srsp, resp->Length);
494 endtag = ACPI_NEXT_RESOURCE(srsp);
495 endtag->Type = ACPI_RESOURCE_TYPE_END_TAG;
496 endtag->Length = 0;
497 break; /* drop out of the loop */
498 }
499 }
500
501 /*
502 * We're done with the PRS values, toss 'em lest we forget
503 */
504 AcpiOsFree(rsb.Pointer);
505
506 if (srsp == NULL)
507 return (ACPI_PSM_FAILURE);
508
509 /*
510 * The Interrupts[] array is always at least one entry
511 * long; see the definition of ACPI_RESOURCE.
512 */
513 switch (srsp->Type) {
514 case ACPI_RESOURCE_TYPE_IRQ:
515 srsp->Data.Irq.InterruptCount = 1;
516 srsp->Data.Irq.Interrupts[0] = (uint8_t)irq;
|
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright 2013 PALO, Richard. All rights reserved.
24 */
25
26 #include <sys/types.h>
27 #include <sys/param.h>
28 #include <sys/cmn_err.h>
29 #include <sys/promif.h>
30 #include <acpica/include/acpi.h>
31 #include <sys/acpica.h>
32 #include <sys/sunddi.h>
33 #include <sys/ddi.h>
34 #include <sys/ddi_impldefs.h>
35 #include <sys/pci.h>
36 #include <sys/debug.h>
37 #include <sys/psm_common.h>
38 #include <sys/sunndi.h>
39 #include <sys/ksynch.h>
40
41 /* Global configurables */
42
43 char *psm_module_name; /* used to store name of psm module */
44
45 /*
46 * acpi_irq_check_elcr: when set elcr will also be consulted for building
47 * the reserved irq list. When 0 (false), the existing state of the ELCR
48 * is ignored when selecting a vector during IRQ translation, and the ELCR
49 * is programmed to the proper setting for the type of bus (level-triggered
50 * for PCI, edge-triggered for non-PCI). When non-zero (true), vectors
472 rsb.Length = ACPI_ALLOCATE_BUFFER;
473 status = AcpiGetPossibleResources(lnkobj, &rsb);
474 if (status != AE_OK) {
475 cmn_err(CE_WARN, "!psm: set_irq: _PRS failed");
476 return (ACPI_PSM_FAILURE);
477 }
478
479 /*
480 * Find an IRQ resource descriptor to use as template
481 */
482 srsp = NULL;
483 for (resp = rsb.Pointer; resp->Type != ACPI_RESOURCE_TYPE_END_TAG;
484 resp = ACPI_NEXT_RESOURCE(resp)) {
485 if ((resp->Type == ACPI_RESOURCE_TYPE_IRQ) ||
486 (resp->Type == ACPI_RESOURCE_TYPE_EXTENDED_IRQ)) {
487 ACPI_RESOURCE *endtag;
488 /*
489 * Allocate enough room for this resource entry
490 * and one end tag following it
491 */
492 srs_len = resp->Length + ACPI_RS_SIZE_NO_DATA;
493 srsp = kmem_zalloc(srs_len, KM_SLEEP);
494 bcopy(resp, srsp, resp->Length);
495 endtag = ACPI_NEXT_RESOURCE(srsp);
496 endtag->Type = ACPI_RESOURCE_TYPE_END_TAG;
497 endtag->Length = ACPI_RS_SIZE_NO_DATA;
498 break; /* drop out of the loop */
499 }
500 }
501
502 /*
503 * We're done with the PRS values, toss 'em lest we forget
504 */
505 AcpiOsFree(rsb.Pointer);
506
507 if (srsp == NULL)
508 return (ACPI_PSM_FAILURE);
509
510 /*
511 * The Interrupts[] array is always at least one entry
512 * long; see the definition of ACPI_RESOURCE.
513 */
514 switch (srsp->Type) {
515 case ACPI_RESOURCE_TYPE_IRQ:
516 srsp->Data.Irq.InterruptCount = 1;
517 srsp->Data.Irq.Interrupts[0] = (uint8_t)irq;
|