]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Nt32Pkg/CpuRuntimeDxe/CpuIo.c
Nt32Pkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / Nt32Pkg / CpuRuntimeDxe / CpuIo.c
index 4aaa431d540582b8d1a35d51f9b4b2acbb21c9f5..4809f9c00d207f784469265af40f0801c9c21893 100644 (file)
@@ -1,13 +1,7 @@
-/*++\r
+/**@file\r
 \r
-Copyright (c) 2006, Intel Corporation                                                         \r
-All rights reserved. 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
+Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 Module Name:\r
 \r
@@ -21,15 +15,13 @@ Abstract:
   the implementations of architectural protocols and the PCI Root\r
   Bridge I/O Protocol.\r
 \r
---*/\r
+**/\r
 \r
 #include <CpuDriver.h>\r
 \r
 #define IA32_MAX_IO_ADDRESS   0xFFFF\r
 #define IA32_MAX_MEM_ADDRESS  0xFFFFFFFF\r
 \r
-EFI_CPU_IO_PROTOCOL mCpuIoProtocol;\r
-\r
 EFI_STATUS\r
 CpuIoCheckAddressRange (\r
   IN  EFI_CPU_IO_PROTOCOL_WIDTH         Width,\r
@@ -42,7 +34,7 @@ CpuIoCheckAddressRange (
 EFI_STATUS\r
 EFIAPI\r
 CpuMemoryServiceRead (\r
-  IN  EFI_CPU_IO_PROTOCOL               *This,\r
+  IN  EFI_CPU_IO2_PROTOCOL              *This,\r
   IN  EFI_CPU_IO_PROTOCOL_WIDTH         Width,\r
   IN  UINT64                            Address,\r
   IN  UINTN                             Count,\r
@@ -83,6 +75,10 @@ Returns:
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
+  if ((Width < 0) || (Width >= EfiCpuIoWidthMaximum)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
   Status = CpuIoCheckAddressRange (Width, Address, Count, Buffer, IA32_MAX_MEM_ADDRESS);\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
@@ -91,13 +87,13 @@ Returns:
   //\r
   // Do nothing for Nt32 version\r
   //\r
-  return EFI_SUCCESS;\r
+  return EFI_UNSUPPORTED;\r
 }\r
 \r
 EFI_STATUS\r
 EFIAPI\r
 CpuMemoryServiceWrite (\r
-  IN EFI_CPU_IO_PROTOCOL                *This,\r
+  IN EFI_CPU_IO2_PROTOCOL               *This,\r
   IN  EFI_CPU_IO_PROTOCOL_WIDTH         Width,\r
   IN  UINT64                            Address,\r
   IN  UINTN                             Count,\r
@@ -137,6 +133,10 @@ Returns:
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
+  if ((Width < 0) || (Width >= EfiCpuIoWidthMaximum)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
   Status = CpuIoCheckAddressRange (Width, Address, Count, Buffer, IA32_MAX_MEM_ADDRESS);\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
@@ -145,13 +145,13 @@ Returns:
   //\r
   // Do nothing for Nt32 version\r
   //\r
-  return EFI_SUCCESS;\r
+  return EFI_UNSUPPORTED;\r
 }\r
 \r
 EFI_STATUS\r
 EFIAPI\r
 CpuIoServiceRead (\r
-  IN EFI_CPU_IO_PROTOCOL                *This,\r
+  IN EFI_CPU_IO2_PROTOCOL               *This,\r
   IN  EFI_CPU_IO_PROTOCOL_WIDTH         Width,\r
   IN  UINT64                            UserAddress,\r
   IN  UINTN                             Count,\r
@@ -194,7 +194,7 @@ Returns:
 \r
   Address = (UINTN) UserAddress;\r
 \r
-  if (Width >= EfiCpuIoWidthMaximum) {\r
+  if ((Width < 0) || (Width >= EfiCpuIoWidthMaximum)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -206,13 +206,13 @@ Returns:
   //\r
   // Do nothing for Nt32 version\r
   //\r
-  return EFI_SUCCESS;\r
+  return EFI_UNSUPPORTED;\r
 }\r
 \r
 EFI_STATUS\r
 EFIAPI\r
 CpuIoServiceWrite (\r
-  IN EFI_CPU_IO_PROTOCOL                *This,\r
+  IN EFI_CPU_IO2_PROTOCOL               *This,\r
   IN  EFI_CPU_IO_PROTOCOL_WIDTH         Width,\r
   IN  UINT64                            UserAddress,\r
   IN  UINTN                             Count,\r
@@ -259,7 +259,7 @@ Returns:
 \r
   Address = (UINTN) UserAddress;\r
 \r
-  if (Width >= EfiCpuIoWidthMaximum) {\r
+  if ((Width < 0) || (Width >= EfiCpuIoWidthMaximum)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -271,7 +271,7 @@ Returns:
   //\r
   // Do nothing for Nt32 version\r
   //\r
-  return EFI_SUCCESS;\r
+  return EFI_UNSUPPORTED;\r
 }\r
 \r
 \r
@@ -319,12 +319,12 @@ Returns:
     Count = 1;\r
   }\r
 \r
-  Width = Width & 0x03;\r
-  if (Address - 1 + (1 << Width) * Count > Limit) {\r
+  Width = (EFI_CPU_IO_PROTOCOL_WIDTH)(Width & 0x03);\r
+  if (Address - 1 + ((UINTN)1 << Width) * Count > Limit) {\r
     return EFI_UNSUPPORTED;\r
   }\r
 \r
-  AlignMask = (1 << Width) - 1;\r
+  AlignMask = ((UINTN)1 << Width) - 1;\r
   if ((UINTN) Buffer & AlignMask) {\r
     return EFI_UNSUPPORTED;\r
   }\r