Skip to content

Commit

Permalink
Drop dependency on string.h
Browse files Browse the repository at this point in the history
Signed-off-by: Mario Bălănică <[email protected]>
  • Loading branch information
mariobalanica committed Jan 19, 2024
1 parent 21c4983 commit 4af3a03
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <Library/DebugLib.h>
#include <Library/IoLib.h>
#include <Library/PcdLib.h>
#include <string.h>
#include <Library/TimerLib.h>
#include <Library/SpiMem.h>
#include <Library/Fspi.h>
Expand Down Expand Up @@ -1003,7 +1002,7 @@ SpiFlashUpdateBlock (
}

if (Align) {
memcpy(&TmpBuf[Align], Buf, ToUpdate);
CopyMem (&TmpBuf[Align], Buf, ToUpdate);
Status = HAL_SNOR_ProgData (g_nor, Offset - Align, TmpBuf, EraseSize);
if (EFI_ERROR (Status)) {
DEBUG((DEBUG_ERROR, "SpiFlash: Update: Error while writing new data\n"));
Expand Down
5 changes: 2 additions & 3 deletions edk2-rockchip/Silicon/Rockchip/Drivers/Vop2Dxe/Vop2Dxe.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <Library/IoLib.h>
#include <Library/TimerLib.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/RockchipDisplayLib.h>
Expand All @@ -19,8 +20,6 @@
#include <Library/MediaBusFormat.h>
#include <Library/DrmModes.h>

#include <string.h>

#include <Protocol/RockchipCrtcProtocol.h>

#include "Vop2Dxe.h"
Expand Down Expand Up @@ -1435,7 +1434,7 @@ Vop2PreInit (
RockchipVop2->Version = mVop2RK3588.Version;
RockchipVop2->Data = &mVop2RK3588;
RockchipVop2->GlobalInit = FALSE;
memset(RockchipVop2->VpPlaneMask, 0, sizeof(VOP2_VP_PLANE_MASK) * VOP2_VP_MAX);
ZeroMem (RockchipVop2->VpPlaneMask, sizeof(VOP2_VP_PLANE_MASK) * VOP2_VP_MAX);
}

CrtcState->Private = RockchipVop2;
Expand Down
1 change: 1 addition & 0 deletions edk2-rockchip/Silicon/Rockchip/Drivers/Vop2Dxe/Vop2Dxe.inf
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
IoLib
DebugLib
BaseLib
BaseMemoryLib
MemoryAllocationLib
RockchipDisplayLib
UefiDriverEntryPoint
Expand Down
5 changes: 0 additions & 5 deletions edk2-rockchip/Silicon/Rockchip/Include/Library/DwHdmiQpLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@
#define EINVAL 22 /* Invalid argument */
#define ETIMEDOUT 110 /* Connection timed out */

#define BITS_PER_LONG 32
#define GENMASK(h, l) \
(((~0U) << (l)) & (~0U >> (BITS_PER_LONG - 1 - (h))))

/* Main Unit Registers */
#define CORE_ID 0x0
#define VER_NUMBER 0x4
Expand Down Expand Up @@ -910,7 +906,6 @@
#define HDPTXPHY0_GRF_BASE 0xFD5E0000
#define HDPTXPHY1_GRF_BASE 0xFD5E4000

#define PMU1CRU_BASE 0xFD7F0000
#define PMU1CRU_SOFTRST_CON03 0xA0C
#define PMU1CRU_SOFTRST_CON04 0xA10

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
#include <Library/MediaBusFormat.h>
#include <Library/DrmModes.h>

#include <string.h>

#include <Protocol/RockchipConnectorProtocol.h>

#include <Uefi/UefiBaseType.h>

#include "uboot-env.h"

# define DP_MAX_LINK_RATE 0x001
# define DP_MAX_LANE_COUNT 0x002

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
DebugLib
IoLib
BaseLib
BaseMemoryLib
RockchipDisplayLib
MemoryAllocationLib
PWMLib
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
#include <Library/DrmModes.h>
#include <Library/GpioLib.h>

#include <string.h>

#include <Protocol/RockchipConnectorProtocol.h>

#include <Uefi/UefiBaseType.h>

#include "uboot-env.h"

#define HIWORD_UPDATE(val, mask) (val | (mask) << 16)

#define RK3588_GRF_SOC_CON2 0x0308
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
DebugLib
IoLib
BaseLib
BaseMemoryLib
RockchipDisplayLib
MemoryAllocationLib
PWMLib
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
#include <Library/PWMLib.h>
#include <Library/DrmModes.h>

#define BITS_PER_LONG 32
#define GENMASK(h, l) \
(((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
#include "uboot-env.h"

#define RO_REF_CLK_SEL GENMASK(11, 10)
#define LC_REF_CLK_SEL GENMASK(9, 8)
#define PLL_EN BIT(7)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include <Library/PWMLib.h>
#include <Library/DrmModes.h>

#include "uboot-env.h"

#define UPDATE(x, h, l) (((x) << (l)) & GENMASK((h), (l)))

#define GRF_HDPTX_CON0 0x00
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
UefiBootServicesTableLib
MemoryAllocationLib
BaseLib
BaseMemoryLib

[Packages]
ArmPlatformPkg/ArmPlatformPkg.dec
Expand Down
15 changes: 14 additions & 1 deletion edk2-rockchip/Silicon/Rockchip/Library/DisplayLib/uboot-env.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <Library/IoLib.h>
#include <Library/TimerLib.h>
#include <Library/BaseLib.h>
#include <string.h>
#include <Library/BaseMemoryLib.h>
#include <Soc.h>
#include "errno.h"

Expand All @@ -19,6 +19,7 @@ typedef UINT64 u64;
typedef unsigned int uint;
typedef UINTN ulong;
typedef INTN ssize_t;
typedef UINTN size_t;
typedef BOOLEAN bool;

#define true TRUE
Expand Down Expand Up @@ -132,4 +133,16 @@ static inline u32 get_unaligned_le32(const void *p)
return __get_unaligned_le32((const u8 *)p);
}

#define memcpy(dest, source, count) CopyMem(dest,source, (UINTN)(count))
#define memset(dest, ch, count) SetMem(dest, (UINTN)(count),(UINT8)(ch))
#define memchr(buf, ch, count) ScanMem8(buf, (UINTN)(count),(UINT8)ch)
#define memcmp(buf1, buf2, count) (int)(CompareMem(buf1, buf2, (UINTN)(count)))
#define memmove(dest, source, count) CopyMem(dest, source, (UINTN)(count))
#define strlen(str) (size_t)(AsciiStrLen(str))
#define strnlen(str, count) (size_t)(AsciiStrnLenS(str, count))
#define strncpy(strDest, strSource, count) AsciiStrnCpyS(strDest, MAX_STRING_SIZE, strSource, (UINTN)count)
#define strcat(strDest, strSource) AsciiStrCatS(strDest, MAX_STRING_SIZE, strSource)
#define strcmp(string1, string2, count) (int)(AsciiStrCmp(string1, string2))
#define strncmp(string1, string2, count) (int)(AsciiStrnCmp(string1, string2, (UINTN)(count)))

#endif // _UBOOT_ENV_H

0 comments on commit 4af3a03

Please sign in to comment.