628c3bb40e
Add basic boot, setup and reset routines for LoongArch. Now, LoongArch machines use UEFI-based firmware. The firmware passes configuration information to the kernel via ACPI and DMI/SMBIOS. Currently an existing interface between the kernel and the bootloader is implemented. Kernel gets 2 values from the bootloader, passed in registers a0 and a1; a0 is an "EFI boot flag" distinguishing UEFI and non-UEFI firmware, while a1 is a pointer to an FDT with systable, memmap, cmdline and initrd information. The standard UEFI boot protocol (EFISTUB) will be added later. Cc: linux-efi@vger.kernel.org Cc: Ard Biesheuvel <ardb@kernel.org> Reviewed-by: WANG Xuerui <git@xen0n.name> Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com> Co-developed-by: Yun Liu <liuyun@loongson.cn> Signed-off-by: Yun Liu <liuyun@loongson.cn> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
73 lines
1.8 KiB
C
73 lines
1.8 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* EFI initialization
|
|
*
|
|
* Author: Jianmin Lv <lvjianmin@loongson.cn>
|
|
* Huacai Chen <chenhuacai@loongson.cn>
|
|
*
|
|
* Copyright (C) 2020-2022 Loongson Technology Corporation Limited
|
|
*/
|
|
|
|
#include <linux/acpi.h>
|
|
#include <linux/efi.h>
|
|
#include <linux/efi-bgrt.h>
|
|
#include <linux/init.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/export.h>
|
|
#include <linux/io.h>
|
|
#include <linux/kobject.h>
|
|
#include <linux/memblock.h>
|
|
#include <linux/reboot.h>
|
|
#include <linux/uaccess.h>
|
|
|
|
#include <asm/early_ioremap.h>
|
|
#include <asm/efi.h>
|
|
#include <asm/loongson.h>
|
|
|
|
static unsigned long efi_nr_tables;
|
|
static unsigned long efi_config_table;
|
|
|
|
static efi_system_table_t *efi_systab;
|
|
static efi_config_table_type_t arch_tables[] __initdata = {{},};
|
|
|
|
void __init efi_runtime_init(void)
|
|
{
|
|
if (!efi_enabled(EFI_BOOT))
|
|
return;
|
|
|
|
if (efi_runtime_disabled()) {
|
|
pr_info("EFI runtime services will be disabled.\n");
|
|
return;
|
|
}
|
|
|
|
efi.runtime = (efi_runtime_services_t *)efi_systab->runtime;
|
|
efi.runtime_version = (unsigned int)efi.runtime->hdr.revision;
|
|
|
|
efi_native_runtime_setup();
|
|
set_bit(EFI_RUNTIME_SERVICES, &efi.flags);
|
|
}
|
|
|
|
void __init efi_init(void)
|
|
{
|
|
int size;
|
|
void *config_tables;
|
|
|
|
if (!efi_system_table)
|
|
return;
|
|
|
|
efi_systab = (efi_system_table_t *)early_memremap_ro(efi_system_table, sizeof(*efi_systab));
|
|
if (!efi_systab) {
|
|
pr_err("Can't find EFI system table.\n");
|
|
return;
|
|
}
|
|
|
|
set_bit(EFI_64BIT, &efi.flags);
|
|
efi_nr_tables = efi_systab->nr_tables;
|
|
efi_config_table = (unsigned long)efi_systab->tables;
|
|
|
|
size = sizeof(efi_config_table_t);
|
|
config_tables = early_memremap(efi_config_table, efi_nr_tables * size);
|
|
efi_config_parse_tables(config_tables, efi_systab->nr_tables, arch_tables);
|
|
early_memunmap(config_tables, efi_nr_tables * size);
|
|
}
|