--- /dev/null
+#/** @file\r
+# Component description file for RepStr Base Memory Library\r
+#\r
+# Base Memory Library that uses REP string instructions for\r
+# high performance and small size. Optimized for use in PEI.\r
+# Copyright (c) 2007, Intel Corporation\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 = BaseMemoryLibOptDxe\r
+ FILE_GUID = 02BD55C2-AB1D-4b75-B0FD-9A63AE09B31D\r
+ MODULE_TYPE = BASE\r
+ VERSION_STRING = 1.0\r
+ LIBRARY_CLASS = BaseMemoryLib \r
+ EDK_RELEASE_VERSION = 0x00020000\r
+ EFI_SPECIFICATION_VERSION = 0x00020000\r
+\r
+\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64\r
+#\r
+\r
+[Sources.common]\r
+ MemLibInternals.h\r
+\r
+[Sources.Ia32]\r
+ Ia32/ScanMem64.S\r
+ Ia32/ScanMem32.S\r
+ Ia32/ScanMem16.S\r
+ Ia32/ScanMem8.S\r
+ Ia32/CompareMem.S\r
+ Ia32/ZeroMem.S\r
+ Ia32/SetMem64.S\r
+ Ia32/SetMem32.S\r
+ Ia32/SetMem16.S\r
+ Ia32/SetMem.S\r
+ Ia32/CopyMem.S\r
+ Ia32/ScanMem64.asm\r
+ Ia32/ScanMem32.asm\r
+ Ia32/ScanMem16.asm\r
+ Ia32/ScanMem8.asm\r
+ Ia32/CompareMem.asm\r
+ Ia32/ZeroMem.asm\r
+ Ia32/SetMem64.asm\r
+ Ia32/SetMem32.asm\r
+ Ia32/SetMem16.asm\r
+ Ia32/SetMem.asm\r
+ Ia32/CopyMem.asm\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
+ MemLibGuid.c\r
+\r
+[Sources.X64]\r
+ x64/ScanMem64.asm\r
+ x64/ScanMem32.asm\r
+ x64/ScanMem16.asm\r
+ x64/ScanMem8.asm\r
+ x64/CompareMem.asm\r
+ x64/ZeroMem.asm\r
+ x64/SetMem64.asm\r
+ x64/SetMem32.asm\r
+ x64/SetMem16.asm\r
+ x64/SetMem.asm\r
+ x64/CopyMem.asm\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
+ MemLibGuid.c\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+\r
+[LibraryClasses]\r
+ DebugLib\r
+ BaseLib\r
+\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+ <MsaHeader>\r
+ <ModuleName>BaseMemoryLibOptDxe</ModuleName>\r
+ <ModuleType>BASE</ModuleType>\r
+ <GuidValue>02BD55C2-AB1D-4b75-B0FD-9A63AE09B31D</GuidValue>\r
+ <Version>1.0</Version>\r
+ <Abstract>Component description file for RepStr Base Memory Library</Abstract>\r
+ <Description>Base Memory Library that uses REP string instructions for
+ high performance and small size. Optimized for use in PEI.</Description>\r
+ <Copyright>Copyright (c) 2006, Intel Corporation</Copyright>\r
+ <License>All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
+ <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>\r
+ </MsaHeader>\r
+ <ModuleDefinitions>\r
+ <SupportedArchitectures>IA32 X64</SupportedArchitectures>\r
+ <BinaryModule>false</BinaryModule>\r
+ <OutputFileBasename>BaseMemoryLibRepStr</OutputFileBasename>\r
+ </ModuleDefinitions>\r
+ <LibraryClassDefinitions>\r
+ <LibraryClass Usage="ALWAYS_PRODUCED">\r
+ <Keyword>BaseMemoryLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>BaseLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>DebugLib</Keyword>\r
+ </LibraryClass>\r
+ </LibraryClassDefinitions>\r
+ <SourceFiles>\r
+ <Filename>MemLibInternals.h</Filename>\r
+ <Filename SupArchList="IA32">MemLibGuid.c</Filename>\r
+ <Filename SupArchList="IA32">CopyMemWrapper.c</Filename>\r
+ <Filename SupArchList="IA32">SetMemWrapper.c</Filename>\r
+ <Filename SupArchList="IA32">SetMem16Wrapper.c</Filename>\r
+ <Filename SupArchList="IA32">SetMem32Wrapper.c</Filename>\r
+ <Filename SupArchList="IA32">SetMem64Wrapper.c</Filename>\r
+ <Filename SupArchList="IA32">CompareMemWrapper.c</Filename>\r
+ <Filename SupArchList="IA32">ZeroMemWrapper.c</Filename>\r
+ <Filename SupArchList="IA32">ScanMem8Wrapper.c</Filename>\r
+ <Filename SupArchList="IA32">ScanMem16Wrapper.c</Filename>\r
+ <Filename SupArchList="IA32">ScanMem32Wrapper.c</Filename>\r
+ <Filename SupArchList="IA32">ScanMem64Wrapper.c</Filename>\r
+ <Filename SupArchList="IA32">Ia32/CopyMem.asm</Filename>\r
+ <Filename SupArchList="IA32">Ia32/SetMem.asm</Filename>\r
+ <Filename SupArchList="IA32">Ia32/SetMem16.asm</Filename>\r
+ <Filename SupArchList="IA32">Ia32/SetMem32.asm</Filename>\r
+ <Filename SupArchList="IA32">Ia32/SetMem64.asm</Filename>\r
+ <Filename SupArchList="IA32">Ia32/ZeroMem.asm</Filename>\r
+ <Filename SupArchList="IA32">Ia32/CompareMem.asm</Filename>\r
+ <Filename SupArchList="IA32">Ia32/ScanMem8.asm</Filename>\r
+ <Filename SupArchList="IA32">Ia32/ScanMem16.asm</Filename>\r
+ <Filename SupArchList="IA32">Ia32/ScanMem32.asm</Filename>\r
+ <Filename SupArchList="IA32">Ia32/ScanMem64.asm</Filename>\r
+ <Filename SupArchList="IA32">Ia32/CopyMem.S</Filename>\r
+ <Filename SupArchList="IA32">Ia32/SetMem.S</Filename>\r
+ <Filename SupArchList="IA32">Ia32/SetMem16.S</Filename>\r
+ <Filename SupArchList="IA32">Ia32/SetMem32.S</Filename>\r
+ <Filename SupArchList="IA32">Ia32/SetMem64.S</Filename>\r
+ <Filename SupArchList="IA32">Ia32/ZeroMem.S</Filename>\r
+ <Filename SupArchList="IA32">Ia32/CompareMem.S</Filename>\r
+ <Filename SupArchList="IA32">Ia32/ScanMem8.S</Filename>\r
+ <Filename SupArchList="IA32">Ia32/ScanMem16.S</Filename>\r
+ <Filename SupArchList="IA32">Ia32/ScanMem32.S</Filename>\r
+ <Filename SupArchList="IA32">Ia32/ScanMem64.S</Filename>\r
+ <Filename SupArchList="X64">MemLibGuid.c</Filename>\r
+ <Filename SupArchList="X64">CopyMemWrapper.c</Filename>\r
+ <Filename SupArchList="X64">SetMemWrapper.c</Filename>\r
+ <Filename SupArchList="X64">SetMem16Wrapper.c</Filename>\r
+ <Filename SupArchList="X64">SetMem32Wrapper.c</Filename>\r
+ <Filename SupArchList="X64">SetMem64Wrapper.c</Filename>\r
+ <Filename SupArchList="X64">CompareMemWrapper.c</Filename>\r
+ <Filename SupArchList="X64">ZeroMemWrapper.c</Filename>\r
+ <Filename SupArchList="X64">ScanMem8Wrapper.c</Filename>\r
+ <Filename SupArchList="X64">ScanMem16Wrapper.c</Filename>\r
+ <Filename SupArchList="X64">ScanMem32Wrapper.c</Filename>\r
+ <Filename SupArchList="X64">ScanMem64Wrapper.c</Filename>\r
+ <Filename SupArchList="X64">x64/CopyMem.asm</Filename>\r
+ <Filename SupArchList="X64">x64/SetMem.asm</Filename>\r
+ <Filename SupArchList="X64">x64/SetMem16.asm</Filename>\r
+ <Filename SupArchList="X64">x64/SetMem32.asm</Filename>\r
+ <Filename SupArchList="X64">x64/SetMem64.asm</Filename>\r
+ <Filename SupArchList="X64">x64/ZeroMem.asm</Filename>\r
+ <Filename SupArchList="X64">x64/CompareMem.asm</Filename>\r
+ <Filename SupArchList="X64">x64/ScanMem8.asm</Filename>\r
+ <Filename SupArchList="X64">x64/ScanMem16.asm</Filename>\r
+ <Filename SupArchList="X64">x64/ScanMem32.asm</Filename>\r
+ <Filename SupArchList="X64">x64/ScanMem64.asm</Filename>\r
+ </SourceFiles>\r
+ <PackageDependencies>\r
+ <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+ </PackageDependencies>\r
+ <Externs>\r
+ <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+ <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+ </Externs>\r
+</ModuleSurfaceArea>
\ No newline at end of file
--- /dev/null
+/** @file\r
+ CompareMem() implementation.\r
+\r
+ Copyright (c) 2006, Intel Corporation<BR>\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+ The following BaseMemoryLib instances share the same version of this file:\r
+\r
+ BaseMemoryLib\r
+ BaseMemoryLibMmx\r
+ BaseMemoryLibSse2\r
+ BaseMemoryLibRepStr\r
+ PeiMemoryLib\r
+ DxeMemoryLib\r
+\r
+**/\r
+\r
+//\r
+// Include common header file for this module.\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
+ If Length > 0 and DestinationBuffer is NULL and Length > 0, then ASSERT().\r
+ If Length > 0 and SourceBuffer is NULL and Length > 0, 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
+\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) {\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
--- /dev/null
+/** @file\r
+ CopyMem() implementation.\r
+\r
+ Copyright (c) 2006, Intel Corporation<BR>\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+ The following BaseMemoryLib instances share the same version of this file:\r
+\r
+ BaseMemoryLib\r
+ BaseMemoryLibMmx\r
+ BaseMemoryLibSse2\r
+ BaseMemoryLibRepStr\r
+ PeiMemoryLib\r
+ DxeMemoryLib\r
+\r
+**/\r
+\r
+//\r
+// Include common header file for this module.\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
+ 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
--- /dev/null
+#------------------------------------------------------------------------------
+#
+# Copyright (c) 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# CompareMem.Asm
+#
+# Abstract:
+#
+# CompareMem function
+#
+# Notes:
+#
+# The following BaseMemoryLib instances share the same version of this file:
+#
+# BaseMemoryLibRepStr
+# BaseMemoryLibMmx
+# BaseMemoryLibSse2
+#
+#------------------------------------------------------------------------------
+
+.globl _InternalMemCompareMem
+
+#------------------------------------------------------------------------------
+# INTN
+# EFIAPI
+# InternalMemCompareMem (
+# IN CONST VOID *DestinationBuffer,
+# IN CONST VOID *SourceBuffer,
+# IN UINTN Length
+# );
+#------------------------------------------------------------------------------
+_InternalMemCompareMem:
+ push %esi
+ push %edi
+ movl 12(%esp), %esi
+ movl 16(%esp), %edi
+ movl 20(%esp), %ecx
+ repe cmpsb
+ movzbl -1(%esi), %eax
+ movzbl -1(%edi), %edx
+ subl %edx, %eax
+ pop %edi
+ pop %esi
+ ret
--- /dev/null
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2006, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution. The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+; CompareMem.Asm\r
+;\r
+; Abstract:\r
+;\r
+; CompareMem function\r
+;\r
+; Notes:\r
+;\r
+; The following BaseMemoryLib instances share the same version of this file:\r
+;\r
+; BaseMemoryLibRepStr\r
+; BaseMemoryLibMmx\r
+; BaseMemoryLibSse2\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+ .686\r
+ .model flat,C\r
+ .code\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
+InternalMemCompareMem PROC USES esi edi\r
+ mov esi, [esp + 12]\r
+ mov edi, [esp + 16]\r
+ mov ecx, [esp + 20]\r
+ repe cmpsb\r
+ movzx eax, byte ptr [esi - 1]\r
+ movzx edx, byte ptr [edi - 1]\r
+ sub eax, edx\r
+ ret\r
+InternalMemCompareMem ENDP\r
+\r
+ END\r
--- /dev/null
+#------------------------------------------------------------------------------
+#
+# Copyright (c) 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# CopyMem.asm
+#
+# Abstract:
+#
+# CopyMem function
+#
+# Notes:
+#
+#------------------------------------------------------------------------------
+
+.globl _InternalMemCopyMem
+
+#------------------------------------------------------------------------------
+# VOID *
+# EFIAPI
+# InternalMemCopyMem (
+# IN VOID *Destination,
+# IN VOID *Source,
+# IN UINTN Count
+# );
+#------------------------------------------------------------------------------
+_InternalMemCopyMem:
+ push %esi
+ push %edi
+ movl 16(%esp), %esi # esi <- Source
+ movl 12(%esp), %edi # edi <- Destination
+ movl 20(%esp), %edx # edx <- Count
+ leal -1(%esi,%edx,), %eax # eax <- End of Source
+ cmpl %edi, %esi
+ jae L0
+ cmpl %edi, %eax # Overlapped?
+ jae L_CopyBackward # Copy backward if overlapped
+L0:
+ xorl %ecx, %ecx
+ subl %edi, %ecx
+ andl $15, %ecx # ecx + edi aligns on 16-byte boundary
+ jz L1
+ cmpl %edx, %ecx
+ cmova %edx, %ecx
+ subl %ecx, %edx # edx <- remaining bytes to copy
+ rep
+ movsb
+L1:
+ movl %edx, %ecx
+ andl $15, %edx
+ shrl $4, %ecx # ecx <- # of DQwords to copy
+ jz L_CopyBytes
+ addl $-16, %esp
+ movdqu %xmm0, (%esp)
+L2:
+ movdqu (%esi), %xmm0
+ movntdq %xmm0, (%edi)
+ addl $16, %esi
+ addl $16, %edi
+ loop L2
+ mfence
+ movdqu (%esp),%xmm0
+ addl $16, %esp # stack cleanup
+ jmp L_CopyBytes
+L_CopyBackward:
+ movl %eax, %esi # esi <- Last byte in Source
+ leal -1(%edi,%edx,), %edi # edi <- Last byte in Destination
+ std
+L_CopyBytes:
+ movl %edx, %ecx
+ rep
+ movsb
+ cld
+ movl 12(%esp), %eax # eax <- Destination as return value
+ pop %edi
+ pop %esi
+ ret
--- /dev/null
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2006, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution. The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+; CopyMem.asm\r
+;\r
+; Abstract:\r
+;\r
+; CopyMem function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+ .686\r
+ .model flat,C\r
+ .xmm\r
+ .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID *\r
+; InternalMemCopyMem (\r
+; IN VOID *Destination,\r
+; IN VOID *Source,\r
+; IN UINTN Count\r
+; );\r
+;------------------------------------------------------------------------------\r
+InternalMemCopyMem PROC USES esi edi\r
+ mov esi, [esp + 16] ; esi <- Source\r
+ mov edi, [esp + 12] ; edi <- Destination\r
+ mov edx, [esp + 20] ; edx <- Count\r
+ lea eax, [esi + edx - 1] ; eax <- End of Source\r
+ cmp esi, edi\r
+ jae @F\r
+ cmp eax, edi ; Overlapped?\r
+ jae @CopyBackward ; Copy backward if overlapped\r
+@@:\r
+ xor ecx, ecx\r
+ sub ecx, edi\r
+ and ecx, 15 ; ecx + edi aligns on 16-byte boundary\r
+ jz @F\r
+ cmp ecx, edx\r
+ cmova ecx, edx\r
+ sub edx, ecx ; edx <- remaining bytes to copy\r
+ rep movsb\r
+@@:\r
+ mov ecx, edx\r
+ and edx, 15\r
+ shr ecx, 4 ; ecx <- # of DQwords to copy\r
+ jz @CopyBytes\r
+ add esp, -16\r
+ movdqu [esp], xmm0 ; save xmm0\r
+@@:\r
+ movdqu xmm0, [esi] ; esi may not be 16-bytes aligned\r
+ movntdq [edi], xmm0 ; edi should be 16-bytes aligned\r
+ add esi, 16\r
+ add edi, 16\r
+ loop @B\r
+ mfence\r
+ movdqu xmm0, [esp] ; restore xmm0\r
+ add esp, 16 ; stack cleanup\r
+ jmp @CopyBytes\r
+@CopyBackward:\r
+ mov esi, eax ; esi <- Last byte in Source\r
+ lea edi, [edi + edx - 1] ; edi <- Last byte in Destination\r
+ std\r
+@CopyBytes:\r
+ mov ecx, edx\r
+ rep movsb\r
+ cld\r
+ mov eax, [esp + 12] ; eax <- Destination as return value\r
+ ret\r
+InternalMemCopyMem ENDP\r
+\r
+ END\r
--- /dev/null
+#------------------------------------------------------------------------------
+#
+# Copyright (c) 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# ScanMem16.Asm
+#
+# Abstract:
+#
+# ScanMem16 function
+#
+# Notes:
+#
+# The following BaseMemoryLib instances share the same version of this file:
+#
+# BaseMemoryLibRepStr
+# BaseMemoryLibMmx
+# BaseMemoryLibSse2
+#
+#------------------------------------------------------------------------------
+
+.globl _InternalMemScanMem16
+
+#------------------------------------------------------------------------------
+# CONST VOID *
+# EFIAPI
+# InternalMemScanMem16 (
+# IN CONST VOID *Buffer,
+# IN UINTN Length,
+# IN UINT16 Value
+# );
+#------------------------------------------------------------------------------
+_InternalMemScanMem16:
+ push %edi
+ movl 12(%esp), %ecx
+ movl 8(%esp), %edi
+ movl 16(%esp), %eax
+ repne scasw
+ leal -2(%edi), %eax
+ cmovnz %ecx, %eax
+ pop %edi
+ ret
--- /dev/null
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2006, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution. The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+; ScanMem16.Asm\r
+;\r
+; Abstract:\r
+;\r
+; ScanMem16 function\r
+;\r
+; Notes:\r
+;\r
+; The following BaseMemoryLib instances share the same version of this file:\r
+;\r
+; BaseMemoryLibRepStr\r
+; BaseMemoryLibMmx\r
+; BaseMemoryLibSse2\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+ .686\r
+ .model flat,C\r
+ .code\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
+InternalMemScanMem16 PROC USES edi\r
+ mov ecx, [esp + 12]\r
+ mov edi, [esp + 8]\r
+ mov eax, [esp + 16]\r
+ repne scasw\r
+ lea eax, [edi - 2]\r
+ cmovnz eax, ecx\r
+ ret\r
+InternalMemScanMem16 ENDP\r
+\r
+ END\r
--- /dev/null
+#------------------------------------------------------------------------------
+#
+# Copyright (c) 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# ScanMem32.Asm
+#
+# Abstract:
+#
+# ScanMem32 function
+#
+# Notes:
+#
+# The following BaseMemoryLib instances share the same version of this file:
+#
+# BaseMemoryLibRepStr
+# BaseMemoryLibMmx
+# BaseMemoryLibSse2
+#
+#------------------------------------------------------------------------------
+
+.globl _InternalMemScanMem32
+
+#------------------------------------------------------------------------------
+# CONST VOID *
+# EFIAPI
+# InternalMemScanMem32 (
+# IN CONST VOID *Buffer,
+# IN UINTN Length,
+# IN UINT32 Value
+# );
+#------------------------------------------------------------------------------
+_InternalMemScanMem32:
+ push %edi
+ movl 12(%esp), %ecx
+ movl 8(%esp), %edi
+ movl 16(%esp), %eax
+ repne scasl
+ leal -4(%edi), %eax
+ cmovnz %ecx, %eax
+ pop %edi
+ ret
--- /dev/null
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2006, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution. The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+; ScanMem32.Asm\r
+;\r
+; Abstract:\r
+;\r
+; ScanMem32 function\r
+;\r
+; Notes:\r
+;\r
+; The following BaseMemoryLib instances share the same version of this file:\r
+;\r
+; BaseMemoryLibRepStr\r
+; BaseMemoryLibMmx\r
+; BaseMemoryLibSse2\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+ .686\r
+ .model flat,C\r
+ .code\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
+InternalMemScanMem32 PROC USES edi\r
+ mov ecx, [esp + 12]\r
+ mov edi, [esp + 8]\r
+ mov eax, [esp + 16]\r
+ repne scasd\r
+ lea eax, [edi - 4]\r
+ cmovnz eax, ecx\r
+ ret\r
+InternalMemScanMem32 ENDP\r
+\r
+ END\r
--- /dev/null
+#------------------------------------------------------------------------------
+#
+# Copyright (c) 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# ScanMem64.Asm
+#
+# Abstract:
+#
+# ScanMem64 function
+#
+# Notes:
+#
+# The following BaseMemoryLib instances share the same version of this file:
+#
+# BaseMemoryLibRepStr
+# BaseMemoryLibMmx
+# BaseMemoryLibSse2
+#
+#------------------------------------------------------------------------------
+
+.globl _InternalMemScanMem64
+
+#------------------------------------------------------------------------------
+# CONST VOID *
+# EFIAPI
+# InternalMemScanMem64 (
+# IN CONST VOID *Buffer,
+# IN UINTN Length,
+# IN UINT64 Value
+# );
+#------------------------------------------------------------------------------
+_InternalMemScanMem64:
+ push %edi
+ movl 12(%esp), %ecx
+ movl 16(%esp), %eax
+ movl 20(%esp), %edx
+ movl 8(%esp), %edi
+L0:
+ cmpl (%edi), %eax
+ leal 8(%edi), %edi
+ loopne L0
+ jne L1
+ cmpl -4(%edi), %edx
+ jecxz L1
+ jne L0
+L1:
+ leal -8(%edi), %eax
+ cmovne %ecx, %eax
+ pop %edi
+ ret
--- /dev/null
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2006, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution. The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+; ScanMem64.Asm\r
+;\r
+; Abstract:\r
+;\r
+; ScanMem64 function\r
+;\r
+; Notes:\r
+;\r
+; The following BaseMemoryLib instances share the same version of this file:\r
+;\r
+; BaseMemoryLibRepStr\r
+; BaseMemoryLibMmx\r
+; BaseMemoryLibSse2\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+ .686\r
+ .model flat,C\r
+ .code\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
+InternalMemScanMem64 PROC USES edi\r
+ mov ecx, [esp + 12]\r
+ mov eax, [esp + 16]\r
+ mov edx, [esp + 20]\r
+ mov edi, [esp + 8]\r
+@@:\r
+ cmp eax, [edi]\r
+ lea edi, [edi + 8]\r
+ loopne @B\r
+ jne @F\r
+ cmp edx, [edi - 4]\r
+ jecxz @F\r
+ jne @B\r
+@@:\r
+ lea eax, [edi - 8]\r
+ cmovne eax, ecx\r
+ ret\r
+InternalMemScanMem64 ENDP\r
+\r
+ END\r
--- /dev/null
+#------------------------------------------------------------------------------
+#
+# Copyright (c) 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# ScanMem8.Asm
+#
+# Abstract:
+#
+# ScanMem8 function
+#
+# Notes:
+#
+# The following BaseMemoryLib instances share the same version of this file:
+#
+# BaseMemoryLibRepStr
+# BaseMemoryLibMmx
+# BaseMemoryLibSse2
+#
+#------------------------------------------------------------------------------
+
+.globl _InternalMemScanMem8
+
+#------------------------------------------------------------------------------
+# CONST VOID *
+# EFIAPI
+# InternalMemScanMem8 (
+# IN CONST VOID *Buffer,
+# IN UINTN Length,
+# IN UINT8 Value
+# );
+#------------------------------------------------------------------------------
+_InternalMemScanMem8:
+ push %edi
+ movl 12(%esp), %ecx
+ movl 8(%esp), %edi
+ movb 16(%esp), %al
+ repne scasb
+ leal -1(%edi), %eax
+ cmovnz %ecx, %eax
+ pop %edi
+ ret
--- /dev/null
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2006, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution. The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+; ScanMem8.Asm\r
+;\r
+; Abstract:\r
+;\r
+; ScanMem8 function\r
+;\r
+; Notes:\r
+;\r
+; The following BaseMemoryLib instances share the same version of this file:\r
+;\r
+; BaseMemoryLibRepStr\r
+; BaseMemoryLibMmx\r
+; BaseMemoryLibSse2\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+ .686\r
+ .model flat,C\r
+ .code\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
+InternalMemScanMem8 PROC USES edi\r
+ mov ecx, [esp + 12]\r
+ mov edi, [esp + 8]\r
+ mov al, [esp + 16]\r
+ repne scasb\r
+ lea eax, [edi - 1]\r
+ cmovnz eax, ecx\r
+ ret\r
+InternalMemScanMem8 ENDP\r
+\r
+ END\r
--- /dev/null
+#------------------------------------------------------------------------------
+#
+# Copyright (c) 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# SetMem.Asm
+#
+# Abstract:
+#
+# SetMem function
+#
+# Notes:
+#
+#------------------------------------------------------------------------------
+
+ .386:
+ .code:
+
+.globl _InternalMemSetMem
+
+#------------------------------------------------------------------------------
+# VOID *
+# InternalMemSetMem (
+# IN VOID *Buffer,
+# IN UINTN Count,
+# IN UINT8 Value
+# )
+#------------------------------------------------------------------------------
+_InternalMemSetMem:
+ push %edi
+ movl 12(%esp),%ecx
+ movl 16(%esp),%al
+ movb %ah, %al\r
+ shrd %edx, %eax, $16\r
+ shld %eax, %edx, $16\r
+ movl %edx, %ecx\r
+ movl 8(%esp),%edi
+ shr $2, %ecx\r
+ rep \r
+ stosd\r
+ movl %ecx, %edx\r
+ andl $3, %ecx\r
+ rep
+ stosb
+ movl 8(%esp),%eax
+ pop %edi
+ ret
--- /dev/null
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2006, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution. The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+; SetMem.Asm\r
+;\r
+; Abstract:\r
+;\r
+; SetMem function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+ .386\r
+ .model flat,C\r
+ .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID *\r
+; InternalMemSetMem (\r
+; IN VOID *Buffer,\r
+; IN UINTN Count,\r
+; IN UINT8 Value\r
+; )\r
+;------------------------------------------------------------------------------\r
+InternalMemSetMem PROC USES edi\r
+ mov ecx, [esp + 12]\r
+ mov al, [esp + 16]\r
+ mov ah, al\r
+ shrd edx, eax, 16\r
+ shld eax, edx, 16\r
+ mov edx, ecx\r
+ mov edi, [esp + 8]\r
+ shr ecx, 2\r
+ rep stosd\r
+ mov ecx, edx\r
+ and ecx, 3\r
+ rep stosb\r
+ mov eax, [esp + 8]\r
+ ret\r
+InternalMemSetMem ENDP\r
+\r
+ END\r
--- /dev/null
+#------------------------------------------------------------------------------
+#
+# Copyright (c) 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# SetMem16.Asm
+#
+# Abstract:
+#
+# SetMem16 function
+#
+# Notes:
+#
+#------------------------------------------------------------------------------
+
+.globl _InternalMemSetMem16
+
+#------------------------------------------------------------------------------
+# VOID *
+# InternalMemSetMem16 (
+# IN VOID *Buffer,
+# IN UINTN Count,
+# IN UINT16 Value
+# )
+#------------------------------------------------------------------------------
+_InternalMemSetMem16:
+ push %edi
+ movl 16(%esp), %eax
+ movl 8(%esp), %edi
+ movl 12(%esp), %ecx
+ rep
+ stosw
+ movl 8(%esp), %eax
+ pop %edi
+ ret
--- /dev/null
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2006, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution. The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+; SetMem16.Asm\r
+;\r
+; Abstract:\r
+;\r
+; SetMem16 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+ .386\r
+ .model flat,C\r
+ .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID *\r
+; InternalMemSetMem16 (\r
+; IN VOID *Buffer,\r
+; IN UINTN Count,\r
+; IN UINT16 Value\r
+; )\r
+;------------------------------------------------------------------------------\r
+InternalMemSetMem16 PROC USES edi\r
+ mov eax, [esp + 16]\r
+ mov edi, [esp + 8]\r
+ mov ecx, [esp + 12]\r
+ rep stosw\r
+ mov eax, [esp + 8]\r
+ ret\r
+InternalMemSetMem16 ENDP\r
+\r
+ END\r
--- /dev/null
+#------------------------------------------------------------------------------
+#
+# Copyright (c) 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# SetMem32.Asm
+#
+# Abstract:
+#
+# SetMem32 function
+#
+# Notes:
+#
+#------------------------------------------------------------------------------
+
+.globl _InternalMemSetMem32
+
+#------------------------------------------------------------------------------
+# VOID *
+# InternalMemSetMem32 (
+# IN VOID *Buffer,
+# IN UINTN Count,
+# IN UINT32 Value
+# )
+#------------------------------------------------------------------------------
+_InternalMemSetMem32:
+ push %edi
+ movl 16(%esp),%eax
+ movl 8(%esp),%edi
+ movl 12(%esp),%ecx
+ rep
+ stosl
+ movl 8(%esp),%eax
+ pop %edi
+ ret
--- /dev/null
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2006, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution. The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+; SetMem32.Asm\r
+;\r
+; Abstract:\r
+;\r
+; SetMem32 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+ .386\r
+ .model flat,C\r
+ .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID *\r
+; InternalMemSetMem32 (\r
+; IN VOID *Buffer,\r
+; IN UINTN Count,\r
+; IN UINT32 Value\r
+; )\r
+;------------------------------------------------------------------------------\r
+InternalMemSetMem32 PROC USES edi\r
+ mov eax, [esp + 16]\r
+ mov edi, [esp + 8]\r
+ mov ecx, [esp + 12]\r
+ rep stosd\r
+ mov eax, [esp + 8]\r
+ ret\r
+InternalMemSetMem32 ENDP\r
+\r
+ END\r
--- /dev/null
+#------------------------------------------------------------------------------
+#
+# Copyright (c) 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# SetMem64.Asm
+#
+# Abstract:
+#
+# SetMem64 function
+#
+# Notes:
+#
+#------------------------------------------------------------------------------
+
+.globl _InternalMemSetMem64
+
+#------------------------------------------------------------------------------
+# VOID *
+# InternalMemSetMem64 (
+# IN VOID *Buffer,
+# IN UINTN Count,
+# IN UINT64 Value
+# )
+#------------------------------------------------------------------------------
+_InternalMemSetMem64:
+ push %edi
+ movl 12(%esp), %ecx
+ movl 16(%esp), %eax
+ movl 20(%esp), %edx
+ movl 8(%esp), %edi
+L0:
+ mov %eax, -8(%edi, %ecx, 8)
+ mov %edx, -4(%edi, %ecx, 8)
+ loop L0
+ movl %edi, %eax
+ pop %edi
+ ret
--- /dev/null
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2006, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution. The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+; SetMem64.Asm\r
+;\r
+; Abstract:\r
+;\r
+; SetMem64 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+ .386\r
+ .model flat,C\r
+ .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID *\r
+; InternalMemSetMem64 (\r
+; IN VOID *Buffer,\r
+; IN UINTN Count,\r
+; IN UINT64 Value\r
+; )\r
+;------------------------------------------------------------------------------\r
+InternalMemSetMem64 PROC USES edi\r
+ mov ecx, [esp + 12]\r
+ mov eax, [esp + 16]\r
+ mov edx, [esp + 20]\r
+ mov edi, [esp + 8]\r
+@@:\r
+ mov [edi + ecx*8 - 8], eax\r
+ mov [edi + ecx*8 - 4], edx\r
+ loop @B\r
+ mov eax, edi\r
+ ret\r
+InternalMemSetMem64 ENDP\r
+\r
+ END\r
--- /dev/null
+#------------------------------------------------------------------------------
+#
+# Copyright (c) 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# ZeroMem.Asm
+#
+# Abstract:
+#
+# ZeroMem function
+#
+# Notes:
+#
+#------------------------------------------------------------------------------
+
+.globl _InternalMemZeroMem
+
+#------------------------------------------------------------------------------
+# VOID *
+# InternalMemZeroMem (
+# IN VOID *Buffer,
+# IN UINTN Count
+# );
+#------------------------------------------------------------------------------
+_InternalMemZeroMem:
+ push %edi
+ xorl %eax,%eax
+ movl 8(%esp),%edi
+ movl 12(%esp),%ecx
+ movl %ecx,%edx
+ shrl $2,%ecx
+ andl $3,%edx
+ pushl %edi
+ rep
+ stosl
+ movl %edx,%ecx
+ rep
+ stosb
+ popl %eax
+ pop %edi
+ ret
--- /dev/null
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2006, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution. The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+; ZeroMem.Asm\r
+;\r
+; Abstract:\r
+;\r
+; ZeroMem function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+ .386\r
+ .model flat,C\r
+ .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID *\r
+; InternalMemZeroMem (\r
+; IN VOID *Buffer,\r
+; IN UINTN Count\r
+; );\r
+;------------------------------------------------------------------------------\r
+InternalMemZeroMem PROC USES edi\r
+ xor eax, eax\r
+ mov edi, [esp + 8]\r
+ mov ecx, [esp + 12]\r
+ mov edx, ecx\r
+ shr ecx, 2\r
+ and edx, 3\r
+ push edi\r
+ rep stosd\r
+ mov ecx, edx\r
+ rep stosb\r
+ pop eax\r
+ ret\r
+InternalMemZeroMem ENDP\r
+\r
+ END\r
--- /dev/null
+/** @file\r
+ Implementation of GUID functions.\r
+\r
+ Copyright (c) 2006, Intel Corporation<BR>\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+ The following BaseMemoryLib instances share the same version of this file:\r
+\r
+ BaseMemoryLib\r
+ BaseMemoryLibMmx\r
+ BaseMemoryLibSse2\r
+ BaseMemoryLibRepStr\r
+ PeiMemoryLib\r
+ DxeMemoryLib\r
+\r
+**/\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include <MemLibInternals.h>\r
+\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
+ 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
+ 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 target the 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
+ 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
--- /dev/null
+/** @file\r
+ Declaration of internal functions for Base Memory Library.\r
+\r
+ The following BaseMemoryLib instances share the same version of this file:\r
+ BaseMemoryLib\r
+ BaseMemoryLibMmx\r
+ BaseMemoryLibSse2\r
+ BaseMemoryLibRepStr\r
+ PeiMemoryLib\r
+ DxeMemoryLib\r
+\r
+ Copyright (c) 2006, Intel Corporation<BR>\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\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
+/**\r
+ Copy Length bytes from Source to Destination.\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
+/**\r
+ Set Buffer to Value for Size bytes.\r
+\r
+ @param Buffer Memory to set.\r
+ @param Size 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 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
+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 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
+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 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
+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 Size 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
+ @retval 0 if MemOne == MemTwo\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 Number of bytes in Buffer 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 Number of bytes in Buffer 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 Number of bytes in Buffer 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 Number of bytes in Buffer 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
--- /dev/null
+/** @file\r
+ ScanMem16() implementation.\r
+\r
+ Copyright (c) 2006, Intel Corporation<BR>\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+ The following BaseMemoryLib instances share the same version of this file:\r
+\r
+ BaseMemoryLib\r
+ BaseMemoryLibMmx\r
+ BaseMemoryLibSse2\r
+ BaseMemoryLibRepStr\r
+ PeiMemoryLib\r
+ DxeMemoryLib\r
+\r
+**/\r
+\r
+//\r
+// Include common header file for this module.\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 target the 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
+ 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
--- /dev/null
+/** @file\r
+ ScanMem32() implementation.\r
+\r
+ Copyright (c) 2006, Intel Corporation<BR>\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+ The following BaseMemoryLib instances share the same version of this file:\r
+\r
+ BaseMemoryLib\r
+ BaseMemoryLibMmx\r
+ BaseMemoryLibSse2\r
+ BaseMemoryLibRepStr\r
+ PeiMemoryLib\r
+ DxeMemoryLib\r
+\r
+**/\r
+\r
+//\r
+// Include common header file for this module.\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 target the 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
+ 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
--- /dev/null
+/** @file\r
+ ScanMem64() implementation.\r
+\r
+ Copyright (c) 2006, Intel Corporation<BR>\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+ The following BaseMemoryLib instances share the same version of this file:\r
+\r
+ BaseMemoryLib\r
+ BaseMemoryLibMmx\r
+ BaseMemoryLibSse2\r
+ BaseMemoryLibRepStr\r
+ PeiMemoryLib\r
+ DxeMemoryLib\r
+\r
+**/\r
+\r
+//\r
+// Include common header file for this module.\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 target the 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
+ 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
--- /dev/null
+/** @file\r
+ ScanMem8() implementation.\r
+\r
+ Copyright (c) 2006, Intel Corporation<BR>\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+ The following BaseMemoryLib instances share the same version of this file:\r
+\r
+ BaseMemoryLib\r
+ BaseMemoryLibMmx\r
+ BaseMemoryLibSse2\r
+ BaseMemoryLibRepStr\r
+ PeiMemoryLib\r
+ DxeMemoryLib\r
+\r
+**/\r
+\r
+//\r
+// Include common header file for this module.\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 target the 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
+ 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
--- /dev/null
+/** @file\r
+ SetMem16() implementation.\r
+\r
+ Copyright (c) 2006, Intel Corporation<BR>\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+ The following BaseMemoryLib instances share the same version of this file:\r
+\r
+ BaseMemoryLib\r
+ BaseMemoryLibMmx\r
+ BaseMemoryLibSse2\r
+ BaseMemoryLibRepStr\r
+ PeiMemoryLib\r
+ DxeMemoryLib\r
+\r
+**/\r
+\r
+//\r
+// Include common header file for this module.\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
--- /dev/null
+/** @file\r
+ SetMem32() implementation.\r
+\r
+ Copyright (c) 2006, Intel Corporation<BR>\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+ The following BaseMemoryLib instances share the same version of this file:\r
+\r
+ BaseMemoryLib\r
+ BaseMemoryLibMmx\r
+ BaseMemoryLibSse2\r
+ BaseMemoryLibRepStr\r
+ PeiMemoryLib\r
+ DxeMemoryLib\r
+\r
+**/\r
+\r
+//\r
+// Include common header file for this module.\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
--- /dev/null
+/** @file\r
+ SetMem64() implementation.\r
+\r
+ Copyright (c) 2006, Intel Corporation<BR>\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+ The following BaseMemoryLib instances share the same version of this file:\r
+\r
+ BaseMemoryLib\r
+ BaseMemoryLibMmx\r
+ BaseMemoryLibSse2\r
+ BaseMemoryLibRepStr\r
+ PeiMemoryLib\r
+ DxeMemoryLib\r
+\r
+**/\r
+\r
+//\r
+// Include common header file for this module.\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
--- /dev/null
+/** @file\r
+ SetMem() implementation.\r
+\r
+ Copyright (c) 2006, Intel Corporation<BR>\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+ The following BaseMemoryLib instances share the same version of this file:\r
+\r
+ BaseMemoryLib\r
+ BaseMemoryLibMmx\r
+ BaseMemoryLibSse2\r
+ BaseMemoryLibRepStr\r
+ PeiMemoryLib\r
+ DxeMemoryLib\r
+\r
+**/\r
+\r
+//\r
+// Include common header file for this module.\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
+ 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 of the set operation.\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
--- /dev/null
+/** @file\r
+ ZeroMem() implementation.\r
+\r
+ Copyright (c) 2006, Intel Corporation<BR>\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+ The following BaseMemoryLib instances share the same version of this file:\r
+\r
+ BaseMemoryLib\r
+ BaseMemoryLibMmx\r
+ BaseMemoryLibSse2\r
+ BaseMemoryLibRepStr\r
+ PeiMemoryLib\r
+ DxeMemoryLib\r
+\r
+**/\r
+\r
+//\r
+// Include common header file for this module.\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
+ 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
--- /dev/null
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2006, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution. The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+; CompareMem.Asm\r
+;\r
+; Abstract:\r
+;\r
+; CompareMem function\r
+;\r
+; Notes:\r
+;\r
+; The following BaseMemoryLib instances share the same version of this file:\r
+;\r
+; BaseMemoryLibRepStr\r
+; BaseMemoryLibMmx\r
+; BaseMemoryLibSse2\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+ .code\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
+InternalMemCompareMem PROC USES rsi rdi\r
+ mov rsi, rcx\r
+ mov rdi, rdx\r
+ mov rcx, r8\r
+ repe cmpsb\r
+ movzx rax, byte ptr [rsi - 1]\r
+ movzx rdx, byte ptr [rdi - 1]\r
+ sub rax, rdx\r
+ ret\r
+InternalMemCompareMem ENDP\r
+\r
+ END\r
--- /dev/null
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2006, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution. The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+; CopyMem.asm\r
+;\r
+; Abstract:\r
+;\r
+; CopyMem function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+ .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID *\r
+; EFIAPI\r
+; InternalMemCopyMem (\r
+; IN VOID *Destination,\r
+; IN VOID *Source,\r
+; IN UINTN Count\r
+; );\r
+;------------------------------------------------------------------------------\r
+InternalMemCopyMem PROC USES rsi rdi\r
+ mov rsi, rdx ; rsi <- Source\r
+ mov rdi, rcx ; rdi <- Destination\r
+ lea r9, [rsi + r8 - 1] ; r9 <- Last byte of Source\r
+ cmp rsi, rdi\r
+ mov rax, rdi ; rax <- Destination as return value\r
+ jae @F ; Copy forward if Source > Destination\r
+ cmp r9, rdi ; Overlapped?\r
+ jae @CopyBackward ; Copy backward if overlapped\r
+@@:\r
+ xor rcx, rcx\r
+ sub rcx, rdi ; rcx <- -rdi\r
+ and rcx, 15 ; rcx + rsi should be 16 bytes aligned\r
+ jz @F ; skip if rcx == 0\r
+ cmp rcx, r8\r
+ cmova rcx, r8\r
+ sub r8, rcx\r
+ rep movsb\r
+@@:\r
+ mov rcx, r8\r
+ and r8, 15\r
+ shr rcx, 4 ; rcx <- # of DQwords to copy\r
+ jz @CopyBytes\r
+ movdqa [rsp + 18h], xmm0 ; save xmm0 on stack\r
+@@:\r
+ movdqu xmm0, [rsi] ; rsi may not be 16-byte aligned\r
+ movntdq [rdi], xmm0 ; rdi should be 16-byte aligned\r
+ add rsi, 16\r
+ add rdi, 16\r
+ loop @B\r
+ mfence\r
+ movdqa xmm0, [rsp + 18h] ; restore xmm0\r
+ jmp @CopyBytes ; copy remaining bytes\r
+@CopyBackward:\r
+ mov rsi, r9 ; rsi <- Last byte of Source\r
+ lea rdi, [rdi + r8 - 1] ; rdi <- Last byte of Destination\r
+ std\r
+@CopyBytes:\r
+ mov rcx, r8\r
+ rep movsb\r
+ cld\r
+ ret\r
+InternalMemCopyMem ENDP\r
+\r
+ END\r
--- /dev/null
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2006, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution. The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+; ScanMem16.Asm\r
+;\r
+; Abstract:\r
+;\r
+; ScanMem16 function\r
+;\r
+; Notes:\r
+;\r
+; The following BaseMemoryLib instances share the same version of this file:\r
+;\r
+; BaseMemoryLibRepStr\r
+; BaseMemoryLibMmx\r
+; BaseMemoryLibSse2\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+ .code\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
+InternalMemScanMem16 PROC USES rdi\r
+ mov rdi, rcx\r
+ mov rax, r8\r
+ mov rcx, rdx\r
+ repne scasw\r
+ lea rax, [rdi - 2]\r
+ cmovnz rax, rcx\r
+ ret\r
+InternalMemScanMem16 ENDP\r
+\r
+ END\r
--- /dev/null
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2006, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution. The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+; ScanMem32.Asm\r
+;\r
+; Abstract:\r
+;\r
+; ScanMem32 function\r
+;\r
+; Notes:\r
+;\r
+; The following BaseMemoryLib instances share the same version of this file:\r
+;\r
+; BaseMemoryLibRepStr\r
+; BaseMemoryLibMmx\r
+; BaseMemoryLibSse2\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+ .code\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
+InternalMemScanMem32 PROC USES rdi\r
+ mov rdi, rcx\r
+ mov rax, r8\r
+ mov rcx, rdx\r
+ repne scasd\r
+ lea rax, [rdi - 4]\r
+ cmovnz rax, rcx\r
+ ret\r
+InternalMemScanMem32 ENDP\r
+\r
+ END\r
--- /dev/null
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2006, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution. The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+; ScanMem64.Asm\r
+;\r
+; Abstract:\r
+;\r
+; ScanMem64 function\r
+;\r
+; Notes:\r
+;\r
+; The following BaseMemoryLib instances share the same version of this file:\r
+;\r
+; BaseMemoryLibRepStr\r
+; BaseMemoryLibMmx\r
+; BaseMemoryLibSse2\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+ .code\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
+InternalMemScanMem64 PROC USES rdi\r
+ mov rdi, rcx\r
+ mov rax, r8\r
+ mov rcx, rdx\r
+ repne scasq\r
+ lea rax, [rdi - 8]\r
+ cmovnz rax, rcx\r
+ ret\r
+InternalMemScanMem64 ENDP\r
+\r
+ END\r
--- /dev/null
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2006, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution. The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+; ScanMem8.Asm\r
+;\r
+; Abstract:\r
+;\r
+; ScanMem8 function\r
+;\r
+; Notes:\r
+;\r
+; The following BaseMemoryLib instances share the same version of this file:\r
+;\r
+; BaseMemoryLibRepStr\r
+; BaseMemoryLibMmx\r
+; BaseMemoryLibSse2\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+ .code\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
+InternalMemScanMem8 PROC USES rdi\r
+ mov rdi, rcx\r
+ mov rcx, rdx\r
+ mov rax, r8\r
+ repne scasb\r
+ lea rax, [rdi - 1]\r
+ cmovnz rax, rcx ; set rax to 0 if not found\r
+ ret\r
+InternalMemScanMem8 ENDP\r
+\r
+ END\r
--- /dev/null
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2006, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution. The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+; SetMem.Asm\r
+;\r
+; Abstract:\r
+;\r
+; SetMem function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+ .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID *\r
+; EFIAPI\r
+; InternalMemSetMem (\r
+; IN VOID *Buffer,\r
+; IN UINTN Count,\r
+; IN UINT8 Value\r
+; )\r
+;------------------------------------------------------------------------------\r
+InternalMemSetMem PROC USES rdi rbx\r
+ push rcx ; push Buffer\r
+ mov rax, r8 ; rax = Value\r
+ and rax, 0ffh ; rax = lower 8 bits of r8, upper 56 bits are 0\r
+ mov ah, al ; ah = al\r
+ mov bx, ax ; bx = ax\r
+ shl rax, 10h ; rax = ax << 16\r
+ mov ax, bx ; ax = bx\r
+ mov rbx, rax ; ebx = eax\r
+ shl rax, 20h ; rax = rax << 32\r
+ or rax, rbx ; eax = ebx\r
+ mov rdi, rcx ; rdi = Buffer\r
+ mov rcx, rdx ; rcx = Count\r
+ shr rcx, 3 ; rcx = rcx / 8\r
+ cld\r
+ rep stosq \r
+ mov rcx, rdx ; rcx = rdx\r
+ and rcx, 7 ; rcx = rcx & 7\r
+ rep stosb \r
+ pop rax ; rax = Buffer\r
+ ret\r
+InternalMemSetMem ENDP\r
+\r
+ END\r
--- /dev/null
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2006, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution. The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+; SetMem16.Asm\r
+;\r
+; Abstract:\r
+;\r
+; SetMem16 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+ .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID *\r
+; EFIAPI\r
+; InternalMemSetMem16 (\r
+; IN VOID *Buffer,\r
+; IN UINTN Count,\r
+; IN UINT16 Value\r
+; )\r
+;------------------------------------------------------------------------------\r
+InternalMemSetMem16 PROC USES rdi\r
+ push rcx\r
+ mov rdi, rcx\r
+ mov rax, r8\r
+ xchg rcx, rdx\r
+ rep stosw\r
+ pop rax\r
+ ret\r
+InternalMemSetMem16 ENDP\r
+\r
+ END\r
--- /dev/null
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2006, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution. The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+; SetMem32.Asm\r
+;\r
+; Abstract:\r
+;\r
+; SetMem32 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+ .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID *\r
+; EFIAPI\r
+; InternalMemSetMem32 (\r
+; IN VOID *Buffer,\r
+; IN UINTN Count,\r
+; IN UINT32 Value\r
+; );\r
+;------------------------------------------------------------------------------\r
+InternalMemSetMem32 PROC USES rdi\r
+ push rcx\r
+ mov rdi, rcx\r
+ mov rax, r8\r
+ xchg rcx, rdx\r
+ rep stosd\r
+ pop rax\r
+ ret\r
+InternalMemSetMem32 ENDP\r
+\r
+ END\r
--- /dev/null
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2006, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution. The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+; SetMem64.Asm\r
+;\r
+; Abstract:\r
+;\r
+; SetMem64 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+ .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID *\r
+; InternalMemSetMem64 (\r
+; IN VOID *Buffer,\r
+; IN UINTN Count,\r
+; IN UINT64 Value\r
+; )\r
+;------------------------------------------------------------------------------\r
+InternalMemSetMem64 PROC USES rdi\r
+ push rcx\r
+ mov rdi, rcx\r
+ mov rax, r8\r
+ xchg rcx, rdx\r
+ rep stosq\r
+ pop rax\r
+ ret\r
+InternalMemSetMem64 ENDP\r
+\r
+ END\r
--- /dev/null
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2006, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution. The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+; ZeroMem.Asm\r
+;\r
+; Abstract:\r
+;\r
+; ZeroMem function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+ .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID *\r
+; InternalMemZeroMem (\r
+; IN VOID *Buffer,\r
+; IN UINTN Count\r
+; );\r
+;------------------------------------------------------------------------------\r
+InternalMemZeroMem PROC USES rdi\r
+ push rcx ; push Buffer\r
+ xor rax, rax ; rax = 0\r
+ mov rdi, rcx ; rdi = Buffer\r
+ mov rcx, rdx ; rcx = Count\r
+ shr rcx, 3 ; rcx = rcx / 8\r
+ and rdx, 7 ; rdx = rdx & 7\r
+ cld\r
+ rep stosq\r
+ mov rcx, rdx ; rcx = rdx\r
+ rep stosb\r
+ pop rax ; rax = Buffer\r
+ ret\r
+InternalMemZeroMem ENDP\r
+\r
+ END\r