1 // SPDX-License-Identifier: GPL-2.0
5 * Author: Jianmin Lv <lvjianmin@loongson.cn>
6 * Huacai Chen <chenhuacai@loongson.cn>
8 * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
11 #include <linux/acpi.h>
12 #include <linux/efi.h>
13 #include <linux/efi-bgrt.h>
14 #include <linux/init.h>
15 #include <linux/kernel.h>
16 #include <linux/export.h>
18 #include <linux/kobject.h>
19 #include <linux/memblock.h>
20 #include <linux/reboot.h>
21 #include <linux/uaccess.h>
23 #include <asm/early_ioremap.h>
25 #include <asm/loongson.h>
27 static unsigned long efi_nr_tables;
28 static unsigned long efi_config_table;
30 static efi_system_table_t *efi_systab;
31 static efi_config_table_type_t arch_tables[] __initdata = {{},};
33 void __init efi_runtime_init(void)
35 if (!efi_enabled(EFI_BOOT))
38 if (efi_runtime_disabled()) {
39 pr_info("EFI runtime services will be disabled.\n");
43 efi.runtime = (efi_runtime_services_t *)efi_systab->runtime;
44 efi.runtime_version = (unsigned int)efi.runtime->hdr.revision;
46 efi_native_runtime_setup();
47 set_bit(EFI_RUNTIME_SERVICES, &efi.flags);
50 void __init efi_init(void)
55 if (!efi_system_table)
58 efi_systab = (efi_system_table_t *)early_memremap_ro(efi_system_table, sizeof(*efi_systab));
60 pr_err("Can't find EFI system table.\n");
64 set_bit(EFI_64BIT, &efi.flags);
65 efi_nr_tables = efi_systab->nr_tables;
66 efi_config_table = (unsigned long)efi_systab->tables;
68 size = sizeof(efi_config_table_t);
69 config_tables = early_memremap(efi_config_table, efi_nr_tables * size);
70 efi_config_parse_tables(config_tables, efi_systab->nr_tables, arch_tables);
71 early_memunmap(config_tables, efi_nr_tables * size);