forked from tianocore/edk2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor SetMemWrapper to reduce binary size
Moved SetMemN API to a separate file to eliminate unnecessary inclusion of InternalMemSetMem64 and InternalMemSetMem32 APIs in driver binary. When the compiler linking the Object files it may not remove all the unused from NASM OBJs. This change is to reorganize the C files to minimize the impact of the NASM behavior resulting is code size reduction. Signed-off-by: Ashraf Ali <[email protected]>
- Loading branch information
1 parent
03c8ec6
commit e41e728
Showing
21 changed files
with
392 additions
and
246 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** @file | ||
SetMemN() implementation. | ||
The following BaseMemoryLib instances contain the same copy of this file: | ||
BaseMemoryLib | ||
BaseMemoryLibMmx | ||
BaseMemoryLibSse2 | ||
BaseMemoryLibRepStr | ||
BaseMemoryLibOptDxe | ||
BaseMemoryLibOptPei | ||
PeiMemoryLib | ||
UefiMemoryLib | ||
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR> | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
|
||
#include "MemLibInternals.h" | ||
|
||
/** | ||
Fills a target buffer with a value that is size UINTN, and returns the target buffer. | ||
This function fills Length bytes of Buffer with the UINTN sized value specified by | ||
Value, and returns Buffer. Value is repeated every sizeof(UINTN) bytes for Length | ||
bytes of Buffer. | ||
If Length > 0 and Buffer is NULL, then ASSERT(). | ||
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). | ||
If Buffer is not aligned on a UINTN boundary, then ASSERT(). | ||
If Length is not aligned on a UINTN boundary, then ASSERT(). | ||
@param Buffer The pointer to the target buffer to fill. | ||
@param Length The number of bytes in Buffer to fill. | ||
@param Value The value with which to fill Length bytes of Buffer. | ||
@return Buffer. | ||
**/ | ||
VOID * | ||
EFIAPI | ||
SetMemN ( | ||
OUT VOID *Buffer, | ||
IN UINTN Length, | ||
IN UINTN Value | ||
) | ||
{ | ||
if (sizeof (UINTN) == sizeof (UINT64)) { | ||
return SetMem64 (Buffer, Length, (UINT64)Value); | ||
} else { | ||
return SetMem32 (Buffer, Length, (UINT32)Value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** @file | ||
SetMemN() implementation. | ||
The following BaseMemoryLib instances contain the same copy of this file: | ||
BaseMemoryLib | ||
BaseMemoryLibMmx | ||
BaseMemoryLibSse2 | ||
BaseMemoryLibRepStr | ||
BaseMemoryLibOptDxe | ||
BaseMemoryLibOptPei | ||
PeiMemoryLib | ||
UefiMemoryLib | ||
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR> | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
|
||
#include "MemLibInternals.h" | ||
|
||
/** | ||
Fills a target buffer with a value that is size UINTN, and returns the target buffer. | ||
This function fills Length bytes of Buffer with the UINTN sized value specified by | ||
Value, and returns Buffer. Value is repeated every sizeof(UINTN) bytes for Length | ||
bytes of Buffer. | ||
If Length > 0 and Buffer is NULL, then ASSERT(). | ||
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). | ||
If Buffer is not aligned on a UINTN boundary, then ASSERT(). | ||
If Length is not aligned on a UINTN boundary, then ASSERT(). | ||
@param Buffer The pointer to the target buffer to fill. | ||
@param Length The number of bytes in Buffer to fill. | ||
@param Value The value with which to fill Length bytes of Buffer. | ||
@return Buffer. | ||
**/ | ||
VOID * | ||
EFIAPI | ||
SetMemN ( | ||
OUT VOID *Buffer, | ||
IN UINTN Length, | ||
IN UINTN Value | ||
) | ||
{ | ||
if (sizeof (UINTN) == sizeof (UINT64)) { | ||
return SetMem64 (Buffer, Length, (UINT64)Value); | ||
} else { | ||
return SetMem32 (Buffer, Length, (UINT32)Value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** @file | ||
SetMemN() implementation. | ||
The following BaseMemoryLib instances contain the same copy of this file: | ||
BaseMemoryLib | ||
BaseMemoryLibMmx | ||
BaseMemoryLibSse2 | ||
BaseMemoryLibRepStr | ||
BaseMemoryLibOptDxe | ||
BaseMemoryLibOptPei | ||
PeiMemoryLib | ||
UefiMemoryLib | ||
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR> | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
|
||
#include "MemLibInternals.h" | ||
|
||
/** | ||
Fills a target buffer with a value that is size UINTN, and returns the target buffer. | ||
This function fills Length bytes of Buffer with the UINTN sized value specified by | ||
Value, and returns Buffer. Value is repeated every sizeof(UINTN) bytes for Length | ||
bytes of Buffer. | ||
If Length > 0 and Buffer is NULL, then ASSERT(). | ||
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). | ||
If Buffer is not aligned on a UINTN boundary, then ASSERT(). | ||
If Length is not aligned on a UINTN boundary, then ASSERT(). | ||
@param Buffer The pointer to the target buffer to fill. | ||
@param Length The number of bytes in Buffer to fill. | ||
@param Value The value with which to fill Length bytes of Buffer. | ||
@return Buffer. | ||
**/ | ||
VOID * | ||
EFIAPI | ||
SetMemN ( | ||
OUT VOID *Buffer, | ||
IN UINTN Length, | ||
IN UINTN Value | ||
) | ||
{ | ||
if (sizeof (UINTN) == sizeof (UINT64)) { | ||
return SetMem64 (Buffer, Length, (UINT64)Value); | ||
} else { | ||
return SetMem32 (Buffer, Length, (UINT32)Value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** @file | ||
SetMemN() implementation. | ||
The following BaseMemoryLib instances contain the same copy of this file: | ||
BaseMemoryLib | ||
BaseMemoryLibMmx | ||
BaseMemoryLibSse2 | ||
BaseMemoryLibRepStr | ||
BaseMemoryLibOptDxe | ||
BaseMemoryLibOptPei | ||
PeiMemoryLib | ||
UefiMemoryLib | ||
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR> | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
|
||
#include "MemLibInternals.h" | ||
|
||
/** | ||
Fills a target buffer with a value that is size UINTN, and returns the target buffer. | ||
This function fills Length bytes of Buffer with the UINTN sized value specified by | ||
Value, and returns Buffer. Value is repeated every sizeof(UINTN) bytes for Length | ||
bytes of Buffer. | ||
If Length > 0 and Buffer is NULL, then ASSERT(). | ||
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). | ||
If Buffer is not aligned on a UINTN boundary, then ASSERT(). | ||
If Length is not aligned on a UINTN boundary, then ASSERT(). | ||
@param Buffer The pointer to the target buffer to fill. | ||
@param Length The number of bytes in Buffer to fill. | ||
@param Value The value with which to fill Length bytes of Buffer. | ||
@return Buffer. | ||
**/ | ||
VOID * | ||
EFIAPI | ||
SetMemN ( | ||
OUT VOID *Buffer, | ||
IN UINTN Length, | ||
IN UINTN Value | ||
) | ||
{ | ||
if (sizeof (UINTN) == sizeof (UINT64)) { | ||
return SetMem64 (Buffer, Length, (UINT64)Value); | ||
} else { | ||
return SetMem32 (Buffer, Length, (UINT32)Value); | ||
} | ||
} |
Oops, something went wrong.