Home | History | Annotate | Download | only in AcpiSmm
      1 /** @file
      2 Header file for SMM S3 Handler Driver.
      3 
      4 Copyright (c) 2013-2015 Intel Corporation.
      5 
      6 This program and the accompanying materials
      7 are licensed and made available under the terms and conditions of the BSD License
      8 which accompanies this distribution.  The full text of the license may be found at
      9 http://opensource.org/licenses/bsd-license.php
     10 
     11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     13 
     14 
     15 **/
     16 
     17 #ifndef _ACPI_SMM_DRIVER_H
     18 #define _ACPI_SMM_DRIVER_H
     19 //
     20 // Include files
     21 //
     22 //
     23 // Driver Consumed Protocol Prototypes
     24 //
     25 #include <Protocol/SmmSxDispatch2.h>
     26 #include <Protocol/SmmSwDispatch2.h>
     27 #include <Protocol/FirmwareVolume.h>
     28 #include <Protocol/GlobalNvsArea.h>
     29 #include <Protocol/PciRootBridgeIo.h>
     30 #include <Library/UefiDriverEntryPoint.h>
     31 #include <Protocol/Spi.h>
     32 #include <Library/IoLib.h>
     33 #include <Library/PciLib.h>
     34 #include <Library/PcdLib.h>
     35 #include <Library/LockBoxLib.h>
     36 #include <Library/DebugLib.h>
     37 #include <Library/BaseMemoryLib.h>
     38 #include <Library/UefiBootServicesTableLib.h>
     39 #include <Library/BaseLib.h>
     40 #include <Library/UefiRuntimeServicesTableLib.h>
     41 #include <Library/S3IoLib.h>
     42 #include <Library/S3BootScriptLib.h>
     43 #include <Guid/Acpi.h>
     44 #include <Guid/GlobalVariable.h>
     45 #include <Library/SmmServicesTableLib.h>
     46 #include <Guid/SmramMemoryReserve.h>
     47 #include <Library/ReportStatusCodeLib.h>
     48 #include <Library/HobLib.h>
     49 #include <QNCAccess.h>
     50 #include <Library/QNCAccessLib.h>
     51 #include <Library/IntelQNCLib.h>
     52 #include <Library/PlatformHelperLib.h>
     53 #include <Library/PlatformPcieHelperLib.h>
     54 #include "Platform.h"
     55 #include <IndustryStandard/Pci22.h>
     56 
     57 #define EFI_ACPI_ACPI_ENABLE          0xA0
     58 #define EFI_ACPI_ACPI_DISABLE         0xA1
     59 
     60 #define R_IOPORT_CMOS_STANDARD_INDEX            0x70
     61 #define R_IOPORT_CMOS_STANDARD_DATA             0x71
     62 #define RTC_ADDRESS_REGISTER_C    12
     63 #define RTC_ADDRESS_REGISTER_D    13
     64 
     65 #define PCI_DEVICE(Bus, Dev, Func)  \
     66           Bus, Dev, Func
     67 
     68 #define PCI_REG_MASK(Byte0, Byte1, Byte2, Byte3, Byte4, Byte5, Byte6, Byte7) \
     69           Byte0, Byte1, Byte2, Byte3, Byte4, Byte5, Byte6, Byte7
     70 
     71 #define PCI_DEVICE_END    0xFF
     72 
     73 //
     74 // Related data structures definition
     75 //
     76 typedef struct _EFI_ACPI_SMM_DEV {
     77 
     78   //
     79   // Parent dispatch driver returned sleep handle
     80   //
     81   EFI_HANDLE  S3SleepEntryHandle;
     82 
     83   EFI_HANDLE  S4SleepEntryHandle;
     84 
     85   EFI_HANDLE  S1SleepEntryHandle;
     86 
     87   EFI_HANDLE  S5SoftOffEntryHandle;
     88 
     89   EFI_HANDLE  EnableAcpiHandle;
     90 
     91   EFI_HANDLE  DisableAcpiHandle;
     92 
     93   EFI_HANDLE  PpCallbackHandle;
     94 
     95   EFI_HANDLE  MorCallbackHandle;
     96 
     97   //
     98   // QNC Power Management I/O register base
     99   //
    100   UINT32      QncPmBase;
    101 
    102   //
    103   // QNC General Purpose Event0 register base
    104   //
    105   UINT32      QncGpe0Base;
    106 
    107   UINT32      BootScriptSaved;
    108 
    109 } EFI_ACPI_SMM_DEV;
    110 
    111 //
    112 // Prototypes
    113 //
    114 EFI_STATUS
    115 InitPlatformAcpiSmm (
    116   IN EFI_HANDLE           ImageHandle,
    117   IN EFI_SYSTEM_TABLE     *SystemTable,
    118   IN  OUT VOID            *CommBuffer,
    119   IN  OUT UINTN           *CommBufferSize
    120   );
    121 
    122 EFI_STATUS
    123 SxSleepEntryCallBack (
    124   IN  EFI_HANDLE                    DispatchHandle,
    125   IN  CONST VOID                    *DispatchContext,
    126 
    127   IN  OUT VOID                      *CommBuffer,
    128   IN  OUT UINTN                     *CommBufferSize
    129   );
    130 
    131 EFI_STATUS
    132 DisableAcpiCallback (
    133   IN  EFI_HANDLE                    DispatchHandle,
    134   IN  CONST VOID                    *DispatchContext,
    135   IN  OUT VOID                      *CommBuffer,
    136   IN  OUT UINTN                     *CommBufferSize
    137   );
    138 
    139 EFI_STATUS
    140 EnableAcpiCallback (
    141   IN  EFI_HANDLE                    DispatchHandle,
    142   IN  CONST VOID                    *DispatchContext,
    143   IN  OUT VOID                      *CommBuffer,
    144   IN  OUT UINTN                     *CommBufferSize
    145   );
    146 
    147 EFI_STATUS
    148 RegisterToDispatchDriver (
    149   VOID
    150   );
    151 
    152 EFI_STATUS
    153 GetAllQncPmBase (
    154   IN EFI_SMM_SYSTEM_TABLE2       *Smst
    155   );
    156 
    157 EFI_STATUS
    158 SaveRuntimeScriptTable (
    159   IN EFI_SMM_SYSTEM_TABLE2       *Smst
    160   );
    161 
    162 EFI_STATUS
    163 RestoreQncS3SwCallback (
    164   IN  EFI_HANDLE                    DispatchHandle,
    165   IN  CONST VOID                    *DispatchContext,
    166   IN  OUT VOID                      *CommBuffer,
    167   IN  OUT UINTN                     *CommBufferSize
    168   );
    169 
    170 extern EFI_GUID gQncS3CodeInLockBoxGuid;
    171 extern EFI_GUID gQncS3ContextInLockBoxGuid;
    172 
    173 #endif
    174