1/*- 2 * Copyright (c) 2004 Nate Lawson (SDG) 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_quirk.c 167814 2007-03-22 18:16:43Z jkim $"); |
29 30#include <sys/param.h> 31#include <sys/bus.h> 32 33#include <contrib/dev/acpica/acpi.h> 34#include <dev/acpica/acpivar.h> 35 36enum ops_t { --- 5 unchanged lines hidden (view full) --- 42 43enum val_t { 44 OEM, 45 OEM_REV, 46 CREATOR, 47 CREATOR_REV, 48}; 49 |
50struct acpi_q_rule { |
51 char sig[ACPI_NAME_SIZE]; /* Table signature to match */ |
52 enum val_t val; 53 union { 54 char *id; 55 enum ops_t op; 56 } x; 57 union { 58 char *tid; 59 int rev; --- 74 unchanged lines hidden (view full) --- 134 return (result); 135} 136 137int 138acpi_table_quirks(int *quirks) 139{ 140 const struct acpi_q_entry *entry; 141 const struct acpi_q_rule *match; |
142 ACPI_TABLE_HEADER fadt, dsdt, xsdt, *hdr; |
143 int done; 144 145 /* First, allow the machdep system to set its idea of quirks. */ 146 KASSERT(quirks != NULL, ("acpi quirks ptr is NULL")); 147 acpi_machdep_quirks(quirks); 148 |
149 if (ACPI_FAILURE(AcpiGetTableHeader(ACPI_SIG_FADT, 0, &fadt))) 150 bzero(&fadt, sizeof(fadt)); 151 if (ACPI_FAILURE(AcpiGetTableHeader(ACPI_SIG_DSDT, 0, &dsdt))) 152 bzero(&fadt, sizeof(dsdt)); 153 if (ACPI_FAILURE(AcpiGetTableHeader(ACPI_SIG_XSDT, 0, &xsdt))) 154 bzero(&fadt, sizeof(xsdt)); 155 |
156 /* Then, override the quirks with any matched from table signatures. */ 157 for (entry = acpi_quirks_table; entry->match; entry++) { 158 done = TRUE; |
159 for (match = entry->match; match->sig[0] != '\0'; match++) { 160 if (!strncmp(match->sig, "FADT", ACPI_NAME_SIZE)) 161 hdr = &fadt; 162 else if (!strncmp(match->sig, ACPI_SIG_DSDT, ACPI_NAME_SIZE)) 163 hdr = &dsdt; 164 else if (!strncmp(match->sig, ACPI_SIG_XSDT, ACPI_NAME_SIZE)) 165 hdr = &xsdt; 166 else |
167 panic("invalid quirk header\n"); |
168 169 /* If we don't match any, skip to the next entry. */ |
170 if (aq_match_header(hdr, match) == FALSE) { |
171 done = FALSE; 172 break; 173 } 174 } 175 176 /* If all entries matched, update the quirks and return. */ 177 if (done) { 178 *quirks = entry->quirks; 179 break; 180 } 181 } 182 183 return (0); 184} |