]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.c
UefiCpuPkg/CpuDxe: Enable protection for newly added page table
[mirror_edk2.git] / UefiCpuPkg / CpuIo2Smm / CpuIo2Smm.c
index 30ef9ec8a8c5ee97af6bf30f38918d0927a6266b..20b8350fe4a4e189a80dd64b05bd8de65af8cc73 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
   Produces the SMM CPU I/O Protocol.\r
 \r
-Copyright (c) 2009 - 2010, Intel Corporation\r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2009 - 2017, 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
@@ -12,60 +12,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 **/\r
 \r
-#include <PiSmm.h>\r
-\r
-#include <Protocol/SmmCpuIo2.h>\r
-\r
-#include <Library/BaseLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/IoLib.h>\r
-#include <Library/SmmServicesTableLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-\r
-#define MAX_IO_PORT_ADDRESS   0xFFFF\r
-\r
-//\r
-// Function Prototypes\r
-//\r
-EFI_STATUS\r
-EFIAPI\r
-CpuMemoryServiceRead (\r
-  IN  CONST EFI_SMM_CPU_IO2_PROTOCOL  *This,\r
-  IN  EFI_SMM_IO_WIDTH                Width,\r
-  IN  UINT64                          Address,\r
-  IN  UINTN                           Count,\r
-  OUT VOID                            *Buffer\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-CpuMemoryServiceWrite (\r
-  IN CONST EFI_SMM_CPU_IO2_PROTOCOL  *This,\r
-  IN EFI_SMM_IO_WIDTH                Width,\r
-  IN UINT64                          Address,\r
-  IN UINTN                           Count,\r
-  IN VOID                            *Buffer\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-CpuIoServiceRead (\r
-  IN  CONST EFI_SMM_CPU_IO2_PROTOCOL  *This,\r
-  IN  EFI_SMM_IO_WIDTH                Width,\r
-  IN  UINT64                          Address,\r
-  IN  UINTN                           Count,\r
-  OUT VOID                            *Buffer\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-CpuIoServiceWrite (\r
-  IN CONST EFI_SMM_CPU_IO2_PROTOCOL  *This,\r
-  IN EFI_SMM_IO_WIDTH                Width,\r
-  IN UINT64                          Address,\r
-  IN UINTN                           Count,\r
-  IN VOID                            *Buffer\r
-  );\r
+#include "CpuIo2Smm.h"\r
 \r
 //\r
 // Handle for the SMM CPU I/O Protocol\r
@@ -104,7 +51,7 @@ UINT8 mStride[] = {
   @param[in]  Address        The base address of the I/O operations.  The caller is \r
                              responsible for aligning the Address if required. \r
   @param[in]  Count          The number of I/O operations to perform.\r
-  @param[out] Buffer         For read operations, the destination buffer to store \r
+  @param[in]  Buffer         For read operations, the destination buffer to store \r
                              the results.  For write operations, the source buffer \r
                              from which to write data.\r
 \r
@@ -135,7 +82,7 @@ CpuIoCheckParameter (
   //\r
   // Check to see if Width is in the valid range\r
   //\r
-  if (Width < 0 || Width > SMM_IO_UINT64) {\r
+  if ((UINT32)Width > SMM_IO_UINT64) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -156,9 +103,9 @@ CpuIoCheckParameter (
   //\r
   // Since MAX_ADDRESS can be the maximum integer value supported by the CPU and Count \r
   // can also be the maximum integer value supported by the CPU, this range\r
-  // check must be adjusted to avoid all oveflow conditions.\r
+  // check must be adjusted to avoid all overflow conditions.\r
   //   \r
-  // The follwing form of the range check is equivalent but assumes that \r
+  // The following form of the range check is equivalent but assumes that \r
   // MAX_ADDRESS and MAX_IO_PORT_ADDRESS are of the form (2^n - 1).\r
   //\r
   Limit = (MmioOperation ? MAX_ADDRESS : MAX_IO_PORT_ADDRESS);\r
@@ -179,7 +126,7 @@ CpuIoCheckParameter (
   //\r
   // Check to see if Address is aligned\r
   //\r
-  if ((Address & (UINT64)(mStride[Width] - 1)) != 0) {\r
+  if ((Address & ((UINT64)mStride[Width] - 1)) != 0) {\r
     return EFI_UNSUPPORTED;\r
   }\r
 \r
@@ -443,7 +390,7 @@ SmmCpuIo2Initialize (
   IN EFI_HANDLE        ImageHandle,\r
   IN EFI_SYSTEM_TABLE  *SystemTable\r
   )\r
- {\r
+{\r
   EFI_STATUS  Status;\r
 \r
   //\r