1 /****************************************************************************** 2 * 3 * Module Name: dttable.c - handling for specific ACPI tables 4 * 5 *****************************************************************************/ 6 7 /* 8 * Copyright (C) 2000 - 2016, Intel Corp. 9 * All rights reserved. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions, and the following disclaimer, 16 * without modification. 17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18 * substantially similar to the "NO WARRANTY" disclaimer below 19 * ("Disclaimer") and any redistribution must be conditioned upon 20 * including a substantially similar Disclaimer requirement for further 21 * binary redistribution. 22 * 3. Neither the names of the above-listed copyright holders nor the names 23 * of any contributors may be used to endorse or promote products derived 24 * from this software without specific prior written permission. 25 * 26 * Alternatively, this software may be distributed under the terms of the 27 * GNU General Public License ("GPL") version 2 as published by the Free 28 * Software Foundation. 29 * 30 * NO WARRANTY 31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41 * POSSIBILITY OF SUCH DAMAGES. 42 */ 43 44 /* Compile routines for the basic ACPI tables */ 45 46 #include <contrib/dev/acpica/compiler/aslcompiler.h> 47 #include <contrib/dev/acpica/compiler/dtcompiler.h> 48 49 #define _COMPONENT DT_COMPILER 50 ACPI_MODULE_NAME ("dttable") 51 52 53 /****************************************************************************** 54 * 55 * FUNCTION: DtCompileRsdp 56 * 57 * PARAMETERS: PFieldList - Current field list pointer 58 * 59 * RETURN: Status 60 * 61 * DESCRIPTION: Compile RSDP. 62 * 63 *****************************************************************************/ 64 65 ACPI_STATUS 66 DtCompileRsdp ( 67 DT_FIELD **PFieldList) 68 { 69 DT_SUBTABLE *Subtable; 70 ACPI_TABLE_RSDP *Rsdp; 71 ACPI_RSDP_EXTENSION *RsdpExtension; 72 ACPI_STATUS Status; 73 74 75 /* Compile the "common" RSDP (ACPI 1.0) */ 76 77 Status = DtCompileTable (PFieldList, AcpiDmTableInfoRsdp1, 78 &Gbl_RootTable, TRUE); 79 if (ACPI_FAILURE (Status)) 80 { 81 return (Status); 82 } 83 84 Rsdp = ACPI_CAST_PTR (ACPI_TABLE_RSDP, Gbl_RootTable->Buffer); 85 DtSetTableChecksum (&Rsdp->Checksum); 86 87 if (Rsdp->Revision > 0) 88 { 89 /* Compile the "extended" part of the RSDP as a subtable */ 90 91 Status = DtCompileTable (PFieldList, AcpiDmTableInfoRsdp2, 92 &Subtable, TRUE); 93 if (ACPI_FAILURE (Status)) 94 { 95 return (Status); 96 } 97 98 DtInsertSubtable (Gbl_RootTable, Subtable); 99 100 /* Set length and extended checksum for entire RSDP */ 101 102 RsdpExtension = ACPI_CAST_PTR (ACPI_RSDP_EXTENSION, Subtable->Buffer); 103 RsdpExtension->Length = Gbl_RootTable->Length + Subtable->Length; 104 DtSetTableChecksum (&RsdpExtension->ExtendedChecksum); 105 } 106 107 return (AE_OK); 108 } 109 110 111 /****************************************************************************** 112 * 113 * FUNCTION: DtCompileFadt 114 * 115 * PARAMETERS: List - Current field list pointer 116 * 117 * RETURN: Status 118 * 119 * DESCRIPTION: Compile FADT. 120 * 121 *****************************************************************************/ 122 123 ACPI_STATUS 124 DtCompileFadt ( 125 void **List) 126 { 127 ACPI_STATUS Status; 128 DT_SUBTABLE *Subtable; 129 DT_SUBTABLE *ParentTable; 130 DT_FIELD **PFieldList = (DT_FIELD **) List; 131 ACPI_TABLE_HEADER *Table; 132 UINT8 Revision; 133 134 135 Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt1, 136 &Subtable, TRUE); 137 if (ACPI_FAILURE (Status)) 138 { 139 return (Status); 140 } 141 142 ParentTable = DtPeekSubtable (); 143 DtInsertSubtable (ParentTable, Subtable); 144 145 Table = ACPI_CAST_PTR (ACPI_TABLE_HEADER, ParentTable->Buffer); 146 Revision = Table->Revision; 147 148 if (Revision == 2) 149 { 150 Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt2, 151 &Subtable, TRUE); 152 if (ACPI_FAILURE (Status)) 153 { 154 return (Status); 155 } 156 157 DtInsertSubtable (ParentTable, Subtable); 158 } 159 else if (Revision >= 2) 160 { 161 Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt3, 162 &Subtable, TRUE); 163 if (ACPI_FAILURE (Status)) 164 { 165 return (Status); 166 } 167 168 DtInsertSubtable (ParentTable, Subtable); 169 170 if (Revision >= 5) 171 { 172 Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt5, 173 &Subtable, TRUE); 174 if (ACPI_FAILURE (Status)) 175 { 176 return (Status); 177 } 178 179 DtInsertSubtable (ParentTable, Subtable); 180 } 181 182 if (Revision >= 6) 183 { 184 Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt6, 185 &Subtable, TRUE); 186 if (ACPI_FAILURE (Status)) 187 { 188 return (Status); 189 } 190 191 DtInsertSubtable (ParentTable, Subtable); 192 } 193 } 194 195 return (AE_OK); 196 } 197 198 199 /****************************************************************************** 200 * 201 * FUNCTION: DtCompileFacs 202 * 203 * PARAMETERS: PFieldList - Current field list pointer 204 * 205 * RETURN: Status 206 * 207 * DESCRIPTION: Compile FACS. 208 * 209 *****************************************************************************/ 210 211 ACPI_STATUS 212 DtCompileFacs ( 213 DT_FIELD **PFieldList) 214 { 215 DT_SUBTABLE *Subtable; 216 UINT8 *ReservedBuffer; 217 ACPI_STATUS Status; 218 UINT32 ReservedSize; 219 220 221 Status = DtCompileTable (PFieldList, AcpiDmTableInfoFacs, 222 &Gbl_RootTable, TRUE); 223 if (ACPI_FAILURE (Status)) 224 { 225 return (Status); 226 } 227 228 /* Large FACS reserved area at the end of the table */ 229 230 ReservedSize = (UINT32) sizeof (((ACPI_TABLE_FACS *) NULL)->Reserved1); 231 ReservedBuffer = UtLocalCalloc (ReservedSize); 232 233 DtCreateSubtable (ReservedBuffer, ReservedSize, &Subtable); 234 235 ACPI_FREE (ReservedBuffer); 236 DtInsertSubtable (Gbl_RootTable, Subtable); 237 return (AE_OK); 238 } 239