From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from loongson.cn (loongson.cn [114.242.206.163]) by mx.groups.io with SMTP id smtpd.web09.8760.1649756396172768280 for ; Tue, 12 Apr 2022 02:39:56 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: loongson.cn, ip: 114.242.206.163, mailfrom: lichao@loongson.cn) Received: from lichao-PC (unknown [10.40.24.65]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9AxSszqSFViMTQgAA--.11246S2; Tue, 12 Apr 2022 17:39:54 +0800 (CST) Date: Tue, 12 Apr 2022 17:39:53 +0800 From: "Chao Li" To: "=?utf-8?Q?=22Chang=2C_Abner_(HPS_SW/FW_Technologist)=22?=" Cc: "=?utf-8?Q?=22devel=40edk2.groups.io=22?=" , Michael D Kinney , Liming Gao , Zhiguang Liu , =?utf-8?Q?=22Baoqi_Zhang=22?= Message-ID: <43C36A0E-67B1-41B9-A4A3-9BD6BB6530FD@getmailspring.com> In-Reply-To: References: Subject: Re: [edk2-devel] [staging/LoongArch RESEND PATCH v1 24/33] MdePkg/BasePeCoff: Add LoongArch PE/Coff related code. X-Mailer: Mailspring MIME-Version: 1.0 X-CM-TRANSID: AQAAf9AxSszqSFViMTQgAA--.11246S2 X-Coremail-Antispam: 1UD129KBjvJXoWfGrWUtw1DGF47trW3ZF13Arb_yoWDWr4xpF 9rtanxWwnrJw4fAryYq3W7GrsYgF4kGasIkFyq9w48ZFsxZa1vkw4Utr4rtrWUXrWDA348 u3Z09r43ua1kJr7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUQvb7Iv0xC_Cr1lb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rw A2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xII jxv20xvEc7CjxVAFwI0_Cr0_Gr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I 8E87Iv6xkF7I0E14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVAYj202 j2C_Jr0_Gr1l5I8CrVACY4xI64kE6c02F40Ex7xfMc02F40Ew4AK048IF2xKxVW8JVW5Jw Aqx4xG6I80eVA0xI0YY7vIx2IE14AGzxvEb7x7McIj6xIIjxv20xvE14v26r126r1DMcIj 6I8E87Iv67AKxVW8JVWxJwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l74 80Y4vEI4kI2Ix0rVAqx4xJMxkIecxEwVCm-wCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE 7xkEbVWUJVW8JwCFI7km07C267AKxVW8ZVWrXwC20s026c02F40E14v26r106r1rMI8I3I 0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAI cVC0I7IYx2IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Jr0_Gr1lIxAIcV CF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r4j6F4UMIIF0xvEx4A2jsIE c7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x07jwXo7UUUUU= X-CM-SenderInfo: xolfxt3r6o00pqjv00gofq/1tbiAQAOCF3QvPKREwACsE Content-Type: multipart/alternative; boundary="625548e9_571b6d28_6697" --625548e9_571b6d28_6697 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline -- Thanks, Chao ------------------------ On 4=E6=9C=88 8 2022, at 5:38 =E4=B8=8B=E5=8D=88, "Chang, Abner (HPS SW/FW = Technologist)" wrote: > > > > -----Original Message----- > > From: devel@edk2.groups.io On Behalf Of Chao Li > > Sent: Wednesday, February 9, 2022 2:56 PM > > To: devel@edk2.groups.io > > Cc: Michael D Kinney ; Liming Gao > > ; Zhiguang Liu ; Baoq= i > > Zhang > > Subject: [edk2-devel] [staging/LoongArch RESEND PATCH v1 24/33] > > MdePkg/BasePeCoff: Add LoongArch PE/Coff related code. > > > > Add LoongArch image relocation. > > > > Cc: Michael D Kinney > > Cc: Liming Gao > > Cc: Zhiguang Liu > > > > Signed-off-by: Chao Li > > Co-authored-by: Baoqi Zhang > > --- > > MdePkg/Library/BasePeCoffLib/BasePeCoff.c | 3 +- > > .../Library/BasePeCoffLib/BasePeCoffLib.inf | 5 + > > .../Library/BasePeCoffLib/BasePeCoffLib.uni | 2 + > > .../BasePeCoffLib/LoongArch/PeCoffLoaderEx.c | 132 > > ++++++++++++++++++ > > 4 files changed, 141 insertions(+), 1 deletion(-) > > create mode 100644 > > MdePkg/Library/BasePeCoffLib/LoongArch/PeCoffLoaderEx.c > > > > diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c > > b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c > > index 6d8d9faeb8..97a8aaf8c7 100644 > > --- a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c > > +++ b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c > > @@ -1,6 +1,6 @@ > > /** @file > > Base PE/COFF loader supports loading any PE32/PE32+ or TE image, but > > - only supports relocating IA32, x64, IPF, ARM, RISC-V and EBC images. > > + only supports relocating IA32, x64, IPF, ARM, RISC-V, LoongArch and E= BC > > images. > > > > Caution: This file requires additional review when modified. > > This library will have external input - PE/COFF image. > > @@ -18,6 +18,7 @@ > > Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
> > Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
> > Portions Copyright (c) 2020, Hewlett Packard Enterprise Development LP. > > All rights reserved.
> > + Portions Copyright (c) 2022, Loongson Technology Corporation Limited.= All > > rights reserved.
> > SPDX-License-Identifier: BSD-2-Clause-Patent > > > > **/ > > diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf > > b/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf > > index 110b6d5a09..3b8b8eb191 100644 > > --- a/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf > > +++ b/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf > > @@ -4,6 +4,7 @@ > > # The IA32 version library support loading IA32, X64 and EBC PE/COFF im= ages. > > # The X64 version library support loading IA32, X64 and EBC PE/COFF ima= ges. > > # The RISC-V version library support loading RISC-V images. > > +# The LoongArch version library support loading LoongArch images. > > # > > # Caution: This module requires additional review when modified. > > # This library will have external input - PE/COFF image. > > @@ -13,6 +14,7 @@ > > # Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved. > > # Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved. > > # Portions Copyright (c) 2020, Hewlett Packard Enterprise Development L= P. > > All rights reserved.
> > +# Portions Copyright (c) 2022, Loongson Technology Corporation Limited= . All > > rights reserved.
> > # > > # SPDX-License-Identifier: BSD-2-Clause-Patent > > # > > @@ -46,6 +48,9 @@ > > [Sources.RISCV64] > > RiscV/PeCoffLoaderEx.c > > > > +[Sources.LOONGARCH64] > > + LoongArch/PeCoffLoaderEx.c > > + > > [Packages] > > MdePkg/MdePkg.dec > > > > diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.uni > > b/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.uni > > index 55417029f2..1f731344e1 100644 > > --- a/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.uni > > +++ b/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.uni > > @@ -5,6 +5,7 @@ > > // The IA32 version library support loading IA32, X64 and EBC PE/COFF > > images. > > // The X64 version library support loading IA32, X64 and EBC PE/COFF im= ages. > > // The RISC-V version library support loading RISC-V32 and RISC-V64 PE/= COFF > > images. > > +// The LoongArch version library support loading LoongArch32 and > > LoongArch64 PE/COFF images. > > // > > // Caution: This module requires additional review when modified. > > // This library will have external input - PE/COFF image. > > @@ -14,6 +15,7 @@ > > // Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved. > > // Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<= BR> > > // Portions Copyright (c) 2020, Hewlett Packard Enterprise Development = LP. > > All rights reserved.
> > +// Portions Copyright (c) 2022, Loongson Technology Corporation Limite= d. > > All rights reserved.
> > // > > // SPDX-License-Identifier: BSD-2-Clause-Patent > > // > > diff --git a/MdePkg/Library/BasePeCoffLib/LoongArch/PeCoffLoaderEx.c > > b/MdePkg/Library/BasePeCoffLib/LoongArch/PeCoffLoaderEx.c > > new file mode 100644 > > index 0000000000..ec572c2dd6 > > --- /dev/null > > +++ b/MdePkg/Library/BasePeCoffLib/LoongArch/PeCoffLoaderEx.c > > @@ -0,0 +1,132 @@ > > +/** @file > > + PE/Coff loader for LoongArch PE image > > + > > + Copyright (c) 2022, Loongson Technology Corporation Limited. All righ= ts > > reserved.
> > + > > + SPDX-License-Identifier: BSD-2-Clause-Patent > > +**/ > > + > > +#include "BasePeCoffLibInternals.h" > > +#include > > + > > +/** > > + Performs an LoongArch specific relocation fixup and is a no-op on oth= er > > + instruction sets. > > + > > + @param Reloc Pointer to the relocation record. > > + @param Fixup Pointer to the address to fix up. > > + @param FixupData Pointer to a buffer to log the fixups. > > + @param Adjust The offset to adjust the fixup. > > + > > + @return Status code. > > + > > +**/ > > +RETURN_STATUS > > +PeCoffLoaderRelocateImageEx ( > > + IN UINT16 *Reloc, > > + IN OUT CHAR8 *Fixup, > > + IN OUT CHAR8 **FixupData, > > + IN UINT64 Adjust > > + ) > > +{ > > + UINT8 RelocType; > > + UINT64 Value =3D 0; > > + UINT64 Tmp1 =3D 0; > > + UINT64 Tmp2 =3D 0; > > + > > + RelocType =3D (*Reloc) >> 12; > > + > > + switch (RelocType) { > > + case EFI_IMAGE_REL_BASED_LOONGARCH64_MARK_LA: > > + Value =3D (*(UINT32*)Fixup & 0x1ffffe0) << 7 | /* lu12i.w 20bits from > > bit5 */ > > + (*((UINT32*)Fixup + 1) & 0x3ffc00) >> 10; /* ori 12bits from bit10 */ > > + Tmp1 =3D *((UINT32*)Fixup + 2) & 0x1ffffe0; /* lu32i.d 20bits from bi= t5 > > */ > > + Tmp2 =3D *((UINT32*)Fixup + 3) & 0x3ffc00; /* lu52i.d 12bits from > > bit10 */ > > + Value =3D Value | (Tmp1 << 27) | (Tmp2 << 42); > > + Value +=3D Adjust; > Please use double back slash for the comments in the function in this fil= e. > > Abner Chao: Okay, I will revise it in the next version. > + > + *(UINT32*)Fixup =3D (*(UINT32*)Fixup & ~0x1ffffe0) | (((Value >> 12) & > 0xfffff) << 5); > + if (*FixupData !=3D NULL) { > + *FixupData =3D ALIGN_POINTER (*FixupData, sizeof (UINT32)); > + *(UINT32 *) (*FixupData) =3D *(UINT32*)Fixup; > + *FixupData =3D *FixupData + sizeof (UINT32); > + } > + > + Fixup +=3D sizeof(UINT32); > + *(UINT32*)Fixup =3D (*(UINT32*)Fixup & ~0x3ffc00) | ((Value & 0xfff) << > 10); > + if (*FixupData !=3D NULL) { > + *FixupData =3D ALIGN_POINTER (*FixupData, sizeof (UINT32)); > + *(UINT32 *) (*FixupData) =3D *(UINT32*)Fixup; > + *FixupData =3D *FixupData + sizeof (UINT32); > + } > + > + Fixup +=3D sizeof(UINT32); > + *(UINT32*)Fixup =3D (*(UINT32*)Fixup & ~0x1ffffe0) | (((Value >> 32) & > 0xfffff) << 5); > + if (*FixupData !=3D NULL) { > + *FixupData =3D ALIGN_POINTER (*FixupData, sizeof (UINT32)); > + *(UINT32 *) (*FixupData) =3D *(UINT32*)Fixup; > + *FixupData =3D *FixupData + sizeof (UINT32); > + } > + > + Fixup +=3D sizeof(UINT32); > + *(UINT32*)Fixup =3D (*(UINT32*)Fixup & ~0x3ffc00) | (((Value >> 52) & > 0xfff) << 10); > + if (*FixupData !=3D NULL) { > + *FixupData =3D ALIGN_POINTER (*FixupData, sizeof (UINT32)); > + *(UINT32 *) (*FixupData) =3D *(UINT32*)Fixup; > + *FixupData =3D *FixupData + sizeof (UINT32); > + } > + break; > + default: > + return RETURN_UNSUPPORTED; > + } > + > + return RETURN_SUCCESS; > +} > + > +/** > + Returns TRUE if the machine type of PE/COFF image is supported. > Supported > + does not mean the image can be executed it means the PE/COFF loader > supports > + loading and relocating of the image type. It's up to the caller to supp= ort > + the entry point. > + > + @param Machine Machine type from the PE Header. > + > + @return TRUE if this PE/COFF loader can load the image > + > +**/ > +BOOLEAN > +PeCoffLoaderImageFormatSupported ( > + IN UINT16 Machine > + ) > +{ > + if (Machine =3D=3D IMAGE_FILE_MACHINE_LOONGARCH64) { > + return TRUE; > + } > + > + return FALSE; > +} > + > +/** > + Performs an LOONGARCH-based specific re-relocation fixup and is a no-op > on other > + instruction sets. This is used to re-relocated the image into the EFI v= irtual > + space for runtime calls. > + > + @param Reloc The pointer to the relocation record. > + @param Fixup The pointer to the address to fix up. > + @param FixupData The pointer to a buffer to log the fixups. > + @param Adjust The offset to adjust the fixup. > + > + @return Status code. > + > +**/ > +RETURN_STATUS > +PeHotRelocateImageEx ( > + IN UINT16 *Reloc, > + IN OUT CHAR8 *Fixup, > + IN OUT CHAR8 **FixupData, > + IN UINT64 Adjust > + ) > +{ > + /* to check */ > + return PeCoffLoaderRelocateImageEx (Reloc, Fixup, FixupData, Adjust); > +} > -- > 2.27.0 > > > >=20 > --625548e9_571b6d28_6697 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline

--
Thanks,
Chao
------------------------


On 4=E6=9C=88 = 8 2022, at 5:38 =E4=B8=8B=E5=8D=88, "Chang, Abner (HPS SW/FW Technologist)"= <abner.chang@hpe.com> wrote:


>= -----Original Message-----
> From: devel@edk2.groups.io <d= evel@edk2.groups.io> On Behalf Of Chao Li
> Sent: Wednesday= , February 9, 2022 2:56 PM
> To: devel@edk2.groups.io
> Cc: Michael D Kinney <michael.d.kinney@intel.com>; Liming Gao<= /div>
> <gaoliming@byosoft.com.cn>; Zhiguang Liu <zhiguang.= liu@intel.com>; Baoqi
> Zhang <zhangbaoqi@loongson.cn>= ;
> Subject: [edk2-devel] [staging/LoongArch RESEND PATCH v1 2= 4/33]
> MdePkg/BasePeCoff: Add LoongArch PE/Coff related code.=
>
> Add LoongArch image relocation.
&g= t;
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
>= ; Cc: Zhiguang Liu <zhiguang.liu@intel.com>
>
= > Signed-off-by: Chao Li <lichao@loongson.cn>
> Co-au= thored-by: Baoqi Zhang <zhangbaoqi@loongson.cn>
> ---
> MdePkg/Library/BasePeCoffLib/BasePeCoff.c | 3 +-
>= ; .../Library/BasePeCoffLib/BasePeCoffLib.inf | 5 +
> .../Libr= ary/BasePeCoffLib/BasePeCoffLib.uni | 2 +
> .../BasePeCoffLib/= LoongArch/PeCoffLoaderEx.c | 132
> ++++++++++++++++++
> 4 files changed, 141 insertions(+), 1 deletion(-)
> cre= ate mode 100644
> MdePkg/Library/BasePeCoffLib/LoongArch/PeCof= fLoaderEx.c
>
> diff --git a/MdePkg/Library/BaseP= eCoffLib/BasePeCoff.c
> b/MdePkg/Library/BasePeCoffLib/BasePeC= off.c
> index 6d8d9faeb8..97a8aaf8c7 100644
> ---= a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
> +++ b/MdePkg/Li= brary/BasePeCoffLib/BasePeCoff.c
> @@ -1,6 +1,6 @@
&= gt; /** @file
> Base PE/COFF loader supports loading any PE32/= PE32+ or TE image, but
> - only supports relocating IA32, x64,= IPF, ARM, RISC-V and EBC images.
> + only supports relocating= IA32, x64, IPF, ARM, RISC-V, LoongArch and EBC
> images.
>
> Caution: This file requires additional review whe= n modified.
> This library will have external input - PE/COFF = image.
> @@ -18,6 +18,7 @@
> Copyright (c) 2006 -= 2019, Intel Corporation. All rights reserved.<BR>
> Por= tions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR><= /div>
> Portions Copyright (c) 2020, Hewlett Packard Enterprise Deve= lopment LP.
> All rights reserved.<BR>
> + = Portions Copyright (c) 2022, Loongson Technology Corporation Limited. All
> rights reserved.<BR>
> SPDX-License-Identi= fier: BSD-2-Clause-Patent
>
> **/
> = diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
> = b/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
> index 110b6= d5a09..3b8b8eb191 100644
> --- a/MdePkg/Library/BasePeCoffLib/= BasePeCoffLib.inf
> +++ b/MdePkg/Library/BasePeCoffLib/BasePeC= offLib.inf
> @@ -4,6 +4,7 @@
> # The IA32 version= library support loading IA32, X64 and EBC PE/COFF images.
> #= The X64 version library support loading IA32, X64 and EBC PE/COFF images.<= /div>
> # The RISC-V version library support loading RISC-V images.<= /div>
> +# The LoongArch version library support loading LoongArch i= mages.
> #
> # Caution: This module requires addi= tional review when modified.
> # This library will have extern= al input - PE/COFF image.
> @@ -13,6 +14,7 @@
> #= Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR&g= t;
> # Portions copyright (c) 2008 - 2009, Apple Inc. All righ= ts reserved.<BR>
> # Portions Copyright (c) 2020, Hewlet= t Packard Enterprise Development LP.
> All rights reserved.<= ;BR>
> +# Portions Copyright (c) 2022, Loongson Technology = Corporation Limited. All
> rights reserved.<BR>
> #
> # SPDX-License-Identifier: BSD-2-Clause-Patent
> #
> @@ -46,6 +48,9 @@
> [Sources.RISCV= 64]
> RiscV/PeCoffLoaderEx.c
>
> +[S= ources.LOONGARCH64]
> + LoongArch/PeCoffLoaderEx.c
&= gt; +
> [Packages]
> MdePkg/MdePkg.dec
= >
> diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoffLib= .uni
> b/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.uni
<= div>> index 55417029f2..1f731344e1 100644
> --- a/MdePkg/Li= brary/BasePeCoffLib/BasePeCoffLib.uni
> +++ b/MdePkg/Library/B= asePeCoffLib/BasePeCoffLib.uni
> @@ -5,6 +5,7 @@
>= ; // The IA32 version library support loading IA32, X64 and EBC PE/COFF
> images.
> // The X64 version library support loadi= ng IA32, X64 and EBC PE/COFF images.
> // The RISC-V version l= ibrary support loading RISC-V32 and RISC-V64 PE/COFF
> images.=
> +// The LoongArch version library support loading LoongArch= 32 and
> LoongArch64 PE/COFF images.
> //
> // Caution: This module requires additional review when modified.
> // This library will have external input - PE/COFF image.
> @@ -14,6 +15,7 @@
> // Copyright (c) 2006 - 2018, = Intel Corporation. All rights reserved.<BR>
> // Portion= s copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
> // Portions Copyright (c) 2020, Hewlett Packard Enterprise Devel= opment LP.
> All rights reserved.<BR>
> +//= Portions Copyright (c) 2022, Loongson Technology Corporation Limited.
> All rights reserved.<BR>
> //
> = // SPDX-License-Identifier: BSD-2-Clause-Patent
> //
> diff --git a/MdePkg/Library/BasePeCoffLib/LoongArch/PeCoffLoaderEx.c<= /div>
> b/MdePkg/Library/BasePeCoffLib/LoongArch/PeCoffLoaderEx.c
> new file mode 100644
> index 0000000000..ec572c2d= d6
> --- /dev/null
> +++ b/MdePkg/Library/BasePeC= offLib/LoongArch/PeCoffLoaderEx.c
> @@ -0,0 +1,132 @@
> +/** @file
> + PE/Coff loader for LoongArch PE image
> +
> + Copyright (c) 2022, Loongson Technology Cor= poration Limited. All rights
> reserved.<BR>
&= gt; +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +**/
> +
> +#include "BasePeCoffLibIntern= als.h"
> +#include <Library/BaseLib.h>
> +<= /div>
> +/**
> + Performs an LoongArch specific relocat= ion fixup and is a no-op on other
> + instruction sets.
<= div>> +
> + @param Reloc Pointer to the relocation record.<= /div>
> + @param Fixup Pointer to the address to fix up.
&= gt; + @param FixupData Pointer to a buffer to log the fixups.
>= ; + @param Adjust The offset to adjust the fixup.
> +
> + @return Status code.
> +
> +**/
> +RETURN_STATUS
> +PeCoffLoaderRelocateImageEx (
> + IN UINT16 *Reloc,
> + IN OUT CHAR8 *Fixup,
> + IN OUT CHAR8 **FixupData,
> + IN UINT64 Adjust
> + )
> +{
> + UINT8 RelocType;
&= gt; + UINT64 Value =3D 0;
> + UINT64 Tmp1 =3D 0;
>= ; + UINT64 Tmp2 =3D 0;
> +
> + RelocType =3D (*Re= loc) >> 12;
> +
> + switch (RelocType) {
> + case EFI_IMAGE_REL_BASED_LOONGARCH64_MARK_LA:
>= + Value =3D (*(UINT32*)Fixup & 0x1ffffe0) << 7 | /* lu12i.w 20bi= ts from
> bit5 */
> + (*((UINT32*)Fixup + 1) &= ; 0x3ffc00) >> 10; /* ori 12bits from bit10 */
> + Tmp1 = =3D *((UINT32*)Fixup + 2) & 0x1ffffe0; /* lu32i.d 20bits from bit5
> */
> + Tmp2 =3D *((UINT32*)Fixup + 3) & 0x3ffc0= 0; /* lu52i.d 12bits from
> bit10 */
> + Value = =3D Value | (Tmp1 << 27) | (Tmp2 << 42);
> + Value= +=3D Adjust;
Please use double back slash for the comments in th= e function in this file.

Abner
<= div>    Chao: Okay, I will revise it in the next version= .
> +
> + *(UINT32*)Fixup =3D (*(UINT32*)Fix= up & ~0x1ffffe0) | (((Value >> 12) &
> 0xfffff) = << 5);
> + if (*FixupData !=3D NULL) {
> + = *FixupData =3D ALIGN_POINTER (*FixupData, sizeof (UINT32));
> = + *(UINT32 *) (*FixupData) =3D *(UINT32*)Fixup;
> + *FixupData= =3D *FixupData + sizeof (UINT32);
> + }
> +
> + Fixup +=3D sizeof(UINT32);
> + *(UINT32*)Fixup = =3D (*(UINT32*)Fixup & ~0x3ffc00) | ((Value & 0xfff) <<
=
> 10);
> + if (*FixupData !=3D NULL) {
> = + *FixupData =3D ALIGN_POINTER (*FixupData, sizeof (UINT32));
>= ; + *(UINT32 *) (*FixupData) =3D *(UINT32*)Fixup;
> + *FixupDa= ta =3D *FixupData + sizeof (UINT32);
> + }
> +
> + Fixup +=3D sizeof(UINT32);
> + *(UINT32*)Fixup = =3D (*(UINT32*)Fixup & ~0x1ffffe0) | (((Value >> 32) &
<= div>> 0xfffff) << 5);
> + if (*FixupData !=3D NULL) {=
> + *FixupData =3D ALIGN_POINTER (*FixupData, sizeof (UINT32)= );
> + *(UINT32 *) (*FixupData) =3D *(UINT32*)Fixup;
> + *FixupData =3D *FixupData + sizeof (UINT32);
> + }
> +
> + Fixup +=3D sizeof(UINT32);
> + = *(UINT32*)Fixup =3D (*(UINT32*)Fixup & ~0x3ffc00) | (((Value >> 5= 2) &
> 0xfff) << 10);
> + if (*FixupDat= a !=3D NULL) {
> + *FixupData =3D ALIGN_POINTER (*FixupData, s= izeof (UINT32));
> + *(UINT32 *) (*FixupData) =3D *(UINT32*)Fi= xup;
> + *FixupData =3D *FixupData + sizeof (UINT32);
> + }
> + break;
> + default:
>= + return RETURN_UNSUPPORTED;
> + }
> +
> + return RETURN_SUCCESS;
> +}
> +
> +/**
> + Returns TRUE if the machine type of PE/COFF ima= ge is supported.
> Supported
> + does not mean th= e image can be executed it means the PE/COFF loader
> supports=
> + loading and relocating of the image type. It's up to the = caller to support
> + the entry point.
> +
<= div>> + @param Machine Machine type from the PE Header.
> +=
> + @return TRUE if this PE/COFF loader can load the image
> +
> +**/
> +BOOLEAN
> += PeCoffLoaderImageFormatSupported (
> + IN UINT16 Machine
=
> + )
> +{
> + if (Machine =3D=3D IMAGE_F= ILE_MACHINE_LOONGARCH64) {
> + return TRUE;
> + }=
> +
> + return FALSE;
> +}
> +
> +/**
> + Performs an LOONGARCH-based s= pecific re-relocation fixup and is a no-op
> on other
> + instruction sets. This is used to re-relocated the image into the = EFI virtual
> + space for runtime calls.
> +
> + @param Reloc The pointer to the relocation record.
&= gt; + @param Fixup The pointer to the address to fix up.
> + @= param FixupData The pointer to a buffer to log the fixups.
> += @param Adjust The offset to adjust the fixup.
> +
&= gt; + @return Status code.
> +
> +**/
&= gt; +RETURN_STATUS
> +PeHotRelocateImageEx (
> + = IN UINT16 *Reloc,
> + IN OUT CHAR8 *Fixup,
> + IN= OUT CHAR8 **FixupData,
> + IN UINT64 Adjust
> + = )
> +{
> + /* to check */
> + return= PeCoffLoaderRelocateImageEx (Reloc, Fixup, FixupData, Adjust);
&= gt; +}
> --
> 2.27.0
>
>= ;
>
>
>
3D"Sent --625548e9_571b6d28_6697--