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