]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg: Add LoongArch LOONGARCH64 binding
authorChao Li <lichao@loongson.cn>
Fri, 19 Nov 2021 10:06:06 +0000 (18:06 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Fri, 14 Oct 2022 02:16:33 +0000 (02:16 +0000)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4053

Add LOONGARCH64 sections in MdePkg.dec and LOONGARCH64 ProcessorBind.h

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-authored-by: Baoqi Zhang <zhangbaoqi@loongson.cn>
Co-authored-by: Dongyan Qian <qiandongyan@loongson.cn>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
MdePkg/Include/LoongArch64/ProcessorBind.h [new file with mode: 0644]
MdePkg/MdePkg.dec
MdePkg/MdePkg.dsc

diff --git a/MdePkg/Include/LoongArch64/ProcessorBind.h b/MdePkg/Include/LoongArch64/ProcessorBind.h
new file mode 100644 (file)
index 0000000..502d479
--- /dev/null
@@ -0,0 +1,120 @@
+/** @file\r
+  Processor or Compiler specific defines and types for LoongArch\r
+\r
+  Copyright (c) 2022, Loongson Technology Corporation Limited. All rights reserved.<BR>\r
+\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#ifndef PROCESSOR_BIND_H_\r
+#define PROCESSOR_BIND_H_\r
+\r
+//\r
+// Define the processor type so other code can make processor based choices\r
+//\r
+#define MDE_CPU_LOONGARCH64\r
+\r
+#define EFIAPI\r
+\r
+//\r
+// Make sure we are using the correct packing rules per EFI specification\r
+//\r
+#ifndef __GNUC__\r
+  #pragma pack()\r
+#endif\r
+\r
+//\r
+// Assume standard LoongArch 64-bit alignment.\r
+// Need to check portability of long long\r
+//\r
+typedef unsigned long   UINT64;\r
+typedef long            INT64;\r
+typedef unsigned int    UINT32;\r
+typedef int             INT32;\r
+typedef unsigned short  UINT16;\r
+typedef unsigned short  CHAR16;\r
+typedef short           INT16;\r
+typedef unsigned char   BOOLEAN;\r
+typedef unsigned char   UINT8;\r
+typedef char            CHAR8;\r
+typedef char            INT8;\r
+\r
+//\r
+// Unsigned value of native width.  (4 bytes on supported 32-bit processor instructions,\r
+// 8 bytes on supported 64-bit processor instructions)\r
+//\r
+\r
+typedef UINT64 UINTN;\r
+\r
+//\r
+// Signed value of native width.  (4 bytes on supported 32-bit processor instructions,\r
+// 8 bytes on supported 64-bit processor instructions)\r
+//\r
+typedef INT64 INTN;\r
+\r
+//\r
+// Processor specific defines\r
+//\r
+\r
+//\r
+// A value of native width with the highest bit set.\r
+//\r
+#define MAX_BIT  0x8000000000000000ULL\r
+//\r
+// A value of native width with the two highest bits set.\r
+//\r
+#define MAX_2_BITS  0xC000000000000000ULL\r
+\r
+//\r
+// Maximum legal LoongArch 64-bit address\r
+//\r
+#define MAX_ADDRESS  0xFFFFFFFFFFFFFFFFULL\r
+\r
+//\r
+// Maximum usable address at boot time (48 bits using 4KB pages)\r
+//\r
+#define MAX_ALLOC_ADDRESS  0xFFFFFFFFFFFFULL\r
+\r
+//\r
+// Maximum legal LoongArch  64-bit INTN and UINTN values.\r
+//\r
+#define MAX_INTN   ((INTN)0x7FFFFFFFFFFFFFFFULL)\r
+#define MAX_UINTN  ((UINTN)0xFFFFFFFFFFFFFFFFULL)\r
+\r
+//\r
+// Page allocation granularity for LoongArch\r
+//\r
+#define DEFAULT_PAGE_ALLOCATION_GRANULARITY  (0x1000)\r
+#define RUNTIME_PAGE_ALLOCATION_GRANULARITY  (0x10000)\r
+\r
+#if defined (__GNUC__)\r
+//\r
+// For GNU assembly code, .global or .globl can declare global symbols.\r
+// Define this macro to unify the usage.\r
+//\r
+#define ASM_GLOBAL  .globl\r
+#endif\r
+\r
+//\r
+// The stack alignment required for LoongArch\r
+//\r
+#define CPU_STACK_ALIGNMENT  16\r
+\r
+/**\r
+  Return the pointer to the first instruction of a function given a function pointer.\r
+  On LOONGARCH CPU architectures, these two pointer values are the same,\r
+  so the implementation of this macro is very simple.\r
+\r
+  @param  FunctionPointer   A pointer to a function.\r
+\r
+  @return The pointer to the first instruction of a function given a function pointer.\r
+\r
+**/\r
+#define FUNCTION_ENTRY_POINT(FunctionPointer)  (VOID *)(UINTN)(FunctionPointer)\r
+\r
+#ifndef __USER_LABEL_PREFIX__\r
+#define __USER_LABEL_PREFIX__\r
+#endif\r
+\r
+#endif\r
index f1ebf9e251c19b485889e65af3243497b85ddef5..4c81cbd75ab2b1ac6fe27c954ebcf20f4355845a 100644 (file)
@@ -7,6 +7,7 @@
 # Copyright (c) 2007 - 2022, Intel Corporation. All rights reserved.<BR>\r
 # Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
 # (C) Copyright 2016 - 2021 Hewlett Packard Enterprise Development LP<BR>\r
+# Copyright (c) 2022, Loongson Technology Corporation Limited. All rights reserved.<BR>\r
 #\r
 # SPDX-License-Identifier: BSD-2-Clause-Patent\r
 #\r
@@ -43,6 +44,9 @@
 [Includes.RISCV64]\r
   Include/RiscV64\r
 \r
+[Includes.LOONGARCH64]\r
+  Include/LoongArch64\r
+\r
 [LibraryClasses]\r
   ##  @libraryclass  Provides most usb APIs to support the Hid requests defined in Usb Hid 1.1 spec\r
   #                  and the standard requests defined in Usb 1.1 spec.\r
index cc1ac196a9319bb66b9c75ec573febffca9244f6..493a13ec91974a202db05866c076f0865fc7a914 100644 (file)
@@ -4,6 +4,7 @@
 # Copyright (c) 2007 - 2022, Intel Corporation. All rights reserved.<BR>\r
 # Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
 # (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>\r
+# Copyright (c) 2022, Loongson Technology Corporation Limited. All rights reserved.<BR>\r
 #\r
 #    SPDX-License-Identifier: BSD-2-Clause-Patent\r
 #\r
@@ -15,7 +16,7 @@
   PLATFORM_VERSION               = 1.08\r
   DSC_SPECIFICATION              = 0x00010005\r
   OUTPUT_DIRECTORY               = Build/Mde\r
-  SUPPORTED_ARCHITECTURES        = IA32|X64|EBC|ARM|AARCH64|RISCV64\r
+  SUPPORTED_ARCHITECTURES        = IA32|X64|EBC|ARM|AARCH64|RISCV64|LOONGARCH64\r
   BUILD_TARGETS                  = DEBUG|RELEASE|NOOPT\r
   SKUID_IDENTIFIER               = DEFAULT\r
 \r