]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Add some ldm/vldm optimized CopyMem routines. Add performance macros to BDS
authorandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 21 Apr 2010 22:04:35 +0000 (22:04 +0000)
committerandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 21 Apr 2010 22:04:35 +0000 (22:04 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10388 6f19259b-4bc3-4df7-8a09-765794883524

47 files changed:
ArmPkg/Library/BaseMemoryLibStm/Arm/CopyMem.S [new file with mode: 0755]
ArmPkg/Library/BaseMemoryLibStm/Arm/CopyMem.asm [new file with mode: 0755]
ArmPkg/Library/BaseMemoryLibStm/Arm/SetMem.S [new file with mode: 0755]
ArmPkg/Library/BaseMemoryLibStm/Arm/SetMem.asm [new file with mode: 0755]
ArmPkg/Library/BaseMemoryLibStm/BaseMemoryLibStm.inf [new file with mode: 0755]
ArmPkg/Library/BaseMemoryLibStm/CompareMemWrapper.c [new file with mode: 0755]
ArmPkg/Library/BaseMemoryLibStm/CopyMem.c [new file with mode: 0755]
ArmPkg/Library/BaseMemoryLibStm/CopyMemWrapper.c [new file with mode: 0755]
ArmPkg/Library/BaseMemoryLibStm/MemLibGeneric.c [new file with mode: 0755]
ArmPkg/Library/BaseMemoryLibStm/MemLibGuid.c [new file with mode: 0755]
ArmPkg/Library/BaseMemoryLibStm/MemLibInternals.h [new file with mode: 0755]
ArmPkg/Library/BaseMemoryLibStm/ScanMem16Wrapper.c [new file with mode: 0755]
ArmPkg/Library/BaseMemoryLibStm/ScanMem32Wrapper.c [new file with mode: 0755]
ArmPkg/Library/BaseMemoryLibStm/ScanMem64Wrapper.c [new file with mode: 0755]
ArmPkg/Library/BaseMemoryLibStm/ScanMem8Wrapper.c [new file with mode: 0755]
ArmPkg/Library/BaseMemoryLibStm/SetMem.c [new file with mode: 0755]
ArmPkg/Library/BaseMemoryLibStm/SetMem16Wrapper.c [new file with mode: 0755]
ArmPkg/Library/BaseMemoryLibStm/SetMem32Wrapper.c [new file with mode: 0755]
ArmPkg/Library/BaseMemoryLibStm/SetMem64Wrapper.c [new file with mode: 0755]
ArmPkg/Library/BaseMemoryLibStm/SetMemWrapper.c [new file with mode: 0755]
ArmPkg/Library/BaseMemoryLibStm/ZeroMemWrapper.c [new file with mode: 0755]
ArmPkg/Library/BaseMemoryLibVstm/Arm/CopyMem.S [new file with mode: 0755]
ArmPkg/Library/BaseMemoryLibVstm/Arm/CopyMem.asm [new file with mode: 0755]
ArmPkg/Library/BaseMemoryLibVstm/Arm/SetMem.S [new file with mode: 0755]
ArmPkg/Library/BaseMemoryLibVstm/Arm/SetMem.asm [new file with mode: 0755]
ArmPkg/Library/BaseMemoryLibVstm/BaseMemoryLibVstm.inf [new file with mode: 0755]
ArmPkg/Library/BaseMemoryLibVstm/CompareMemWrapper.c [new file with mode: 0755]
ArmPkg/Library/BaseMemoryLibVstm/CopyMem.c [new file with mode: 0755]
ArmPkg/Library/BaseMemoryLibVstm/CopyMemWrapper.c [new file with mode: 0755]
ArmPkg/Library/BaseMemoryLibVstm/MemLibGeneric.c [new file with mode: 0755]
ArmPkg/Library/BaseMemoryLibVstm/MemLibGuid.c [new file with mode: 0755]
ArmPkg/Library/BaseMemoryLibVstm/MemLibInternals.h [new file with mode: 0755]
ArmPkg/Library/BaseMemoryLibVstm/ScanMem16Wrapper.c [new file with mode: 0755]
ArmPkg/Library/BaseMemoryLibVstm/ScanMem32Wrapper.c [new file with mode: 0755]
ArmPkg/Library/BaseMemoryLibVstm/ScanMem64Wrapper.c [new file with mode: 0755]
ArmPkg/Library/BaseMemoryLibVstm/ScanMem8Wrapper.c [new file with mode: 0755]
ArmPkg/Library/BaseMemoryLibVstm/SetMem.c [new file with mode: 0755]
ArmPkg/Library/BaseMemoryLibVstm/SetMem16Wrapper.c [new file with mode: 0755]
ArmPkg/Library/BaseMemoryLibVstm/SetMem32Wrapper.c [new file with mode: 0755]
ArmPkg/Library/BaseMemoryLibVstm/SetMem64Wrapper.c [new file with mode: 0755]
ArmPkg/Library/BaseMemoryLibVstm/SetMemWrapper.c [new file with mode: 0755]
ArmPkg/Library/BaseMemoryLibVstm/ZeroMemWrapper.c [new file with mode: 0755]
BeagleBoardPkg/Bds/BdsEntry.c
BeagleBoardPkg/Bds/BdsEntry.h
BeagleBoardPkg/Bds/FirmwareVolume.c
BeagleBoardPkg/BeagleBoardPkg.dsc
BeagleBoardPkg/Library/EblCmdLib/EblCmdLib.c

diff --git a/ArmPkg/Library/BaseMemoryLibStm/Arm/CopyMem.S b/ArmPkg/Library/BaseMemoryLibStm/Arm/CopyMem.S
new file mode 100755 (executable)
index 0000000..91a4dfc
--- /dev/null
@@ -0,0 +1,112 @@
+#------------------------------------------------------------------------------ \r
+#\r
+# CopyMem() worker for ARM\r
+#\r
+# This file started out as C code that did 64 bit moves if the buffer was\r
+# 32-bit aligned, else it does a byte copy. It also does a byte copy for\r
+# any trailing bytes. It was updated to do 32-byte copies using stm/ldm. \r
+#\r
+# Copyright (c) 2008-2010 Apple Inc. All rights reserved.<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
+#------------------------------------------------------------------------------\r
+\r
+/**\r
+  Copy Length bytes from Source to Destination. Overlap is OK.\r
+\r
+  This implementation \r
+\r
+  @param  Destination Target of copy\r
+  @param  Source      Place to copy from\r
+  @param  Length      Number of bytes to copy\r
+\r
+  @return Destination\r
+\r
+\r
+VOID *\r
+EFIAPI\r
+InternalMemCopyMem (\r
+  OUT     VOID                      *DestinationBuffer,\r
+  IN      CONST VOID                *SourceBuffer,\r
+  IN      UINTN                     Length\r
+  )\r
+**/\r
+.text\r
+.align 2\r
+.globl ASM_PFX(InternalMemCopyMem)\r
+\r
+ASM_PFX(InternalMemCopyMem):\r
+       stmfd   sp!, {r4-r11, lr}\r
+       tst     r0, #3\r
+       mov     r11, r0\r
+       mov     r10, r0\r
+       mov     ip, r2\r
+       mov     lr, r1\r
+       movne   r0, #0\r
+       bne     L4\r
+       tst     r1, #3\r
+       movne   r3, #0\r
+       moveq   r3, #1\r
+       cmp     r2, #31\r
+       movls   r0, #0\r
+       andhi   r0, r3, #1\r
+L4:\r
+       cmp     r11, r1\r
+       bcc     L26\r
+       bls     L7\r
+       rsb     r3, r1, r11\r
+       cmp     ip, r3\r
+       bcc     L26\r
+       cmp     ip, #0\r
+       beq     L7\r
+       add     r10, r11, ip\r
+       add     lr, ip, r1\r
+       b       L16\r
+L29:\r
+       sub     ip, ip, #8\r
+       cmp     ip, #7\r
+       ldrd    r2, [lr, #-8]!\r
+       movls   r0, #0\r
+       cmp     ip, #0\r
+       strd    r2, [r10, #-8]!\r
+       beq     L7\r
+L16:\r
+       cmp     r0, #0\r
+       bne     L29\r
+       sub     r3, lr, #1\r
+       sub     ip, ip, #1\r
+       ldrb    r3, [r3, #0]    \r
+       sub     r2, r10, #1\r
+       cmp     ip, #0\r
+       sub     r10, r10, #1\r
+       sub     lr, lr, #1\r
+       strb    r3, [r2, #0]\r
+       bne     L16\r
+       b   L7\r
+L11:\r
+       ldrb    r3, [lr], #1    \r
+       sub     ip, ip, #1\r
+       strb    r3, [r10], #1\r
+L26:\r
+       cmp     ip, #0\r
+       beq     L7\r
+L30:\r
+       cmp     r0, #0\r
+       beq     L11\r
+       sub     ip, ip, #32\r
+       cmp     ip, #31\r
+       ldmia   lr!, {r2-r9}\r
+       movls   r0, #0\r
+       cmp     ip, #0\r
+       stmia   r10!, {r2-r9}\r
+       bne     L30\r
+L7:\r
+  mov  r0, r11\r
+       ldmfd   sp!, {r4-r11, pc}\r
+  \r
diff --git a/ArmPkg/Library/BaseMemoryLibStm/Arm/CopyMem.asm b/ArmPkg/Library/BaseMemoryLibStm/Arm/CopyMem.asm
new file mode 100755 (executable)
index 0000000..19b68ee
--- /dev/null
@@ -0,0 +1,114 @@
+;------------------------------------------------------------------------------ \r
+;\r
+; CopyMem() worker for ARM\r
+;\r
+; This file started out as C code that did 64 bit moves if the buffer was\r
+; 32-bit aligned, else it does a byte copy. It also does a byte copy for\r
+; any trailing bytes. It was updated to do 32-byte copies using stm/ldm.\r
+;\r
+; Copyright (c) 2008-2010 Apple Inc. All rights reserved.<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
+;------------------------------------------------------------------------------\r
+\r
+/**\r
+  Copy Length bytes from Source to Destination. Overlap is OK.\r
+\r
+  This implementation \r
+\r
+  @param  Destination Target of copy\r
+  @param  Source      Place to copy from\r
+  @param  Length      Number of bytes to copy\r
+\r
+  @return Destination\r
+\r
+\r
+VOID *\r
+EFIAPI\r
+InternalMemCopyMem (\r
+  OUT     VOID                      *DestinationBuffer,\r
+  IN      CONST VOID                *SourceBuffer,\r
+  IN      UINTN                     Length\r
+  )\r
+**/\r
+       EXPORT InternalMemCopyMem\r
+
+       AREA AsmMemStuff, CODE, READONLY
+\r
+InternalMemCopyMem\r
+       stmfd   sp!, {r4-r11, lr}
+       tst     r0, #3
+       mov     r11, r0
+       mov     r10, r0
+       mov     ip, r2
+       mov     lr, r1
+       movne   r0, #0
+       bne     L4
+       tst     r1, #3
+       movne   r3, #0
+       moveq   r3, #1
+       cmp     r2, #31
+       movls   r0, #0
+       andhi   r0, r3, #1
+L4
+       cmp     r11, r1
+       bcc     L26
+       bls     L7
+       rsb     r3, r1, r11
+       cmp     ip, r3
+       bcc     L26
+       cmp     ip, #0
+       beq     L7
+       add     r10, r11, ip
+       add     lr, ip, r1
+       b       L16
+L29
+       sub     ip, ip, #8
+       cmp     ip, #7
+       ldrd    r2, [lr, #-8]!
+       movls   r0, #0
+       cmp     ip, #0
+       strd    r2, [r10, #-8]!
+       beq     L7
+L16
+       cmp     r0, #0
+       bne     L29
+       sub     r3, lr, #1
+       sub     ip, ip, #1
+       ldrb    r3, [r3, #0]    
+       sub     r2, r10, #1
+       cmp     ip, #0
+       sub     r10, r10, #1
+       sub     lr, lr, #1
+       strb    r3, [r2, #0]
+       bne     L16
+       b   L7
+L11
+       ldrb    r3, [lr], #1    
+       sub     ip, ip, #1
+       strb    r3, [r10], #1
+L26
+       cmp     ip, #0
+       beq     L7
+L30
+       cmp     r0, #0
+       beq     L11
+       sub     ip, ip, #32
+       cmp     ip, #31
+       ldmia   lr!, {r2-r9}
+       movls   r0, #0
+       cmp     ip, #0
+       stmia   r10!, {r2-r9}
+       bne     L30
+L7
+  mov  r0, r11
+       ldmfd   sp!, {r4-r11, pc}\r
+       \r
+  END\r
+  \r
diff --git a/ArmPkg/Library/BaseMemoryLibStm/Arm/SetMem.S b/ArmPkg/Library/BaseMemoryLibStm/Arm/SetMem.S
new file mode 100755 (executable)
index 0000000..0c3697f
--- /dev/null
@@ -0,0 +1,82 @@
+#------------------------------------------------------------------------------ \r
+#\r
+# SemMem() worker for ARM\r
+#\r
+# This file started out as C code that did 64 bit moves if the buffer was\r
+# 32-bit aligned, else it does a byte copy. It also does a byte copy for\r
+# any trailing bytes. It was updated to do 32-byte at a time. \r
+#\r
+# Copyright (c) 2008-2010 Apple Inc. All rights reserved.<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
+#------------------------------------------------------------------------------\r
+\r
+/**\r
+  Set Buffer to Value for Size bytes.\r
+\r
+  @param  Buffer   Memory to set.\r
+  @param  Length   Number of bytes to set\r
+  @param  Value    Value of the set operation.\r
+\r
+  @return Buffer\r
+\r
+VOID *\r
+EFIAPI\r
+InternalMemSetMem (\r
+  OUT     VOID                      *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT8                     Value\r
+  )\r
+**/\r
+       \r
+.text\r
+.align 2\r
+.globl ASM_PFX(InternalMemSetMem)\r
+\r
+ASM_PFX(InternalMemSetMem):\r
+       stmfd   sp!, {r4-r11, lr}\r
+       tst       r0, #3\r
+       movne   r3, #0\r
+       moveq   r3, #1\r
+       cmp       r1, #31\r
+       movls lr, #0\r
+       andhi   lr, r3, #1\r
+       cmp       lr, #0\r
+       mov       r12, r0\r
+       bne       L31\r
+L32:\r
+       mov       r3, #0\r
+       b           L43\r
+L31:\r
+  and   r4, r2, #0xff\r
+  orr   r4, r4, r4, LSL #8\r
+  orr   r4, r4, r4, LSL #16  \r
+       mov   r5, r4\r
+       mov   r5, r4\r
+       mov   r6, r4\r
+       mov   r7, r4 \r
+       mov   r8, r4 \r
+       mov   r9, r4 \r
+       mov   r10, r4 \r
+       mov   r11, r4 \r
+       b           L32\r
+L34:\r
+       cmp         lr, #0\r
+       streqb  r2, [r12], #1\r
+       subeq     r1, r1, #1\r
+       beq         L43\r
+       sub         r1, r1, #32\r
+       cmp         r1, #31\r
+       movls     lr, r3\r
+       stmia     r12!, {r4-r11}\r
+L43:\r
+       cmp         r1, #0\r
+       bne         L34\r
+       ldmfd     sp!, {r4-r11, pc}\r
+       
\ No newline at end of file
diff --git a/ArmPkg/Library/BaseMemoryLibStm/Arm/SetMem.asm b/ArmPkg/Library/BaseMemoryLibStm/Arm/SetMem.asm
new file mode 100755 (executable)
index 0000000..7304f1c
--- /dev/null
@@ -0,0 +1,83 @@
+;------------------------------------------------------------------------------ \r
+;\r
+; SetMem() worker for ARM\r
+;\r
+; This file started out as C code that did 64 bit moves if the buffer was\r
+; 32-bit aligned, else it does a byte copy. It also does a byte copy for\r
+; any trailing bytes. It was updated to do 32-byte at a time.\r
+;\r
+; Copyright (c) 2008-2010 Apple Inc. All rights reserved.<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
+\r
+/**\r
+  Set Buffer to Value for Size bytes.\r
+\r
+  @param  Buffer   Memory to set.\r
+  @param  Length   Number of bytes to set\r
+  @param  Value    Value of the set operation.\r
+\r
+  @return Buffer\r
+\r
+VOID *\r
+EFIAPI\r
+InternalMemSetMem (\r
+  OUT     VOID                      *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT8                     Value\r
+  )\r
+**/\r
+       \r
+       EXPORT InternalMemSetMem\r
+       \r
+       AREA AsmMemStuff, CODE, READONLY\r
+\r
+InternalMemSetMem\r
+       stmfd   sp!, {r4-r11, lr}\r
+       tst       r0, #3\r
+       movne   r3, #0\r
+       moveq   r3, #1\r
+       cmp       r1, #31\r
+       movls lr, #0\r
+       andhi   lr, r3, #1\r
+       cmp       lr, #0\r
+       mov       r12, r0\r
+       bne       L31\r
+L32\r
+       mov       r3, #0\r
+       b           L43\r
+L31\r
+  and   r4, r2, #0xff\r
+  orr   r4, r4, r4, LSL #8\r
+  orr   r4, r4, r4, LSL #16  \r
+       mov   r5, r4\r
+       mov   r5, r4\r
+       mov   r6, r4\r
+       mov   r7, r4 \r
+       mov   r8, r4 \r
+       mov   r9, r4 \r
+       mov   r10, r4 \r
+       mov   r11, r4 \r
+       b           L32\r
+L34\r
+       cmp         lr, #0\r
+       streqb  r2, [r12], #1\r
+       subeq     r1, r1, #1\r
+       beq         L43\r
+       sub         r1, r1, #32\r
+       cmp         r1, #31\r
+       movls     lr, r3\r
+       stmia     r12!, {r4-r11}\r
+L43\r
+       cmp         r1, #0\r
+       bne         L34\r
+       ldmfd     sp!, {r4-r11, pc}\r
+       \r
+  END\r
+  
\ No newline at end of file
diff --git a/ArmPkg/Library/BaseMemoryLibStm/BaseMemoryLibStm.inf b/ArmPkg/Library/BaseMemoryLibStm/BaseMemoryLibStm.inf
new file mode 100755 (executable)
index 0000000..15e15c8
--- /dev/null
@@ -0,0 +1,62 @@
+## @file\r
+#  Instance of Base Memory Library with some ARM ldm/stm assembly.\r
+#\r
+#  This is a copy of the MdePkg BaseMemoryLib with the CopyMem and \r
+#  SetMem worker functions replaced with assembler that uses \r
+#  ldm/stm.\r
+#\r
+#  Copyright (c) 2007 - 2010, Intel Corporation.\r
+#  Portions Copyright (c) 2010, Apple, Inc. All rights reserved.\r
+#\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
+#  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
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = BaseMemoryLibStm\r
+  FILE_GUID                      = 4D466AF3-2380-448D-A337-E4033F29F3F7\r
+  MODULE_TYPE                    = BASE\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = BaseMemoryLib \r
+\r
+\r
+#\r
+#  VALID_ARCHITECTURES           = ARM\r
+#\r
+\r
+\r
+[Sources.ARM]\r
+  ScanMem64Wrapper.c\r
+  ScanMem32Wrapper.c\r
+  ScanMem16Wrapper.c\r
+  ScanMem8Wrapper.c\r
+  ZeroMemWrapper.c\r
+  CompareMemWrapper.c\r
+  SetMem64Wrapper.c\r
+  SetMem32Wrapper.c\r
+  SetMem16Wrapper.c\r
+  SetMemWrapper.c\r
+  CopyMemWrapper.c\r
+  MemLibGeneric.c\r
+  MemLibGuid.c  \r
+  MemLibInternals.h\r
+  Arm/CopyMem.asm\r
+  Arm/CopyMem.S\r
+  Arm/SetMem.asm\r
+  Arm/SetMem.S\r
+\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+\r
+[LibraryClasses]\r
+  DebugLib\r
+  BaseLib\r
+\r
diff --git a/ArmPkg/Library/BaseMemoryLibStm/CompareMemWrapper.c b/ArmPkg/Library/BaseMemoryLibStm/CompareMemWrapper.c
new file mode 100755 (executable)
index 0000000..278ef33
--- /dev/null
@@ -0,0 +1,66 @@
+/** @file\r
+  CompareMem() implementation.\r
+\r
+  The following BaseMemoryLib instances contain the same copy of this file:\r
+    BaseMemoryLib\r
+    BaseMemoryLibMmx\r
+    BaseMemoryLibSse2\r
+    BaseMemoryLibRepStr\r
+    BaseMemoryLibOptDxe\r
+    BaseMemoryLibOptPei\r
+    PeiMemoryLib\r
+    UefiMemoryLib\r
+\r
+Copyright (c) 2006 - 2009, 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
+**/\r
+\r
+#include "MemLibInternals.h"\r
+\r
+/**\r
+  Compares the contents of two buffers.\r
+\r
+  This function compares Length bytes of SourceBuffer to Length bytes of DestinationBuffer.\r
+  If all Length bytes of the two buffers are identical, then 0 is returned.  Otherwise, the\r
+  value returned is the first mismatched byte in SourceBuffer subtracted from the first\r
+  mismatched byte in DestinationBuffer.\r
+  \r
+  If Length > 0 and DestinationBuffer is NULL, then ASSERT().\r
+  If Length > 0 and SourceBuffer is NULL, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT().\r
+\r
+  @param  DestinationBuffer Pointer to the destination buffer to compare.\r
+  @param  SourceBuffer      Pointer to the source buffer to compare.\r
+  @param  Length            Number of bytes to compare.\r
+\r
+  @return 0                 All Length bytes of the two buffers are identical.\r
+  @retval Non-zero          The first mismatched byte in SourceBuffer subtracted from the first\r
+                            mismatched byte in DestinationBuffer.\r
+                            \r
+**/\r
+INTN\r
+EFIAPI\r
+CompareMem (\r
+  IN CONST VOID  *DestinationBuffer,\r
+  IN CONST VOID  *SourceBuffer,\r
+  IN UINTN       Length\r
+  )\r
+{\r
+  if (Length == 0 || DestinationBuffer == SourceBuffer) {\r
+    return 0;\r
+  }\r
+  ASSERT (DestinationBuffer != NULL);\r
+  ASSERT (SourceBuffer != NULL);\r
+  ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)DestinationBuffer));\r
+  ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)SourceBuffer));\r
+\r
+  return InternalMemCompareMem (DestinationBuffer, SourceBuffer, Length);\r
+}\r
diff --git a/ArmPkg/Library/BaseMemoryLibStm/CopyMem.c b/ArmPkg/Library/BaseMemoryLibStm/CopyMem.c
new file mode 100755 (executable)
index 0000000..aa2ffea
--- /dev/null
@@ -0,0 +1,62 @@
+/** @file\r
+  Implementation of the InternalMemCopyMem routine. This function is broken\r
+  out into its own source file so that it can be excluded from a build for a\r
+  particular platform easily if an optimized version is desired.\r
+\r
+  Copyright (c) 2006 - 2008, 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
+**/\r
+\r
+\r
+\r
+\r
+#include "MemLibInternals.h"\r
+\r
+/**\r
+  Copy Length bytes from Source to Destination.\r
+\r
+  @param  DestinationBuffer Target of copy\r
+  @param  SourceBuffer      Place to copy from\r
+  @param  Length            Number of bytes to copy\r
+\r
+  @return Destination\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InternalMemCopyMem (\r
+  OUT     VOID                      *DestinationBuffer,\r
+  IN      CONST VOID                *SourceBuffer,\r
+  IN      UINTN                     Length\r
+  )\r
+{\r
+  //\r
+  // Declare the local variables that actually move the data elements as\r
+  // volatile to prevent the optimizer from replacing this function with\r
+  // the intrinsic memcpy()\r
+  //\r
+  volatile UINT8                    *Destination8;\r
+  CONST UINT8                       *Source8;\r
+\r
+  if (SourceBuffer > DestinationBuffer) {\r
+    Destination8 = (UINT8*)DestinationBuffer;\r
+    Source8 = (CONST UINT8*)SourceBuffer;\r
+    while (Length-- != 0) {\r
+      *(Destination8++) = *(Source8++);\r
+    }\r
+  } else if (SourceBuffer < DestinationBuffer) {\r
+    Destination8 = (UINT8*)DestinationBuffer + Length;\r
+    Source8 = (CONST UINT8*)SourceBuffer + Length;\r
+    while (Length-- != 0) {\r
+      *(--Destination8) = *(--Source8);\r
+    }\r
+  }\r
+  return DestinationBuffer;\r
+}\r
diff --git a/ArmPkg/Library/BaseMemoryLibStm/CopyMemWrapper.c b/ArmPkg/Library/BaseMemoryLibStm/CopyMemWrapper.c
new file mode 100755 (executable)
index 0000000..5077820
--- /dev/null
@@ -0,0 +1,63 @@
+/** @file\r
+  CopyMem() implementation.\r
+\r
+  The following BaseMemoryLib instances contain the same copy of this file:\r
+  \r
+    BaseMemoryLib\r
+    BaseMemoryLibMmx\r
+    BaseMemoryLibSse2\r
+    BaseMemoryLibRepStr\r
+    BaseMemoryLibOptDxe\r
+    BaseMemoryLibOptPei\r
+    PeiMemoryLib\r
+    UefiMemoryLib\r
+\r
+  Copyright (c) 2006 - 2009, 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
+**/\r
+\r
+#include "MemLibInternals.h"\r
+\r
+/**\r
+  Copies a source buffer to a destination buffer, and returns the destination buffer.\r
+\r
+  This function copies Length bytes from SourceBuffer to DestinationBuffer, and returns\r
+  DestinationBuffer.  The implementation must be reentrant, and it must handle the case\r
+  where SourceBuffer overlaps DestinationBuffer.\r
+  \r
+  If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT().\r
+\r
+  @param  DestinationBuffer   Pointer to the destination buffer of the memory copy.\r
+  @param  SourceBuffer        Pointer to the source buffer of the memory copy.\r
+  @param  Length              Number of bytes to copy from SourceBuffer to DestinationBuffer.\r
+\r
+  @return DestinationBuffer.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+CopyMem (\r
+  OUT VOID       *DestinationBuffer,\r
+  IN CONST VOID  *SourceBuffer,\r
+  IN UINTN       Length\r
+  )\r
+{\r
+  if (Length == 0) {\r
+    return DestinationBuffer;\r
+  }\r
+  ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)DestinationBuffer));\r
+  ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)SourceBuffer));\r
+\r
+  if (DestinationBuffer == SourceBuffer) {\r
+    return DestinationBuffer;\r
+  }\r
+  return InternalMemCopyMem (DestinationBuffer, SourceBuffer, Length);\r
+}\r
diff --git a/ArmPkg/Library/BaseMemoryLibStm/MemLibGeneric.c b/ArmPkg/Library/BaseMemoryLibStm/MemLibGeneric.c
new file mode 100755 (executable)
index 0000000..e9e0f17
--- /dev/null
@@ -0,0 +1,260 @@
+/** @file\r
+  Architecture Independent Base Memory Library Implementation.\r
+\r
+  The following BaseMemoryLib instances contain the same copy of this file:\r
+    BaseMemoryLib\r
+    PeiMemoryLib\r
+    UefiMemoryLib\r
+\r
+  Copyright (c) 2006 - 2009, 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
+**/\r
+\r
+#include "MemLibInternals.h"\r
+\r
+/**\r
+  Fills a target buffer with a 16-bit value, and returns the target buffer.\r
+\r
+  @param  Buffer  Pointer to the target buffer to fill.\r
+  @param  Length  Count of 16-bit value to fill.\r
+  @param  Value   Value with which to fill Length bytes of Buffer.\r
+\r
+  @return Buffer\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InternalMemSetMem16 (\r
+  OUT     VOID                      *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT16                    Value\r
+  )\r
+{\r
+  do {\r
+    ((UINT16*)Buffer)[--Length] = Value;\r
+  } while (Length != 0);\r
+  return Buffer;\r
+}\r
+\r
+/**\r
+  Fills a target buffer with a 32-bit value, and returns the target buffer.\r
+\r
+  @param  Buffer  Pointer to the target buffer to fill.\r
+  @param  Length  Count of 32-bit value to fill.\r
+  @param  Value   Value with which to fill Length bytes of Buffer.\r
+\r
+  @return Buffer\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InternalMemSetMem32 (\r
+  OUT     VOID                      *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT32                    Value\r
+  )\r
+{\r
+  do {\r
+    ((UINT32*)Buffer)[--Length] = Value;\r
+  } while (Length != 0);\r
+  return Buffer;\r
+}\r
+\r
+/**\r
+  Fills a target buffer with a 64-bit value, and returns the target buffer.\r
+\r
+  @param  Buffer  Pointer to the target buffer to fill.\r
+  @param  Length  Count of 64-bit value to fill.\r
+  @param  Value   Value with which to fill Length bytes of Buffer.\r
+\r
+  @return Buffer\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InternalMemSetMem64 (\r
+  OUT     VOID                      *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT64                    Value\r
+  )\r
+{\r
+  do {\r
+    ((UINT64*)Buffer)[--Length] = Value;\r
+  } while (Length != 0);\r
+  return Buffer;\r
+}\r
+\r
+/**\r
+  Set Buffer to 0 for Size bytes.\r
+\r
+  @param  Buffer Memory to set.\r
+  @param  Length Number of bytes to set\r
+\r
+  @return Buffer\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InternalMemZeroMem (\r
+  OUT     VOID                      *Buffer,\r
+  IN      UINTN                     Length\r
+  )\r
+{\r
+  return InternalMemSetMem (Buffer, Length, 0);\r
+}\r
+\r
+/**\r
+  Compares two memory buffers of a given length.\r
+\r
+  @param  DestinationBuffer First memory buffer\r
+  @param  SourceBuffer      Second memory buffer\r
+  @param  Length            Length of DestinationBuffer and SourceBuffer memory\r
+                            regions to compare. Must be non-zero.\r
+\r
+  @return 0                 All Length bytes of the two buffers are identical.\r
+  @retval Non-zero          The first mismatched byte in SourceBuffer subtracted from the first\r
+                            mismatched byte in DestinationBuffer.\r
+\r
+**/\r
+INTN\r
+EFIAPI\r
+InternalMemCompareMem (\r
+  IN      CONST VOID                *DestinationBuffer,\r
+  IN      CONST VOID                *SourceBuffer,\r
+  IN      UINTN                     Length\r
+  )\r
+{\r
+  while ((--Length != 0) &&\r
+         (*(INT8*)DestinationBuffer == *(INT8*)SourceBuffer)) {\r
+    DestinationBuffer = (INT8*)DestinationBuffer + 1;\r
+    SourceBuffer = (INT8*)SourceBuffer + 1;\r
+  }\r
+  return (INTN)*(UINT8*)DestinationBuffer - (INTN)*(UINT8*)SourceBuffer;\r
+}\r
+\r
+/**\r
+  Scans a target buffer for an 8-bit value, and returns a pointer to the\r
+  matching 8-bit value in the target buffer.\r
+\r
+  @param  Buffer  Pointer to the target buffer to scan.\r
+  @param  Length  Count of 8-bit value to scan. Must be non-zero.\r
+  @param  Value   Value to search for in the target buffer.\r
+\r
+  @return Pointer to the first occurrence or NULL if not found.\r
+\r
+**/\r
+CONST VOID *\r
+EFIAPI\r
+InternalMemScanMem8 (\r
+  IN      CONST VOID                *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT8                     Value\r
+  )\r
+{\r
+  CONST UINT8                       *Pointer;\r
+\r
+  Pointer = (CONST UINT8*)Buffer;\r
+  do {\r
+    if (*(Pointer++) == Value) {\r
+      return Pointer;\r
+    }\r
+  } while (--Length != 0);\r
+  return NULL;\r
+}\r
+\r
+/**\r
+  Scans a target buffer for a 16-bit value, and returns a pointer to the\r
+  matching 16-bit value in the target buffer.\r
+\r
+  @param  Buffer  Pointer to the target buffer to scan.\r
+  @param  Length  Count of 16-bit value to scan. Must be non-zero.\r
+  @param  Value   Value to search for in the target buffer.\r
+\r
+  @return Pointer to the first occurrence or NULL if not found.\r
+\r
+**/\r
+CONST VOID *\r
+EFIAPI\r
+InternalMemScanMem16 (\r
+  IN      CONST VOID                *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT16                    Value\r
+  )\r
+{\r
+  CONST UINT16                      *Pointer;\r
+\r
+  Pointer = (CONST UINT16*)Buffer;\r
+  do {\r
+    if (*(Pointer++) == Value) {\r
+      return Pointer;\r
+    }\r
+  } while (--Length != 0);\r
+  return NULL;\r
+}\r
+\r
+/**\r
+  Scans a target buffer for a 32-bit value, and returns a pointer to the\r
+  matching 32-bit value in the target buffer.\r
+\r
+  @param  Buffer  Pointer to the target buffer to scan.\r
+  @param  Length  Count of 32-bit value to scan. Must be non-zero.\r
+  @param  Value   Value to search for in the target buffer.\r
+\r
+  @return Pointer to the first occurrence or NULL if not found.\r
+\r
+**/\r
+CONST VOID *\r
+EFIAPI\r
+InternalMemScanMem32 (\r
+  IN      CONST VOID                *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT32                    Value\r
+  )\r
+{\r
+  CONST UINT32                      *Pointer;\r
+\r
+  Pointer = (CONST UINT32*)Buffer;\r
+  do {\r
+    if (*(Pointer++) == Value) {\r
+      return Pointer;\r
+    }\r
+  } while (--Length != 0);\r
+  return NULL;\r
+}\r
+\r
+/**\r
+  Scans a target buffer for a 64-bit value, and returns a pointer to the\r
+  matching 64-bit value in the target buffer.\r
+\r
+  @param  Buffer  Pointer to the target buffer to scan.\r
+  @param  Length  Count of 64-bit value to scan. Must be non-zero.\r
+  @param  Value   Value to search for in the target buffer.\r
+\r
+  @return Pointer to the first occurrence or NULL if not found.\r
+\r
+**/\r
+CONST VOID *\r
+EFIAPI\r
+InternalMemScanMem64 (\r
+  IN      CONST VOID                *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT64                    Value\r
+  )\r
+{\r
+  CONST UINT64                      *Pointer;\r
+\r
+  Pointer = (CONST UINT64*)Buffer;\r
+  do {\r
+    if (*(Pointer++) == Value) {\r
+      return Pointer;\r
+    }\r
+  } while (--Length != 0);\r
+  return NULL;\r
+}\r
diff --git a/ArmPkg/Library/BaseMemoryLibStm/MemLibGuid.c b/ArmPkg/Library/BaseMemoryLibStm/MemLibGuid.c
new file mode 100755 (executable)
index 0000000..7373410
--- /dev/null
@@ -0,0 +1,142 @@
+/** @file\r
+  Implementation of GUID functions.\r
+\r
+  The following BaseMemoryLib instances contain the same copy of this file:\r
+  \r
+    BaseMemoryLib\r
+    BaseMemoryLibMmx\r
+    BaseMemoryLibSse2\r
+    BaseMemoryLibRepStr\r
+    BaseMemoryLibOptDxe\r
+    BaseMemoryLibOptPei\r
+    PeiMemoryLib\r
+    UefiMemoryLib\r
+\r
+  Copyright (c) 2006 - 2009, 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
+**/\r
+\r
+#include "MemLibInternals.h"\r
+\r
+/**\r
+  Copies a source GUID to a destination GUID.\r
+\r
+  This function copies the contents of the 128-bit GUID specified by SourceGuid to\r
+  DestinationGuid, and returns DestinationGuid.\r
+  \r
+  If DestinationGuid is NULL, then ASSERT().\r
+  If SourceGuid is NULL, then ASSERT().\r
+\r
+  @param  DestinationGuid   Pointer to the destination GUID.\r
+  @param  SourceGuid        Pointer to the source GUID.\r
+\r
+  @return DestinationGuid.\r
+\r
+**/\r
+GUID *\r
+EFIAPI\r
+CopyGuid (\r
+  OUT GUID       *DestinationGuid,\r
+  IN CONST GUID  *SourceGuid\r
+  )\r
+{\r
+  WriteUnaligned64 (\r
+    (UINT64*)DestinationGuid,\r
+    ReadUnaligned64 ((CONST UINT64*)SourceGuid)\r
+    );\r
+  WriteUnaligned64 (\r
+    (UINT64*)DestinationGuid + 1,\r
+    ReadUnaligned64 ((CONST UINT64*)SourceGuid + 1)\r
+    );\r
+  return DestinationGuid;\r
+}\r
+\r
+/**\r
+  Compares two GUIDs.\r
+\r
+  This function compares Guid1 to Guid2.  If the GUIDs are identical then TRUE is returned.\r
+  If there are any bit differences in the two GUIDs, then FALSE is returned.\r
+  \r
+  If Guid1 is NULL, then ASSERT().\r
+  If Guid2 is NULL, then ASSERT().\r
+\r
+  @param  Guid1       A pointer to a 128 bit GUID.\r
+  @param  Guid2       A pointer to a 128 bit GUID.\r
+\r
+  @retval TRUE        Guid1 and Guid2 are identical.\r
+  @retval FALSE       Guid1 and Guid2 are not identical.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+CompareGuid (\r
+  IN CONST GUID  *Guid1,\r
+  IN CONST GUID  *Guid2\r
+  )\r
+{\r
+  UINT64  LowPartOfGuid1;\r
+  UINT64  LowPartOfGuid2;\r
+  UINT64  HighPartOfGuid1;\r
+  UINT64  HighPartOfGuid2;\r
+\r
+  LowPartOfGuid1  = ReadUnaligned64 ((CONST UINT64*) Guid1);\r
+  LowPartOfGuid2  = ReadUnaligned64 ((CONST UINT64*) Guid2);\r
+  HighPartOfGuid1 = ReadUnaligned64 ((CONST UINT64*) Guid1 + 1);\r
+  HighPartOfGuid2 = ReadUnaligned64 ((CONST UINT64*) Guid2 + 1);\r
+\r
+  return (BOOLEAN) (LowPartOfGuid1 == LowPartOfGuid2 && HighPartOfGuid1 == HighPartOfGuid2);\r
+}\r
+\r
+/**\r
+  Scans a target buffer for a GUID, and returns a pointer to the matching GUID\r
+  in the target buffer.\r
+\r
+  This function searches the target buffer specified by Buffer and Length from\r
+  the lowest address to the highest address at 128-bit increments for the 128-bit\r
+  GUID value that matches Guid.  If a match is found, then a pointer to the matching\r
+  GUID in the target buffer is returned.  If no match is found, then NULL is returned.\r
+  If Length is 0, then NULL is returned.\r
+  \r
+  If Length > 0 and Buffer is NULL, then ASSERT().\r
+  If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r
+  If Length is not aligned on a 128-bit boundary, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+\r
+  @param  Buffer  Pointer to the target buffer to scan.\r
+  @param  Length  Number of bytes in Buffer to scan.\r
+  @param  Guid    Value to search for in the target buffer.\r
+\r
+  @return A pointer to the matching Guid in the target buffer or NULL otherwise.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+ScanGuid (\r
+  IN CONST VOID  *Buffer,\r
+  IN UINTN       Length,\r
+  IN CONST GUID  *Guid\r
+  )\r
+{\r
+  CONST GUID                        *GuidPtr;\r
+\r
+  ASSERT (((UINTN)Buffer & (sizeof (Guid->Data1) - 1)) == 0);\r
+  ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));\r
+  ASSERT ((Length & (sizeof (*GuidPtr) - 1)) == 0);\r
+\r
+  GuidPtr = (GUID*)Buffer;\r
+  Buffer  = GuidPtr + Length / sizeof (*GuidPtr);\r
+  while (GuidPtr < (CONST GUID*)Buffer) {\r
+    if (CompareGuid (GuidPtr, Guid)) {\r
+      return (VOID*)GuidPtr;\r
+    }\r
+    GuidPtr++;\r
+  }\r
+  return NULL;\r
+}\r
diff --git a/ArmPkg/Library/BaseMemoryLibStm/MemLibInternals.h b/ArmPkg/Library/BaseMemoryLibStm/MemLibInternals.h
new file mode 100755 (executable)
index 0000000..f40299b
--- /dev/null
@@ -0,0 +1,234 @@
+/** @file\r
+  Declaration of internal functions for Base Memory Library.\r
+\r
+  The following BaseMemoryLib instances contain the same copy of this file:\r
+    BaseMemoryLib\r
+    BaseMemoryLibMmx\r
+    BaseMemoryLibSse2\r
+    BaseMemoryLibRepStr\r
+    BaseMemoryLibOptDxe\r
+    BaseMemoryLibOptPei\r
+\r
+  Copyright (c) 2006 - 2009, 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
+**/\r
+\r
+#ifndef __MEM_LIB_INTERNALS__\r
+#define __MEM_LIB_INTERNALS__\r
+\r
+#include <Base.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/DebugLib.h>\r
+\r
+/**\r
+  Copy Length bytes from Source to Destination.\r
+\r
+  @param  DestinationBuffer Target of copy\r
+  @param  SourceBuffer      Place to copy from\r
+  @param  Length            Number of bytes to copy\r
+\r
+  @return Destination\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InternalMemCopyMem (\r
+  OUT     VOID                      *DestinationBuffer,\r
+  IN      CONST VOID                *SourceBuffer,\r
+  IN      UINTN                     Length\r
+  );\r
+\r
+/**\r
+  Set Buffer to Value for Size bytes.\r
+\r
+  @param  Buffer   Memory to set.\r
+  @param  Length   Number of bytes to set\r
+  @param  Value    Value of the set operation.\r
+\r
+  @return Buffer\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InternalMemSetMem (\r
+  OUT     VOID                      *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT8                     Value\r
+  );\r
+\r
+/**\r
+  Fills a target buffer with a 16-bit value, and returns the target buffer.\r
+\r
+  @param  Buffer  Pointer to the target buffer to fill.\r
+  @param  Length  Count of 16-bit value to fill.\r
+  @param  Value   Value with which to fill Length bytes of Buffer.\r
+\r
+  @return Buffer\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InternalMemSetMem16 (\r
+  OUT     VOID                      *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT16                    Value\r
+  );\r
+\r
+/**\r
+  Fills a target buffer with a 32-bit value, and returns the target buffer.\r
+\r
+  @param  Buffer  Pointer to the target buffer to fill.\r
+  @param  Length  Count of 32-bit value to fill.\r
+  @param  Value   Value with which to fill Length bytes of Buffer.\r
+\r
+  @return Buffer\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InternalMemSetMem32 (\r
+  OUT     VOID                      *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT32                    Value\r
+  );\r
+\r
+/**\r
+  Fills a target buffer with a 64-bit value, and returns the target buffer.\r
+\r
+  @param  Buffer  Pointer to the target buffer to fill.\r
+  @param  Length  Count of 64-bit value to fill.\r
+  @param  Value   Value with which to fill Length bytes of Buffer.\r
+\r
+  @return Buffer\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InternalMemSetMem64 (\r
+  OUT     VOID                      *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT64                    Value\r
+  );\r
+\r
+/**\r
+  Set Buffer to 0 for Size bytes.\r
+\r
+  @param  Buffer Memory to set.\r
+  @param  Length Number of bytes to set\r
+\r
+  @return Buffer\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InternalMemZeroMem (\r
+  OUT     VOID                      *Buffer,\r
+  IN      UINTN                     Length\r
+  );\r
+\r
+/**\r
+  Compares two memory buffers of a given length.\r
+\r
+  @param  DestinationBuffer First memory buffer\r
+  @param  SourceBuffer      Second memory buffer\r
+  @param  Length            Length of DestinationBuffer and SourceBuffer memory\r
+                            regions to compare. Must be non-zero.\r
+\r
+  @return 0                 All Length bytes of the two buffers are identical.\r
+  @retval Non-zero          The first mismatched byte in SourceBuffer subtracted from the first\r
+                            mismatched byte in DestinationBuffer.\r
+\r
+**/\r
+INTN\r
+EFIAPI\r
+InternalMemCompareMem (\r
+  IN      CONST VOID                *DestinationBuffer,\r
+  IN      CONST VOID                *SourceBuffer,\r
+  IN      UINTN                     Length\r
+  );\r
+\r
+/**\r
+  Scans a target buffer for an 8-bit value, and returns a pointer to the\r
+  matching 8-bit value in the target buffer.\r
+\r
+  @param  Buffer  Pointer to the target buffer to scan.\r
+  @param  Length  Count of 8-bit value to scan. Must be non-zero.\r
+  @param  Value   Value to search for in the target buffer.\r
+\r
+  @return Pointer to the first occurrence or NULL if not found.\r
+\r
+**/\r
+CONST VOID *\r
+EFIAPI\r
+InternalMemScanMem8 (\r
+  IN      CONST VOID                *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT8                     Value\r
+  );\r
+\r
+/**\r
+  Scans a target buffer for a 16-bit value, and returns a pointer to the\r
+  matching 16-bit value in the target buffer.\r
+\r
+  @param  Buffer  Pointer to the target buffer to scan.\r
+  @param  Length  Count of 16-bit value to scan. Must be non-zero.\r
+  @param  Value   Value to search for in the target buffer.\r
+\r
+  @return Pointer to the first occurrence or NULL if not found.\r
+\r
+**/\r
+CONST VOID *\r
+EFIAPI\r
+InternalMemScanMem16 (\r
+  IN      CONST VOID                *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT16                    Value\r
+  );\r
+\r
+/**\r
+  Scans a target buffer for a 32-bit value, and returns a pointer to the\r
+  matching 32-bit value in the target buffer.\r
+\r
+  @param  Buffer  Pointer to the target buffer to scan.\r
+  @param  Length  Count of 32-bit value to scan. Must be non-zero.\r
+  @param  Value   Value to search for in the target buffer.\r
+\r
+  @return Pointer to the first occurrence or NULL if not found.\r
+\r
+**/\r
+CONST VOID *\r
+EFIAPI\r
+InternalMemScanMem32 (\r
+  IN      CONST VOID                *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT32                    Value\r
+  );\r
+\r
+/**\r
+  Scans a target buffer for a 64-bit value, and returns a pointer to the\r
+  matching 64-bit value in the target buffer.\r
+\r
+  @param  Buffer  Pointer to the target buffer to scan.\r
+  @param  Length  Count of 64-bit value to scan. Must be non-zero.\r
+  @param  Value   Value to search for in the target buffer.\r
+\r
+  @return Pointer to the first occurrence or NULL if not found.\r
+\r
+**/\r
+CONST VOID *\r
+EFIAPI\r
+InternalMemScanMem64 (\r
+  IN      CONST VOID                *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT64                    Value\r
+  );\r
+\r
+#endif\r
diff --git a/ArmPkg/Library/BaseMemoryLibStm/ScanMem16Wrapper.c b/ArmPkg/Library/BaseMemoryLibStm/ScanMem16Wrapper.c
new file mode 100755 (executable)
index 0000000..1122fb5
--- /dev/null
@@ -0,0 +1,67 @@
+/** @file\r
+  ScanMem16() implementation.\r
+\r
+  The following BaseMemoryLib instances contain the same copy of this file:\r
+\r
+    BaseMemoryLib\r
+    BaseMemoryLibMmx\r
+    BaseMemoryLibSse2\r
+    BaseMemoryLibRepStr\r
+    BaseMemoryLibOptDxe\r
+    BaseMemoryLibOptPei\r
+    PeiMemoryLib\r
+    UefiMemoryLib\r
+\r
+  Copyright (c) 2006 - 2009, 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
+**/\r
+\r
+#include "MemLibInternals.h"\r
+\r
+/**\r
+  Scans a target buffer for a 16-bit value, and returns a pointer to the matching 16-bit value\r
+  in the target buffer.\r
+\r
+  This function searches the target buffer specified by Buffer and Length from the lowest\r
+  address to the highest address for a 16-bit value that matches Value.  If a match is found,\r
+  then a pointer to the matching byte in the target buffer is returned.  If no match is found,\r
+  then NULL is returned.  If Length is 0, then NULL is returned.\r
+  \r
+  If Length > 0 and Buffer is NULL, then ASSERT().\r
+  If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r
+  If Length is not aligned on a 16-bit boundary, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+\r
+  @param  Buffer      Pointer to the target buffer to scan.\r
+  @param  Length      Number of bytes in Buffer to scan.\r
+  @param  Value       Value to search for in the target buffer.\r
+\r
+  @return A pointer to the matching byte in the target buffer or NULL otherwise.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+ScanMem16 (\r
+  IN CONST VOID  *Buffer,\r
+  IN UINTN       Length,\r
+  IN UINT16      Value\r
+  )\r
+{\r
+  if (Length == 0) {\r
+    return NULL;\r
+  }\r
+\r
+  ASSERT (Buffer != NULL);\r
+  ASSERT (((UINTN)Buffer & (sizeof (Value) - 1)) == 0);\r
+  ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));\r
+  ASSERT ((Length & (sizeof (Value) - 1)) == 0);\r
+\r
+  return (VOID*)InternalMemScanMem16 (Buffer, Length / sizeof (Value), Value);\r
+}\r
diff --git a/ArmPkg/Library/BaseMemoryLibStm/ScanMem32Wrapper.c b/ArmPkg/Library/BaseMemoryLibStm/ScanMem32Wrapper.c
new file mode 100755 (executable)
index 0000000..60d5eff
--- /dev/null
@@ -0,0 +1,66 @@
+/** @file\r
+  ScanMem32() implementation.\r
+\r
+  The following BaseMemoryLib instances contain the same copy of this file:\r
+    BaseMemoryLib\r
+    BaseMemoryLibMmx\r
+    BaseMemoryLibSse2\r
+    BaseMemoryLibRepStr\r
+    BaseMemoryLibOptDxe\r
+    BaseMemoryLibOptPei\r
+    PeiMemoryLib\r
+    UefiMemoryLib\r
+\r
+  Copyright (c) 2006 - 2009, 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
+**/\r
+\r
+#include "MemLibInternals.h"\r
+\r
+/**\r
+  Scans a target buffer for a 32-bit value, and returns a pointer to the matching 32-bit value\r
+  in the target buffer.\r
+\r
+  This function searches the target buffer specified by Buffer and Length from the lowest\r
+  address to the highest address for a 32-bit value that matches Value.  If a match is found,\r
+  then a pointer to the matching byte in the target buffer is returned.  If no match is found,\r
+  then NULL is returned.  If Length is 0, then NULL is returned.\r
+  \r
+  If Length > 0 and Buffer is NULL, then ASSERT().\r
+  If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r
+  If Length is not aligned on a 32-bit boundary, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+\r
+  @param  Buffer      Pointer to the target buffer to scan.\r
+  @param  Length      Number of bytes in Buffer to scan.\r
+  @param  Value       Value to search for in the target buffer.\r
+\r
+  @return A pointer to the matching byte in the target buffer or NULL otherwise.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+ScanMem32 (\r
+  IN CONST VOID  *Buffer,\r
+  IN UINTN       Length,\r
+  IN UINT32      Value\r
+  )\r
+{\r
+  if (Length == 0) {\r
+    return NULL;\r
+  }\r
+\r
+  ASSERT (Buffer != NULL);\r
+  ASSERT (((UINTN)Buffer & (sizeof (Value) - 1)) == 0);\r
+  ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));\r
+  ASSERT ((Length & (sizeof (Value) - 1)) == 0);\r
+\r
+  return (VOID*)InternalMemScanMem32 (Buffer, Length / sizeof (Value), Value);\r
+}\r
diff --git a/ArmPkg/Library/BaseMemoryLibStm/ScanMem64Wrapper.c b/ArmPkg/Library/BaseMemoryLibStm/ScanMem64Wrapper.c
new file mode 100755 (executable)
index 0000000..87d1643
--- /dev/null
@@ -0,0 +1,67 @@
+/** @file\r
+  ScanMem64() implementation.\r
+\r
+  The following BaseMemoryLib instances contain the same copy of this file:\r
+\r
+    BaseMemoryLib\r
+    BaseMemoryLibMmx\r
+    BaseMemoryLibSse2\r
+    BaseMemoryLibRepStr\r
+    BaseMemoryLibOptDxe\r
+    BaseMemoryLibOptPei\r
+    PeiMemoryLib\r
+    UefiMemoryLib\r
+\r
+  Copyright (c) 2006 - 2009, 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
+**/\r
+\r
+#include "MemLibInternals.h"\r
+\r
+/**\r
+  Scans a target buffer for a 64-bit value, and returns a pointer to the matching 64-bit value\r
+  in the target buffer.\r
+\r
+  This function searches the target buffer specified by Buffer and Length from the lowest\r
+  address to the highest address for a 64-bit value that matches Value.  If a match is found,\r
+  then a pointer to the matching byte in the target buffer is returned.  If no match is found,\r
+  then NULL is returned.  If Length is 0, then NULL is returned.\r
+  \r
+  If Length > 0 and Buffer is NULL, then ASSERT().\r
+  If Buffer is not aligned on a 64-bit boundary, then ASSERT().\r
+  If Length is not aligned on a 64-bit boundary, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+\r
+  @param  Buffer      Pointer to the target buffer to scan.\r
+  @param  Length      Number of bytes in Buffer to scan.\r
+  @param  Value       Value to search for in the target buffer.\r
+\r
+  @return A pointer to the matching byte in the target buffer or NULL otherwise.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+ScanMem64 (\r
+  IN CONST VOID  *Buffer,\r
+  IN UINTN       Length,\r
+  IN UINT64      Value\r
+  )\r
+{\r
+  if (Length == 0) {\r
+    return NULL;\r
+  }\r
+\r
+  ASSERT (Buffer != NULL);\r
+  ASSERT (((UINTN)Buffer & (sizeof (Value) - 1)) == 0);\r
+  ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));\r
+  ASSERT ((Length & (sizeof (Value) - 1)) == 0);\r
+\r
+  return (VOID*)InternalMemScanMem64 (Buffer, Length / sizeof (Value), Value);\r
+}\r
diff --git a/ArmPkg/Library/BaseMemoryLibStm/ScanMem8Wrapper.c b/ArmPkg/Library/BaseMemoryLibStm/ScanMem8Wrapper.c
new file mode 100755 (executable)
index 0000000..ecf1bdd
--- /dev/null
@@ -0,0 +1,99 @@
+/** @file\r
+  ScanMem8() and ScanMemN() implementation.\r
+\r
+  The following BaseMemoryLib instances contain the same copy of this file:\r
+\r
+    BaseMemoryLib\r
+    BaseMemoryLibMmx\r
+    BaseMemoryLibSse2\r
+    BaseMemoryLibRepStr\r
+    BaseMemoryLibOptDxe\r
+    BaseMemoryLibOptPei\r
+    PeiMemoryLib\r
+    UefiMemoryLib\r
+\r
+  Copyright (c) 2006 - 2009, 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
+**/\r
+\r
+#include "MemLibInternals.h"\r
+\r
+/**\r
+  Scans a target buffer for an 8-bit value, and returns a pointer to the matching 8-bit value\r
+  in the target buffer.\r
+\r
+  This function searches the target buffer specified by Buffer and Length from the lowest\r
+  address to the highest address for an 8-bit value that matches Value.  If a match is found,\r
+  then a pointer to the matching byte in the target buffer is returned.  If no match is found,\r
+  then NULL is returned.  If Length is 0, then NULL is returned.\r
+  \r
+  If Length > 0 and Buffer is NULL, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+\r
+  @param  Buffer      Pointer to the target buffer to scan.\r
+  @param  Length      Number of bytes in Buffer to scan.\r
+  @param  Value       Value to search for in the target buffer.\r
+\r
+  @return A pointer to the matching byte in the target buffer or NULL otherwise.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+ScanMem8 (\r
+  IN CONST VOID  *Buffer,\r
+  IN UINTN       Length,\r
+  IN UINT8       Value\r
+  )\r
+{\r
+  if (Length == 0) {\r
+    return NULL;\r
+  }\r
+  ASSERT (Buffer != NULL);\r
+  ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));\r
\r
+  return (VOID*)InternalMemScanMem8 (Buffer, Length, Value);\r
+}\r
+\r
+/**\r
+  Scans a target buffer for a UINTN sized value, and returns a pointer to the matching \r
+  UINTN sized value in the target buffer.\r
+\r
+  This function searches the target buffer specified by Buffer and Length from the lowest\r
+  address to the highest address for a UINTN sized value that matches Value.  If a match is found,\r
+  then a pointer to the matching byte in the target buffer is returned.  If no match is found,\r
+  then NULL is returned.  If Length is 0, then NULL is returned.\r
+  \r
+  If Length > 0 and Buffer is NULL, then ASSERT().\r
+  If Buffer is not aligned on a UINTN boundary, then ASSERT().\r
+  If Length is not aligned on a UINTN boundary, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+\r
+  @param  Buffer      Pointer to the target buffer to scan.\r
+  @param  Length      Number of bytes in Buffer to scan.\r
+  @param  Value       Value to search for in the target buffer.\r
+\r
+  @return A pointer to the matching byte in the target buffer or NULL otherwise.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+ScanMemN (\r
+  IN CONST VOID  *Buffer,\r
+  IN UINTN       Length,\r
+  IN UINTN       Value\r
+  )\r
+{\r
+  if (sizeof (UINTN) == sizeof (UINT64)) {\r
+    return ScanMem64 (Buffer, Length, (UINT64)Value);\r
+  } else {\r
+    return ScanMem32 (Buffer, Length, (UINT32)Value);\r
+  }\r
+}\r
+\r
diff --git a/ArmPkg/Library/BaseMemoryLibStm/SetMem.c b/ArmPkg/Library/BaseMemoryLibStm/SetMem.c
new file mode 100755 (executable)
index 0000000..2394f48
--- /dev/null
@@ -0,0 +1,53 @@
+/** @file\r
+  Implementation of the EfiSetMem routine. This function is broken\r
+  out into its own source file so that it can be excluded from a\r
+  build for a particular platform easily if an optimized version\r
+  is desired.\r
+\r
+  Copyright (c) 2006 - 2010, 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
+**/\r
+\r
+\r
+\r
+\r
+#include "MemLibInternals.h"\r
+\r
+/**\r
+  Set Buffer to Value for Size bytes.\r
+\r
+  @param  Buffer   Memory to set.\r
+  @param  Length   Number of bytes to set\r
+  @param  Value    Value of the set operation.\r
+\r
+  @return Buffer\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InternalMemSetMem (\r
+  OUT     VOID                      *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT8                     Value\r
+  )\r
+{\r
+  //\r
+  // Declare the local variables that actually move the data elements as\r
+  // volatile to prevent the optimizer from replacing this function with\r
+  // the intrinsic memset()\r
+  //\r
+  volatile UINT8                    *Pointer;\r
+\r
+  Pointer = (UINT8*)Buffer;\r
+  while (Length-- > 0) {\r
+    *(Pointer++) = Value;\r
+  }\r
+  return Buffer;\r
+}\r
diff --git a/ArmPkg/Library/BaseMemoryLibStm/SetMem16Wrapper.c b/ArmPkg/Library/BaseMemoryLibStm/SetMem16Wrapper.c
new file mode 100755 (executable)
index 0000000..d74b80f
--- /dev/null
@@ -0,0 +1,64 @@
+/** @file\r
+  SetMem16() implementation.\r
+\r
+  The following BaseMemoryLib instances contain the same copy of this file:\r
+    BaseMemoryLib\r
+    BaseMemoryLibMmx\r
+    BaseMemoryLibSse2\r
+    BaseMemoryLibRepStr\r
+    BaseMemoryLibOptDxe\r
+    BaseMemoryLibOptPei\r
+    PeiMemoryLib\r
+    UefiMemoryLib\r
+\r
+  Copyright (c) 2006 - 2009, 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
+**/\r
+\r
+#include "MemLibInternals.h"\r
+\r
+/**\r
+  Fills a target buffer with a 16-bit value, and returns the target buffer.\r
+\r
+  This function fills Length bytes of Buffer with the 16-bit value specified by\r
+  Value, and returns Buffer. Value is repeated every 16-bits in for Length\r
+  bytes of Buffer.\r
+\r
+  If Length > 0 and Buffer is NULL, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+  If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r
+  If Length is not aligned on a 16-bit boundary, then ASSERT().\r
+\r
+  @param  Buffer  Pointer to the target buffer to fill.\r
+  @param  Length  Number of bytes in Buffer to fill.\r
+  @param  Value   Value with which to fill Length bytes of Buffer.\r
+\r
+  @return Buffer.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+SetMem16 (\r
+  OUT VOID   *Buffer,\r
+  IN UINTN   Length,\r
+  IN UINT16  Value\r
+  )\r
+{\r
+  if (Length == 0) {\r
+    return Buffer;\r
+  }\r
+\r
+  ASSERT (Buffer != NULL);\r
+  ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));\r
+  ASSERT ((((UINTN)Buffer) & (sizeof (Value) - 1)) == 0);\r
+  ASSERT ((Length & (sizeof (Value) - 1)) == 0);\r
+\r
+  return InternalMemSetMem16 (Buffer, Length / sizeof (Value), Value);\r
+}\r
diff --git a/ArmPkg/Library/BaseMemoryLibStm/SetMem32Wrapper.c b/ArmPkg/Library/BaseMemoryLibStm/SetMem32Wrapper.c
new file mode 100755 (executable)
index 0000000..dc84d20
--- /dev/null
@@ -0,0 +1,64 @@
+/** @file\r
+  SetMem32() implementation.\r
+\r
+  The following BaseMemoryLib instances contain the same copy of this file:\r
+    BaseMemoryLib\r
+    BaseMemoryLibMmx\r
+    BaseMemoryLibSse2\r
+    BaseMemoryLibRepStr\r
+    BaseMemoryLibOptDxe\r
+    BaseMemoryLibOptPei\r
+    PeiMemoryLib\r
+    UefiMemoryLib\r
+\r
+  Copyright (c) 2006 - 2009, 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
+**/\r
+\r
+#include "MemLibInternals.h"\r
+\r
+/**\r
+  Fills a target buffer with a 32-bit value, and returns the target buffer.\r
+\r
+  This function fills Length bytes of Buffer with the 32-bit value specified by\r
+  Value, and returns Buffer. Value is repeated every 32-bits in for Length\r
+  bytes of Buffer.\r
+\r
+  If Length > 0 and Buffer is NULL, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+  If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r
+  If Length is not aligned on a 32-bit boundary, then ASSERT().\r
+\r
+  @param  Buffer  Pointer to the target buffer to fill.\r
+  @param  Length  Number of bytes in Buffer to fill.\r
+  @param  Value   Value with which to fill Length bytes of Buffer.\r
+\r
+  @return Buffer.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+SetMem32 (\r
+  OUT VOID   *Buffer,\r
+  IN UINTN   Length,\r
+  IN UINT32  Value\r
+  )\r
+{\r
+  if (Length == 0) {\r
+    return Buffer;\r
+  }\r
+\r
+  ASSERT (Buffer != NULL);\r
+  ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));\r
+  ASSERT ((((UINTN)Buffer) & (sizeof (Value) - 1)) == 0);\r
+  ASSERT ((Length & (sizeof (Value) - 1)) == 0);\r
+\r
+  return InternalMemSetMem32 (Buffer, Length / sizeof (Value), Value);\r
+}\r
diff --git a/ArmPkg/Library/BaseMemoryLibStm/SetMem64Wrapper.c b/ArmPkg/Library/BaseMemoryLibStm/SetMem64Wrapper.c
new file mode 100755 (executable)
index 0000000..05dc453
--- /dev/null
@@ -0,0 +1,64 @@
+/** @file\r
+  SetMem64() implementation.\r
+\r
+  The following BaseMemoryLib instances contain the same copy of this file:\r
+    BaseMemoryLib\r
+    BaseMemoryLibMmx\r
+    BaseMemoryLibSse2\r
+    BaseMemoryLibRepStr\r
+    BaseMemoryLibOptDxe\r
+    BaseMemoryLibOptPei\r
+    PeiMemoryLib\r
+    UefiMemoryLib\r
+\r
+  Copyright (c) 2006 - 2009, 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
+**/\r
+\r
+#include "MemLibInternals.h"\r
+\r
+/**\r
+  Fills a target buffer with a 64-bit value, and returns the target buffer.\r
+\r
+  This function fills Length bytes of Buffer with the 64-bit value specified by\r
+  Value, and returns Buffer. Value is repeated every 64-bits in for Length\r
+  bytes of Buffer.\r
+\r
+  If Length > 0 and Buffer is NULL, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+  If Buffer is not aligned on a 64-bit boundary, then ASSERT().\r
+  If Length is not aligned on a 64-bit boundary, then ASSERT().\r
+\r
+  @param  Buffer  Pointer to the target buffer to fill.\r
+  @param  Length  Number of bytes in Buffer to fill.\r
+  @param  Value   Value with which to fill Length bytes of Buffer.\r
+\r
+  @return Buffer.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+SetMem64 (\r
+  OUT VOID   *Buffer,\r
+  IN UINTN   Length,\r
+  IN UINT64  Value\r
+  )\r
+{\r
+  if (Length == 0) {\r
+    return Buffer;\r
+  }\r
+\r
+  ASSERT (Buffer != NULL);\r
+  ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));\r
+  ASSERT ((((UINTN)Buffer) & (sizeof (Value) - 1)) == 0);\r
+  ASSERT ((Length & (sizeof (Value) - 1)) == 0);\r
+\r
+  return InternalMemSetMem64 (Buffer, Length / sizeof (Value), Value);\r
+}\r
diff --git a/ArmPkg/Library/BaseMemoryLibStm/SetMemWrapper.c b/ArmPkg/Library/BaseMemoryLibStm/SetMemWrapper.c
new file mode 100755 (executable)
index 0000000..e728175
--- /dev/null
@@ -0,0 +1,91 @@
+/** @file\r
+  SetMem() and SetMemN() implementation.\r
+\r
+  The following BaseMemoryLib instances contain the same copy of this file:\r
+\r
+    BaseMemoryLib\r
+    BaseMemoryLibMmx\r
+    BaseMemoryLibSse2\r
+    BaseMemoryLibRepStr\r
+    BaseMemoryLibOptDxe\r
+    BaseMemoryLibOptPei\r
+    PeiMemoryLib\r
+    UefiMemoryLib\r
+\r
+  Copyright (c) 2006 - 2009, 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
+**/\r
+\r
+#include "MemLibInternals.h"\r
+\r
+/**\r
+  Fills a target buffer with a byte value, and returns the target buffer.\r
+\r
+  This function fills Length bytes of Buffer with Value, and returns Buffer.\r
+  \r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+\r
+  @param  Buffer    Memory to set.\r
+  @param  Length    Number of bytes to set.\r
+  @param  Value     Value with which to fill Length bytes of Buffer.\r
+\r
+  @return Buffer.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+SetMem (\r
+  OUT VOID  *Buffer,\r
+  IN UINTN  Length,\r
+  IN UINT8  Value\r
+  )\r
+{\r
+  if (Length == 0) {\r
+    return Buffer;\r
+  }\r
+\r
+  ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));\r
+\r
+  return InternalMemSetMem (Buffer, Length, Value);\r
+}\r
+\r
+/**\r
+  Fills a target buffer with a value that is size UINTN, and returns the target buffer.\r
+\r
+  This function fills Length bytes of Buffer with the UINTN sized value specified by\r
+  Value, and returns Buffer. Value is repeated every sizeof(UINTN) bytes for Length\r
+  bytes of Buffer.\r
+\r
+  If Length > 0 and Buffer is NULL, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+  If Buffer is not aligned on a UINTN boundary, then ASSERT().\r
+  If Length is not aligned on a UINTN boundary, then ASSERT().\r
+\r
+  @param  Buffer  Pointer to the target buffer to fill.\r
+  @param  Length  Number of bytes in Buffer to fill.\r
+  @param  Value   Value with which to fill Length bytes of Buffer.\r
+\r
+  @return Buffer.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+SetMemN (\r
+  OUT VOID  *Buffer,\r
+  IN UINTN  Length,\r
+  IN UINTN  Value\r
+  )\r
+{\r
+  if (sizeof (UINTN) == sizeof (UINT64)) {\r
+    return SetMem64 (Buffer, Length, (UINT64)Value);\r
+  } else {\r
+    return SetMem32 (Buffer, Length, (UINT32)Value);\r
+  }\r
+}\r
diff --git a/ArmPkg/Library/BaseMemoryLibStm/ZeroMemWrapper.c b/ArmPkg/Library/BaseMemoryLibStm/ZeroMemWrapper.c
new file mode 100755 (executable)
index 0000000..2923356
--- /dev/null
@@ -0,0 +1,52 @@
+/** @file\r
+  ZeroMem() implementation.\r
+\r
+  The following BaseMemoryLib instances contain the same copy of this file:\r
+\r
+    BaseMemoryLib\r
+    BaseMemoryLibMmx\r
+    BaseMemoryLibSse2\r
+    BaseMemoryLibRepStr\r
+    BaseMemoryLibOptDxe\r
+    BaseMemoryLibOptPei\r
+    PeiMemoryLib\r
+    UefiMemoryLib\r
+    \r
+  Copyright (c) 2006 - 2009 , 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
+**/\r
+\r
+#include "MemLibInternals.h"\r
+\r
+/**\r
+  Fills a target buffer with zeros, and returns the target buffer.\r
+\r
+  This function fills Length bytes of Buffer with zeros, and returns Buffer.\r
+  \r
+  If Length > 0 and Buffer is NULL, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+\r
+  @param  Buffer      Pointer to the target buffer to fill with zeros.\r
+  @param  Length      Number of bytes in Buffer to fill with zeros.\r
+\r
+  @return Buffer.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+ZeroMem (\r
+  OUT VOID  *Buffer,\r
+  IN UINTN  Length\r
+  )\r
+{\r
+  ASSERT (!(Buffer == NULL && Length > 0));\r
+  ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));\r
+  return InternalMemZeroMem (Buffer, Length);\r
+}\r
diff --git a/ArmPkg/Library/BaseMemoryLibVstm/Arm/CopyMem.S b/ArmPkg/Library/BaseMemoryLibVstm/Arm/CopyMem.S
new file mode 100755 (executable)
index 0000000..2ce686c
--- /dev/null
@@ -0,0 +1,114 @@
+#------------------------------------------------------------------------------ \r
+#\r
+# CopyMem() worker for ARM\r
+#\r
+# This file started out as C code that did 64 bit moves if the buffer was\r
+# 32-bit aligned, else it does a byte copy. It also does a byte copy for\r
+# any trailing bytes. Update using VSTM/SLDM to do 128 byte copies.\r
+#\r
+# Copyright (c) 2008-2010 Apple Inc. All rights reserved.<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
+#------------------------------------------------------------------------------\r
+\r
+/**\r
+  Copy Length bytes from Source to Destination. Overlap is OK.\r
+\r
+  This implementation \r
+\r
+  @param  Destination Target of copy\r
+  @param  Source      Place to copy from\r
+  @param  Length      Number of bytes to copy\r
+\r
+  @return Destination\r
+\r
+\r
+VOID *\r
+EFIAPI\r
+InternalMemCopyMem (\r
+  OUT     VOID                      *DestinationBuffer,\r
+  IN      CONST VOID                *SourceBuffer,\r
+  IN      UINTN                     Length\r
+  )\r
+**/\r
+.text\r
+.align 2\r
+.globl ASM_PFX(InternalMemCopyMem)\r
+\r
+ASM_PFX(InternalMemCopyMem):\r
+       stmfd   sp!, {r4, r9, lr}\r
+       tst     r0, #3\r
+       mov     r4, r0\r
+       mov     r9, r0\r
+       mov     ip, r2\r
+       mov     lr, r1\r
+       movne   r0, #0\r
+       bne     L4\r
+       tst     r1, #3\r
+       movne   r3, #0\r
+       moveq   r3, #1\r
+       cmp     r2, #127\r
+       movls   r0, #0\r
+       andhi   r0, r3, #1\r
+L4:\r
+       cmp     r4, r1\r
+       bcc     L26\r
+       bls     L7\r
+       rsb     r3, r1, r4\r
+       cmp     ip, r3\r
+       bcc     L26\r
+       cmp     ip, #0\r
+       beq     L7\r
+       add     r9, r4, ip\r
+       add     lr, ip, r1\r
+       b       L16\r
+L29:\r
+       sub     ip, ip, #8\r
+       cmp     ip, #7\r
+       ldrd    r2, [lr, #-8]!\r
+       movls   r0, #0\r
+       cmp     ip, #0\r
+       strd    r2, [r9, #-8]!\r
+       beq     L7\r
+L16:\r
+       cmp     r0, #0\r
+       bne     L29\r
+       sub     r3, lr, #1\r
+       sub     ip, ip, #1\r
+       ldrb    r3, [r3, #0]    \r
+       sub     r2, r9, #1\r
+       cmp     ip, #0\r
+       sub     r9, r9, #1\r
+       sub     lr, lr, #1\r
+       strb    r3, [r2, #0]\r
+       bne     L16\r
+       b   L7\r
+L11:\r
+       ldrb    r3, [lr], #1    \r
+       sub     ip, ip, #1\r
+       strb    r3, [r9], #1\r
+L26:\r
+       cmp     ip, #0\r
+       beq     L7\r
+L30:\r
+       cmp     r0, #0\r
+       beq     L11\r
+       sub     ip, ip, #128          // 32\r
+       cmp     ip, #127              // 31\r
+       vldm     lr!, {d0-d15}\r
+       movls   r0, #0\r
+       cmp     ip, #0\r
+       vstm  r9!, {d0-d15}\r
+       bne     L30\r
+L7:\r
+  dsb\r
+  mov  r0, r4\r
+       ldmfd   sp!, {r4, r9, pc}\r
+\r
+  \r
diff --git a/ArmPkg/Library/BaseMemoryLibVstm/Arm/CopyMem.asm b/ArmPkg/Library/BaseMemoryLibVstm/Arm/CopyMem.asm
new file mode 100755 (executable)
index 0000000..ce049d2
--- /dev/null
@@ -0,0 +1,115 @@
+;------------------------------------------------------------------------------ \r
+;\r
+; CopyMem() worker for ARM\r
+;\r
+; This file started out as C code that did 64 bit moves if the buffer was\r
+; 32-bit aligned, else it does a byte copy. It also does a byte copy for\r
+; any trailing bytes. Update using VSTM/SLDM to do 128 byte copies.\r
+;\r
+; Copyright (c) 2008-2010 Apple Inc. All rights reserved.<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
+;------------------------------------------------------------------------------\r
+\r
+/**\r
+  Copy Length bytes from Source to Destination. Overlap is OK.\r
+\r
+  This implementation \r
+\r
+  @param  Destination Target of copy\r
+  @param  Source      Place to copy from\r
+  @param  Length      Number of bytes to copy\r
+\r
+  @return Destination\r
+\r
+\r
+VOID *\r
+EFIAPI\r
+InternalMemCopyMem (\r
+  OUT     VOID                      *DestinationBuffer,\r
+  IN      CONST VOID                *SourceBuffer,\r
+  IN      UINTN                     Length\r
+  )\r
+**/\r
+       EXPORT InternalMemCopyMem\r
+
+       AREA AsmMemStuff, CODE, READONLY
+\r
+InternalMemCopyMem\r
+       stmfd   sp!, {r4, r9, lr}
+       tst     r0, #3
+       mov     r4, r0
+       mov     r9, r0
+       mov     ip, r2
+       mov     lr, r1
+       movne   r0, #0
+       bne     L4
+       tst     r1, #3
+       movne   r3, #0
+       moveq   r3, #1
+       cmp     r2, #127
+       movls   r0, #0
+       andhi   r0, r3, #1
+L4
+       cmp     r4, r1
+       bcc     L26
+       bls     L7
+       rsb     r3, r1, r4
+       cmp     ip, r3
+       bcc     L26
+       cmp     ip, #0
+       beq     L7
+       add     r9, r4, ip
+       add     lr, ip, r1
+       b       L16
+L29
+       sub     ip, ip, #8
+       cmp     ip, #7
+       ldrd    r2, [lr, #-8]!
+       movls   r0, #0
+       cmp     ip, #0
+       strd    r2, [r9, #-8]!
+       beq     L7
+L16
+       cmp     r0, #0
+       bne     L29
+       sub     r3, lr, #1
+       sub     ip, ip, #1
+       ldrb    r3, [r3, #0]    
+       sub     r2, r9, #1
+       cmp     ip, #0
+       sub     r9, r9, #1
+       sub     lr, lr, #1
+       strb    r3, [r2, #0]
+       bne     L16
+       b   L7
+L11
+       ldrb    r3, [lr], #1    
+       sub     ip, ip, #1
+       strb    r3, [r9], #1
+L26
+       cmp     ip, #0
+       beq     L7
+L30
+       cmp     r0, #0
+       beq     L11
+       sub     ip, ip, #128          // 32
+       cmp     ip, #127              // 31
+       vldm     lr!, {d0-d15}
+       movls   r0, #0
+       cmp     ip, #0
+       vstm  r9!, {d0-d15}
+       bne     L30
+L7
+  dsb
+  mov  r0, r4
+       ldmfd   sp!, {r4, r9, pc}
+\r
+  END\r
+  \r
diff --git a/ArmPkg/Library/BaseMemoryLibVstm/Arm/SetMem.S b/ArmPkg/Library/BaseMemoryLibVstm/Arm/SetMem.S
new file mode 100755 (executable)
index 0000000..44c6d4b
--- /dev/null
@@ -0,0 +1,80 @@
+#------------------------------------------------------------------------------ \r
+#\r
+# SemMem() worker for ARM\r
+#\r
+# This file started out as C code that did 64 bit moves if the buffer was\r
+# 32-bit aligned, else it does a byte copy. It also does a byte copy for\r
+# any trailing bytes. Update to use VSTM/VLDM to do 128 byte writes.\r
+#\r
+# Copyright (c) 2008-2010 Apple Inc. All rights reserved.<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
+#------------------------------------------------------------------------------\r
+\r
+/**\r
+  Set Buffer to Value for Size bytes.\r
+\r
+  @param  Buffer   Memory to set.\r
+  @param  Length   Number of bytes to set\r
+  @param  Value    Value of the set operation.\r
+\r
+  @return Buffer\r
+\r
+VOID *\r
+EFIAPI\r
+InternalMemSetMem (\r
+  OUT     VOID                      *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT8                     Value\r
+  )\r
+**/\r
+       \r
+.text\r
+.align 2\r
+.globl ASM_PFX(InternalMemSetMem)\r
+\r
+ASM_PFX(InternalMemSetMem):\r
+       stmfd   sp!, {r4-r7, lr}\r
+       tst       r0, #3\r
+       movne   r3, #0\r
+       moveq   r3, #1\r
+       cmp       r1, #127\r
+       movls lr, #0\r
+       andhi   lr, r3, #1\r
+       cmp       lr, #0\r
+       mov       r12, r0\r
+       bne       L31\r
+L32:\r
+       mov       r3, #0\r
+       b           L43\r
+L31:\r
+  vdup.8  q0,r2\r
+  vmov    q1,q0\r
+  vmov    q2,q0\r
+  vmov    q3,q0\r
+  vmov    q4,q0\r
+  vmov    q5,q0\r
+  vmov    q6,q0\r
+  vmov    q7,q0\r
+       b             L32\r
+L34:\r
+       cmp         lr, #0\r
+       streqb  r2, [r12], #1\r
+       subeq     r1, r1, #1\r
+       beq         L43\r
+       sub         r1, r1, #128\r
+       cmp         r1, #127\r
+       cmp         r1, #31\r
+       movls     lr, r3\r
+       vstm    r12!, {d0-d15}\r
+L43:\r
+       cmp         r1, #0\r
+       bne         L34\r
+       ldmfd     sp!, {pc}\r
+       
\ No newline at end of file
diff --git a/ArmPkg/Library/BaseMemoryLibVstm/Arm/SetMem.asm b/ArmPkg/Library/BaseMemoryLibVstm/Arm/SetMem.asm
new file mode 100755 (executable)
index 0000000..4e16ac6
--- /dev/null
@@ -0,0 +1,80 @@
+;------------------------------------------------------------------------------ \r
+;\r
+; SetMem() worker for ARM\r
+;\r
+; This file started out as C code that did 64 bit moves if the buffer was\r
+; 32-bit aligned, else it does a byte copy. It also does a byte copy for\r
+; any trailing bytes. Update to use VSTM/VLDM to do 128 byte writes.\r
+;\r
+; Copyright (c) 2008-2010 Apple Inc. All rights reserved.<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
+\r
+/**\r
+  Set Buffer to Value for Size bytes.\r
+\r
+  @param  Buffer   Memory to set.\r
+  @param  Length   Number of bytes to set\r
+  @param  Value    Value of the set operation.\r
+\r
+  @return Buffer\r
+\r
+VOID *\r
+EFIAPI\r
+InternalMemSetMem (\r
+  OUT     VOID                      *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT8                     Value\r
+  )\r
+**/\r
+       \r
+       EXPORT InternalMemSetMem\r
+       \r
+       AREA AsmMemStuff, CODE, READONLY
+\r
+InternalMemSetMem\r
+       stmfd   sp!, {lr}\r
+       tst       r0, #3\r
+       movne   r3, #0\r
+       moveq   r3, #1\r
+       cmp       r1, #127\r
+       movls lr, #0\r
+       andhi   lr, r3, #1\r
+       cmp       lr, #0\r
+       mov       r12, r0\r
+       bne       L31\r
+L32\r
+       mov       r3, #0\r
+       b           L43\r
+L31\r
+  vdup.8  q0,r2\r
+  vmov    q1,q0\r
+  vmov    q2,q0\r
+  vmov    q3,q0\r
+  vmov    q4,q0\r
+  vmov    q5,q0\r
+  vmov    q6,q0\r
+  vmov    q7,q0\r
+       b             L32\r
+L34\r
+       cmp         lr, #0\r
+       streqb  r2, [r12], #1\r
+       subeq     r1, r1, #1\r
+       beq         L43\r
+       sub         r1, r1, #128\r
+       cmp         r1, #127\r
+       movls     lr, r3\r
+       vstm    r12!, {d0-d15}\r
+L43\r
+       cmp         r1, #0\r
+       bne         L34\r
+       ldmfd     sp!, {pc}\r
+       \r
+  END\r
+  
\ No newline at end of file
diff --git a/ArmPkg/Library/BaseMemoryLibVstm/BaseMemoryLibVstm.inf b/ArmPkg/Library/BaseMemoryLibVstm/BaseMemoryLibVstm.inf
new file mode 100755 (executable)
index 0000000..7725eb8
--- /dev/null
@@ -0,0 +1,69 @@
+## @file\r
+#  Instance of Base Memory Library with some ARM vldm/vstm assembly.\r
+#\r
+#  This is a copy of the MdePkg BaseMemoryLib with the CopyMem and \r
+#  SetMem worker functions replaced with assembler that uses \r
+#  vldm/vstm (part of NEON SIMD, optional in ARMv7-A).\r
+#\r
+#  Note: You need to enable NEON in SEC to use this library\r
+#  // Enable NEON register in case folks want to use them for optimizations (CopyMem)\r
+#  mrc     p15, 0, r0, c1, c0, 2\r
+#  orr     r0, r0, #0x00f00000   // Enable VPF access (V* instructions)\r
+#  mcr     p15, 0, r0, c1, c0, 2\r
+#  mov     r0, #0x40000000       // Set EN bit in FPEXC\r
+#  msr     FPEXC,r0\r
+#\r
+#  Copyright (c) 2007 - 2010, Intel Corporation.\r
+#  Portions Copyright (c) 2010, Apple, Inc. All rights reserved.\r
+#\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
+#  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
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = BaseMemoryLibVstm\r
+  FILE_GUID                      = 09EE1E8D-7A2E-4573-8117-68A18569C1F5\r
+  MODULE_TYPE                    = BASE\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = BaseMemoryLib \r
+\r
+\r
+#\r
+#  VALID_ARCHITECTURES           = ARM\r
+#\r
+\r
+[Sources.ARM]\r
+  ScanMem64Wrapper.c\r
+  ScanMem32Wrapper.c\r
+  ScanMem16Wrapper.c\r
+  ScanMem8Wrapper.c\r
+  ZeroMemWrapper.c\r
+  CompareMemWrapper.c\r
+  SetMem64Wrapper.c\r
+  SetMem32Wrapper.c\r
+  SetMem16Wrapper.c\r
+  SetMemWrapper.c\r
+  CopyMemWrapper.c\r
+  MemLibGeneric.c\r
+  MemLibGuid.c  \r
+  MemLibInternals.h\r
+  Arm/CopyMem.asm\r
+  Arm/CopyMem.S\r
+  Arm/SetMem.asm\r
+  Arm/SetMem.S\r
+\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+\r
+[LibraryClasses]\r
+  DebugLib\r
+  BaseLib\r
+\r
diff --git a/ArmPkg/Library/BaseMemoryLibVstm/CompareMemWrapper.c b/ArmPkg/Library/BaseMemoryLibVstm/CompareMemWrapper.c
new file mode 100755 (executable)
index 0000000..278ef33
--- /dev/null
@@ -0,0 +1,66 @@
+/** @file\r
+  CompareMem() implementation.\r
+\r
+  The following BaseMemoryLib instances contain the same copy of this file:\r
+    BaseMemoryLib\r
+    BaseMemoryLibMmx\r
+    BaseMemoryLibSse2\r
+    BaseMemoryLibRepStr\r
+    BaseMemoryLibOptDxe\r
+    BaseMemoryLibOptPei\r
+    PeiMemoryLib\r
+    UefiMemoryLib\r
+\r
+Copyright (c) 2006 - 2009, 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
+**/\r
+\r
+#include "MemLibInternals.h"\r
+\r
+/**\r
+  Compares the contents of two buffers.\r
+\r
+  This function compares Length bytes of SourceBuffer to Length bytes of DestinationBuffer.\r
+  If all Length bytes of the two buffers are identical, then 0 is returned.  Otherwise, the\r
+  value returned is the first mismatched byte in SourceBuffer subtracted from the first\r
+  mismatched byte in DestinationBuffer.\r
+  \r
+  If Length > 0 and DestinationBuffer is NULL, then ASSERT().\r
+  If Length > 0 and SourceBuffer is NULL, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT().\r
+\r
+  @param  DestinationBuffer Pointer to the destination buffer to compare.\r
+  @param  SourceBuffer      Pointer to the source buffer to compare.\r
+  @param  Length            Number of bytes to compare.\r
+\r
+  @return 0                 All Length bytes of the two buffers are identical.\r
+  @retval Non-zero          The first mismatched byte in SourceBuffer subtracted from the first\r
+                            mismatched byte in DestinationBuffer.\r
+                            \r
+**/\r
+INTN\r
+EFIAPI\r
+CompareMem (\r
+  IN CONST VOID  *DestinationBuffer,\r
+  IN CONST VOID  *SourceBuffer,\r
+  IN UINTN       Length\r
+  )\r
+{\r
+  if (Length == 0 || DestinationBuffer == SourceBuffer) {\r
+    return 0;\r
+  }\r
+  ASSERT (DestinationBuffer != NULL);\r
+  ASSERT (SourceBuffer != NULL);\r
+  ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)DestinationBuffer));\r
+  ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)SourceBuffer));\r
+\r
+  return InternalMemCompareMem (DestinationBuffer, SourceBuffer, Length);\r
+}\r
diff --git a/ArmPkg/Library/BaseMemoryLibVstm/CopyMem.c b/ArmPkg/Library/BaseMemoryLibVstm/CopyMem.c
new file mode 100755 (executable)
index 0000000..aa2ffea
--- /dev/null
@@ -0,0 +1,62 @@
+/** @file\r
+  Implementation of the InternalMemCopyMem routine. This function is broken\r
+  out into its own source file so that it can be excluded from a build for a\r
+  particular platform easily if an optimized version is desired.\r
+\r
+  Copyright (c) 2006 - 2008, 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
+**/\r
+\r
+\r
+\r
+\r
+#include "MemLibInternals.h"\r
+\r
+/**\r
+  Copy Length bytes from Source to Destination.\r
+\r
+  @param  DestinationBuffer Target of copy\r
+  @param  SourceBuffer      Place to copy from\r
+  @param  Length            Number of bytes to copy\r
+\r
+  @return Destination\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InternalMemCopyMem (\r
+  OUT     VOID                      *DestinationBuffer,\r
+  IN      CONST VOID                *SourceBuffer,\r
+  IN      UINTN                     Length\r
+  )\r
+{\r
+  //\r
+  // Declare the local variables that actually move the data elements as\r
+  // volatile to prevent the optimizer from replacing this function with\r
+  // the intrinsic memcpy()\r
+  //\r
+  volatile UINT8                    *Destination8;\r
+  CONST UINT8                       *Source8;\r
+\r
+  if (SourceBuffer > DestinationBuffer) {\r
+    Destination8 = (UINT8*)DestinationBuffer;\r
+    Source8 = (CONST UINT8*)SourceBuffer;\r
+    while (Length-- != 0) {\r
+      *(Destination8++) = *(Source8++);\r
+    }\r
+  } else if (SourceBuffer < DestinationBuffer) {\r
+    Destination8 = (UINT8*)DestinationBuffer + Length;\r
+    Source8 = (CONST UINT8*)SourceBuffer + Length;\r
+    while (Length-- != 0) {\r
+      *(--Destination8) = *(--Source8);\r
+    }\r
+  }\r
+  return DestinationBuffer;\r
+}\r
diff --git a/ArmPkg/Library/BaseMemoryLibVstm/CopyMemWrapper.c b/ArmPkg/Library/BaseMemoryLibVstm/CopyMemWrapper.c
new file mode 100755 (executable)
index 0000000..5077820
--- /dev/null
@@ -0,0 +1,63 @@
+/** @file\r
+  CopyMem() implementation.\r
+\r
+  The following BaseMemoryLib instances contain the same copy of this file:\r
+  \r
+    BaseMemoryLib\r
+    BaseMemoryLibMmx\r
+    BaseMemoryLibSse2\r
+    BaseMemoryLibRepStr\r
+    BaseMemoryLibOptDxe\r
+    BaseMemoryLibOptPei\r
+    PeiMemoryLib\r
+    UefiMemoryLib\r
+\r
+  Copyright (c) 2006 - 2009, 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
+**/\r
+\r
+#include "MemLibInternals.h"\r
+\r
+/**\r
+  Copies a source buffer to a destination buffer, and returns the destination buffer.\r
+\r
+  This function copies Length bytes from SourceBuffer to DestinationBuffer, and returns\r
+  DestinationBuffer.  The implementation must be reentrant, and it must handle the case\r
+  where SourceBuffer overlaps DestinationBuffer.\r
+  \r
+  If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT().\r
+\r
+  @param  DestinationBuffer   Pointer to the destination buffer of the memory copy.\r
+  @param  SourceBuffer        Pointer to the source buffer of the memory copy.\r
+  @param  Length              Number of bytes to copy from SourceBuffer to DestinationBuffer.\r
+\r
+  @return DestinationBuffer.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+CopyMem (\r
+  OUT VOID       *DestinationBuffer,\r
+  IN CONST VOID  *SourceBuffer,\r
+  IN UINTN       Length\r
+  )\r
+{\r
+  if (Length == 0) {\r
+    return DestinationBuffer;\r
+  }\r
+  ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)DestinationBuffer));\r
+  ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)SourceBuffer));\r
+\r
+  if (DestinationBuffer == SourceBuffer) {\r
+    return DestinationBuffer;\r
+  }\r
+  return InternalMemCopyMem (DestinationBuffer, SourceBuffer, Length);\r
+}\r
diff --git a/ArmPkg/Library/BaseMemoryLibVstm/MemLibGeneric.c b/ArmPkg/Library/BaseMemoryLibVstm/MemLibGeneric.c
new file mode 100755 (executable)
index 0000000..e9e0f17
--- /dev/null
@@ -0,0 +1,260 @@
+/** @file\r
+  Architecture Independent Base Memory Library Implementation.\r
+\r
+  The following BaseMemoryLib instances contain the same copy of this file:\r
+    BaseMemoryLib\r
+    PeiMemoryLib\r
+    UefiMemoryLib\r
+\r
+  Copyright (c) 2006 - 2009, 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
+**/\r
+\r
+#include "MemLibInternals.h"\r
+\r
+/**\r
+  Fills a target buffer with a 16-bit value, and returns the target buffer.\r
+\r
+  @param  Buffer  Pointer to the target buffer to fill.\r
+  @param  Length  Count of 16-bit value to fill.\r
+  @param  Value   Value with which to fill Length bytes of Buffer.\r
+\r
+  @return Buffer\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InternalMemSetMem16 (\r
+  OUT     VOID                      *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT16                    Value\r
+  )\r
+{\r
+  do {\r
+    ((UINT16*)Buffer)[--Length] = Value;\r
+  } while (Length != 0);\r
+  return Buffer;\r
+}\r
+\r
+/**\r
+  Fills a target buffer with a 32-bit value, and returns the target buffer.\r
+\r
+  @param  Buffer  Pointer to the target buffer to fill.\r
+  @param  Length  Count of 32-bit value to fill.\r
+  @param  Value   Value with which to fill Length bytes of Buffer.\r
+\r
+  @return Buffer\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InternalMemSetMem32 (\r
+  OUT     VOID                      *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT32                    Value\r
+  )\r
+{\r
+  do {\r
+    ((UINT32*)Buffer)[--Length] = Value;\r
+  } while (Length != 0);\r
+  return Buffer;\r
+}\r
+\r
+/**\r
+  Fills a target buffer with a 64-bit value, and returns the target buffer.\r
+\r
+  @param  Buffer  Pointer to the target buffer to fill.\r
+  @param  Length  Count of 64-bit value to fill.\r
+  @param  Value   Value with which to fill Length bytes of Buffer.\r
+\r
+  @return Buffer\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InternalMemSetMem64 (\r
+  OUT     VOID                      *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT64                    Value\r
+  )\r
+{\r
+  do {\r
+    ((UINT64*)Buffer)[--Length] = Value;\r
+  } while (Length != 0);\r
+  return Buffer;\r
+}\r
+\r
+/**\r
+  Set Buffer to 0 for Size bytes.\r
+\r
+  @param  Buffer Memory to set.\r
+  @param  Length Number of bytes to set\r
+\r
+  @return Buffer\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InternalMemZeroMem (\r
+  OUT     VOID                      *Buffer,\r
+  IN      UINTN                     Length\r
+  )\r
+{\r
+  return InternalMemSetMem (Buffer, Length, 0);\r
+}\r
+\r
+/**\r
+  Compares two memory buffers of a given length.\r
+\r
+  @param  DestinationBuffer First memory buffer\r
+  @param  SourceBuffer      Second memory buffer\r
+  @param  Length            Length of DestinationBuffer and SourceBuffer memory\r
+                            regions to compare. Must be non-zero.\r
+\r
+  @return 0                 All Length bytes of the two buffers are identical.\r
+  @retval Non-zero          The first mismatched byte in SourceBuffer subtracted from the first\r
+                            mismatched byte in DestinationBuffer.\r
+\r
+**/\r
+INTN\r
+EFIAPI\r
+InternalMemCompareMem (\r
+  IN      CONST VOID                *DestinationBuffer,\r
+  IN      CONST VOID                *SourceBuffer,\r
+  IN      UINTN                     Length\r
+  )\r
+{\r
+  while ((--Length != 0) &&\r
+         (*(INT8*)DestinationBuffer == *(INT8*)SourceBuffer)) {\r
+    DestinationBuffer = (INT8*)DestinationBuffer + 1;\r
+    SourceBuffer = (INT8*)SourceBuffer + 1;\r
+  }\r
+  return (INTN)*(UINT8*)DestinationBuffer - (INTN)*(UINT8*)SourceBuffer;\r
+}\r
+\r
+/**\r
+  Scans a target buffer for an 8-bit value, and returns a pointer to the\r
+  matching 8-bit value in the target buffer.\r
+\r
+  @param  Buffer  Pointer to the target buffer to scan.\r
+  @param  Length  Count of 8-bit value to scan. Must be non-zero.\r
+  @param  Value   Value to search for in the target buffer.\r
+\r
+  @return Pointer to the first occurrence or NULL if not found.\r
+\r
+**/\r
+CONST VOID *\r
+EFIAPI\r
+InternalMemScanMem8 (\r
+  IN      CONST VOID                *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT8                     Value\r
+  )\r
+{\r
+  CONST UINT8                       *Pointer;\r
+\r
+  Pointer = (CONST UINT8*)Buffer;\r
+  do {\r
+    if (*(Pointer++) == Value) {\r
+      return Pointer;\r
+    }\r
+  } while (--Length != 0);\r
+  return NULL;\r
+}\r
+\r
+/**\r
+  Scans a target buffer for a 16-bit value, and returns a pointer to the\r
+  matching 16-bit value in the target buffer.\r
+\r
+  @param  Buffer  Pointer to the target buffer to scan.\r
+  @param  Length  Count of 16-bit value to scan. Must be non-zero.\r
+  @param  Value   Value to search for in the target buffer.\r
+\r
+  @return Pointer to the first occurrence or NULL if not found.\r
+\r
+**/\r
+CONST VOID *\r
+EFIAPI\r
+InternalMemScanMem16 (\r
+  IN      CONST VOID                *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT16                    Value\r
+  )\r
+{\r
+  CONST UINT16                      *Pointer;\r
+\r
+  Pointer = (CONST UINT16*)Buffer;\r
+  do {\r
+    if (*(Pointer++) == Value) {\r
+      return Pointer;\r
+    }\r
+  } while (--Length != 0);\r
+  return NULL;\r
+}\r
+\r
+/**\r
+  Scans a target buffer for a 32-bit value, and returns a pointer to the\r
+  matching 32-bit value in the target buffer.\r
+\r
+  @param  Buffer  Pointer to the target buffer to scan.\r
+  @param  Length  Count of 32-bit value to scan. Must be non-zero.\r
+  @param  Value   Value to search for in the target buffer.\r
+\r
+  @return Pointer to the first occurrence or NULL if not found.\r
+\r
+**/\r
+CONST VOID *\r
+EFIAPI\r
+InternalMemScanMem32 (\r
+  IN      CONST VOID                *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT32                    Value\r
+  )\r
+{\r
+  CONST UINT32                      *Pointer;\r
+\r
+  Pointer = (CONST UINT32*)Buffer;\r
+  do {\r
+    if (*(Pointer++) == Value) {\r
+      return Pointer;\r
+    }\r
+  } while (--Length != 0);\r
+  return NULL;\r
+}\r
+\r
+/**\r
+  Scans a target buffer for a 64-bit value, and returns a pointer to the\r
+  matching 64-bit value in the target buffer.\r
+\r
+  @param  Buffer  Pointer to the target buffer to scan.\r
+  @param  Length  Count of 64-bit value to scan. Must be non-zero.\r
+  @param  Value   Value to search for in the target buffer.\r
+\r
+  @return Pointer to the first occurrence or NULL if not found.\r
+\r
+**/\r
+CONST VOID *\r
+EFIAPI\r
+InternalMemScanMem64 (\r
+  IN      CONST VOID                *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT64                    Value\r
+  )\r
+{\r
+  CONST UINT64                      *Pointer;\r
+\r
+  Pointer = (CONST UINT64*)Buffer;\r
+  do {\r
+    if (*(Pointer++) == Value) {\r
+      return Pointer;\r
+    }\r
+  } while (--Length != 0);\r
+  return NULL;\r
+}\r
diff --git a/ArmPkg/Library/BaseMemoryLibVstm/MemLibGuid.c b/ArmPkg/Library/BaseMemoryLibVstm/MemLibGuid.c
new file mode 100755 (executable)
index 0000000..7373410
--- /dev/null
@@ -0,0 +1,142 @@
+/** @file\r
+  Implementation of GUID functions.\r
+\r
+  The following BaseMemoryLib instances contain the same copy of this file:\r
+  \r
+    BaseMemoryLib\r
+    BaseMemoryLibMmx\r
+    BaseMemoryLibSse2\r
+    BaseMemoryLibRepStr\r
+    BaseMemoryLibOptDxe\r
+    BaseMemoryLibOptPei\r
+    PeiMemoryLib\r
+    UefiMemoryLib\r
+\r
+  Copyright (c) 2006 - 2009, 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
+**/\r
+\r
+#include "MemLibInternals.h"\r
+\r
+/**\r
+  Copies a source GUID to a destination GUID.\r
+\r
+  This function copies the contents of the 128-bit GUID specified by SourceGuid to\r
+  DestinationGuid, and returns DestinationGuid.\r
+  \r
+  If DestinationGuid is NULL, then ASSERT().\r
+  If SourceGuid is NULL, then ASSERT().\r
+\r
+  @param  DestinationGuid   Pointer to the destination GUID.\r
+  @param  SourceGuid        Pointer to the source GUID.\r
+\r
+  @return DestinationGuid.\r
+\r
+**/\r
+GUID *\r
+EFIAPI\r
+CopyGuid (\r
+  OUT GUID       *DestinationGuid,\r
+  IN CONST GUID  *SourceGuid\r
+  )\r
+{\r
+  WriteUnaligned64 (\r
+    (UINT64*)DestinationGuid,\r
+    ReadUnaligned64 ((CONST UINT64*)SourceGuid)\r
+    );\r
+  WriteUnaligned64 (\r
+    (UINT64*)DestinationGuid + 1,\r
+    ReadUnaligned64 ((CONST UINT64*)SourceGuid + 1)\r
+    );\r
+  return DestinationGuid;\r
+}\r
+\r
+/**\r
+  Compares two GUIDs.\r
+\r
+  This function compares Guid1 to Guid2.  If the GUIDs are identical then TRUE is returned.\r
+  If there are any bit differences in the two GUIDs, then FALSE is returned.\r
+  \r
+  If Guid1 is NULL, then ASSERT().\r
+  If Guid2 is NULL, then ASSERT().\r
+\r
+  @param  Guid1       A pointer to a 128 bit GUID.\r
+  @param  Guid2       A pointer to a 128 bit GUID.\r
+\r
+  @retval TRUE        Guid1 and Guid2 are identical.\r
+  @retval FALSE       Guid1 and Guid2 are not identical.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+CompareGuid (\r
+  IN CONST GUID  *Guid1,\r
+  IN CONST GUID  *Guid2\r
+  )\r
+{\r
+  UINT64  LowPartOfGuid1;\r
+  UINT64  LowPartOfGuid2;\r
+  UINT64  HighPartOfGuid1;\r
+  UINT64  HighPartOfGuid2;\r
+\r
+  LowPartOfGuid1  = ReadUnaligned64 ((CONST UINT64*) Guid1);\r
+  LowPartOfGuid2  = ReadUnaligned64 ((CONST UINT64*) Guid2);\r
+  HighPartOfGuid1 = ReadUnaligned64 ((CONST UINT64*) Guid1 + 1);\r
+  HighPartOfGuid2 = ReadUnaligned64 ((CONST UINT64*) Guid2 + 1);\r
+\r
+  return (BOOLEAN) (LowPartOfGuid1 == LowPartOfGuid2 && HighPartOfGuid1 == HighPartOfGuid2);\r
+}\r
+\r
+/**\r
+  Scans a target buffer for a GUID, and returns a pointer to the matching GUID\r
+  in the target buffer.\r
+\r
+  This function searches the target buffer specified by Buffer and Length from\r
+  the lowest address to the highest address at 128-bit increments for the 128-bit\r
+  GUID value that matches Guid.  If a match is found, then a pointer to the matching\r
+  GUID in the target buffer is returned.  If no match is found, then NULL is returned.\r
+  If Length is 0, then NULL is returned.\r
+  \r
+  If Length > 0 and Buffer is NULL, then ASSERT().\r
+  If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r
+  If Length is not aligned on a 128-bit boundary, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+\r
+  @param  Buffer  Pointer to the target buffer to scan.\r
+  @param  Length  Number of bytes in Buffer to scan.\r
+  @param  Guid    Value to search for in the target buffer.\r
+\r
+  @return A pointer to the matching Guid in the target buffer or NULL otherwise.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+ScanGuid (\r
+  IN CONST VOID  *Buffer,\r
+  IN UINTN       Length,\r
+  IN CONST GUID  *Guid\r
+  )\r
+{\r
+  CONST GUID                        *GuidPtr;\r
+\r
+  ASSERT (((UINTN)Buffer & (sizeof (Guid->Data1) - 1)) == 0);\r
+  ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));\r
+  ASSERT ((Length & (sizeof (*GuidPtr) - 1)) == 0);\r
+\r
+  GuidPtr = (GUID*)Buffer;\r
+  Buffer  = GuidPtr + Length / sizeof (*GuidPtr);\r
+  while (GuidPtr < (CONST GUID*)Buffer) {\r
+    if (CompareGuid (GuidPtr, Guid)) {\r
+      return (VOID*)GuidPtr;\r
+    }\r
+    GuidPtr++;\r
+  }\r
+  return NULL;\r
+}\r
diff --git a/ArmPkg/Library/BaseMemoryLibVstm/MemLibInternals.h b/ArmPkg/Library/BaseMemoryLibVstm/MemLibInternals.h
new file mode 100755 (executable)
index 0000000..f40299b
--- /dev/null
@@ -0,0 +1,234 @@
+/** @file\r
+  Declaration of internal functions for Base Memory Library.\r
+\r
+  The following BaseMemoryLib instances contain the same copy of this file:\r
+    BaseMemoryLib\r
+    BaseMemoryLibMmx\r
+    BaseMemoryLibSse2\r
+    BaseMemoryLibRepStr\r
+    BaseMemoryLibOptDxe\r
+    BaseMemoryLibOptPei\r
+\r
+  Copyright (c) 2006 - 2009, 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
+**/\r
+\r
+#ifndef __MEM_LIB_INTERNALS__\r
+#define __MEM_LIB_INTERNALS__\r
+\r
+#include <Base.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/DebugLib.h>\r
+\r
+/**\r
+  Copy Length bytes from Source to Destination.\r
+\r
+  @param  DestinationBuffer Target of copy\r
+  @param  SourceBuffer      Place to copy from\r
+  @param  Length            Number of bytes to copy\r
+\r
+  @return Destination\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InternalMemCopyMem (\r
+  OUT     VOID                      *DestinationBuffer,\r
+  IN      CONST VOID                *SourceBuffer,\r
+  IN      UINTN                     Length\r
+  );\r
+\r
+/**\r
+  Set Buffer to Value for Size bytes.\r
+\r
+  @param  Buffer   Memory to set.\r
+  @param  Length   Number of bytes to set\r
+  @param  Value    Value of the set operation.\r
+\r
+  @return Buffer\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InternalMemSetMem (\r
+  OUT     VOID                      *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT8                     Value\r
+  );\r
+\r
+/**\r
+  Fills a target buffer with a 16-bit value, and returns the target buffer.\r
+\r
+  @param  Buffer  Pointer to the target buffer to fill.\r
+  @param  Length  Count of 16-bit value to fill.\r
+  @param  Value   Value with which to fill Length bytes of Buffer.\r
+\r
+  @return Buffer\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InternalMemSetMem16 (\r
+  OUT     VOID                      *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT16                    Value\r
+  );\r
+\r
+/**\r
+  Fills a target buffer with a 32-bit value, and returns the target buffer.\r
+\r
+  @param  Buffer  Pointer to the target buffer to fill.\r
+  @param  Length  Count of 32-bit value to fill.\r
+  @param  Value   Value with which to fill Length bytes of Buffer.\r
+\r
+  @return Buffer\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InternalMemSetMem32 (\r
+  OUT     VOID                      *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT32                    Value\r
+  );\r
+\r
+/**\r
+  Fills a target buffer with a 64-bit value, and returns the target buffer.\r
+\r
+  @param  Buffer  Pointer to the target buffer to fill.\r
+  @param  Length  Count of 64-bit value to fill.\r
+  @param  Value   Value with which to fill Length bytes of Buffer.\r
+\r
+  @return Buffer\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InternalMemSetMem64 (\r
+  OUT     VOID                      *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT64                    Value\r
+  );\r
+\r
+/**\r
+  Set Buffer to 0 for Size bytes.\r
+\r
+  @param  Buffer Memory to set.\r
+  @param  Length Number of bytes to set\r
+\r
+  @return Buffer\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InternalMemZeroMem (\r
+  OUT     VOID                      *Buffer,\r
+  IN      UINTN                     Length\r
+  );\r
+\r
+/**\r
+  Compares two memory buffers of a given length.\r
+\r
+  @param  DestinationBuffer First memory buffer\r
+  @param  SourceBuffer      Second memory buffer\r
+  @param  Length            Length of DestinationBuffer and SourceBuffer memory\r
+                            regions to compare. Must be non-zero.\r
+\r
+  @return 0                 All Length bytes of the two buffers are identical.\r
+  @retval Non-zero          The first mismatched byte in SourceBuffer subtracted from the first\r
+                            mismatched byte in DestinationBuffer.\r
+\r
+**/\r
+INTN\r
+EFIAPI\r
+InternalMemCompareMem (\r
+  IN      CONST VOID                *DestinationBuffer,\r
+  IN      CONST VOID                *SourceBuffer,\r
+  IN      UINTN                     Length\r
+  );\r
+\r
+/**\r
+  Scans a target buffer for an 8-bit value, and returns a pointer to the\r
+  matching 8-bit value in the target buffer.\r
+\r
+  @param  Buffer  Pointer to the target buffer to scan.\r
+  @param  Length  Count of 8-bit value to scan. Must be non-zero.\r
+  @param  Value   Value to search for in the target buffer.\r
+\r
+  @return Pointer to the first occurrence or NULL if not found.\r
+\r
+**/\r
+CONST VOID *\r
+EFIAPI\r
+InternalMemScanMem8 (\r
+  IN      CONST VOID                *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT8                     Value\r
+  );\r
+\r
+/**\r
+  Scans a target buffer for a 16-bit value, and returns a pointer to the\r
+  matching 16-bit value in the target buffer.\r
+\r
+  @param  Buffer  Pointer to the target buffer to scan.\r
+  @param  Length  Count of 16-bit value to scan. Must be non-zero.\r
+  @param  Value   Value to search for in the target buffer.\r
+\r
+  @return Pointer to the first occurrence or NULL if not found.\r
+\r
+**/\r
+CONST VOID *\r
+EFIAPI\r
+InternalMemScanMem16 (\r
+  IN      CONST VOID                *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT16                    Value\r
+  );\r
+\r
+/**\r
+  Scans a target buffer for a 32-bit value, and returns a pointer to the\r
+  matching 32-bit value in the target buffer.\r
+\r
+  @param  Buffer  Pointer to the target buffer to scan.\r
+  @param  Length  Count of 32-bit value to scan. Must be non-zero.\r
+  @param  Value   Value to search for in the target buffer.\r
+\r
+  @return Pointer to the first occurrence or NULL if not found.\r
+\r
+**/\r
+CONST VOID *\r
+EFIAPI\r
+InternalMemScanMem32 (\r
+  IN      CONST VOID                *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT32                    Value\r
+  );\r
+\r
+/**\r
+  Scans a target buffer for a 64-bit value, and returns a pointer to the\r
+  matching 64-bit value in the target buffer.\r
+\r
+  @param  Buffer  Pointer to the target buffer to scan.\r
+  @param  Length  Count of 64-bit value to scan. Must be non-zero.\r
+  @param  Value   Value to search for in the target buffer.\r
+\r
+  @return Pointer to the first occurrence or NULL if not found.\r
+\r
+**/\r
+CONST VOID *\r
+EFIAPI\r
+InternalMemScanMem64 (\r
+  IN      CONST VOID                *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT64                    Value\r
+  );\r
+\r
+#endif\r
diff --git a/ArmPkg/Library/BaseMemoryLibVstm/ScanMem16Wrapper.c b/ArmPkg/Library/BaseMemoryLibVstm/ScanMem16Wrapper.c
new file mode 100755 (executable)
index 0000000..1122fb5
--- /dev/null
@@ -0,0 +1,67 @@
+/** @file\r
+  ScanMem16() implementation.\r
+\r
+  The following BaseMemoryLib instances contain the same copy of this file:\r
+\r
+    BaseMemoryLib\r
+    BaseMemoryLibMmx\r
+    BaseMemoryLibSse2\r
+    BaseMemoryLibRepStr\r
+    BaseMemoryLibOptDxe\r
+    BaseMemoryLibOptPei\r
+    PeiMemoryLib\r
+    UefiMemoryLib\r
+\r
+  Copyright (c) 2006 - 2009, 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
+**/\r
+\r
+#include "MemLibInternals.h"\r
+\r
+/**\r
+  Scans a target buffer for a 16-bit value, and returns a pointer to the matching 16-bit value\r
+  in the target buffer.\r
+\r
+  This function searches the target buffer specified by Buffer and Length from the lowest\r
+  address to the highest address for a 16-bit value that matches Value.  If a match is found,\r
+  then a pointer to the matching byte in the target buffer is returned.  If no match is found,\r
+  then NULL is returned.  If Length is 0, then NULL is returned.\r
+  \r
+  If Length > 0 and Buffer is NULL, then ASSERT().\r
+  If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r
+  If Length is not aligned on a 16-bit boundary, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+\r
+  @param  Buffer      Pointer to the target buffer to scan.\r
+  @param  Length      Number of bytes in Buffer to scan.\r
+  @param  Value       Value to search for in the target buffer.\r
+\r
+  @return A pointer to the matching byte in the target buffer or NULL otherwise.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+ScanMem16 (\r
+  IN CONST VOID  *Buffer,\r
+  IN UINTN       Length,\r
+  IN UINT16      Value\r
+  )\r
+{\r
+  if (Length == 0) {\r
+    return NULL;\r
+  }\r
+\r
+  ASSERT (Buffer != NULL);\r
+  ASSERT (((UINTN)Buffer & (sizeof (Value) - 1)) == 0);\r
+  ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));\r
+  ASSERT ((Length & (sizeof (Value) - 1)) == 0);\r
+\r
+  return (VOID*)InternalMemScanMem16 (Buffer, Length / sizeof (Value), Value);\r
+}\r
diff --git a/ArmPkg/Library/BaseMemoryLibVstm/ScanMem32Wrapper.c b/ArmPkg/Library/BaseMemoryLibVstm/ScanMem32Wrapper.c
new file mode 100755 (executable)
index 0000000..60d5eff
--- /dev/null
@@ -0,0 +1,66 @@
+/** @file\r
+  ScanMem32() implementation.\r
+\r
+  The following BaseMemoryLib instances contain the same copy of this file:\r
+    BaseMemoryLib\r
+    BaseMemoryLibMmx\r
+    BaseMemoryLibSse2\r
+    BaseMemoryLibRepStr\r
+    BaseMemoryLibOptDxe\r
+    BaseMemoryLibOptPei\r
+    PeiMemoryLib\r
+    UefiMemoryLib\r
+\r
+  Copyright (c) 2006 - 2009, 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
+**/\r
+\r
+#include "MemLibInternals.h"\r
+\r
+/**\r
+  Scans a target buffer for a 32-bit value, and returns a pointer to the matching 32-bit value\r
+  in the target buffer.\r
+\r
+  This function searches the target buffer specified by Buffer and Length from the lowest\r
+  address to the highest address for a 32-bit value that matches Value.  If a match is found,\r
+  then a pointer to the matching byte in the target buffer is returned.  If no match is found,\r
+  then NULL is returned.  If Length is 0, then NULL is returned.\r
+  \r
+  If Length > 0 and Buffer is NULL, then ASSERT().\r
+  If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r
+  If Length is not aligned on a 32-bit boundary, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+\r
+  @param  Buffer      Pointer to the target buffer to scan.\r
+  @param  Length      Number of bytes in Buffer to scan.\r
+  @param  Value       Value to search for in the target buffer.\r
+\r
+  @return A pointer to the matching byte in the target buffer or NULL otherwise.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+ScanMem32 (\r
+  IN CONST VOID  *Buffer,\r
+  IN UINTN       Length,\r
+  IN UINT32      Value\r
+  )\r
+{\r
+  if (Length == 0) {\r
+    return NULL;\r
+  }\r
+\r
+  ASSERT (Buffer != NULL);\r
+  ASSERT (((UINTN)Buffer & (sizeof (Value) - 1)) == 0);\r
+  ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));\r
+  ASSERT ((Length & (sizeof (Value) - 1)) == 0);\r
+\r
+  return (VOID*)InternalMemScanMem32 (Buffer, Length / sizeof (Value), Value);\r
+}\r
diff --git a/ArmPkg/Library/BaseMemoryLibVstm/ScanMem64Wrapper.c b/ArmPkg/Library/BaseMemoryLibVstm/ScanMem64Wrapper.c
new file mode 100755 (executable)
index 0000000..87d1643
--- /dev/null
@@ -0,0 +1,67 @@
+/** @file\r
+  ScanMem64() implementation.\r
+\r
+  The following BaseMemoryLib instances contain the same copy of this file:\r
+\r
+    BaseMemoryLib\r
+    BaseMemoryLibMmx\r
+    BaseMemoryLibSse2\r
+    BaseMemoryLibRepStr\r
+    BaseMemoryLibOptDxe\r
+    BaseMemoryLibOptPei\r
+    PeiMemoryLib\r
+    UefiMemoryLib\r
+\r
+  Copyright (c) 2006 - 2009, 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
+**/\r
+\r
+#include "MemLibInternals.h"\r
+\r
+/**\r
+  Scans a target buffer for a 64-bit value, and returns a pointer to the matching 64-bit value\r
+  in the target buffer.\r
+\r
+  This function searches the target buffer specified by Buffer and Length from the lowest\r
+  address to the highest address for a 64-bit value that matches Value.  If a match is found,\r
+  then a pointer to the matching byte in the target buffer is returned.  If no match is found,\r
+  then NULL is returned.  If Length is 0, then NULL is returned.\r
+  \r
+  If Length > 0 and Buffer is NULL, then ASSERT().\r
+  If Buffer is not aligned on a 64-bit boundary, then ASSERT().\r
+  If Length is not aligned on a 64-bit boundary, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+\r
+  @param  Buffer      Pointer to the target buffer to scan.\r
+  @param  Length      Number of bytes in Buffer to scan.\r
+  @param  Value       Value to search for in the target buffer.\r
+\r
+  @return A pointer to the matching byte in the target buffer or NULL otherwise.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+ScanMem64 (\r
+  IN CONST VOID  *Buffer,\r
+  IN UINTN       Length,\r
+  IN UINT64      Value\r
+  )\r
+{\r
+  if (Length == 0) {\r
+    return NULL;\r
+  }\r
+\r
+  ASSERT (Buffer != NULL);\r
+  ASSERT (((UINTN)Buffer & (sizeof (Value) - 1)) == 0);\r
+  ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));\r
+  ASSERT ((Length & (sizeof (Value) - 1)) == 0);\r
+\r
+  return (VOID*)InternalMemScanMem64 (Buffer, Length / sizeof (Value), Value);\r
+}\r
diff --git a/ArmPkg/Library/BaseMemoryLibVstm/ScanMem8Wrapper.c b/ArmPkg/Library/BaseMemoryLibVstm/ScanMem8Wrapper.c
new file mode 100755 (executable)
index 0000000..ecf1bdd
--- /dev/null
@@ -0,0 +1,99 @@
+/** @file\r
+  ScanMem8() and ScanMemN() implementation.\r
+\r
+  The following BaseMemoryLib instances contain the same copy of this file:\r
+\r
+    BaseMemoryLib\r
+    BaseMemoryLibMmx\r
+    BaseMemoryLibSse2\r
+    BaseMemoryLibRepStr\r
+    BaseMemoryLibOptDxe\r
+    BaseMemoryLibOptPei\r
+    PeiMemoryLib\r
+    UefiMemoryLib\r
+\r
+  Copyright (c) 2006 - 2009, 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
+**/\r
+\r
+#include "MemLibInternals.h"\r
+\r
+/**\r
+  Scans a target buffer for an 8-bit value, and returns a pointer to the matching 8-bit value\r
+  in the target buffer.\r
+\r
+  This function searches the target buffer specified by Buffer and Length from the lowest\r
+  address to the highest address for an 8-bit value that matches Value.  If a match is found,\r
+  then a pointer to the matching byte in the target buffer is returned.  If no match is found,\r
+  then NULL is returned.  If Length is 0, then NULL is returned.\r
+  \r
+  If Length > 0 and Buffer is NULL, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+\r
+  @param  Buffer      Pointer to the target buffer to scan.\r
+  @param  Length      Number of bytes in Buffer to scan.\r
+  @param  Value       Value to search for in the target buffer.\r
+\r
+  @return A pointer to the matching byte in the target buffer or NULL otherwise.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+ScanMem8 (\r
+  IN CONST VOID  *Buffer,\r
+  IN UINTN       Length,\r
+  IN UINT8       Value\r
+  )\r
+{\r
+  if (Length == 0) {\r
+    return NULL;\r
+  }\r
+  ASSERT (Buffer != NULL);\r
+  ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));\r
\r
+  return (VOID*)InternalMemScanMem8 (Buffer, Length, Value);\r
+}\r
+\r
+/**\r
+  Scans a target buffer for a UINTN sized value, and returns a pointer to the matching \r
+  UINTN sized value in the target buffer.\r
+\r
+  This function searches the target buffer specified by Buffer and Length from the lowest\r
+  address to the highest address for a UINTN sized value that matches Value.  If a match is found,\r
+  then a pointer to the matching byte in the target buffer is returned.  If no match is found,\r
+  then NULL is returned.  If Length is 0, then NULL is returned.\r
+  \r
+  If Length > 0 and Buffer is NULL, then ASSERT().\r
+  If Buffer is not aligned on a UINTN boundary, then ASSERT().\r
+  If Length is not aligned on a UINTN boundary, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+\r
+  @param  Buffer      Pointer to the target buffer to scan.\r
+  @param  Length      Number of bytes in Buffer to scan.\r
+  @param  Value       Value to search for in the target buffer.\r
+\r
+  @return A pointer to the matching byte in the target buffer or NULL otherwise.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+ScanMemN (\r
+  IN CONST VOID  *Buffer,\r
+  IN UINTN       Length,\r
+  IN UINTN       Value\r
+  )\r
+{\r
+  if (sizeof (UINTN) == sizeof (UINT64)) {\r
+    return ScanMem64 (Buffer, Length, (UINT64)Value);\r
+  } else {\r
+    return ScanMem32 (Buffer, Length, (UINT32)Value);\r
+  }\r
+}\r
+\r
diff --git a/ArmPkg/Library/BaseMemoryLibVstm/SetMem.c b/ArmPkg/Library/BaseMemoryLibVstm/SetMem.c
new file mode 100755 (executable)
index 0000000..2394f48
--- /dev/null
@@ -0,0 +1,53 @@
+/** @file\r
+  Implementation of the EfiSetMem routine. This function is broken\r
+  out into its own source file so that it can be excluded from a\r
+  build for a particular platform easily if an optimized version\r
+  is desired.\r
+\r
+  Copyright (c) 2006 - 2010, 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
+**/\r
+\r
+\r
+\r
+\r
+#include "MemLibInternals.h"\r
+\r
+/**\r
+  Set Buffer to Value for Size bytes.\r
+\r
+  @param  Buffer   Memory to set.\r
+  @param  Length   Number of bytes to set\r
+  @param  Value    Value of the set operation.\r
+\r
+  @return Buffer\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InternalMemSetMem (\r
+  OUT     VOID                      *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT8                     Value\r
+  )\r
+{\r
+  //\r
+  // Declare the local variables that actually move the data elements as\r
+  // volatile to prevent the optimizer from replacing this function with\r
+  // the intrinsic memset()\r
+  //\r
+  volatile UINT8                    *Pointer;\r
+\r
+  Pointer = (UINT8*)Buffer;\r
+  while (Length-- > 0) {\r
+    *(Pointer++) = Value;\r
+  }\r
+  return Buffer;\r
+}\r
diff --git a/ArmPkg/Library/BaseMemoryLibVstm/SetMem16Wrapper.c b/ArmPkg/Library/BaseMemoryLibVstm/SetMem16Wrapper.c
new file mode 100755 (executable)
index 0000000..d74b80f
--- /dev/null
@@ -0,0 +1,64 @@
+/** @file\r
+  SetMem16() implementation.\r
+\r
+  The following BaseMemoryLib instances contain the same copy of this file:\r
+    BaseMemoryLib\r
+    BaseMemoryLibMmx\r
+    BaseMemoryLibSse2\r
+    BaseMemoryLibRepStr\r
+    BaseMemoryLibOptDxe\r
+    BaseMemoryLibOptPei\r
+    PeiMemoryLib\r
+    UefiMemoryLib\r
+\r
+  Copyright (c) 2006 - 2009, 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
+**/\r
+\r
+#include "MemLibInternals.h"\r
+\r
+/**\r
+  Fills a target buffer with a 16-bit value, and returns the target buffer.\r
+\r
+  This function fills Length bytes of Buffer with the 16-bit value specified by\r
+  Value, and returns Buffer. Value is repeated every 16-bits in for Length\r
+  bytes of Buffer.\r
+\r
+  If Length > 0 and Buffer is NULL, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+  If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r
+  If Length is not aligned on a 16-bit boundary, then ASSERT().\r
+\r
+  @param  Buffer  Pointer to the target buffer to fill.\r
+  @param  Length  Number of bytes in Buffer to fill.\r
+  @param  Value   Value with which to fill Length bytes of Buffer.\r
+\r
+  @return Buffer.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+SetMem16 (\r
+  OUT VOID   *Buffer,\r
+  IN UINTN   Length,\r
+  IN UINT16  Value\r
+  )\r
+{\r
+  if (Length == 0) {\r
+    return Buffer;\r
+  }\r
+\r
+  ASSERT (Buffer != NULL);\r
+  ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));\r
+  ASSERT ((((UINTN)Buffer) & (sizeof (Value) - 1)) == 0);\r
+  ASSERT ((Length & (sizeof (Value) - 1)) == 0);\r
+\r
+  return InternalMemSetMem16 (Buffer, Length / sizeof (Value), Value);\r
+}\r
diff --git a/ArmPkg/Library/BaseMemoryLibVstm/SetMem32Wrapper.c b/ArmPkg/Library/BaseMemoryLibVstm/SetMem32Wrapper.c
new file mode 100755 (executable)
index 0000000..dc84d20
--- /dev/null
@@ -0,0 +1,64 @@
+/** @file\r
+  SetMem32() implementation.\r
+\r
+  The following BaseMemoryLib instances contain the same copy of this file:\r
+    BaseMemoryLib\r
+    BaseMemoryLibMmx\r
+    BaseMemoryLibSse2\r
+    BaseMemoryLibRepStr\r
+    BaseMemoryLibOptDxe\r
+    BaseMemoryLibOptPei\r
+    PeiMemoryLib\r
+    UefiMemoryLib\r
+\r
+  Copyright (c) 2006 - 2009, 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
+**/\r
+\r
+#include "MemLibInternals.h"\r
+\r
+/**\r
+  Fills a target buffer with a 32-bit value, and returns the target buffer.\r
+\r
+  This function fills Length bytes of Buffer with the 32-bit value specified by\r
+  Value, and returns Buffer. Value is repeated every 32-bits in for Length\r
+  bytes of Buffer.\r
+\r
+  If Length > 0 and Buffer is NULL, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+  If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r
+  If Length is not aligned on a 32-bit boundary, then ASSERT().\r
+\r
+  @param  Buffer  Pointer to the target buffer to fill.\r
+  @param  Length  Number of bytes in Buffer to fill.\r
+  @param  Value   Value with which to fill Length bytes of Buffer.\r
+\r
+  @return Buffer.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+SetMem32 (\r
+  OUT VOID   *Buffer,\r
+  IN UINTN   Length,\r
+  IN UINT32  Value\r
+  )\r
+{\r
+  if (Length == 0) {\r
+    return Buffer;\r
+  }\r
+\r
+  ASSERT (Buffer != NULL);\r
+  ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));\r
+  ASSERT ((((UINTN)Buffer) & (sizeof (Value) - 1)) == 0);\r
+  ASSERT ((Length & (sizeof (Value) - 1)) == 0);\r
+\r
+  return InternalMemSetMem32 (Buffer, Length / sizeof (Value), Value);\r
+}\r
diff --git a/ArmPkg/Library/BaseMemoryLibVstm/SetMem64Wrapper.c b/ArmPkg/Library/BaseMemoryLibVstm/SetMem64Wrapper.c
new file mode 100755 (executable)
index 0000000..05dc453
--- /dev/null
@@ -0,0 +1,64 @@
+/** @file\r
+  SetMem64() implementation.\r
+\r
+  The following BaseMemoryLib instances contain the same copy of this file:\r
+    BaseMemoryLib\r
+    BaseMemoryLibMmx\r
+    BaseMemoryLibSse2\r
+    BaseMemoryLibRepStr\r
+    BaseMemoryLibOptDxe\r
+    BaseMemoryLibOptPei\r
+    PeiMemoryLib\r
+    UefiMemoryLib\r
+\r
+  Copyright (c) 2006 - 2009, 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
+**/\r
+\r
+#include "MemLibInternals.h"\r
+\r
+/**\r
+  Fills a target buffer with a 64-bit value, and returns the target buffer.\r
+\r
+  This function fills Length bytes of Buffer with the 64-bit value specified by\r
+  Value, and returns Buffer. Value is repeated every 64-bits in for Length\r
+  bytes of Buffer.\r
+\r
+  If Length > 0 and Buffer is NULL, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+  If Buffer is not aligned on a 64-bit boundary, then ASSERT().\r
+  If Length is not aligned on a 64-bit boundary, then ASSERT().\r
+\r
+  @param  Buffer  Pointer to the target buffer to fill.\r
+  @param  Length  Number of bytes in Buffer to fill.\r
+  @param  Value   Value with which to fill Length bytes of Buffer.\r
+\r
+  @return Buffer.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+SetMem64 (\r
+  OUT VOID   *Buffer,\r
+  IN UINTN   Length,\r
+  IN UINT64  Value\r
+  )\r
+{\r
+  if (Length == 0) {\r
+    return Buffer;\r
+  }\r
+\r
+  ASSERT (Buffer != NULL);\r
+  ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));\r
+  ASSERT ((((UINTN)Buffer) & (sizeof (Value) - 1)) == 0);\r
+  ASSERT ((Length & (sizeof (Value) - 1)) == 0);\r
+\r
+  return InternalMemSetMem64 (Buffer, Length / sizeof (Value), Value);\r
+}\r
diff --git a/ArmPkg/Library/BaseMemoryLibVstm/SetMemWrapper.c b/ArmPkg/Library/BaseMemoryLibVstm/SetMemWrapper.c
new file mode 100755 (executable)
index 0000000..e728175
--- /dev/null
@@ -0,0 +1,91 @@
+/** @file\r
+  SetMem() and SetMemN() implementation.\r
+\r
+  The following BaseMemoryLib instances contain the same copy of this file:\r
+\r
+    BaseMemoryLib\r
+    BaseMemoryLibMmx\r
+    BaseMemoryLibSse2\r
+    BaseMemoryLibRepStr\r
+    BaseMemoryLibOptDxe\r
+    BaseMemoryLibOptPei\r
+    PeiMemoryLib\r
+    UefiMemoryLib\r
+\r
+  Copyright (c) 2006 - 2009, 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
+**/\r
+\r
+#include "MemLibInternals.h"\r
+\r
+/**\r
+  Fills a target buffer with a byte value, and returns the target buffer.\r
+\r
+  This function fills Length bytes of Buffer with Value, and returns Buffer.\r
+  \r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+\r
+  @param  Buffer    Memory to set.\r
+  @param  Length    Number of bytes to set.\r
+  @param  Value     Value with which to fill Length bytes of Buffer.\r
+\r
+  @return Buffer.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+SetMem (\r
+  OUT VOID  *Buffer,\r
+  IN UINTN  Length,\r
+  IN UINT8  Value\r
+  )\r
+{\r
+  if (Length == 0) {\r
+    return Buffer;\r
+  }\r
+\r
+  ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));\r
+\r
+  return InternalMemSetMem (Buffer, Length, Value);\r
+}\r
+\r
+/**\r
+  Fills a target buffer with a value that is size UINTN, and returns the target buffer.\r
+\r
+  This function fills Length bytes of Buffer with the UINTN sized value specified by\r
+  Value, and returns Buffer. Value is repeated every sizeof(UINTN) bytes for Length\r
+  bytes of Buffer.\r
+\r
+  If Length > 0 and Buffer is NULL, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+  If Buffer is not aligned on a UINTN boundary, then ASSERT().\r
+  If Length is not aligned on a UINTN boundary, then ASSERT().\r
+\r
+  @param  Buffer  Pointer to the target buffer to fill.\r
+  @param  Length  Number of bytes in Buffer to fill.\r
+  @param  Value   Value with which to fill Length bytes of Buffer.\r
+\r
+  @return Buffer.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+SetMemN (\r
+  OUT VOID  *Buffer,\r
+  IN UINTN  Length,\r
+  IN UINTN  Value\r
+  )\r
+{\r
+  if (sizeof (UINTN) == sizeof (UINT64)) {\r
+    return SetMem64 (Buffer, Length, (UINT64)Value);\r
+  } else {\r
+    return SetMem32 (Buffer, Length, (UINT32)Value);\r
+  }\r
+}\r
diff --git a/ArmPkg/Library/BaseMemoryLibVstm/ZeroMemWrapper.c b/ArmPkg/Library/BaseMemoryLibVstm/ZeroMemWrapper.c
new file mode 100755 (executable)
index 0000000..2923356
--- /dev/null
@@ -0,0 +1,52 @@
+/** @file\r
+  ZeroMem() implementation.\r
+\r
+  The following BaseMemoryLib instances contain the same copy of this file:\r
+\r
+    BaseMemoryLib\r
+    BaseMemoryLibMmx\r
+    BaseMemoryLibSse2\r
+    BaseMemoryLibRepStr\r
+    BaseMemoryLibOptDxe\r
+    BaseMemoryLibOptPei\r
+    PeiMemoryLib\r
+    UefiMemoryLib\r
+    \r
+  Copyright (c) 2006 - 2009 , 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
+**/\r
+\r
+#include "MemLibInternals.h"\r
+\r
+/**\r
+  Fills a target buffer with zeros, and returns the target buffer.\r
+\r
+  This function fills Length bytes of Buffer with zeros, and returns Buffer.\r
+  \r
+  If Length > 0 and Buffer is NULL, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+\r
+  @param  Buffer      Pointer to the target buffer to fill with zeros.\r
+  @param  Length      Number of bytes in Buffer to fill with zeros.\r
+\r
+  @return Buffer.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+ZeroMem (\r
+  OUT VOID  *Buffer,\r
+  IN UINTN  Length\r
+  )\r
+{\r
+  ASSERT (!(Buffer == NULL && Length > 0));\r
+  ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));\r
+  return InternalMemZeroMem (Buffer, Length);\r
+}\r
index 05afd190ddd16941ae08957f69f43f271c9a164f..025de152f58c38be3fff46a3260902ce28fe14ec 100644 (file)
@@ -74,6 +74,10 @@ BdsEntry (
   EFI_DEVICE_PATH_PROTOCOL  *LoadImageDevicePath;\r
   EFI_DEVICE_PATH_PROTOCOL  *FileSystemDevicePath;\r
   \r
+  PERF_END   (NULL, "DXE", NULL, 0);\r
+  PERF_START (NULL, "BDS", NULL, 0);\r
+\r
+\r
   //\r
   // Now do the EFI stuff\r
   //\r
index 21e49498cf66204866bfafb0397359a10e909f82..20a9f9d5cc259839e97ee129e8f5910cde0fa3e8 100644 (file)
@@ -30,6 +30,7 @@
 #include <Library/PcdLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/PrintLib.h>\r
+#include <Library/PerformanceLib.h>\r
 \r
 #include <Protocol/Bds.h>\r
 #include <Protocol/SerialIo.h>\r
index 692e2a56a62e54e411f36306997076bc1ab33b24..ca3cd38376b3b92b3b52f68d8f9a3c045b02ba6d 100644 (file)
@@ -141,6 +141,7 @@ LoadPeCoffSectionFromFv (
     \r
   Status = gBS->LoadImage (TRUE, gImageHandle, DevicePath, NULL, 0, &ImageHandle);\r
   if (!EFI_ERROR (Status)) {\r
+    PERF_END (NULL, "BDS", NULL, 0);\r
     Status = gBS->StartImage (ImageHandle, NULL, NULL);\r
   }\r
   \r
index 3394ed2607e7b4326e544e1976a1fd4621337c6f..ca2b0848c835ce35386bad1b0ed5da48e9c6857b 100644 (file)
@@ -43,7 +43,7 @@
   MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
   
   BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
-  BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
+  BaseMemoryLib|ArmPkg/Library/BaseMemoryLibStm/BaseMemoryLibStm.inf
 
   EfiResetSystemLib|BeagleBoardPkg/Library/ResetSystemLib/ResetSystemLib.inf
   
   PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
   HobLib|EmbeddedPkg/Library/PrePiHobLib/PrePiHobLib.inf
   PerformanceLib|MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.inf
+  
+  # 1/123 faster than Stm or Vstm version
+  BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
 
 [LibraryClasses.common.PEI_CORE]
   PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
index 413bb47fc28ab9fdf86414ed369ebcd9e78633eb..985e78a54df07dce051986808f6ee75c1d91ae65 100644 (file)
@@ -156,15 +156,27 @@ ImageHandleToPdbFileName (
 {\r
   EFI_STATUS                  Status;\r
   EFI_LOADED_IMAGE_PROTOCOL   *LoadedImage;\r
+  CHAR8                       *Pdb;\r
+  CHAR8                       *StripLeading;\r
 \r
   Status = gBS->HandleProtocol (Handle, &gEfiLoadedImageProtocolGuid, (VOID **)&LoadedImage);\r
   if (EFI_ERROR (Status)) {\r
     return "";\r
   }\r
 \r
-  return PeCoffLoaderGetPdbPointer (LoadedImage->ImageBase);\r
+  Pdb = PeCoffLoaderGetPdbPointer (LoadedImage->ImageBase);\r
+  StripLeading = AsciiStrStr (Pdb, "\\ARM\\");\r
+  if (StripLeading == NULL) {\r
+    StripLeading = AsciiStrStr (Pdb, "/ARM/");\r
+    if (StripLeading == NULL) {\r
+      return Pdb;\r
+    }\r
+  }\r
+  // Hopefully we hacked off the unneeded part\r
+  return (StripLeading + 5);\r
 }\r
 \r
+\r
 CHAR8 *mTokenList[] = {\r
   "SEC",\r
   "PEI",\r