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