• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /** @file
2   Implementation of the EfiSetMem routine. This function is broken
3   out into its own source file so that it can be excluded from a
4   build for a particular platform easily if an optimized version
5   is desired.
6 
7   Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
8   This program and the accompanying materials
9   are licensed and made available under the terms and conditions of the BSD License
10   which accompanies this distribution.  The full text of the license may be found at
11   http://opensource.org/licenses/bsd-license.php
12 
13   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 
16 **/
17 
18 
19 
20 
21 #include "MemLibInternals.h"
22 
23 /**
24   Set Buffer to Value for Size bytes.
25 
26   @param  Buffer   Memory to set.
27   @param  Length   Number of bytes to set
28   @param  Value    Value of the set operation.
29 
30   @return Buffer
31 
32 **/
33 VOID *
34 EFIAPI
InternalMemSetMem(OUT VOID * Buffer,IN UINTN Length,IN UINT8 Value)35 InternalMemSetMem (
36   OUT     VOID                      *Buffer,
37   IN      UINTN                     Length,
38   IN      UINT8                     Value
39   )
40 {
41   //
42   // Declare the local variables that actually move the data elements as
43   // volatile to prevent the optimizer from replacing this function with
44   // the intrinsic memset()
45   //
46   volatile UINT8                    *Pointer;
47 
48   Pointer = (UINT8*)Buffer;
49   while (Length-- > 0) {
50     *(Pointer++) = Value;
51   }
52   return Buffer;
53 }
54