]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseMemoryLib: Add missing ASSERT()s for some interfaces.
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 29 May 2006 04:43:26 +0000 (04:43 +0000)
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 29 May 2006 04:43:26 +0000 (04:43 +0000)
BaseTimerLibLocalApic: Add missing EBC architecture support. Note that this instance is a dummy one since EBC does not support local APIC timer.
IoLibDxeCpuIo: Add alignment checking & unsupported width checking by using ASSERT()s.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@311 6f19259b-4bc3-4df7-8a09-765794883524

16 files changed:
MdePkg/Library/BaseMemoryLib/MemLibGuid.c
MdePkg/Library/BaseMemoryLib/ZeroMemWrapper.c
MdePkg/Library/BaseMemoryLibMmx/MemLibGuid.c
MdePkg/Library/BaseMemoryLibMmx/ZeroMemWrapper.c
MdePkg/Library/BaseMemoryLibRepStr/MemLibGuid.c
MdePkg/Library/BaseMemoryLibRepStr/ZeroMemWrapper.c
MdePkg/Library/BaseMemoryLibSse2/MemLibGuid.c
MdePkg/Library/BaseMemoryLibSse2/ZeroMemWrapper.c
MdePkg/Library/BaseTimerLibLocalApic/BaseTimerLibLocalApic.msa
MdePkg/Library/BaseTimerLibLocalApic/Ebc/EbcTimerLib.c [new file with mode: 0644]
MdePkg/Library/DxeIoLibCpuIo/DxeIoLibCpuIo.msa
MdePkg/Library/DxeIoLibCpuIo/IoLib.c
MdePkg/Library/PeiMemoryLib/MemLibGuid.c
MdePkg/Library/PeiMemoryLib/ZeroMemWrapper.c
MdePkg/Library/UefiMemoryLib/MemLibGuid.c
MdePkg/Library/UefiMemoryLib/ZeroMemWrapper.c

index 06b2721c64f407a6ce20c477c6005b8e9ce83f63..c54983c77b5436f21f95faf458bb3d8bb09aba7c 100644 (file)
@@ -119,6 +119,14 @@ ScanGuid (
 {\r
   CONST GUID                        *GuidPtr;\r
 \r
+  ASSERT (Buffer != NULL);\r
+  //\r
+  // Make sure Buffer is aligned on a 64-bit boundary.\r
+  //\r
+  ASSERT (((UINTN) Buffer & 7) == 0);\r
+\r
+  ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));\r
+\r
   GuidPtr = (GUID*)Buffer;\r
   Buffer = GuidPtr + Length / sizeof (*GuidPtr);\r
   while (GuidPtr < (CONST GUID*)Buffer) {\r
index d7d7919ba26a46aa5dabfb8ff71eb0eb9bb0271b..4a3d615ce50839c44ce64259ee4f2314193c74cc 100644 (file)
@@ -43,9 +43,10 @@ VOID *
 EFIAPI\r
 ZeroMem (\r
   IN      VOID                      *Buffer,\r
-  IN      UINTN                     Size\r
+  IN      UINTN                     Length\r
   )\r
 {\r
-  ASSERT (Buffer != NULL);\r
-  return InternalMemSetMem (Buffer, Size, 0);\r
+  ASSERT (!(Buffer == NULL && Length > 0));\r
+  ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));\r
+  return InternalMemSetMem (Buffer, Length, 0);\r
 }\r
index 06b2721c64f407a6ce20c477c6005b8e9ce83f63..c54983c77b5436f21f95faf458bb3d8bb09aba7c 100644 (file)
@@ -119,6 +119,14 @@ ScanGuid (
 {\r
   CONST GUID                        *GuidPtr;\r
 \r
+  ASSERT (Buffer != NULL);\r
+  //\r
+  // Make sure Buffer is aligned on a 64-bit boundary.\r
+  //\r
+  ASSERT (((UINTN) Buffer & 7) == 0);\r
+\r
+  ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));\r
+\r
   GuidPtr = (GUID*)Buffer;\r
   Buffer = GuidPtr + Length / sizeof (*GuidPtr);\r
   while (GuidPtr < (CONST GUID*)Buffer) {\r
index d7d7919ba26a46aa5dabfb8ff71eb0eb9bb0271b..4a3d615ce50839c44ce64259ee4f2314193c74cc 100644 (file)
@@ -43,9 +43,10 @@ VOID *
 EFIAPI\r
 ZeroMem (\r
   IN      VOID                      *Buffer,\r
-  IN      UINTN                     Size\r
+  IN      UINTN                     Length\r
   )\r
 {\r
-  ASSERT (Buffer != NULL);\r
-  return InternalMemSetMem (Buffer, Size, 0);\r
+  ASSERT (!(Buffer == NULL && Length > 0));\r
+  ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));\r
+  return InternalMemSetMem (Buffer, Length, 0);\r
 }\r
