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.web10.9701.1664277273914226063 for ; Tue, 27 Sep 2022 04:14:34 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: loongson.cn, ip: 114.242.206.163, mailfrom: lichao@loongson.cn) Received: from code-server.gen (unknown [10.2.9.245]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Cxrmv02jJjirsiAA--.49762S24; Tue, 27 Sep 2022 19:14:32 +0800 (CST) From: "Chao Li" To: devel@edk2.groups.io Cc: Michael D Kinney , Liming Gao , Zhiguang Liu , Baoqi Zhang , Dongyan Qian Subject: [PATCH v3 22/34] MdePkg: Add LoongArch LOONGARCH64 binding Date: Tue, 27 Sep 2022 19:13:42 +0800 Message-Id: <20220927111354.4107719-23-lichao@loongson.cn> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220927111354.4107719-1-lichao@loongson.cn> References: <20220927111354.4107719-1-lichao@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8Cxrmv02jJjirsiAA--.49762S24 X-Coremail-Antispam: 1UD129KBjvJXoW3JF1rtw18ZrWkCrykZr1fZwb_yoW7urWrpa n2kF4fGw48Jr4xKFy3JFW5Jr13tws5ArWUGFs09347uFWDXa4v934DKF45tFW0yrn0va48 XF4agw1j9ayxArJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnUUvcSsGvfC2KfnxnUUI43ZEXa7xR_UUUUUUUUU== X-CM-SenderInfo: xolfxt3r6o00pqjv00gofq/1tbiAQACCGMxll4dbgAhsD Content-Transfer-Encoding: quoted-printable REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4053 Add LOONGARCH64 sections in MdePkg.dec and LOONGARCH64 ProcessorBind.h Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Signed-off-by: Chao Li Co-authored-by: Baoqi Zhang Co-authored-by: Dongyan Qian Reviewed-by: Michael D Kinney --- MdePkg/Include/LoongArch64/ProcessorBind.h | 120 +++++++++++++++++++++ MdePkg/MdePkg.dec | 4 + MdePkg/MdePkg.dsc | 3 +- 3 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 MdePkg/Include/LoongArch64/ProcessorBind.h diff --git a/MdePkg/Include/LoongArch64/ProcessorBind.h b/MdePkg/Include/Lo= ongArch64/ProcessorBind.h new file mode 100644 index 0000000000..502d479099 --- /dev/null +++ b/MdePkg/Include/LoongArch64/ProcessorBind.h @@ -0,0 +1,120 @@ +/** @file=0D + Processor or Compiler specific defines and types for LoongArch=0D +=0D + Copyright (c) 2022, Loongson Technology Corporation Limited. All rights = reserved.
=0D +=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#ifndef PROCESSOR_BIND_H_=0D +#define PROCESSOR_BIND_H_=0D +=0D +//=0D +// Define the processor type so other code can make processor based choice= s=0D +//=0D +#define MDE_CPU_LOONGARCH64=0D +=0D +#define EFIAPI=0D +=0D +//=0D +// Make sure we are using the correct packing rules per EFI specification= =0D +//=0D +#ifndef __GNUC__=0D + #pragma pack()=0D +#endif=0D +=0D +//=0D +// Assume standard LoongArch 64-bit alignment.=0D +// Need to check portability of long long=0D +//=0D +typedef unsigned long UINT64;=0D +typedef long INT64;=0D +typedef unsigned int UINT32;=0D +typedef int INT32;=0D +typedef unsigned short UINT16;=0D +typedef unsigned short CHAR16;=0D +typedef short INT16;=0D +typedef unsigned char BOOLEAN;=0D +typedef unsigned char UINT8;=0D +typedef char CHAR8;=0D +typedef char INT8;=0D +=0D +//=0D +// Unsigned value of native width. (4 bytes on supported 32-bit processor= instructions,=0D +// 8 bytes on supported 64-bit processor instructions)=0D +//=0D +=0D +typedef UINT64 UINTN;=0D +=0D +//=0D +// Signed value of native width. (4 bytes on supported 32-bit processor i= nstructions,=0D +// 8 bytes on supported 64-bit processor instructions)=0D +//=0D +typedef INT64 INTN;=0D +=0D +//=0D +// Processor specific defines=0D +//=0D +=0D +//=0D +// A value of native width with the highest bit set.=0D +//=0D +#define MAX_BIT 0x8000000000000000ULL=0D +//=0D +// A value of native width with the two highest bits set.=0D +//=0D +#define MAX_2_BITS 0xC000000000000000ULL=0D +=0D +//=0D +// Maximum legal LoongArch 64-bit address=0D +//=0D +#define MAX_ADDRESS 0xFFFFFFFFFFFFFFFFULL=0D +=0D +//=0D +// Maximum usable address at boot time (48 bits using 4KB pages)=0D +//=0D +#define MAX_ALLOC_ADDRESS 0xFFFFFFFFFFFFULL=0D +=0D +//=0D +// Maximum legal LoongArch 64-bit INTN and UINTN values.=0D +//=0D +#define MAX_INTN ((INTN)0x7FFFFFFFFFFFFFFFULL)=0D +#define MAX_UINTN ((UINTN)0xFFFFFFFFFFFFFFFFULL)=0D +=0D +//=0D +// Page allocation granularity for LoongArch=0D +//=0D +#define DEFAULT_PAGE_ALLOCATION_GRANULARITY (0x1000)=0D +#define RUNTIME_PAGE_ALLOCATION_GRANULARITY (0x10000)=0D +=0D +#if defined (__GNUC__)=0D +//=0D +// For GNU assembly code, .global or .globl can declare global symbols.=0D +// Define this macro to unify the usage.=0D +//=0D +#define ASM_GLOBAL .globl=0D +#endif=0D +=0D +//=0D +// The stack alignment required for LoongArch=0D +//=0D +#define CPU_STACK_ALIGNMENT 16=0D +=0D +/**=0D + Return the pointer to the first instruction of a function given a functi= on pointer.=0D + On LOONGARCH CPU architectures, these two pointer values are the same,=0D + so the implementation of this macro is very simple.=0D +=0D + @param FunctionPointer A pointer to a function.=0D +=0D + @return The pointer to the first instruction of a function given a funct= ion pointer.=0D +=0D +**/=0D +#define FUNCTION_ENTRY_POINT(FunctionPointer) (VOID *)(UINTN)(FunctionPoi= nter)=0D +=0D +#ifndef __USER_LABEL_PREFIX__=0D +#define __USER_LABEL_PREFIX__=0D +#endif=0D +=0D +#endif=0D diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index f1ebf9e251..4c81cbd75a 100644 --- a/MdePkg/MdePkg.dec +++ b/MdePkg/MdePkg.dec @@ -7,6 +7,7 @@ # Copyright (c) 2007 - 2022, Intel Corporation. All rights reserved.
=0D # Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
= =0D # (C) Copyright 2016 - 2021 Hewlett Packard Enterprise Development LP
= =0D +# Copyright (c) 2022, Loongson Technology Corporation Limited. All rights = reserved.
=0D #=0D # SPDX-License-Identifier: BSD-2-Clause-Patent=0D #=0D @@ -43,6 +44,9 @@ [Includes.RISCV64]=0D Include/RiscV64=0D =0D +[Includes.LOONGARCH64]=0D + Include/LoongArch64=0D +=0D [LibraryClasses]=0D ## @libraryclass Provides most usb APIs to support the Hid requests de= fined in Usb Hid 1.1 spec=0D # and the standard requests defined in Usb 1.1 spec.=0D diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc index cc1ac196a9..493a13ec91 100644 --- a/MdePkg/MdePkg.dsc +++ b/MdePkg/MdePkg.dsc @@ -4,6 +4,7 @@ # Copyright (c) 2007 - 2022, Intel Corporation. All rights reserved.
=0D # Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
= =0D # (C) Copyright 2020 Hewlett Packard Enterprise Development LP
=0D +# Copyright (c) 2022, Loongson Technology Corporation Limited. All rights = reserved.
=0D #=0D # SPDX-License-Identifier: BSD-2-Clause-Patent=0D #=0D @@ -15,7 +16,7 @@ PLATFORM_VERSION =3D 1.08=0D DSC_SPECIFICATION =3D 0x00010005=0D OUTPUT_DIRECTORY =3D Build/Mde=0D - SUPPORTED_ARCHITECTURES =3D IA32|X64|EBC|ARM|AARCH64|RISCV64=0D + SUPPORTED_ARCHITECTURES =3D IA32|X64|EBC|ARM|AARCH64|RISCV64|LOON= GARCH64=0D BUILD_TARGETS =3D DEBUG|RELEASE|NOOPT=0D SKUID_IDENTIFIER =3D DEFAULT=0D =0D --=20 2.27.0