]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg: Add SmmCpuPlatformHookLib
authorMichael Kinney <michael.d.kinney@intel.com>
Mon, 19 Oct 2015 19:11:15 +0000 (19:11 +0000)
committermdkinney <mdkinney@Edk2>
Mon, 19 Oct 2015 19:11:15 +0000 (19:11 +0000)
Add SmmCpuPlatformHookLib that provides platform specific functions
that are used to initialize SMM and process SMIs.  A Null instance
of this library is provided that should work for most platforms.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney <michael.d.kinney@intel.com>
Reviewed-by: Jeff Fan <jeff.fan@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18639 6f19259b-4bc3-4df7-8a09-765794883524

UefiCpuPkg/Include/Library/SmmCpuPlatformHookLib.h [new file with mode: 0644]
UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.c [new file with mode: 0644]
UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.inf [new file with mode: 0644]
UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.uni [new file with mode: 0644]

diff --git a/UefiCpuPkg/Include/Library/SmmCpuPlatformHookLib.h b/UefiCpuPkg/Include/Library/SmmCpuPlatformHookLib.h
new file mode 100644 (file)
index 0000000..e40084e
--- /dev/null
@@ -0,0 +1,109 @@
+/** @file\r
+  Public include file for the SMM CPU Platform Hook Library.\r
+\r
+  Copyright (c) 2010 - 2015, 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_CPU_PLATFORM_HOOK_LIB_H__\r
+#define __SMM_CPU_PLATFORM_HOOK_LIB_H__\r
+\r
+///\r
+/// SMM Page Size Type\r
+///\r
+typedef enum {\r
+    SmmPageSize4K,\r
+    SmmPageSize2M,\r
+    SmmPageSize1G,\r
+    MaxSmmPageSizeType\r
+} SMM_PAGE_SIZE_TYPE;\r
+\r
+/**\r
+  Checks if platform produces a valid SMI.\r
+\r
+  This function checks if platform produces a valid SMI. This function is\r
+  called at SMM entry to detect if this is a spurious SMI. This function\r
+  must be implemented in an MP safe way because it is called by multiple CPU\r
+  threads.\r
+\r
+  @retval TRUE              There is a valid SMI\r
+  @retval FALSE             There is no valid SMI\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+PlatformValidSmi (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Clears platform top level SMI status bit.\r
+\r
+  This function clears platform top level SMI status bit.\r
+\r
+  @retval TRUE              The platform top level SMI status is cleared.\r
+  @retval FALSE             The platform top level SMI status cannot be cleared.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+ClearTopLevelSmiStatus (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Performs platform specific way of SMM BSP election.\r
+\r
+  This function performs platform specific way of SMM BSP election.\r
+\r
+  @param  IsBsp             Output parameter. TRUE: the CPU this function executes\r
+                            on is elected to be the SMM BSP. FALSE: the CPU this\r
+                            function executes on is to be SMM AP.\r
+\r
+  @retval EFI_SUCCESS       The function executes successfully.\r
+  @retval EFI_NOT_READY     The function does not determine whether this CPU should be\r
+                            BSP or AP. This may occur if hardware init sequence to\r
+                            enable the determination is yet to be done, or the function\r
+                            chooses not to do BSP election and will let SMM CPU driver to\r
+                            use its default BSP election process.\r
+  @retval EFI_DEVICE_ERROR  The function cannot determine whether this CPU should be\r
+                            BSP or AP due to hardware error.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PlatformSmmBspElection (\r
+  OUT BOOLEAN     *IsBsp\r
+  );\r
+\r
+/**\r
+  Get platform page table attribute .\r
+\r
+  This function gets page table attribute of platform.\r
+\r
+  @param  Address        Input parameter. Obtain the page table entries attribute on this address.\r
+  @param  PageSize       Output parameter. The size of the page.\r
+  @param  NumOfPages     Output parameter. Number of page.\r
+  @param  PageAttribute  Output parameter. Paging Attributes (WB, UC, etc).\r
+\r
+  @retval EFI_SUCCESS      The platform page table attribute from the address is determined.\r
+  @retval EFI_UNSUPPORTED  The platform does not support getting page table attribute for the address.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GetPlatformPageTableAttribute (\r
+  IN  UINT64                Address,\r
+  OUT SMM_PAGE_SIZE_TYPE    *PageSize,\r
+  OUT UINTN                 *NumOfPages,\r
+  OUT UINTN                 *PageAttribute\r
+  );\r
+\r
+#endif\r
diff --git a/UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.c b/UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.c
new file mode 100644 (file)
index 0000000..efb61fa
--- /dev/null
@@ -0,0 +1,108 @@
+/** @file\r
+SMM CPU Platform Hook NULL library instance.\r
+\r
+Copyright (c) 2006 - 2015, 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
+#include <PiSmm.h>\r
+#include <Library/SmmCpuPlatformHookLib.h>\r
+\r
+/**\r
+  Checks if platform produces a valid SMI.\r
+\r
+  This function checks if platform produces a valid SMI. This function is\r
+  called at SMM entry to detect if this is a spurious SMI. This function\r
+  must be implemented in an MP safe way because it is called by multiple CPU\r
+  threads.\r
+\r
+  @retval TRUE              There is a valid SMI\r
+  @retval FALSE             There is no valid SMI\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+PlatformValidSmi (\r
+  VOID\r
+  )\r
+{\r
+  return TRUE;\r
+}\r
+\r
+/**\r
+  Clears platform top level SMI status bit.\r
+\r
+  This function clears platform top level SMI status bit.\r
+\r
+  @retval TRUE              The platform top level SMI status is cleared.\r
+  @retval FALSE             The platform top level SMI status cannot be cleared.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+ClearTopLevelSmiStatus (\r
+  VOID\r
+  )\r
+{\r
+  return TRUE;\r
+}\r
+\r
+/**\r
+  Performs platform specific way of SMM BSP election.\r
+\r
+  This function performs platform specific way of SMM BSP election.\r
+\r
+  @param  IsBsp             Output parameter. TRUE: the CPU this function executes\r
+                            on is elected to be the SMM BSP. FALSE: the CPU this\r
+                            function executes on is to be SMM AP.\r
+\r
+  @retval EFI_SUCCESS       The function executes successfully.\r
+  @retval EFI_NOT_READY     The function does not determine whether this CPU should be\r
+                            BSP or AP. This may occur if hardware init sequence to\r
+                            enable the determination is yet to be done, or the function\r
+                            chooses not to do BSP election and will let SMM CPU driver to\r
+                            use its default BSP election process.\r
+  @retval EFI_DEVICE_ERROR  The function cannot determine whether this CPU should be\r
+                            BSP or AP due to hardware error.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PlatformSmmBspElection (\r
+  OUT BOOLEAN     *IsBsp\r
+  )\r
+{\r
+  return EFI_NOT_READY;\r
+}\r
+\r
+/**\r
+  Get platform page table attribute.\r
+\r
+  This function gets page table attribute of platform.\r
+\r
+  @param  Address        Input parameter. Obtain the page table entries attribute on this address.\r
+  @param  PageSize       Output parameter. The size of the page.\r
+  @param  NumOfPages     Output parameter. Number of page.\r
+  @param  PageAttribute  Output parameter. Paging Attributes (WB, UC, etc).\r
+\r
+  @retval EFI_SUCCESS      The platform page table attribute from the address is determined.\r
+  @retval EFI_UNSUPPORTED  The platform does not support getting page table attribute for the address.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GetPlatformPageTableAttribute (\r
+  IN  UINT64                Address,\r
+  IN OUT SMM_PAGE_SIZE_TYPE *PageSize,\r
+  IN OUT UINTN              *NumOfPages,\r
+  IN OUT UINTN              *PageAttribute\r
+  )\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
diff --git a/UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.inf b/UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.inf
new file mode 100644 (file)
index 0000000..4dea5fb
--- /dev/null
@@ -0,0 +1,40 @@
+## @file\r
+#  SMM CPU Platform Hook NULL library instance.\r
+#\r
+#  Copyright (c) 2006 - 2015, 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
+################################################################################\r
+#\r
+# Defines Section - statements that will be processed to create a Makefile.\r
+#\r
+################################################################################\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = SmmCpuPlatformHookLibNull\r
+  MODULE_UNI_FILE                = SmmCpuPlatformHookLibNull.uni\r
+  FILE_GUID                      = D6494E1B-E06F-4ab5-B64D-48B25AA9EB33\r
+  MODULE_TYPE                    = DXE_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = SmmCpuPlatformHookLib\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64\r
+#\r
+\r
+[Sources]\r
+  SmmCpuPlatformHookLibNull.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  UefiCpuPkg/UefiCpuPkg.dec\r
diff --git a/UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.uni b/UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.uni
new file mode 100644 (file)
index 0000000..9935934
Binary files /dev/null and b/UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.uni differ