Page MenuHomeFreeBSD

D59889.1794615679.diff
No OneTemporary

Authored By
Unknown
Size
36 KB
Referenced Files
None
Subscribers
None

D59889.1794615679.diff

diff --git a/lib/libc/loongarch/gen/_setjmp.S b/lib/libc/loongarch/gen/_setjmp.S
new file mode 100644
--- /dev/null
+++ b/lib/libc/loongarch/gen/_setjmp.S
@@ -0,0 +1,142 @@
+/*-
+ * Copyright (c) 2015-2016 Ruslan Bukin <br@bsdpad.com>
+ * All rights reserved.
+ *
+ * Portions of this software were developed by SRI International and the
+ * University of Cambridge Computer Laboratory under DARPA/AFRL contract
+ * FA8750-10-C-0237 ("CTSRD"), as part of the DARPA CRASH research programme.
+ *
+ * Portions of this software were developed by the University of Cambridge
+ * Computer Laboratory as part of the CTSRD Project, with support from the
+ * UK Higher Education Innovation Fund (HEIF).
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+#include <machine/setjmp.h>
+
+ENTRY(_setjmp)
+ /* Store the magic value and stack pointer */
+ la.pcrel $t0, .Lmagic
+ ld.d $t0, $t0, 0
+ st.d $t0, $a0, (0 * 8)
+ st.d $sp, $a0, (1 * 8)
+ addi.d $a0, $a0, (2 * 8)
+
+ /* Store the general purpose registers and ra */
+ st.d $fp, $a0, (0 * 8)
+ st.d $s0, $a0, (1 * 8)
+ st.d $s1, $a0, (2 * 8)
+ st.d $s2, $a0, (3 * 8)
+ st.d $s3, $a0, (4 * 8)
+ st.d $s4, $a0, (5 * 8)
+ st.d $s5, $a0, (6 * 8)
+ st.d $s6, $a0, (7 * 8)
+ st.d $s7, $a0, (8 * 8)
+ st.d $s8, $a0, (9 * 8)
+ st.d $ra, $a0, (10 * 8)
+ addi.d $a0, $a0, (11 * 8)
+
+#if !defined(_STANDALONE) && defined(__loongarch_double_float)
+ /* Store the fpe registers */
+ fst.d $fs0, $a0, (0 * 8)
+ fst.d $fs1, $a0, (1 * 8)
+ fst.d $fs2, $a0, (2 * 8)
+ fst.d $fs3, $a0, (3 * 8)
+ fst.d $fs4, $a0, (4 * 8)
+ fst.d $fs5, $a0, (5 * 8)
+ fst.d $fs6, $a0, (6 * 8)
+ fst.d $fs7, $a0, (7 * 8)
+ addi.d $a0, $a0, (8 * 8)
+
+ /* Save fcsr0 (FP control/status register) */
+ movfcsr2gr $t0, $fcsr0
+ st.d $t0, $a0, 0
+#endif
+
+ /* Return value */
+ li.d $a0, 0
+ jr $ra
+ .align 3
+.Lmagic:
+ .quad _JB_MAGIC__SETJMP
+END(_setjmp)
+
+ENTRY(_longjmp)
+ /* Check the magic value */
+ ld.d $t0, $a0, 0
+ la.pcrel $t1, .Lmagic
+ ld.d $t1, $t1, 0
+ bne $t0, $t1, botch
+
+ /* Restore the stack pointer */
+ ld.d $t0, $a0, 8
+ move $sp, $t0
+ addi.d $a0, $a0, (2 * 8)
+
+ /* Restore the general purpose registers and ra */
+ ld.d $fp, $a0, (0 * 8)
+ ld.d $s0, $a0, (1 * 8)
+ ld.d $s1, $a0, (2 * 8)
+ ld.d $s2, $a0, (3 * 8)
+ ld.d $s3, $a0, (4 * 8)
+ ld.d $s4, $a0, (5 * 8)
+ ld.d $s5, $a0, (6 * 8)
+ ld.d $s6, $a0, (7 * 8)
+ ld.d $s7, $a0, (8 * 8)
+ ld.d $s8, $a0, (9 * 8)
+ ld.d $ra, $a0, (10 * 8)
+ addi.d $a0, $a0, (11 * 8)
+
+#if !defined(_STANDALONE) && defined(__loongarch_double_float)
+ /* Restore the fpe registers */
+ fld.d $fs0, $a0, (0 * 8)
+ fld.d $fs1, $a0, (1 * 8)
+ fld.d $fs2, $a0, (2 * 8)
+ fld.d $fs3, $a0, (3 * 8)
+ fld.d $fs4, $a0, (4 * 8)
+ fld.d $fs5, $a0, (5 * 8)
+ fld.d $fs6, $a0, (6 * 8)
+ fld.d $fs7, $a0, (7 * 8)
+ addi.d $a0, $a0, (8 * 8)
+
+ /* Restore fcsr0 */
+ ld.d $t0, $a0, 0
+ movgr2fcsr $fcsr0, $t0
+#endif
+
+ /* Load the return value */
+ move $a0, $a1
+ bnez $a1, 1f
+ li.d $a0, 1
+1:
+ jr $ra
+
+botch:
+#ifdef _STANDALONE
+ b botch
+#else
+ bl _C_LABEL(longjmperror)
+ bl _C_LABEL(abort)
+#endif
+END(_longjmp)
diff --git a/stand/common/self_reloc.c b/stand/common/self_reloc.c
--- a/stand/common/self_reloc.c
+++ b/stand/common/self_reloc.c
@@ -28,7 +28,7 @@
#include <elf.h>
#include <bootstrap.h>
-#if defined(__aarch64__) || defined(__amd64__) || defined(__riscv)
+#if defined(__aarch64__) || defined(__amd64__) || defined(__riscv) || defined(__loongarch__)
#define ElfW_Rel Elf64_Rela
#define ElfW_Dyn Elf64_Dyn
#define ELFW_R_TYPE ELF64_R_TYPE
@@ -55,6 +55,9 @@
#elif defined(__riscv)
#define RELOC_TYPE_NONE R_RISCV_NONE
#define RELOC_TYPE_RELATIVE R_RISCV_RELATIVE
+#elif defined(__loongarch__)
+#define RELOC_TYPE_NONE R_LARCH_NONE
+#define RELOC_TYPE_RELATIVE R_LARCH_RELATIVE
#endif
void self_reloc(Elf_Addr baseaddr, ElfW_Dyn *dynamic);
diff --git a/stand/defs.mk b/stand/defs.mk
--- a/stand/defs.mk
+++ b/stand/defs.mk
@@ -160,6 +160,8 @@
CFLAGS+= -march=rv64imac -mabi=lp64 -fPIC
CFLAGS.clang+= -mcmodel=medium
CFLAGS.gcc+= -mcmodel=medany
+.elif ${MACHINE_CPUARCH} == "loongarch"
+CFLAGS+= -march=loongarch64 -mabi=lp64d -fPIC
.else
CFLAGS+= -msoft-float
.endif
diff --git a/stand/efi/libefi/Makefile b/stand/efi/libefi/Makefile
--- a/stand/efi/libefi/Makefile
+++ b/stand/efi/libefi/Makefile
@@ -29,7 +29,8 @@
.if ${MACHINE_CPUARCH} == "amd64"
SRCS+= time.c
-.elif ${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "riscv"
+.elif ${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "riscv" || \
+ ${MACHINE_CPUARCH} == "loongarch"
SRCS+= time_event.c
.elif ${MACHINE_CPUARCH} == "aarch64"
SRCS+= time_arm64.c
diff --git a/stand/efi/libefi/libefi.c b/stand/efi/libefi/libefi.c
--- a/stand/efi/libefi/libefi.c
+++ b/stand/efi/libefi/libefi.c
@@ -28,22 +28,72 @@
#include <eficonsctl.h>
#include <efilib.h>
#include <stand.h>
+#include <Guid/FdtHob.h>
+#include <Guid/HobList.h>
+#include <Pi/PiBootMode.h>
+#include <Pi/PiHob.h>
EFI_HANDLE IH;
EFI_SYSTEM_TABLE *ST;
EFI_BOOT_SERVICES *BS;
EFI_RUNTIME_SERVICES *RS;
+/*
+ * Some firmware (e.g. the EDK2 ArmVirt and LoongArch platforms) does not
+ * publish the device tree as a FDT_TABLE_GUID configuration table. Instead
+ * a copy of the FDT is reachable through a FDT_HOB_GUID HOB on the HOB list,
+ * which the firmware publishes as a configuration table of its own. Walk
+ * the HOB list and return the FDT address if it is found there.
+ */
+static void *
+efi_get_fdt_hob(EFI_HOB_GENERIC_HEADER *hob)
+{
+ EFI_HOB_GUID_TYPE *guidh;
+ EFI_GUID fdt = FDT_HOB_GUID;
+ UINT64 fdtbase;
+
+ while (hob->HobType != EFI_HOB_TYPE_END_OF_HOB_LIST) {
+ if (hob->HobType == EFI_HOB_TYPE_GUID_EXTENSION) {
+ guidh = (EFI_HOB_GUID_TYPE *)hob;
+ if (!memcmp(&guidh->Name, &fdt, sizeof(EFI_GUID))) {
+ memcpy(&fdtbase, guidh + 1, sizeof(fdtbase));
+ return ((void *)(uintptr_t)fdtbase);
+ }
+ }
+ hob = (EFI_HOB_GENERIC_HEADER *)((char *)hob + hob->HobLength);
+ }
+
+ return (NULL);
+}
+
void *
efi_get_table(EFI_GUID *tbl)
{
+ EFI_HOB_GENERIC_HEADER *hoblist;
EFI_GUID *id;
+ EFI_GUID hoblist_guid = HOB_LIST_GUID;
int i;
+ hoblist = NULL;
for (i = 0; i < ST->NumberOfTableEntries; i++) {
id = &ST->ConfigurationTable[i].VendorGuid;
+
if (!memcmp(id, tbl, sizeof(EFI_GUID)))
return (ST->ConfigurationTable[i].VendorTable);
+
+ if (!memcmp(id, &hoblist_guid, sizeof(EFI_GUID)))
+ hoblist = ST->ConfigurationTable[i].VendorTable;
+ }
+
+ /*
+ * No configuration table matched; if the firmware published a HOB
+ * list, fall back to it (e.g. for the FDT on LoongArch).
+ */
+ if (hoblist != NULL) {
+ void *fdt = efi_get_fdt_hob(hoblist);
+
+ if (fdt != NULL)
+ return (fdt);
}
return (NULL);
}
diff --git a/stand/efi/loader/arch/loongarch/Makefile.inc b/stand/efi/loader/arch/loongarch/Makefile.inc
new file mode 100644
--- /dev/null
+++ b/stand/efi/loader/arch/loongarch/Makefile.inc
@@ -0,0 +1,5 @@
+
+HAVE_FDT=yes
+
+SRCS+= exec.c \
+ start.S
diff --git a/stand/efi/loader/arch/loongarch/exec.c b/stand/efi/loader/arch/loongarch/exec.c
new file mode 100644
--- /dev/null
+++ b/stand/efi/loader/arch/loongarch/exec.c
@@ -0,0 +1,110 @@
+/*-
+ * Copyright (c) 2001 Benno Rice <benno@FreeBSD.org>
+ * Copyright (c) 2007 Semihalf, Rafal Jaworowski <raj@semihalf.com>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <sys/param.h>
+#include <sys/linker.h>
+
+#include <machine/md_var.h>
+#include <machine/metadata.h>
+#include <machine/elf.h>
+
+#include <stand.h>
+
+#include <efi.h>
+#include <efilib.h>
+#include <Pi/PiMultiPhase.h>
+#include <Protocol/MpService.h>
+
+#include "bootstrap.h"
+#include "loader_efi.h"
+
+extern int bi_load(char *, vm_offset_t *, vm_offset_t *, bool);
+
+static int
+__elfN(exec)(struct preloaded_file *fp)
+{
+ struct file_metadata *fmp;
+ vm_offset_t modulep, kernend;
+ Elf_Ehdr *e;
+ int error;
+ void (*entry)(void *, void *, vm_offset_t);
+ UINTN cpu_num, cpu_enum;
+ EFI_MP_SERVICES_PROTOCOL *mp_service;
+ EFI_STATUS Status;
+ EFI_GUID mps = EFI_MP_SERVICES_PROTOCOL_GUID;
+
+ if ((fmp = file_findmetadata(fp, MODINFOMD_ELFHDR)) == NULL)
+ return (EFTYPE);
+
+ e = (Elf_Ehdr *)&fmp->md_data;
+
+ efi_time_fini();
+
+ Status = BS->LocateProtocol(&mps, NULL, (VOID**)&mp_service);
+
+ if (EFI_ERROR(Status)) {
+ printf("Failed to locate MP Service Protocol.\n");
+ }
+
+ Status = mp_service->GetNumberOfProcessors(mp_service, &cpu_num, &cpu_enum);
+ if (EFI_ERROR(Status)) {
+ printf("Failed to get number of processors\n");
+ }
+
+ printf("Total processors: %lu, Enabled processors: %lu\n", cpu_num, cpu_enum);
+
+ entry = efi_translate(e->e_entry);
+
+ printf("Kernel entry at %p...\n", entry);
+ printf("Kernel args: %s\n", fp->f_args);
+
+ if ((error = bi_load(fp->f_args, &modulep, &kernend, true)) != 0) {
+ efi_time_init();
+ return (error);
+ }
+
+ /*
+ * At this point we've called ExitBootServices, so we can't call
+ * printf or any other function that uses Boot Services
+ */
+ dev_cleanup();
+
+ printf("call kernel entry with arg: %p\n", (void*)modulep);
+ (*entry)((void *)modulep, (void *)entry, kernend);
+ panic("exec returned");
+}
+
+static struct file_format loongarch_elf = {
+ __elfN(loadfile),
+ __elfN(exec)
+};
+
+struct file_format *file_formats[] = {
+ &loongarch_elf,
+ NULL
+};
diff --git a/stand/efi/loader/arch/loongarch/loongarch.ldscript b/stand/efi/loader/arch/loongarch/loongarch.ldscript
new file mode 100644
--- /dev/null
+++ b/stand/efi/loader/arch/loongarch/loongarch.ldscript
@@ -0,0 +1,87 @@
+OUTPUT_FORMAT("elf64-loongarch", "elf64-loongarch", "elf64-loongarch")
+OUTPUT_ARCH(loongarch64)
+ENTRY(_start)
+SECTIONS
+{
+ /* Read-only sections, merged into text segment: */
+ . = 0;
+ ImageBase = .;
+ .text : {
+ *(.peheader)
+ *(.text .stub .text.* .gnu.linkonce.t.*)
+ /* .gnu.warning sections are handled specially by elf32.em. */
+ *(.gnu.warning)
+ *(.plt)
+ } =0x9090
+ . = ALIGN(16);
+ .data : {
+ *(.rodata .rodata.* .gnu.linkonce.r.*)
+ *(.rodata1)
+ *(.sdata2 .sdata2.* .gnu.linkonce.s2.*)
+ *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*)
+ *(.opd)
+ *(.data .data.* .gnu.linkonce.d.*)
+ *(.data1)
+ *(.plabel)
+
+ . = ALIGN(16);
+ __bss_start = .;
+ *(.sbss .sbss.* .gnu.linkonce.sb.*)
+ *(.scommon)
+ *(.dynbss)
+ *(.bss *.bss.*)
+ *(COMMON)
+ . = ALIGN(16);
+ __bss_end = .;
+ }
+ . = ALIGN(16);
+ set_Xcommand_set : {
+ __start_set_Xcommand_set = .;
+ *(set_Xcommand_set)
+ __stop_set_Xcommand_set = .;
+ }
+ set_Xficl_compile_set : {
+ __start_set_Xficl_compile_set = .;
+ *(set_Xficl_compile_set)
+ __stop_set_Xficl_compile_set = .;
+ }
+ . = ALIGN(16);
+ .sdata : {
+ /*
+ * u-boot expects the gp register to be untouched by the EFI payload, so we
+ * can't enable this yet.
+ */
+ /* __global_pointer$ = . + 0x800; */
+ *(.got.plt .got)
+ *(.sdata .sdata.* .gnu.linkonce.s.*)
+ *(dynsbss)
+ *(.scommon)
+ }
+ . = ALIGN(16);
+ .dynamic : { *(.dynamic) }
+ . = ALIGN(16);
+ .rela.dyn : {
+ *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
+ *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
+ *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)
+ *(.rela.got)
+ *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*)
+ *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*)
+ *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*)
+ *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*)
+ *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
+ *(.rela.plt)
+ *(.relset_*)
+ *(.rela.dyn .rela.dyn.*)
+ }
+ . = ALIGN(16);
+ .reloc : { *(.reloc) }
+ . = ALIGN(16);
+ .dynsym : { *(.dynsym) }
+ _edata = .;
+
+ /* Unused sections */
+ .interp : { *(.interp) }
+ .dynstr : { *(.dynstr) }
+ .hash : { *(.hash) }
+}
diff --git a/stand/efi/loader/arch/loongarch/start.S b/stand/efi/loader/arch/loongarch/start.S
new file mode 100644
--- /dev/null
+++ b/stand/efi/loader/arch/loongarch/start.S
@@ -0,0 +1,161 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2020 Mitchell Horne <mhorne@FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#define IMAGE_FILE_MACHINE_LOONGARCH32 0x6232
+#define IMAGE_FILE_MACHINE_LOONGARCH64 0x6264
+
+#define IMAGE_SCN_CNT_CODE 0x00000020
+#define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040
+#define IMAGE_SCN_MEM_DISCARDABLE 0x02000000
+#define IMAGE_SCN_MEM_EXECUTE 0x20000000
+#define IMAGE_SCN_MEM_READ 0x40000000
+
+ .section .peheader,"a"
+efi_start:
+ /* The MS-DOS Stub, only used to get the offset of the COFF header */
+ .ascii "MZ"
+ .short 0
+ .space 0x38
+ .long pe_sig - efi_start
+
+ /* The PE32 Signature. Needs to be 8-byte aligned */
+ .align 3
+pe_sig:
+ .ascii "PE"
+ .short 0
+coff_head:
+ .short IMAGE_FILE_MACHINE_LOONGARCH64 /* loongarch 64 file */
+ .short 2 /* 2 Sections */
+ .long 0 /* Timestamp */
+ .long 0 /* No symbol table */
+ .long 0 /* No symbols */
+ .short section_table - optional_header /* Optional header size */
+ .short 0 /* Characteristics TODO: Fill in */
+
+optional_header:
+ .short 0x020b /* PE32+ (64-bit addressing) */
+ .byte 0 /* Major linker version */
+ .byte 0 /* Minor linker version */
+ .long _edata - _end_header /* Code size */
+ .long 0 /* No initialized data */
+ .long 0 /* No uninitialized data */
+ .long _start - efi_start /* Entry point */
+ .long _end_header - efi_start /* Start of code */
+
+optional_windows_header:
+ .quad 0 /* Image base */
+ .long 32 /* Section Alignment */
+ .long 8 /* File alignment */
+ .short 0 /* Major OS version */
+ .short 0 /* Minor OS version */
+ .short 0 /* Major image version */
+ .short 0 /* Minor image version */
+ .short 0 /* Major subsystem version */
+ .short 0 /* Minor subsystem version */
+ .long 0 /* Win32 version */
+ .long _edata - efi_start /* Image size */
+ .long _end_header - efi_start /* Header size */
+ .long 0 /* Checksum */
+ .short 0xa /* Subsystem (EFI app) */
+ .short 0 /* DLL Characteristics */
+ .quad 0 /* Stack reserve */
+ .quad 0 /* Stack commit */
+ .quad 0 /* Heap reserve */
+ .quad 0 /* Heap commit */
+ .long 0 /* Loader flags */
+ .long 6 /* Number of RVAs */
+
+ /* RVAs: */
+ .quad 0
+ .quad 0
+ .quad 0
+ .quad 0
+ .quad 0
+ .quad 0
+
+section_table:
+ /* We need a .reloc section for EFI */
+ .ascii ".reloc"
+ .byte 0
+ .byte 0 /* Pad to 8 bytes */
+ .long 0 /* Virtual size */
+ .long 0 /* Virtual address */
+ .long 0 /* Size of raw data */
+ .long 0 /* Pointer to raw data */
+ .long 0 /* Pointer to relocations */
+ .long 0 /* Pointer to line numbers */
+ .short 0 /* Number of relocations */
+ .short 0 /* Number of line numbers */
+ .long (IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ | \
+ IMAGE_SCN_MEM_DISCARDABLE) /* Characteristics */
+
+ /* The contents of the loader */
+ .ascii ".text"
+ .byte 0
+ .byte 0
+ .byte 0 /* Pad to 8 bytes */
+ .long _edata - _end_header /* Virtual size */
+ .long _end_header - efi_start /* Virtual address */
+ .long _edata - _end_header /* Size of raw data */
+ .long _end_header - efi_start /* Pointer to raw data */
+ .long 0 /* Pointer to relocations */
+ .long 0 /* Pointer to line numbers */
+ .short 0 /* Number of relocations */
+ .short 0 /* Number of line numbers */
+ .long (IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_EXECUTE | \
+ IMAGE_SCN_MEM_READ) /* Characteristics */
+_end_header:
+
+ .text
+ .globl _start
+_start:
+ /* Save the boot params to the stack */
+ addi.d $sp, $sp, -16
+ st.d $a0, $sp, 0
+ st.d $a1, $sp, 8
+
+ /* Zero the BSS */
+ la.local $t0, __bss_start
+ la.local $t1, __bss_end
+
+1: st.d $zero, $t0, 0
+ addi.d $t0, $t0, 8
+ bltu $t0, $t1, 1b
+
+ la.local $a0, ImageBase
+ la.local $a1, _DYNAMIC
+ bl _C_LABEL(self_reloc)
+
+ ld.d $a1, $sp, 8
+ ld.d $a0, $sp, 0
+ bl _C_LABEL(efi_main)
+
+ /* NOTREACHED */
+2: idle 0
+ b 2b
diff --git a/stand/efi/loader/main.c b/stand/efi/loader/main.c
--- a/stand/efi/loader/main.c
+++ b/stand/efi/loader/main.c
@@ -46,6 +46,9 @@
#include <dev_net.h>
#include <net.h>
#include <machine/_inttypes.h>
+#ifdef __loongarch__
+#include <machine/loongarchreg.h> /* CSR_DMW0_BASE */
+#endif
#include <efi.h>
#include <efilib.h>
@@ -828,8 +831,18 @@
static void *
acpi_map_sdt(vm_offset_t addr)
{
+#ifdef __loongarch__
+ /*
+ * Under UEFI the firmware's page tables do not identity-map all of
+ * physical RAM, so an ACPI table's physical address is not a usable
+ * virtual address. Reach it through the DMW0 direct-map window that
+ * the firmware establishes for PLV0.
+ */
+ return ((void *)(addr | CSR_DMW0_BASE));
+#else
/* PA == VA */
return ((void *)addr);
+#endif
}
static int
@@ -858,8 +871,8 @@
if (rsdp == NULL)
return (NULL);
- rsdt = (ACPI_TABLE_RSDT *)(uintptr_t)rsdp->RsdtPhysicalAddress;
- xsdt = (ACPI_TABLE_XSDT *)(uintptr_t)rsdp->XsdtPhysicalAddress;
+ rsdt = (ACPI_TABLE_RSDT *)acpi_map_sdt(rsdp->RsdtPhysicalAddress);
+ xsdt = (ACPI_TABLE_XSDT *)acpi_map_sdt(rsdp->XsdtPhysicalAddress);
if (rsdp->Revision < 2) {
sdp = (ACPI_TABLE_HEADER *)rsdt;
addr_size = sizeof(uint32_t);
@@ -1051,7 +1064,9 @@
* console. It may mirror a video console, or may be stand alone. If it
* is present, we return RB_SERIAL and will use it for the kernel.
*/
+#ifndef __loongarch__
how = check_acpi_spcr();
+#endif
sz = sizeof(buf);
rv = efi_global_getenv("ConOut", buf, &sz);
if (rv != EFI_SUCCESS)
diff --git a/stand/ficl/loongarch/sysdep.h b/stand/ficl/loongarch/sysdep.h
new file mode 100644
--- /dev/null
+++ b/stand/ficl/loongarch/sysdep.h
@@ -0,0 +1,410 @@
+/*******************************************************************
+ s y s d e p . h
+** Forth Inspired Command Language
+** Author: John Sadler (john_sadler@alum.mit.edu)
+** Created: 16 Oct 1997
+** Ficl system dependent types and prototypes...
+**
+** Note: Ficl also depends on the use of "assert" when
+** FICL_ROBUST is enabled. This may require some consideration
+** in firmware systems since assert often
+** assumes stderr/stdout.
+** $Id: sysdep.h,v 1.6 2001-04-26 21:41:55-07 jsadler Exp jsadler $
+*******************************************************************/
+/*
+** Copyright (c) 1997-2001 John Sadler (john_sadler@alum.mit.edu)
+** All rights reserved.
+**
+** Get the latest Ficl release at http://ficl.sourceforge.net
+**
+** L I C E N S E and D I S C L A I M E R
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+** 1. Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in the
+** documentation and/or other materials provided with the distribution.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+** SUCH DAMAGE.
+**
+** I am interested in hearing from anyone who uses ficl. If you have
+** a problem, a success story, a defect, an enhancement request, or
+** if you would like to contribute to the ficl release, please send
+** contact me by email at the address above.
+**
+** $Id: sysdep.h,v 1.6 2001-04-26 21:41:55-07 jsadler Exp jsadler $
+*/
+
+#if !defined (__SYSDEP_H__)
+#define __SYSDEP_H__
+
+#include <sys/types.h>
+
+#include <stddef.h> /* size_t, NULL */
+#include <setjmp.h>
+#include <assert.h>
+
+#if !defined IGNORE /* Macro to silence unused param warnings */
+#define IGNORE(x) (void)(x)
+#endif
+
+/*
+** TRUE and FALSE for C boolean operations, and
+** portable 32 bit types for CELLs
+**
+*/
+#if !defined TRUE
+#define TRUE 1
+#endif
+#if !defined FALSE
+#define FALSE 0
+#endif
+
+
+/*
+** System dependent data type declarations...
+*/
+#if !defined INT32
+#define INT32 int
+#endif
+
+#if !defined UNS32
+#define UNS32 unsigned int
+#endif
+
+#if !defined UNS16
+#define UNS16 unsigned short
+#endif
+
+#if !defined UNS8
+#define UNS8 unsigned char
+#endif
+
+#if !defined NULL
+#define NULL ((void *)0)
+#endif
+
+/*
+** FICL_UNS and FICL_INT must have the same size as a void* on
+** the target system. A CELL is a union of void*, FICL_UNS, and
+** FICL_INT.
+** (11/2000: same for FICL_FLOAT)
+*/
+#if !defined FICL_INT
+#define FICL_INT long
+#endif
+
+#if !defined FICL_UNS
+#define FICL_UNS unsigned long
+#endif
+
+#if !defined FICL_FLOAT
+#define FICL_FLOAT float
+#endif
+
+/*
+** Ficl presently supports values of 32 and 64 for BITS_PER_CELL
+*/
+#if !defined BITS_PER_CELL
+#define BITS_PER_CELL 64
+#endif
+
+#if ((BITS_PER_CELL != 32) && (BITS_PER_CELL != 64))
+ Error!
+#endif
+
+typedef struct
+{
+ FICL_UNS hi;
+ FICL_UNS lo;
+} DPUNS;
+
+typedef struct
+{
+ FICL_UNS quot;
+ FICL_UNS rem;
+} UNSQR;
+
+typedef struct
+{
+ FICL_INT hi;
+ FICL_INT lo;
+} DPINT;
+
+typedef struct
+{
+ FICL_INT quot;
+ FICL_INT rem;
+} INTQR;
+
+
+/*
+** B U I L D C O N T R O L S
+*/
+
+#if !defined (FICL_MINIMAL)
+#define FICL_MINIMAL 0
+#endif
+#if (FICL_MINIMAL)
+#define FICL_WANT_SOFTWORDS 0
+#define FICL_WANT_FLOAT 0
+#define FICL_WANT_USER 0
+#define FICL_WANT_LOCALS 0
+#define FICL_WANT_DEBUGGER 0
+#define FICL_WANT_OOP 0
+#define FICL_PLATFORM_EXTEND 0
+#define FICL_MULTITHREAD 0
+#define FICL_ROBUST 0
+#define FICL_EXTENDED_PREFIX 0
+#endif
+
+/*
+** FICL_PLATFORM_EXTEND
+** Includes words defined in ficlCompilePlatform
+*/
+#if !defined (FICL_PLATFORM_EXTEND)
+#define FICL_PLATFORM_EXTEND 1
+#endif
+
+/*
+** FICL_WANT_FLOAT
+** Includes a floating point stack for the VM, and words to do float operations.
+** Contributed by Guy Carver
+*/
+#if !defined (FICL_WANT_FLOAT)
+#define FICL_WANT_FLOAT 0
+#endif
+
+/*
+** FICL_WANT_DEBUGGER
+** Inludes a simple source level debugger
+*/
+#if !defined (FICL_WANT_DEBUGGER)
+#define FICL_WANT_DEBUGGER 1
+#endif
+
+/*
+** User variables: per-instance variables bound to the VM.
+** Kinda like thread-local storage. Could be implemented in a
+** VM private dictionary, but I've chosen the lower overhead
+** approach of an array of CELLs instead.
+*/
+#if !defined FICL_WANT_USER
+#define FICL_WANT_USER 1
+#endif
+
+#if !defined FICL_USER_CELLS
+#define FICL_USER_CELLS 16
+#endif
+
+/*
+** FICL_WANT_LOCALS controls the creation of the LOCALS wordset and
+** a private dictionary for local variable compilation.
+*/
+#if !defined FICL_WANT_LOCALS
+#define FICL_WANT_LOCALS 1
+#endif
+
+/* Max number of local variables per definition */
+#if !defined FICL_MAX_LOCALS
+#define FICL_MAX_LOCALS 16
+#endif
+
+/*
+** FICL_WANT_OOP
+** Inludes object oriented programming support (in softwords)
+** OOP support requires locals and user variables!
+*/
+#if !(FICL_WANT_LOCALS) || !(FICL_WANT_USER)
+#if !defined (FICL_WANT_OOP)
+#define FICL_WANT_OOP 0
+#endif
+#endif
+
+#if !defined (FICL_WANT_OOP)
+#define FICL_WANT_OOP 1
+#endif
+
+/*
+** FICL_WANT_SOFTWORDS
+** Controls inclusion of all softwords in softcore.c
+*/
+#if !defined (FICL_WANT_SOFTWORDS)
+#define FICL_WANT_SOFTWORDS 1
+#endif
+
+/*
+** FICL_MULTITHREAD enables dictionary mutual exclusion
+** wia the ficlLockDictionary system dependent function.
+** Note: this implementation is experimental and poorly
+** tested. Further, it's unnecessary unless you really
+** intend to have multiple SESSIONS (poor choice of name
+** on my part) - that is, threads that modify the dictionary
+** at the same time.
+*/
+#if !defined FICL_MULTITHREAD
+#define FICL_MULTITHREAD 0
+#endif
+
+/*
+** PORTABLE_LONGMULDIV causes ficlLongMul and ficlLongDiv to be
+** defined in C in sysdep.c. Use this if you cannot easily
+** generate an inline asm definition
+*/
+#if !defined (PORTABLE_LONGMULDIV)
+#define PORTABLE_LONGMULDIV 0
+#endif
+
+/*
+** INLINE_INNER_LOOP causes the inner interpreter to be inline code
+** instead of a function call. This is mainly because MS VC++ 5
+** chokes with an internal compiler error on the function version.
+** in release mode. Sheesh.
+*/
+#if !defined INLINE_INNER_LOOP
+#if defined _DEBUG
+#define INLINE_INNER_LOOP 0
+#else
+#define INLINE_INNER_LOOP 1
+#endif
+#endif
+
+/*
+** FICL_ROBUST enables bounds checking of stacks and the dictionary.
+** This will detect stack over and underflows and dictionary overflows.
+** Any exceptional condition will result in an assertion failure.
+** (As generated by the ANSI assert macro)
+** FICL_ROBUST == 1 --> stack checking in the outer interpreter
+** FICL_ROBUST == 2 also enables checking in many primitives
+*/
+
+#if !defined FICL_ROBUST
+#define FICL_ROBUST 2
+#endif
+
+/*
+** FICL_DEFAULT_STACK Specifies the default size (in CELLs) of
+** a new virtual machine's stacks, unless overridden at
+** create time.
+*/
+#if !defined FICL_DEFAULT_STACK
+#define FICL_DEFAULT_STACK 128
+#endif
+
+/*
+** FICL_DEFAULT_DICT specifies the number of CELLs to allocate
+** for the system dictionary by default. The value
+** can be overridden at startup time as well.
+** FICL_DEFAULT_ENV specifies the number of cells to allot
+** for the environment-query dictionary.
+*/
+#if !defined FICL_DEFAULT_DICT
+#define FICL_DEFAULT_DICT 12288
+#endif
+
+#if !defined FICL_DEFAULT_ENV
+#define FICL_DEFAULT_ENV 260
+#endif
+
+/*
+** FICL_DEFAULT_VOCS specifies the maximum number of wordlists in
+** the dictionary search order. See Forth DPANS sec 16.3.3
+** (file://dpans16.htm#16.3.3)
+*/
+#if !defined FICL_DEFAULT_VOCS
+#define FICL_DEFAULT_VOCS 16
+#endif
+
+/*
+** FICL_MAX_PARSE_STEPS controls the size of an array in the FICL_SYSTEM structure
+** that stores pointers to parser extension functions. I would never expect to have
+** more than 8 of these, so that's the default limit. Too many of these functions
+** will probably exact a nasty performance penalty.
+*/
+#if !defined FICL_MAX_PARSE_STEPS
+#define FICL_MAX_PARSE_STEPS 8
+#endif
+
+/*
+** FICL_EXTENDED_PREFIX enables a bunch of extra prefixes in prefix.c and prefix.fr (if
+** included as part of softcore.c)
+*/
+#if !defined FICL_EXTENDED_PREFIX
+#define FICL_EXTENDED_PREFIX 0
+#endif
+
+/*
+** FICL_ALIGN is the power of two to which the dictionary
+** pointer address must be aligned. This value is usually
+** either 1 or 2, depending on the memory architecture
+** of the target system; 2 is safe on any 16 or 32 bit
+** machine. 3 would be appropriate for a 64 bit machine.
+*/
+#if !defined FICL_ALIGN
+#define FICL_ALIGN 3
+#define FICL_ALIGN_ADD ((1 << FICL_ALIGN) - 1)
+#endif
+
+/*
+** System dependent routines --
+** edit the implementations in sysdep.c to be compatible
+** with your runtime environment...
+** ficlTextOut sends a NULL terminated string to the
+** default output device - used for system error messages
+** ficlMalloc and ficlFree have the same semantics as malloc and free
+** in standard C
+** ficlLongMul multiplies two UNS32s and returns a 64 bit unsigned
+** product
+** ficlLongDiv divides an UNS64 by an UNS32 and returns UNS32 quotient
+** and remainder
+*/
+struct vm;
+void ficlTextOut(struct vm *pVM, char *msg, int fNewline);
+void *ficlMalloc (size_t size);
+void ficlFree (void *p);
+void *ficlRealloc(void *p, size_t size);
+/*
+** Stub function for dictionary access control - does nothing
+** by default, user can redefine to guarantee exclusive dict
+** access to a single thread for updates. All dict update code
+** must be bracketed as follows:
+** ficlLockDictionary(TRUE);
+** <code that updates dictionary>
+** ficlLockDictionary(FALSE);
+**
+** Returns zero if successful, nonzero if unable to acquire lock
+** before timeout (optional - could also block forever)
+**
+** NOTE: this function must be implemented with lock counting
+** semantics: nested calls must behave properly.
+*/
+#if FICL_MULTITHREAD
+int ficlLockDictionary(short fLock);
+#else
+#define ficlLockDictionary(x) 0 /* ignore */
+#endif
+
+/*
+** 64 bit integer math support routines: multiply two UNS32s
+** to get a 64 bit product, & divide the product by an UNS32
+** to get an UNS32 quotient and remainder. Much easier in asm
+** on a 32 bit CPU than in C, which usually doesn't support
+** the double length result (but it should).
+*/
+DPUNS ficlLongMul(FICL_UNS x, FICL_UNS y);
+UNSQR ficlLongDiv(DPUNS q, FICL_UNS y);
+
+#endif /*__SYSDEP_H__*/
diff --git a/stand/ficl/loongarch/sysdep.c b/stand/ficl/loongarch/sysdep.c
new file mode 100644
--- /dev/null
+++ b/stand/ficl/loongarch/sysdep.c
@@ -0,0 +1,98 @@
+/*******************************************************************
+** s y s d e p . c
+** Forth Inspired Command Language
+** Author: John Sadler (john_sadler@alum.mit.edu)
+** Created: 16 Oct 1997
+** Implementations of FICL external interface functions...
+**
+*******************************************************************/
+
+
+#ifdef TESTMAIN
+#include <stdio.h>
+#include <stdlib.h>
+#else
+#include <stand.h>
+#endif
+#include "ficl.h"
+
+/*
+******************* FreeBSD P O R T B E G I N S H E R E ******************** Michael Smith
+*/
+
+#if PORTABLE_LONGMULDIV == 0
+DPUNS ficlLongMul(FICL_UNS x, FICL_UNS y)
+{
+ DPUNS q;
+ uint64_t qx;
+
+ qx = (uint64_t)x * (uint64_t) y;
+
+ q.hi = (uint32_t)( qx >> 32 );
+ q.lo = (uint32_t)( qx & 0xFFFFFFFFL);
+
+ return q;
+}
+
+UNSQR ficlLongDiv(DPUNS q, FICL_UNS y)
+{
+ UNSQR result;
+ uint64_t qx, qh;
+
+ qh = q.hi;
+ qx = (qh << 32) | q.lo;
+
+ result.quot = qx / y;
+ result.rem = qx % y;
+
+ return result;
+}
+#endif
+
+void ficlTextOut(FICL_VM *pVM, char *msg, int fNewline)
+{
+ IGNORE(pVM);
+
+ while(*msg != 0)
+ putchar(*(msg++));
+ if (fNewline)
+ putchar('\n');
+
+ return;
+}
+
+void *ficlMalloc (size_t size)
+{
+ return malloc(size);
+}
+
+void *ficlRealloc (void *p, size_t size)
+{
+ return realloc(p, size);
+}
+
+void ficlFree (void *p)
+{
+ free(p);
+}
+
+
+/*
+** Stub function for dictionary access control - does nothing
+** by default, user can redefine to guarantee exclusive dict
+** access to a single thread for updates. All dict update code
+** is guaranteed to be bracketed as follows:
+** ficlLockDictionary(TRUE);
+** <code that updates dictionary>
+** ficlLockDictionary(FALSE);
+**
+** Returns zero if successful, nonzero if unable to acquire lock
+** befor timeout (optional - could also block forever)
+*/
+#if FICL_MULTITHREAD
+int ficlLockDictionary(short fLock)
+{
+ IGNORE(fLock);
+ return 0;
+}
+#endif /* FICL_MULTITHREAD */
diff --git a/stand/libsa/Makefile b/stand/libsa/Makefile
--- a/stand/libsa/Makefile
+++ b/stand/libsa/Makefile
@@ -54,7 +54,8 @@
SRCS+= aeabi_memcmp.S aeabi_memcpy.S aeabi_memmove.S aeabi_memset.S
.endif
-.if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "riscv"
+.if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "riscv" || \
+ ${MACHINE_CPUARCH} == "loongarch"
.PATH: ${LIBCSRC}/${MACHINE_CPUARCH}/gen
.endif
diff --git a/stand/loader.mk b/stand/loader.mk
--- a/stand/loader.mk
+++ b/stand/loader.mk
@@ -27,6 +27,9 @@
.elif ${MACHINE_CPUARCH} == "riscv"
SRCS+= load_elf64.c reloc_elf64.c
SRCS+= metadata.c
+.elif ${MACHINE_CPUARCH} == "loongarch"
+SRCS+= load_elf64.c reloc_elf64.c
+SRCS+= metadata.c
.endif
#
diff --git a/sys/contrib/edk2/Include/Guid/FdtHob.h b/sys/contrib/edk2/Include/Guid/FdtHob.h
new file mode 100644
--- /dev/null
+++ b/sys/contrib/edk2/Include/Guid/FdtHob.h
@@ -0,0 +1,20 @@
+/** @file
+ GUID for the HOB that contains the copy of the flattened device tree blob
+
+ Copyright (C) 2014, Linaro Ltd.
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef __FDT_HOB_H__
+#define __FDT_HOB_H__
+
+#define FDT_HOB_GUID {\
+ 0x16958446, 0x19B7, 0x480B, \
+ { 0xB0, 0x47, 0x74, 0x85, 0xAD, 0x3F, 0x71, 0x6D } \
+ }
+
+extern EFI_GUID gFdtHobGuid;
+
+#endif
diff --git a/sys/contrib/edk2/Include/Guid/HobList.h b/sys/contrib/edk2/Include/Guid/HobList.h
new file mode 100644
--- /dev/null
+++ b/sys/contrib/edk2/Include/Guid/HobList.h
@@ -0,0 +1,28 @@
+/** @file
+ GUIDs used for HOB List entries
+
+ These GUIDs point the HOB List passed from PEI to DXE.
+
+ Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+ @par Revision Reference:
+ GUID introduced in PI Version 1.0.
+
+**/
+
+#ifndef __HOB_LIST_H__
+#define __HOB_LIST_H__
+
+//
+// The HOB List Table shall be stored in memory of type
+// EfiBootServicesData
+//
+#define HOB_LIST_GUID \
+ { \
+ 0x7739f24c, 0x93d7, 0x11d4, {0x9a, 0x3a, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
+ }
+
+extern EFI_GUID gEfiHobListGuid;
+
+#endif
diff --git a/sys/sys/efi-edk2.h b/sys/sys/efi-edk2.h
--- a/sys/sys/efi-edk2.h
+++ b/sys/sys/efi-edk2.h
@@ -98,6 +98,8 @@
#define MDE_CPU_AARCH64
#elif defined(__riscv)
#define MDE_CPU_RISCV64
+#elif defined(__loongarch__)
+#define MDE_CPU_LOONGARCH64
#endif
/* FreeBSD doesn't have/use MDE_CPU_EBC or MDE_CPU_IPF (ia64) */

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 14, 12:21 AM (13 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41711782
Default Alt Text
D59889.1794615679.diff (36 KB)

Event Timeline