index 06b2721c64f407a6ce20c477c6005b8e9ce83f63..c54983c77b5436f21f95faf458bb3d8bb09aba7c 100644 (file)
@@ -119,6 +119,14 @@ ScanGuid (
 {\r
   CONST GUID                        *GuidPtr;\r
 \r
+  ASSERT (Buffer != NULL);\r
+  //\r
+  // Make sure Buffer is aligned on a 64-bit boundary.\r
+  //\r
+  ASSERT (((UINTN) Buffer & 7) == 0);\r
+\r
+  ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));\r
+\r
   GuidPtr = (GUID*)Buffer;\r
   Buffer = GuidPtr + Length / sizeof (*GuidPtr);\r
   while (GuidPtr < (CONST GUID*)Buffer) {\r
index d7d7919ba26a46aa5dabfb8ff71eb0eb9bb0271b..4a3d615ce50839c44ce64259ee4f2314193c74cc 100644 (file)
@@ -43,9 +43,10 @@ VOID *
 EFIAPI\r
 ZeroMem (\r
   IN      VOID                      *Buffer,\r
-  IN      UINTN                     Size\r
+  IN      UINTN                     Length\r
   )\r
 {\r
-  ASSERT (Buffer != NULL);\r
-  return InternalMemSetMem (Buffer, Size, 0);\r
+  ASSERT (!(Buffer == NULL && Length > 0));\r
+  ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));\r
+  return InternalMemSetMem (Buffer, Length, 0);\r
 }\r
index 06b2721c64f407a6ce20c477c6005b8e9ce83f63..c54983c77b5436f21f95faf458bb3d8bb09aba7c 100644 (file)
@@ -119,6 +119,14 @@ ScanGuid (
 {\r
   CONST GUID                        *GuidPtr;\r
 \r
+  ASSERT (Buffer != NULL);\r
+  //\r
+  // Make sure Buffer is aligned on a 64-bit boundary.\r
+  //\r
+  ASSERT (((UINTN) Buffer & 7) == 0);\r
+\r
+  ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));\r
+\r
   GuidPtr = (GUID*)Buffer;\r
   Buffer = GuidPtr + Length / sizeof (*GuidPtr);\r
   while (GuidPtr < (CONST GUID*)Buffer) {\r
index d7d7919ba26a46aa5dabfb8ff71eb0eb9bb0271b..4a3d615ce50839c44ce64259ee4f2314193c74cc 100644 (file)
@@ -43,9 +43,10 @@ VOID *
 EFIAPI\r
 ZeroMem (\r
   IN      VOID                      *Buffer,\r
-  IN      UINTN                     Size\r
+  IN      UINTN                     Length\r
   )\r
 {\r
-  ASSERT (Buffer != NULL);\r
-  return InternalMemSetMem (Buffer, Size, 0);\r
+  ASSERT (!(Buffer == NULL && Length > 0));\r
+  ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));\r
+  return InternalMemSetMem (Buffer, Length, 0);\r
 }\r
index 563d1a40569cc9d8848d9033bdf6aaa6c73c1e7e..b056c8d9f404abc76b0257dc84648389a31ce19f 100644 (file)
@@ -49,6 +49,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
       <Filename>Ipf/ReadItc.s</Filename>\r
       <Filename>Ipf/IpfTimerLib.c</Filename>\r
     </Arch>\r
+    <Arch ArchType="EBC">\r
+      <Filename>Ebc/EbcTimerLib.c</Filename>\r
+    </Arch>\r
   </SourceFiles>\r
   <Includes>\r
     <PackageName>MdePkg</PackageName>\r
