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