--- /dev/null
+/** @file\r
+ SMM STM support\r
+\r
+ Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
+ This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php.\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef _SMM_STM_H_\r
+#define _SMM_STM_H_\r
+\r
+#include <Protocol/SmMonitorInit.h>\r
+\r
+/**\r
+\r
+ Create 4G page table for STM.\r
+ 2M PAE page table in X64 version.\r
+\r
+ @param PageTableBase The page table base in MSEG\r
+\r
+**/\r
+VOID\r
+StmGen4GPageTable (\r
+ IN UINTN PageTableBase\r
+ );\r
+\r
+/**\r
+ This is SMM exception handle.\r
+ Consumed by STM when exception happen.\r
+\r
+ @param Context STM protection exception stack frame\r
+\r
+ @return the EBX value for STM reference.\r
+ EBX = 0: resume SMM guest using register state found on exception stack.\r
+ EBX = 1 to 0x0F: EBX contains a BIOS error code which the STM must record in the\r
+ TXT.ERRORCODE register and subsequently reset the system via\r
+ TXT.CMD.SYS_RESET. The value of the TXT.ERRORCODE register is calculated as\r
+ follows: TXT.ERRORCODE = (EBX & 0x0F) | STM_CRASH_BIOS_PANIC\r
+ EBX = 0x10 to 0xFFFFFFFF - reserved, do not use.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+SmmStmExceptionHandler (\r
+ IN OUT STM_PROTECTION_EXCEPTION_STACK_FRAME Context\r
+ );\r
+\r
+\r
+/**\r
+\r
+ Get STM state.\r
+\r
+ @return STM state\r
+\r
+**/\r
+EFI_SM_MONITOR_STATE\r
+EFIAPI\r
+GetMonitorState (\r
+ VOID\r
+ );\r
+\r
+/**\r
+\r
+ Load STM image to MSEG.\r
+\r
+ @param StmImage STM image\r
+ @param StmImageSize STM image size\r
+\r
+ @retval EFI_SUCCESS Load STM to MSEG successfully\r
+ @retval EFI_BUFFER_TOO_SMALL MSEG is smaller than minimal requirement of STM image\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+LoadMonitor (\r
+ IN EFI_PHYSICAL_ADDRESS StmImage,\r
+ IN UINTN StmImageSize\r
+ );\r
+\r
+/**\r
+\r
+ Add resources in list to database. Allocate new memory areas as needed.\r
+\r
+ @param ResourceList A pointer to resource list to be added\r
+ @param NumEntries Optional number of entries.\r
+ If 0, list must be terminated by END_OF_RESOURCES.\r
+\r
+ @retval EFI_SUCCESS If resources are added\r
+ @retval EFI_INVALID_PARAMETER If nested procedure detected resource failer\r
+ @retval EFI_OUT_OF_RESOURCES If nested procedure returned it and we cannot allocate more areas.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+AddPiResource (\r
+ IN STM_RSC *ResourceList,\r
+ IN UINT32 NumEntries OPTIONAL\r
+ );\r
+\r
+/**\r
+\r
+ Delete resources in list to database.\r
+\r
+ @param ResourceList A pointer to resource list to be deleted\r
+ NULL means delete all resources.\r
+ @param NumEntries Optional number of entries.\r
+ If 0, list must be terminated by END_OF_RESOURCES.\r
+\r
+ @retval EFI_SUCCESS If resources are deleted\r
+ @retval EFI_INVALID_PARAMETER If nested procedure detected resource failer\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+DeletePiResource (\r
+ IN STM_RSC *ResourceList,\r
+ IN UINT32 NumEntries OPTIONAL\r
+ );\r
+\r
+/**\r
+\r
+ Get BIOS resources.\r
+\r
+ @param ResourceList A pointer to resource list to be filled\r
+ @param ResourceSize On input it means size of resource list input.\r
+ On output it means size of resource list filled,\r
+ or the size of resource list to be filled if size of too small.\r
+\r
+ @retval EFI_SUCCESS If resources are returned.\r
+ @retval EFI_BUFFER_TOO_SMALL If resource list buffer is too small to hold the whole resources.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GetPiResource (\r
+ OUT STM_RSC *ResourceList,\r
+ IN OUT UINT32 *ResourceSize\r
+ );\r
+\r
+/**\r
+ This functin initialize STM configuration table.\r
+**/\r
+VOID\r
+StmSmmConfigurationTableInit (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ This function notify STM resource change.\r
+\r
+ @param StmResource BIOS STM resource\r
+\r
+**/\r
+VOID\r
+NotifyStmResourceChange (\r
+ IN VOID *StmResource\r
+ );\r
+\r
+/**\r
+ This function return BIOS STM resource.\r
+\r
+ @return BIOS STM resource\r
+\r
+**/\r
+VOID *\r
+GetStmResource (\r
+ VOID\r
+ );\r
+\r
+#endif\r