diff --git a/MdePkg/Library/BaseTimerLibLocalApic/Ebc/EbcTimerLib.c b/MdePkg/Library/BaseTimerLibLocalApic/Ebc/EbcTimerLib.c
new file mode 100644 (file)
index 0000000..7de360a
--- /dev/null
@@ -0,0 +1,123 @@
+/** @file\r
+  Timer Library functions for EBC.\r
+\r
+  Copyright (c) 2006, Intel Corporation<BR>\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
+\r
+  Module Name:  EbcTimerLib.c\r
+\r
+**/\r
+\r
+/**\r
+  Stalls the CPU for at least the given number of microseconds.\r
+\r
+  Stalls the CPU for the number of microseconds specified by MicroSeconds.\r
+\r
+  @param  MicroSeconds  The minimum number of microseconds to delay.\r
+\r
+  @return Return value depends on implementation.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+MicroSecondDelay (\r
+  IN      UINTN                     MicroSeconds\r
+  )\r
+{\r
+  //\r
+  // EBC architecture does not support local APIC timer.\r
+  //\r
+  ASSERT (FALSE);\r
+  return 0;\r
+}\r
+\r
+/**\r
+  Stalls the CPU for at least the given number of nanoseconds.\r
+\r
+  Stalls the CPU for the number of nanoseconds specified by NanoSeconds.\r
+\r
+  @param  NanoSeconds The minimum number of nanoseconds to delay.\r
+\r
+  @return Return value depends on implementation.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+NanoSecondDelay (\r
+  IN      UINTN                     NanoSeconds\r
+  )\r
+{\r
+  //\r
+  // EBC architecture does not support local APIC timer.\r
+  //\r
+  ASSERT (FALSE);\r
+  return 0;\r
+}\r
+\r
+/**\r
+  Retrieves the current value of a 64-bit free running performance counter.\r
+\r
+  Retrieves the current value of a 64-bit free running performance counter. The\r
+  counter can either count up by 1 or count down by 1. If the physical\r
+  performance counter counts by a larger increment, then the counter values\r
+  must be translated. The properties of the counter can be retrieved from\r
+  GetPerformanceCounterProperties().\r
+\r
+  @return The current value of the free running performance counter.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+GetPerformanceCounter (\r
+  VOID\r
+  )\r
+{\r
+  //\r
+  // EBC architecture does not support local APIC timer.\r
+  //\r
+  ASSERT (FALSE);\r
+  return 0;\r
+}\r
+\r
+/**\r
+  Retrieves the 64-bit frequency in Hz and the range of performance counter\r
+  values.\r
+\r
+  If StartValue is not NULL, then the value that the performance counter starts\r
+  with immediately after is it rolls over is returned in StartValue. If\r
+  EndValue is not NULL, then the value that the performance counter end with\r
+  immediately before it rolls over is returned in EndValue. The 64-bit\r
+  frequency of the performance counter in Hz is always returned. If StartValue\r
+  is less than EndValue, then the performance counter counts up. If StartValue\r
+  is greater than EndValue, then the performance counter counts down. For\r
+  example, a 64-bit free running counter that counts up would have a StartValue\r
+  of 0 and an EndValue of 0xFFFFFFFFFFFFFFFF. A 24-bit free running counter\r
+  that counts down would have a StartValue of 0xFFFFFF and an EndValue of 0.\r
+\r
+  @param  StartValue  The value the performance counter starts with when it\r
+                      rolls over.\r
+  @param  EndValue    The value that the performance counter ends with before\r
+                      it rolls over.\r
+\r
+  @return The frequency in Hz.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+GetPerformanceCounterProperties (\r
+  IN      UINT64                    *StartValue,\r
+  IN      UINT64                    *EndValue\r
+  )\r
+{\r
+  //\r
+  // EBC architecture does not support local APIC timer.\r
+  //\r
+  ASSERT (FALSE);\r
+  return 0;  \r
+}\r
index 78f6f9387684b3f8052b59640b881a7b3ee8e702..9ae50fe4436b9b90c297c0b92585b18d64566252 100644 (file)
@@ -32,6 +32,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
   </MsaLibHeader>\r
   <LibraryClassDefinitions>\r
     <LibraryClass Usage="ALWAYS_PRODUCED">IoLib</LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">UefiBootServicesTableLib</LibraryClass>\r
     <LibraryClass Usage="ALWAYS_CONSUMED">DebugLib</LibraryClass>\r
     <LibraryClass Usage="ALWAYS_CONSUMED">BaseLib</LibraryClass>\r
   </LibraryClassDefinitions>\r
index 21b23dfe3be68294b0ac5d2003bad71162664884..fa3421bacad4fc95290d381a22b6c9d7b0e67e6f 100644 (file)
 \r
 **/\r
 \r
-static EFI_CPU_IO_PROTOCOL          *gCpuIo;\r
+//\r
+// Globle varible to cache pointer to CpuIo protocol.\r
+//\r
+STATIC EFI_CPU_IO_PROTOCOL          *mCpuIo = NULL;\r
 \r
