1d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish/** @file 2d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish CopyMem() implementation. 3d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish 4d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish The following BaseMemoryLib instances contain the same copy of this file: 53402aac7d985bf8a9f9d3c639f3fe93609380513Ronald Cron 6d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish BaseMemoryLib 7d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish BaseMemoryLibMmx 8d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish BaseMemoryLibSse2 9d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish BaseMemoryLibRepStr 10d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish BaseMemoryLibOptDxe 11d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish BaseMemoryLibOptPei 12d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish PeiMemoryLib 13d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish UefiMemoryLib 14d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish 15d6ebcab76903254f4423b7e7d3808fb0abaadb46hhtian Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR> 16d6ebcab76903254f4423b7e7d3808fb0abaadb46hhtian This program and the accompanying materials 17d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish are licensed and made available under the terms and conditions of the BSD License 18d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish which accompanies this distribution. The full text of the license may be found at 19d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish http://opensource.org/licenses/bsd-license.php 20d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish 21d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 22d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 23d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish 24d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish**/ 25d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish 26d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish#include "MemLibInternals.h" 27d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish 28d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish/** 29d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish Copies a source buffer to a destination buffer, and returns the destination buffer. 30d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish 31d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish This function copies Length bytes from SourceBuffer to DestinationBuffer, and returns 32d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish DestinationBuffer. The implementation must be reentrant, and it must handle the case 33d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish where SourceBuffer overlaps DestinationBuffer. 343402aac7d985bf8a9f9d3c639f3fe93609380513Ronald Cron 35d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT(). 36d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT(). 37d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish 38d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish @param DestinationBuffer Pointer to the destination buffer of the memory copy. 39d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish @param SourceBuffer Pointer to the source buffer of the memory copy. 40d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish @param Length Number of bytes to copy from SourceBuffer to DestinationBuffer. 41d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish 42d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish @return DestinationBuffer. 43d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish 44d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish**/ 45d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfishVOID * 46d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfishEFIAPI 47d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfishCopyMem ( 48d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish OUT VOID *DestinationBuffer, 49d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish IN CONST VOID *SourceBuffer, 50d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish IN UINTN Length 51d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish ) 52d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish{ 53d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish if (Length == 0) { 54d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish return DestinationBuffer; 55d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish } 56d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)DestinationBuffer)); 57d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)SourceBuffer)); 58d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish 59d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish if (DestinationBuffer == SourceBuffer) { 60d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish return DestinationBuffer; 61d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish } 62d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish return InternalMemCopyMem (DestinationBuffer, SourceBuffer, Length); 63d39eb83cc5ce2147264e2ea3566c4dbf7eb9888dandrewfish} 64