From 4af3a03c115e1bd6640e199eaa574a8f689740e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20B=C4=83l=C4=83nic=C4=83?= Date: Fri, 19 Jan 2024 20:39:23 +0200 Subject: [PATCH] Drop dependency on string.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mario Bălănică --- .../Rockchip/Drivers/NorFlashDxe/NorFlashDxe.c | 3 +-- .../Silicon/Rockchip/Drivers/Vop2Dxe/Vop2Dxe.c | 5 ++--- .../Silicon/Rockchip/Drivers/Vop2Dxe/Vop2Dxe.inf | 1 + .../Rockchip/Include/Library/DwHdmiQpLib.h | 5 ----- .../Rockchip/Library/DisplayLib/AnalogixDpLib.c | 4 ++-- .../Rockchip/Library/DisplayLib/AnalogixDpLib.inf | 1 + .../Rockchip/Library/DisplayLib/DwHdmiQpLib.c | 4 ++-- .../Rockchip/Library/DisplayLib/DwHdmiQpLib.inf | 1 + .../Library/DisplayLib/PhyRockchipSamsungHdptx.c | 5 ++--- .../DisplayLib/PhyRockchipSamsungHdptxHdmi.c | 2 ++ .../Library/DisplayLib/RockchipDisplayLib.inf | 1 + .../Rockchip/Library/DisplayLib/uboot-env.h | 15 ++++++++++++++- 12 files changed, 29 insertions(+), 18 deletions(-) diff --git a/edk2-rockchip/Silicon/Rockchip/Drivers/NorFlashDxe/NorFlashDxe.c b/edk2-rockchip/Silicon/Rockchip/Drivers/NorFlashDxe/NorFlashDxe.c index 890b30615..6ba68fe96 100644 --- a/edk2-rockchip/Silicon/Rockchip/Drivers/NorFlashDxe/NorFlashDxe.c +++ b/edk2-rockchip/Silicon/Rockchip/Drivers/NorFlashDxe/NorFlashDxe.c @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include @@ -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")); diff --git a/edk2-rockchip/Silicon/Rockchip/Drivers/Vop2Dxe/Vop2Dxe.c b/edk2-rockchip/Silicon/Rockchip/Drivers/Vop2Dxe/Vop2Dxe.c index e2147104a..27c6c3a45 100644 --- a/edk2-rockchip/Silicon/Rockchip/Drivers/Vop2Dxe/Vop2Dxe.c +++ b/edk2-rockchip/Silicon/Rockchip/Drivers/Vop2Dxe/Vop2Dxe.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -19,8 +20,6 @@ #include #include -#include - #include #include "Vop2Dxe.h" @@ -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; diff --git a/edk2-rockchip/Silicon/Rockchip/Drivers/Vop2Dxe/Vop2Dxe.inf b/edk2-rockchip/Silicon/Rockchip/Drivers/Vop2Dxe/Vop2Dxe.inf index 748077e79..b247971b5 100644 --- a/edk2-rockchip/Silicon/Rockchip/Drivers/Vop2Dxe/Vop2Dxe.inf +++ b/edk2-rockchip/Silicon/Rockchip/Drivers/Vop2Dxe/Vop2Dxe.inf @@ -31,6 +31,7 @@ IoLib DebugLib BaseLib + BaseMemoryLib MemoryAllocationLib RockchipDisplayLib UefiDriverEntryPoint diff --git a/edk2-rockchip/Silicon/Rockchip/Include/Library/DwHdmiQpLib.h b/edk2-rockchip/Silicon/Rockchip/Include/Library/DwHdmiQpLib.h index b74b65983..c0127fd98 100644 --- a/edk2-rockchip/Silicon/Rockchip/Include/Library/DwHdmiQpLib.h +++ b/edk2-rockchip/Silicon/Rockchip/Include/Library/DwHdmiQpLib.h @@ -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 @@ -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 diff --git a/edk2-rockchip/Silicon/Rockchip/Library/DisplayLib/AnalogixDpLib.c b/edk2-rockchip/Silicon/Rockchip/Library/DisplayLib/AnalogixDpLib.c index 826cdfab1..e028e2ed3 100644 --- a/edk2-rockchip/Silicon/Rockchip/Library/DisplayLib/AnalogixDpLib.c +++ b/edk2-rockchip/Silicon/Rockchip/Library/DisplayLib/AnalogixDpLib.c @@ -20,12 +20,12 @@ #include #include -#include - #include #include +#include "uboot-env.h" + # define DP_MAX_LINK_RATE 0x001 # define DP_MAX_LANE_COUNT 0x002 diff --git a/edk2-rockchip/Silicon/Rockchip/Library/DisplayLib/AnalogixDpLib.inf b/edk2-rockchip/Silicon/Rockchip/Library/DisplayLib/AnalogixDpLib.inf index 773588803..a1be628dd 100644 --- a/edk2-rockchip/Silicon/Rockchip/Library/DisplayLib/AnalogixDpLib.inf +++ b/edk2-rockchip/Silicon/Rockchip/Library/DisplayLib/AnalogixDpLib.inf @@ -32,6 +32,7 @@ DebugLib IoLib BaseLib + BaseMemoryLib RockchipDisplayLib MemoryAllocationLib PWMLib diff --git a/edk2-rockchip/Silicon/Rockchip/Library/DisplayLib/DwHdmiQpLib.c b/edk2-rockchip/Silicon/Rockchip/Library/DisplayLib/DwHdmiQpLib.c index f26d428a8..505509a44 100644 --- a/edk2-rockchip/Silicon/Rockchip/Library/DisplayLib/DwHdmiQpLib.c +++ b/edk2-rockchip/Silicon/Rockchip/Library/DisplayLib/DwHdmiQpLib.c @@ -21,12 +21,12 @@ #include #include -#include - #include #include +#include "uboot-env.h" + #define HIWORD_UPDATE(val, mask) (val | (mask) << 16) #define RK3588_GRF_SOC_CON2 0x0308 diff --git a/edk2-rockchip/Silicon/Rockchip/Library/DisplayLib/DwHdmiQpLib.inf b/edk2-rockchip/Silicon/Rockchip/Library/DisplayLib/DwHdmiQpLib.inf index 8279c9b75..c737a0854 100644 --- a/edk2-rockchip/Silicon/Rockchip/Library/DisplayLib/DwHdmiQpLib.inf +++ b/edk2-rockchip/Silicon/Rockchip/Library/DisplayLib/DwHdmiQpLib.inf @@ -31,6 +31,7 @@ DebugLib IoLib BaseLib + BaseMemoryLib RockchipDisplayLib MemoryAllocationLib PWMLib diff --git a/edk2-rockchip/Silicon/Rockchip/Library/DisplayLib/PhyRockchipSamsungHdptx.c b/edk2-rockchip/Silicon/Rockchip/Library/DisplayLib/PhyRockchipSamsungHdptx.c index b3476391e..1ba8e791c 100644 --- a/edk2-rockchip/Silicon/Rockchip/Library/DisplayLib/PhyRockchipSamsungHdptx.c +++ b/edk2-rockchip/Silicon/Rockchip/Library/DisplayLib/PhyRockchipSamsungHdptx.c @@ -18,9 +18,8 @@ #include #include -#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) diff --git a/edk2-rockchip/Silicon/Rockchip/Library/DisplayLib/PhyRockchipSamsungHdptxHdmi.c b/edk2-rockchip/Silicon/Rockchip/Library/DisplayLib/PhyRockchipSamsungHdptxHdmi.c index 3602d6b2e..b6fbeb325 100644 --- a/edk2-rockchip/Silicon/Rockchip/Library/DisplayLib/PhyRockchipSamsungHdptxHdmi.c +++ b/edk2-rockchip/Silicon/Rockchip/Library/DisplayLib/PhyRockchipSamsungHdptxHdmi.c @@ -18,6 +18,8 @@ #include #include +#include "uboot-env.h" + #define UPDATE(x, h, l) (((x) << (l)) & GENMASK((h), (l))) #define GRF_HDPTX_CON0 0x00 diff --git a/edk2-rockchip/Silicon/Rockchip/Library/DisplayLib/RockchipDisplayLib.inf b/edk2-rockchip/Silicon/Rockchip/Library/DisplayLib/RockchipDisplayLib.inf index 83ece2fd6..84afd447b 100644 --- a/edk2-rockchip/Silicon/Rockchip/Library/DisplayLib/RockchipDisplayLib.inf +++ b/edk2-rockchip/Silicon/Rockchip/Library/DisplayLib/RockchipDisplayLib.inf @@ -24,6 +24,7 @@ UefiBootServicesTableLib MemoryAllocationLib BaseLib + BaseMemoryLib [Packages] ArmPlatformPkg/ArmPlatformPkg.dec diff --git a/edk2-rockchip/Silicon/Rockchip/Library/DisplayLib/uboot-env.h b/edk2-rockchip/Silicon/Rockchip/Library/DisplayLib/uboot-env.h index 757df4915..4ade2df30 100644 --- a/edk2-rockchip/Silicon/Rockchip/Library/DisplayLib/uboot-env.h +++ b/edk2-rockchip/Silicon/Rockchip/Library/DisplayLib/uboot-env.h @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include "errno.h" @@ -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 @@ -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