ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.inf\r
ArmPkg/Library/ArmDisassemblerLib/ArmDisassemblerLib.inf\r
ArmPkg/Library/ArmDmaLib/ArmDmaLib.inf\r
- ArmPkg/Library/BaseMemoryLibStm/BaseMemoryLibStm.inf\r
ArmPkg/Library/BdsLib/BdsLib.inf\r
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf\r
ArmPkg/Library/DebugAgentSymbolsBaseLib/DebugAgentSymbolsBaseLib.inf\r
+++ /dev/null
-/** @file\r
-\r
- Copyright (c) 2012-2013, ARM Ltd. All rights reserved.<BR>\r
-\r
- 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
- 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
- volatile UINT32 *Destination32;\r
- CONST UINT32 *Source32;\r
- volatile UINT64 *Destination64;\r
- CONST UINT64 *Source64;\r
- UINTN Alignment;\r
-\r
- if ((((UINTN)DestinationBuffer & 0x7) == 0) && (((UINTN)SourceBuffer & 0x7) == 0) && (Length >= 8)) {\r
- if (SourceBuffer > DestinationBuffer) {\r
- Destination64 = (UINT64*)DestinationBuffer;\r
- Source64 = (CONST UINT64*)SourceBuffer;\r
- while (Length >= 8) {\r
- *(Destination64++) = *(Source64++);\r
- Length -= 8;\r
- }\r
-\r
- // Finish if there are still some bytes to copy\r
- Destination8 = (UINT8*)Destination64;\r
- Source8 = (CONST UINT8*)Source64;\r
- while (Length-- != 0) {\r
- *(Destination8++) = *(Source8++);\r
- }\r
- } else if (SourceBuffer < DestinationBuffer) {\r
- Destination64 = (UINT64*)((UINTN)DestinationBuffer + Length);\r
- Source64 = (CONST UINT64*)((UINTN)SourceBuffer + Length);\r
-\r
- // Destination64 and Source64 were aligned on a 64-bit boundary\r
- // but if length is not a multiple of 8 bytes then they won't be\r
- // anymore.\r
-\r
- Alignment = Length & 0x7;\r
- if (Alignment != 0) {\r
- Destination8 = (UINT8*)Destination64;\r
- Source8 = (CONST UINT8*)Source64;\r
-\r
- while (Alignment-- != 0) {\r
- *(--Destination8) = *(--Source8);\r
- --Length;\r
- }\r
- Destination64 = (UINT64*)Destination8;\r
- Source64 = (CONST UINT64*)Source8;\r
- }\r
-\r
- while (Length > 0) {\r
- *(--Destination64) = *(--Source64);\r
- Length -= 8;\r
- }\r
- }\r
- } else if ((((UINTN)DestinationBuffer & 0x3) == 0) && (((UINTN)SourceBuffer & 0x3) == 0) && (Length >= 4)) {\r
- if (SourceBuffer > DestinationBuffer) {\r
- Destination32 = (UINT32*)DestinationBuffer;\r
- Source32 = (CONST UINT32*)SourceBuffer;\r
- while (Length >= 4) {\r
- *(Destination32++) = *(Source32++);\r
- Length -= 4;\r
- }\r
-\r
- // Finish if there are still some bytes to copy\r
- Destination8 = (UINT8*)Destination32;\r
- Source8 = (CONST UINT8*)Source32;\r
- while (Length-- != 0) {\r
- *(Destination8++) = *(Source8++);\r
- }\r
- } else if (SourceBuffer < DestinationBuffer) {\r
- Destination32 = (UINT32*)((UINTN)DestinationBuffer + Length);\r
- Source32 = (CONST UINT32*)((UINTN)SourceBuffer + Length);\r
-\r
- // Destination32 and Source32 were aligned on a 32-bit boundary\r
- // but if length is not a multiple of 4 bytes then they won't be\r
- // anymore.\r
-\r
- Alignment = Length & 0x3;\r
- if (Alignment != 0) {\r
- Destination8 = (UINT8*)Destination32;\r
- Source8 = (CONST UINT8*)Source32;\r
-\r
- while (Alignment-- != 0) {\r
- *(--Destination8) = *(--Source8);\r
- --Length;\r
- }\r
- Destination32 = (UINT32*)Destination8;\r
- Source32 = (CONST UINT32*)Source8;\r
- }\r
-\r
- while (Length > 0) {\r
- *(--Destination32) = *(--Source32);\r
- Length -= 4;\r
- }\r
- }\r
- } else {\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
- }\r
- return DestinationBuffer;\r
-}\r
+++ /dev/null
-/** @file\r
-\r
- Copyright (c) 2012-2013, ARM Ltd. All rights reserved.<BR>\r
-\r
- 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
- 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 *Pointer8;\r
- volatile UINT32 *Pointer32;\r
- volatile UINT64 *Pointer64;\r
- UINT32 Value32;\r
- UINT64 Value64;\r
-\r
- if ((((UINTN)Buffer & 0x7) == 0) && (Length >= 8)) {\r
- // Generate the 64bit value\r
- Value32 = (Value << 24) | (Value << 16) | (Value << 8) | Value;\r
- Value64 = (((UINT64)Value32) << 32) | Value32;\r
-\r
- Pointer64 = (UINT64*)Buffer;\r
- while (Length >= 8) {\r
- *(Pointer64++) = Value64;\r
- Length -= 8;\r
- }\r
-\r
- // Finish with bytes if needed\r
- Pointer8 = (UINT8*)Pointer64;\r
- while (Length-- > 0) {\r
- *(Pointer8++) = Value;\r
- }\r
- } else if ((((UINTN)Buffer & 0x3) == 0) && (Length >= 4)) {\r
- // Generate the 32bit value\r
- Value32 = (Value << 24) | (Value << 16) | (Value << 8) | Value;\r
-\r
- Pointer32 = (UINT32*)Buffer;\r
- while (Length >= 4) {\r
- *(Pointer32++) = Value32;\r
- Length -= 4;\r
- }\r
-\r
- // Finish with bytes if needed\r
- Pointer8 = (UINT8*)Pointer32;\r
- while (Length-- > 0) {\r
- *(Pointer8++) = Value;\r
- }\r
- } else {\r
- Pointer8 = (UINT8*)Buffer;\r
- while (Length-- > 0) {\r
- *(Pointer8++) = Value;\r
- }\r
- }\r
- return Buffer;\r
-}\r
+++ /dev/null
-#------------------------------------------------------------------------------\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
-# 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 <AsmMacroIoLib.h>\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
-ASM_FUNC(InternalMemCopyMem)\r
- stmfd sp!, {r4-r11, lr}\r
- // Save the input parameters in extra registers (r11 = destination, r14 = source, r12 = length)\r
- mov r11, r0\r
- mov r10, r0\r
- mov r12, r2\r
- mov r14, r1\r
-\r
-memcopy_check_overlapped:\r
- cmp r11, r1\r
- // If (dest < source)\r
- bcc memcopy_check_optim_default\r
- // If (dest <= source). But with the previous condition -> If (dest == source)\r
- bls memcopy_end\r
-\r
- // If (source + length < dest)\r
- rsb r3, r1, r11\r
- cmp r12, r3\r
- bcc memcopy_check_optim_default\r
-\r
- // If (length == 0)\r
- cmp r12, #0\r
- beq memcopy_end\r
-\r
- b memcopy_check_optim_overlap\r
-\r
-memcopy_check_optim_default:\r
- // Check if we can use an optimized path ((length >= 32) && destination word-aligned && source word-aligned) for the memcopy (optimized path if r0 == 1)\r
- tst r0, #0xF\r
- movne r0, #0\r
- bne memcopy_default\r
- tst r1, #0xF\r
- movne r3, #0\r
- moveq r3, #1\r
- cmp r2, #31\r
- movls r0, #0\r
- andhi r0, r3, #1\r
- b memcopy_default\r
-\r
-memcopy_check_optim_overlap:\r
- // r10 = dest_end, r14 = source_end\r
- add r10, r11, r12\r
- add r14, r12, r1\r
-\r
- // Are we in the optimized case ((length >= 32) && dest_end word-aligned && source_end word-aligned)\r
- cmp r2, #31\r
- movls r0, #0\r
- movhi r0, #1\r
- tst r10, #0xF\r
- movne r0, #0\r
- tst r14, #0xF\r
- movne r0, #0\r
- b memcopy_overlapped\r
-\r
-memcopy_overlapped_non_optim:\r
- // We read 1 byte from the end of the source buffer\r
- sub r3, r14, #1\r
- sub r12, r12, #1\r
- ldrb r3, [r3, #0]\r
- sub r2, r10, #1\r
- cmp r12, #0\r
- // We write 1 byte at the end of the dest buffer\r
- sub r10, r10, #1\r
- sub r14, r14, #1\r
- strb r3, [r2, #0]\r
- bne memcopy_overlapped_non_optim\r
- b memcopy_end\r
-\r
-// r10 = dest_end, r14 = source_end\r
-memcopy_overlapped:\r
- // Are we in the optimized case ?\r
- cmp r0, #0\r
- beq memcopy_overlapped_non_optim\r
-\r
- // Optimized Overlapped - Read 32 bytes\r
- sub r14, r14, #32\r
- sub r12, r12, #32\r
- cmp r12, #31\r
- ldmia r14, {r2-r9}\r
-\r
- // If length is less than 32 then disable optim\r
- movls r0, #0\r
-\r
- cmp r12, #0\r
-\r
- // Optimized Overlapped - Write 32 bytes\r
- sub r10, r10, #32\r
- stmia r10, {r2-r9}\r
-\r
- // while (length != 0)\r
- bne memcopy_overlapped\r
- b memcopy_end\r
-\r
-memcopy_default_non_optim:\r
- // Byte copy\r
- ldrb r3, [r14], #1\r
- sub r12, r12, #1\r
- strb r3, [r10], #1\r
-\r
-memcopy_default:\r
- cmp r12, #0\r
- beq memcopy_end\r
-\r
-// r10 = dest, r14 = source\r
-memcopy_default_loop:\r
- cmp r0, #0\r
- beq memcopy_default_non_optim\r
-\r
- // Optimized memcopy - Read 32 Bytes\r
- sub r12, r12, #32\r
- cmp r12, #31\r
- ldmia r14!, {r2-r9}\r
-\r
- // If length is less than 32 then disable optim\r
- movls r0, #0\r
-\r
- cmp r12, #0\r
-\r
- // Optimized memcopy - Write 32 Bytes\r
- stmia r10!, {r2-r9}\r
-\r
- // while (length != 0)\r
- bne memcopy_default_loop\r
-\r
-memcopy_end:\r
- mov r0, r11\r
- ldmfd sp!, {r4-r11, pc}\r
-\r
+++ /dev/null
-;------------------------------------------------------------------------------\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
-; 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
-\r
- INCLUDE AsmMacroExport.inc\r
-\r
- RVCT_ASM_EXPORT InternalMemCopyMem\r
- stmfd sp!, {r4-r11, lr}\r
- // Save the input parameters in extra registers (r11 = destination, r14 = source, r12 = length)\r
- mov r11, r0\r
- mov r10, r0\r
- mov r12, r2\r
- mov r14, r1\r
-\r
-memcopy_check_overlapped\r
- cmp r11, r1\r
- // If (dest < source)\r
- bcc memcopy_check_optim_default\r
- // If (dest <= source). But with the previous condition -> If (dest == source)\r
- bls memcopy_end\r
-\r
- // If (source + length < dest)\r
- rsb r3, r1, r11\r
- cmp r12, r3\r
- bcc memcopy_check_optim_default\r
-\r
- // If (length == 0)\r
- cmp r12, #0\r
- beq memcopy_end\r
-\r
- b memcopy_check_optim_overlap\r
-\r
-memcopy_check_optim_default\r
- // Check if we can use an optimized path ((length >= 32) && destination word-aligned && source word-aligned) for the memcopy (optimized path if r0 == 1)\r
- tst r0, #0xF\r
- movne r0, #0\r
- bne memcopy_default\r
- tst r1, #0xF\r
- movne r3, #0\r
- moveq r3, #1\r
- cmp r2, #31\r
- movls r0, #0\r
- andhi r0, r3, #1\r
- b memcopy_default\r
-\r
-memcopy_check_optim_overlap\r
- // r10 = dest_end, r14 = source_end\r
- add r10, r11, r12\r
- add r14, r12, r1\r
-\r
- // Are we in the optimized case ((length >= 32) && dest_end word-aligned && source_end word-aligned)\r
- cmp r2, #31\r
- movls r0, #0\r
- movhi r0, #1\r
- tst r10, #0xF\r
- movne r0, #0\r
- tst r14, #0xF\r
- movne r0, #0\r
- b memcopy_overlapped\r
-\r
-memcopy_overlapped_non_optim\r
- // We read 1 byte from the end of the source buffer\r
- sub r3, r14, #1\r
- sub r12, r12, #1\r
- ldrb r3, [r3, #0]\r
- sub r2, r10, #1\r
- cmp r12, #0\r
- // We write 1 byte at the end of the dest buffer\r
- sub r10, r10, #1\r
- sub r14, r14, #1\r
- strb r3, [r2, #0]\r
- bne memcopy_overlapped_non_optim\r
- b memcopy_end\r
-\r
-// r10 = dest_end, r14 = source_end\r
-memcopy_overlapped\r
- // Are we in the optimized case ?\r
- cmp r0, #0\r
- beq memcopy_overlapped_non_optim\r
-\r
- // Optimized Overlapped - Read 32 bytes\r
- sub r14, r14, #32\r
- sub r12, r12, #32\r
- cmp r12, #31\r
- ldmia r14, {r2-r9}\r
-\r
- // If length is less than 32 then disable optim\r
- movls r0, #0\r
-\r
- cmp r12, #0\r
-\r
- // Optimized Overlapped - Write 32 bytes\r
- sub r10, r10, #32\r
- stmia r10, {r2-r9}\r
-\r
- // while (length != 0)\r
- bne memcopy_overlapped\r
- b memcopy_end\r
-\r
-memcopy_default_non_optim\r
- // Byte copy\r
- ldrb r3, [r14], #1\r
- sub r12, r12, #1\r
- strb r3, [r10], #1\r
-\r
-memcopy_default\r
- cmp r12, #0\r
- beq memcopy_end\r
-\r
-// r10 = dest, r14 = source\r
-memcopy_default_loop\r
- cmp r0, #0\r
- beq memcopy_default_non_optim\r
-\r
- // Optimized memcopy - Read 32 Bytes\r
- sub r12, r12, #32\r
- cmp r12, #31\r
- ldmia r14!, {r2-r9}\r
-\r
- // If length is less than 32 then disable optim\r
- movls r0, #0\r
-\r
- cmp r12, #0\r
-\r
- // Optimized memcopy - Write 32 Bytes\r
- stmia r10!, {r2-r9}\r
-\r
- // while (length != 0)\r
- bne memcopy_default_loop\r
-\r
-memcopy_end\r
- mov r0, r11\r
- ldmfd sp!, {r4-r11, pc}\r
-\r
- END\r
-\r
+++ /dev/null
-#------------------------------------------------------------------------------\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
-# 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 <AsmMacroIoLib.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
-VOID *\r
-EFIAPI\r
-InternalMemSetMem (\r
- OUT VOID *Buffer,\r
- IN UINTN Length,\r
- IN UINT8 Value\r
- )\r
-**/\r
-\r
-.syntax unified\r
-\r
-ASM_FUNC(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 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
- strbeq 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
+++ /dev/null
-;------------------------------------------------------------------------------\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
-; 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
-\r
- INCLUDE AsmMacroExport.inc\r
-\r
- RVCT_ASM_EXPORT 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 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
+++ /dev/null
-## @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. All rights reserved.<BR>\r
-# Portions copyright (c) 2010, Apple Inc. All rights reserved.<BR>\r
-# Portions copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.<BR>\r
-#\r
-# 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 AARCH64\r
-#\r
-\r
-\r
-[Sources.Common]\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
- IsZeroBufferWrapper.c\r
- MemLibGeneric.c\r
- MemLibGuid.c\r
- MemLibInternals.h\r
-\r
-[Sources.ARM]\r
- Arm/CopyMem.asm\r
- Arm/CopyMem.S\r
- Arm/SetMem.asm\r
- Arm/SetMem.S\r
-\r
-[Sources.AARCH64]\r
- AArch64/CopyMem.c\r
- AArch64/SetMem.c\r
-\r
-[Packages]\r
- MdePkg/MdePkg.dec\r
- ArmPkg/ArmPkg.dec\r
-\r
-[LibraryClasses]\r
- DebugLib\r
- BaseLib\r
-\r
+++ /dev/null
-/** @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. All rights reserved.<BR>\r
-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
+++ /dev/null
-/** @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. All rights reserved.<BR>\r
- 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
+++ /dev/null
-/** @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. All rights reserved.<BR>\r
- 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
+++ /dev/null
-/** @file\r
- Implementation of IsZeroBuffer function.\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) 2016, Intel Corporation. All rights reserved.<BR>\r
- 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
- Checks if the contents of a buffer are all zeros.\r
-\r
- This function checks whether the contents of a buffer are all zeros. If the\r
- contents are all zeros, return TRUE. Otherwise, return FALSE.\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 The pointer to the buffer to be checked.\r
- @param Length The size of the buffer (in bytes) to be checked.\r
-\r
- @retval TRUE Contents of the buffer are all zeros.\r
- @retval FALSE Contents of the buffer are not all zeros.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-IsZeroBuffer (\r
- IN CONST VOID *Buffer,\r
- IN UINTN Length\r
- )\r
-{\r
- ASSERT (!(Buffer == NULL && Length > 0));\r
- ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));\r
- return InternalMemIsZeroBuffer (Buffer, Length);\r
-}\r
+++ /dev/null
-/** @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. All rights reserved.<BR>\r
- 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
- Pointer++;\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
- Pointer++;\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
- Pointer++;\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
- Pointer++;\r
- } while (--Length != 0);\r
- return NULL;\r
-}\r
-\r
-/**\r
- Checks whether the contents of a buffer are all zeros.\r
-\r
- @param Buffer The pointer to the buffer to be checked.\r
- @param Length The size of the buffer (in bytes) to be checked.\r
-\r
- @retval TRUE Contents of the buffer are all zeros.\r
- @retval FALSE Contents of the buffer are not all zeros.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-InternalMemIsZeroBuffer (\r
- IN CONST VOID *Buffer,\r
- IN UINTN Length\r
- )\r
-{\r
- CONST UINT8 *BufferData;\r
- UINTN Index;\r
-\r
- BufferData = Buffer;\r
- for (Index = 0; Index < Length; Index++) {\r
- if (BufferData[Index] != 0) {\r
- return FALSE;\r
- }\r
- }\r
- return TRUE;\r
-}\r
+++ /dev/null
-/** @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. All rights reserved.<BR>\r
- 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
- return (CompareMem(Guid1, Guid2, sizeof(GUID)) == 0) ? TRUE : FALSE;\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
-\r
-/**\r
- Checks if the given GUID is a zero GUID.\r
-\r
- This function checks whether the given GUID is a zero GUID. If the GUID is\r
- identical to a zero GUID then TRUE is returned. Otherwise, FALSE is returned.\r
-\r
- If Guid is NULL, then ASSERT().\r
-\r
- @param Guid The pointer to a 128 bit GUID.\r
-\r
- @retval TRUE Guid is a zero GUID.\r
- @retval FALSE Guid is not a zero GUID.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-IsZeroGuid (\r
- IN CONST GUID *Guid\r
- )\r
-{\r
- UINT64 LowPartOfGuid;\r
- UINT64 HighPartOfGuid;\r
-\r
- LowPartOfGuid = ReadUnaligned64 ((CONST UINT64*) Guid);\r
- HighPartOfGuid = ReadUnaligned64 ((CONST UINT64*) Guid + 1);\r
-\r
- return (BOOLEAN) (LowPartOfGuid == 0 && HighPartOfGuid == 0);\r
-}\r
+++ /dev/null
-/** @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. All rights reserved.<BR>\r
- 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
-/**\r
- Checks whether the contents of a buffer are all zeros.\r
-\r
- @param Buffer The pointer to the buffer to be checked.\r
- @param Length The size of the buffer (in bytes) to be checked.\r
-\r
- @retval TRUE Contents of the buffer are all zeros.\r
- @retval FALSE Contents of the buffer are not all zeros.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-InternalMemIsZeroBuffer (\r
- IN CONST VOID *Buffer,\r
- IN UINTN Length\r
- );\r
-\r
-#endif\r
+++ /dev/null
-/** @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. All rights reserved.<BR>\r
- 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
+++ /dev/null
-/** @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. All rights reserved.<BR>\r
- 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
+++ /dev/null
-/** @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. All rights reserved.<BR>\r
- 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
+++ /dev/null
-/** @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. All rights reserved.<BR>\r
- 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
+++ /dev/null
-/** @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. All rights reserved.<BR>\r
- 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
+++ /dev/null
-/** @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. All rights reserved.<BR>\r
- 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
+++ /dev/null
-/** @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. All rights reserved.<BR>\r
- 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
+++ /dev/null
-/** @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. All rights reserved.<BR>\r
- 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
+++ /dev/null
-/** @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. All rights reserved.<BR>\r
- 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
+++ /dev/null
-/** @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. All rights reserved.<BR>\r
- 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