+/**\r
+  The constructor function caches the pointer to CpuIo protocol.\r
+  \r
+  The constructor function locates CpuIo protocol from protocol database.\r
+  It will ASSERT() if that operation fails and it will always return EFI_SUCCESS. \r
+\r
+  @param  ImageHandle   The firmware allocated handle for the EFI image.\r
+  @param  SystemTable   A pointer to the EFI System Table.\r
+  \r
+  @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.\r
+\r
+**/\r
 EFI_STATUS\r
 IoLibConstructor (\r
   IN      EFI_HANDLE                ImageHandle,\r
@@ -24,15 +39,26 @@ IoLibConstructor (
 {\r
   EFI_STATUS                        Status;\r
 \r
-  Status = SystemTable->BootServices->LocateProtocol (\r
-                                        &gEfiCpuIoProtocolGuid,\r
-                                        NULL,\r
-                                        (VOID**)&gCpuIo\r
-                                        );\r
+  Status = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, (VOID**) &mCpuIo);\r
   ASSERT_EFI_ERROR (Status);\r
+\r
   return Status;\r
 }\r
 \r
+/**\r
+  Reads registers in the EFI CPU I/O space.\r
+\r
+  Reads the I/O port specified by Port with registers width specified by Width.\r
+  The read value is returned. If such operations are not supported, then ASSERT().\r
+  This function must guarantee that all I/O read and write operations are serialized.\r
+\r
+  @param  Port          The base address of the I/O operation.\r
+                        The caller is responsible for aligning the Address if required. \r
+  @param  Width         The width of the I/O operation.\r
+  \r
+  @return Data read from registers in the EFI CPU I/O space.\r
+\r
+**/\r
 UINT64\r
 EFIAPI\r
 IoReadWorker (\r
@@ -40,12 +66,30 @@ IoReadWorker (
   IN      EFI_CPU_IO_PROTOCOL_WIDTH Width\r
   )\r
 {\r
+  EFI_STATUS                        Status;\r
   UINT64                            Data;\r
 \r
-  gCpuIo->Io.Read (gCpuIo, Width, Port, 1, &Data);\r
+  Status = mCpuIo->Io.Read (mCpuIo, Width, Port, 1, &Data);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
   return Data;\r
 }\r
 \r
+/**\r
+  Writes registers in the EFI CPU I/O space.\r
+\r
+  Writes the I/O port specified by Port with registers width and value specified by Width\r
+  and Data respectively.  Data is returned. If such operations are not supported, then ASSERT().\r
+  This function must guarantee that all I/O read and write operations are serialized.\r
+\r
+  @param  Port          The base address of the I/O operation.\r
+                        The caller is responsible for aligning the Address if required. \r
+  @param  Width         The width of the I/O operation.\r
+  @param  Data          The value to write to the I/O port.\r
+  \r
+  @return The paramter of Data.\r
+\r
+**/\r
 UINT64\r
 EFIAPI\r
 IoWriteWorker (\r
@@ -54,10 +98,28 @@ IoWriteWorker (
   IN      UINT64                    Data\r
   )\r
 {\r
-  gCpuIo->Io.Write (gCpuIo, Width, Port, 1, &Data);\r
+  EFI_STATUS                        Status;\r
+\r
+  Status = mCpuIo->Io.Write (mCpuIo, Width, Port, 1, &Data);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
   return Data;\r
 }\r
 \r
+/**\r
+  Reads memory-mapped registers in the EFI system memory space. \r
+\r
+  Reads the MMIO registers specified by Address with registers width specified by Width.\r
+  The read value is returned. If such operations are not supported, then ASSERT().\r
+  This function must guarantee that all MMIO read and write operations are serialized.\r
+\r
+  @param  Address       The MMIO register to read.\r
+                        The caller is responsible for aligning the Address if required. \r
+  @param  Width         The width of the I/O operation.\r
+  \r
+  @return Data read from registers in the EFI system memory space.\r
+\r
+**/\r
 UINT64\r
 EFIAPI\r
 MmioReadWorker (\r
@@ -65,12 +127,29 @@ MmioReadWorker (
   IN      EFI_CPU_IO_PROTOCOL_WIDTH Width\r
   )\r
 {\r
+  EFI_STATUS                        Status;\r
   UINT64                            Data;\r
 \r
-  gCpuIo->Mem.Read (gCpuIo, Width, Address, 1, &Data);\r
+  Status = mCpuIo->Mem.Read (mCpuIo, Width, Address, 1, &Data);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
   return Data;\r
 }\r
 \r
+/**\r
+  Writes memory-mapped registers in the EFI system memory space. \r
+\r
+  Writes the MMIO registers specified by Address with registers width and value specified by Width\r
+  and Data respectively. Data is returned. If such operations are not supported, then ASSERT().\r
+  This function must guarantee that all MMIO read and write operations are serialized.\r
+\r
+  @param  Address       The MMIO register to read.\r
+                        The caller is responsible for aligning the Address if required. \r
+  @param  Width         The width of the I/O operation.\r
+  \r
+  @return Data read from registers in the EFI system memory space.\r
+\r
+**/\r
 UINT64\r
 EFIAPI\r
 MmioWriteWorker (\r
@@ -79,7 +158,11 @@ MmioWriteWorker (
   IN      UINT64                    Data\r
   )\r
 {\r
-  gCpuIo->Mem.Write (gCpuIo, Width, Address, 1, &Data);\r
+  EFI_STATUS                        Status;\r
+\r
+  Status = mCpuIo->Mem.Write (mCpuIo, Width, Address, 1, &Data);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
   return Data;\r
 }\r
 \r
@@ -151,6 +234,10 @@ IoRead16 (
   IN      UINTN                     Port\r
   )\r
 {\r
+  //\r
+  // Make sure Port is aligned on a 16-bit boundary.\r
+  //\r
+  ASSERT ((Port & 1) == 0);\r
   return (UINT16)IoReadWorker (Port, EfiCpuIoWidthUint16);\r
 }\r
 \r
@@ -176,6 +263,10 @@ IoWrite16 (
   IN      UINT16                    Value\r
   )\r
 {\r
+  //\r
+  // Make sure Port is aligned on a 16-bit boundary.\r
+  //\r
+  ASSERT ((Port & 1) == 0);\r
   return (UINT16)IoWriteWorker (Port, EfiCpuIoWidthUint16, Value);\r
 }\r
 \r
@@ -199,6 +290,10 @@ IoRead32 (
   IN      UINTN                     Port\r
   )\r
 {\r
+  //\r
+  // Make sure Port is aligned on a 32-bit boundary.\r
+  //\r
+  ASSERT ((Port & 3) == 0);\r
   return (UINT32)IoReadWorker (Port, EfiCpuIoWidthUint32);\r
 }\r
 \r
@@ -224,6 +319,10 @@ IoWrite32 (
   IN      UINT32                    Value\r
   )\r
 {\r
+  //\r
+  // Make sure Port is aligned on a 32-bit boundary.\r
+  //\r
+  ASSERT ((Port & 3) == 0);\r
   return (UINT32)IoWriteWorker (Port, EfiCpuIoWidthUint32, Value);\r
 }\r
 \r
@@ -247,6 +346,10 @@ IoRead64 (
   IN      UINTN                     Port\r
   )\r
 {\r
+  //\r
+  // Make sure Port is aligned on a 64-bit boundary.\r
+  //\r
+  ASSERT ((Port & 7) == 0);\r
   return IoReadWorker (Port, EfiCpuIoWidthUint64);\r
 }\r
 \r
@@ -272,6 +375,10 @@ IoWrite64 (
   IN      UINT64                    Value\r
   )\r
 {\r
+  //\r
+  // Make sure Port is aligned on a 64-bit boundary.\r
+  //\r
+  ASSERT ((Port & 7) == 0);\r
   return IoWriteWorker (Port, EfiCpuIoWidthUint64, Value);\r
 }\r
 \r
@@ -341,6 +448,10 @@ MmioRead16 (
   IN      UINTN                     Address\r
   )\r
 {\r
+  //\r
+  // Make sure Address is aligned on a 16-bit boundary.\r
+  //\r
+  ASSERT ((Address & 1) == 0);\r
   return (UINT16)MmioReadWorker (Address, EfiCpuIoWidthUint16);\r
 }\r
 \r
@@ -364,6 +475,10 @@ MmioWrite16 (
   IN      UINT16                    Value\r
   )\r
 {\r
+  //\r
+  // Make sure Address is aligned on a 16-bit boundary.\r
+  //\r
+  ASSERT ((Address & 1) == 0);\r
   return (UINT16)MmioWriteWorker (Address, EfiCpuIoWidthUint16, Value);\r
 }\r
 \r
@@ -387,6 +502,10 @@ MmioRead32 (
   IN      UINTN                     Address\r
   )\r
 {\r
+  //\r
+  // Make sure Address is aligned on a 32-bit boundary.\r
+  //\r
+  ASSERT ((Address & 3) == 0);\r
   return (UINT32)MmioReadWorker (Address, EfiCpuIoWidthUint32);\r
 }\r
 \r
@@ -410,6 +529,10 @@ MmioWrite32 (
   IN      UINT32                    Value\r
   )\r
 {\r
+  //\r
+  // Make sure Address is aligned on a 32-bit boundary.\r
+  //\r
+  ASSERT ((Address & 3) == 0);\r
   return (UINT32)MmioWriteWorker (Address, EfiCpuIoWidthUint32, Value);\r
 }\r
 \r
@@ -433,6 +556,10 @@ MmioRead64 (
   IN      UINTN                     Address\r
   )\r
 {\r
+  //\r
+  // Make sure Address is aligned on a 64-bit boundary.\r
+  //\r
+  ASSERT ((Address & 7) == 0);\r
   return (UINT64)MmioReadWorker (Address, EfiCpuIoWidthUint64);\r
 }\r
 \r
@@ -456,5 +583,9 @@ MmioWrite64 (
   IN      UINT64                    Value\r
   )\r
 {\r
+  //\r
+  // Make sure Address is aligned on a 64-bit boundary.\r
+  //\r
+  ASSERT ((Address & 7) == 0);\r
   return (UINT64)MmioWriteWorker (Address, EfiCpuIoWidthUint64, Value);\r
 }\r
index 06b2721c64f407a6ce20c477c6005b8e9ce83f63..c54983c77b5436f21f95faf458bb3d8bb09aba7c 100644 (file)
@@ -119,6 +119,14 @@ ScanGuid (
 {\r
   CONST GUID                        *GuidPtr;\r
 \r
+  ASSERT (Buffer != NULL);\r
+  //\r
+  // Make sure Buffer is aligned on a 64-bit boundary.\r
+  //\r
+  ASSERT (((UINTN) Buffer & 7) == 0);\r
+\r
+  ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));\r
+\r
   GuidPtr = (GUID*)Buffer;\r
   Buffer = GuidPtr + Length / sizeof (*GuidPtr);\r
   while (GuidPtr < (CONST GUID*)Buffer) {\r
index d7d7919ba26a46aa5dabfb8ff71eb0eb9bb0271b..4a3d615ce50839c44ce64259ee4f2314193c74cc 100644 (file)
@@ -43,9 +43,10 @@ VOID *
 EFIAPI\r
 ZeroMem (\r
   IN      VOID                      *Buffer,\r
-  IN      UINTN                     Size\r
+  IN      UINTN                     Length\r
   )\r
 {\r
-  ASSERT (Buffer != NULL);\r
-  return InternalMemSetMem (Buffer, Size, 0);\r
+  ASSERT (!(Buffer == NULL && Length > 0));\r
+  ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));\r
+  return InternalMemSetMem (Buffer, Length, 0);\r
 }\r
index 06b2721c64f407a6ce20c477c6005b8e9ce83f63..c54983c77b5436f21f95faf458bb3d8bb09aba7c 100644 (file)
@@ -119,6 +119,14 @@ ScanGuid (
 {\r
   CONST GUID                        *GuidPtr;\r
 \r
+  ASSERT (Buffer != NULL);\r
+  //\r
+  // Make sure Buffer is aligned on a 64-bit boundary.\r
+  //\r
+  ASSERT (((UINTN) Buffer & 7) == 0);\r
+\r
+  ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));\r
+\r
   GuidPtr = (GUID*)Buffer;\r
   Buffer = GuidPtr + Length / sizeof (*GuidPtr);\r
   while (GuidPtr < (CONST GUID*)Buffer) {\r
index d7d7919ba26a46aa5dabfb8ff71eb0eb9bb0271b..4a3d615ce50839c44ce64259ee4f2314193c74cc 100644 (file)
@@ -43,9 +43,10 @@ VOID *
 EFIAPI\r
 ZeroMem (\r
   IN      VOID                      *Buffer,\r
-  IN      UINTN                     Size\r
+  IN      UINTN                     Length\r
   )\r
 {\r
-  ASSERT (Buffer != NULL);\r
-  return InternalMemSetMem (Buffer, Size, 0);\r
+  ASSERT (!(Buffer == NULL && Length > 0));\r
+  ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));\r
+  return InternalMemSetMem (Buffer, Length, 0);\r
 }\r