1 /****************************************************************************** 2 * 3 * Module Name: dttable.c - handling for specific ACPI tables 4 * 5 *****************************************************************************/ 6 7 /* 8 * Copyright (C) 2000 - 2021, 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 MERCHANTABILITY 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 "aslcompiler.h" 47 48 #define _COMPONENT DT_COMPILER 49 ACPI_MODULE_NAME ("dttable") 50 51 52 /****************************************************************************** 53 * 54 * FUNCTION: DtCompileRsdp 55 * 56 * PARAMETERS: PFieldList - Current field list pointer 57 * 58 * RETURN: Status 59 * 60 * DESCRIPTION: Compile RSDP. 61 * 62 *****************************************************************************/ 63 64 ACPI_STATUS 65 DtCompileRsdp ( 66 DT_FIELD **PFieldList) 67 { 68 DT_SUBTABLE *Subtable; 69 ACPI_TABLE_RSDP *Rsdp; 70 ACPI_RSDP_EXTENSION *RsdpExtension; 71 ACPI_STATUS Status; 72 73 74 /* Compile the "common" RSDP (ACPI 1.0) */ 75 76 Status = DtCompileTable (PFieldList, AcpiDmTableInfoRsdp1, 77 &AslGbl_RootTable); 78 if (ACPI_FAILURE (Status)) 79 { 80 return (Status); 81 } 82 83 Rsdp = ACPI_CAST_PTR (ACPI_TABLE_RSDP, AslGbl_RootTable->Buffer); 84 DtSetTableChecksum (&Rsdp->Checksum); 85 86 if (Rsdp->Revision > 0) 87 { 88 /* Compile the "extended" part of the RSDP as a subtable */ 89 90 Status = DtCompileTable (PFieldList, AcpiDmTableInfoRsdp2, 91 &Subtable); 92 if (ACPI_FAILURE (Status)) 93 { 94 return (Status); 95 } 96 97 DtInsertSubtable (AslGbl_RootTable, Subtable); 98 99 /* Set length and extended checksum for entire RSDP */ 100 101 RsdpExtension = ACPI_CAST_PTR (ACPI_RSDP_EXTENSION, Subtable->Buffer); 102 RsdpExtension->Length = AslGbl_RootTable->Length + Subtable->Length; 103 DtSetTableChecksum (&RsdpExtension->ExtendedChecksum); 104 } 105 106 return (AE_OK); 107 } 108 109 110 /****************************************************************************** 111 * 112 * FUNCTION: DtCompileFadt 113 * 114 * PARAMETERS: List - Current field list pointer 115 * 116 * RETURN: Status 117 * 118 * DESCRIPTION: Compile FADT. 119 * 120 *****************************************************************************/ 121 122 ACPI_STATUS 123 DtCompileFadt ( 124 void **List) 125 { 126 ACPI_STATUS Status; 127 DT_SUBTABLE *Subtable; 128 DT_SUBTABLE *ParentTable; 129 DT_FIELD **PFieldList = (DT_FIELD **) List; 130 ACPI_TABLE_HEADER *Table; 131 UINT8 Revision; 132 133 134 Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt1, 135 &Subtable); 136 if (ACPI_FAILURE (Status)) 137 { 138 return (Status); 139 } 140 141 ParentTable = DtPeekSubtable (); 142 DtInsertSubtable (ParentTable, Subtable); 143 144 Table = ACPI_CAST_PTR (ACPI_TABLE_HEADER, ParentTable->Buffer); 145 Revision = Table->Revision; 146 147 if (Revision == 2) 148 { 149 Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt2, 150 &Subtable); 151 if (ACPI_FAILURE (Status)) 152 { 153 return (Status); 154 } 155 156 DtInsertSubtable (ParentTable, Subtable); 157 } 158 else if (Revision >= 2) 159 { 160 Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt3, 161 &Subtable); 162 if (ACPI_FAILURE (Status)) 163 { 164 return (Status); 165 } 166 167 DtInsertSubtable (ParentTable, Subtable); 168 169 if (Revision >= 5) 170 { 171 Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt5, 172 &Subtable); 173 if (ACPI_FAILURE (Status)) 174 { 175 return (Status); 176 } 177 178 DtInsertSubtable (ParentTable, Subtable); 179 } 180 181 if (Revision >= 6) 182 { 183 Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt6, 184 &Subtable); 185 if (ACPI_FAILURE (Status)) 186 { 187 return (Status); 188 } 189 190 DtInsertSubtable (ParentTable, Subtable); 191 } 192 } 193 194 return (AE_OK); 195 } 196 197 198 /****************************************************************************** 199 * 200 * FUNCTION: DtCompileFacs 201 * 202 * PARAMETERS: PFieldList - Current field list pointer 203 * 204 * RETURN: Status 205 * 206 * DESCRIPTION: Compile FACS. 207 * 208 *****************************************************************************/ 209 210 ACPI_STATUS 211 DtCompileFacs ( 212 DT_FIELD **PFieldList) 213 { 214 DT_SUBTABLE *Subtable; 215 UINT8 *ReservedBuffer; 216 ACPI_STATUS Status; 217 UINT32 ReservedSize; 218 219 220 Status = DtCompileTable (PFieldList, AcpiDmTableInfoFacs, 221 &AslGbl_RootTable); 222 if (ACPI_FAILURE (Status)) 223 { 224 return (Status); 225 } 226 227 /* Large FACS reserved area at the end of the table */ 228 229 ReservedSize = (UINT32) sizeof (((ACPI_TABLE_FACS *) NULL)->Reserved1); 230 ReservedBuffer = UtLocalCalloc (ReservedSize); 231 232 DtCreateSubtable (ReservedBuffer, ReservedSize, &Subtable); 233 234 ACPI_FREE (ReservedBuffer); 235 DtInsertSubtable (AslGbl_RootTable, Subtable); 236 return (AE_OK); 237 } 238