2009-01-25 05:26:30 +03:00
|
|
|
/* $NetBSD: acpi_quirks.c,v 1.10 2009/01/25 02:26:30 christos Exp $ */
|
2003-05-16 01:29:49 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 2002 Wasabi Systems, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Written by Frank van der Linden for Wasabi Systems, Inc.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed for the NetBSD Project by
|
|
|
|
* Wasabi Systems, Inc.
|
|
|
|
* 4. The name of Wasabi Systems, Inc. may not be used to endorse
|
|
|
|
* or promote products derived from this software without specific prior
|
|
|
|
* written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
|
2009-01-25 05:26:30 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: acpi_quirks.c,v 1.10 2009/01/25 02:26:30 christos Exp $");
|
2003-05-16 01:29:49 +04:00
|
|
|
|
|
|
|
#include "opt_acpi.h"
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
|
|
|
|
#include <dev/acpi/acpica.h>
|
|
|
|
#include <dev/acpi/acpireg.h>
|
|
|
|
#include <dev/acpi/acpivar.h>
|
|
|
|
|
2006-07-04 04:30:21 +04:00
|
|
|
static int acpi_rev_cmp(uint32_t, uint32_t, int);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX add more
|
|
|
|
*/
|
2004-04-10 15:48:10 +04:00
|
|
|
static struct acpi_quirk acpi_quirks[] = {
|
2007-12-09 23:27:42 +03:00
|
|
|
{ ACPI_SIG_FADT, "PTLTD ", 0x06040000, AQ_LTE, " FACP ",
|
2006-07-04 04:30:21 +04:00
|
|
|
ACPI_QUIRK_BROKEN },
|
2007-12-09 23:27:42 +03:00
|
|
|
{ ACPI_SIG_FADT, "NVIDIA", 0x06040000, AQ_EQ, "CK8 ",
|
2006-09-23 21:04:26 +04:00
|
|
|
ACPI_QUIRK_IRQ0 },
|
2009-01-25 05:26:30 +03:00
|
|
|
{ ACPI_SIG_FADT, "HP ", 0x06040012, AQ_LTE, "HWPC20F ",
|
|
|
|
ACPI_QUIRK_BROKEN },
|
2003-05-16 01:29:49 +04:00
|
|
|
};
|
|
|
|
|
2006-07-04 04:30:21 +04:00
|
|
|
static int
|
|
|
|
acpi_rev_cmp(uint32_t tabval, uint32_t wanted, int op)
|
|
|
|
{
|
|
|
|
switch (op) {
|
|
|
|
case AQ_GT:
|
|
|
|
if (tabval > wanted)
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return 1;
|
|
|
|
case AQ_LT:
|
|
|
|
if (tabval < wanted)
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return 1;
|
|
|
|
case AQ_LTE:
|
|
|
|
if (tabval <= wanted)
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return 1;
|
|
|
|
case AQ_GTE:
|
|
|
|
if (tabval >= wanted)
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return 1;
|
|
|
|
case AQ_EQ:
|
|
|
|
if (tabval == wanted)
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2003-05-16 01:29:49 +04:00
|
|
|
/*
|
|
|
|
* Simple function to search the quirk table. Only to be used after
|
|
|
|
* AcpiLoadTables has been successfully called.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
acpi_find_quirks(void)
|
|
|
|
{
|
|
|
|
int i, nquirks;
|
|
|
|
struct acpi_quirk *aqp;
|
2007-12-09 23:27:42 +03:00
|
|
|
ACPI_TABLE_HEADER fadt, dsdt, xsdt, *hdr;
|
2003-05-16 01:29:49 +04:00
|
|
|
|
|
|
|
nquirks = sizeof(acpi_quirks) / sizeof(struct acpi_quirk);
|
|
|
|
|
2007-12-09 23:27:42 +03:00
|
|
|
if (ACPI_FAILURE(AcpiGetTableHeader(ACPI_SIG_FADT, 0, &fadt)))
|
|
|
|
memset(&fadt, 0, sizeof(fadt));
|
|
|
|
if (ACPI_FAILURE(AcpiGetTableHeader(ACPI_SIG_DSDT, 0, &dsdt)))
|
|
|
|
memset(&dsdt, 0, sizeof(dsdt));
|
|
|
|
if (ACPI_FAILURE(AcpiGetTableHeader(ACPI_SIG_XSDT, 0, &xsdt)))
|
|
|
|
memset(&xsdt, 0, sizeof(xsdt));
|
|
|
|
|
2003-05-16 01:29:49 +04:00
|
|
|
for (i = 0; i < nquirks; i++) {
|
|
|
|
aqp = &acpi_quirks[i];
|
2007-12-09 23:27:42 +03:00
|
|
|
if (!strncmp(aqp->aq_tabletype, ACPI_SIG_DSDT, 4))
|
|
|
|
hdr = &dsdt;
|
|
|
|
else if (!strncmp(aqp->aq_tabletype, ACPI_SIG_XSDT, 4))
|
|
|
|
hdr = &xsdt;
|
|
|
|
else if (!strncmp(aqp->aq_tabletype, ACPI_SIG_FADT, 4))
|
|
|
|
hdr = &fadt;
|
|
|
|
else
|
2006-07-04 04:30:21 +04:00
|
|
|
continue;
|
|
|
|
if (strncmp(aqp->aq_oemid, hdr->OemId, strlen(aqp->aq_oemid)))
|
|
|
|
continue;
|
|
|
|
if (acpi_rev_cmp(aqp->aq_oemrev, hdr->OemRevision,
|
|
|
|
aqp->aq_cmpop))
|
|
|
|
continue;
|
|
|
|
if (strncmp(aqp->aq_tabid, hdr->OemTableId,
|
|
|
|
strlen(aqp->aq_tabid)))
|
|
|
|
continue;
|
|
|
|
return aqp->aq_quirks;
|
2003-05-16 01:29:49 +04:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|