License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[linux-block.git] / arch / x86 / platform / efi / efi_32.c
CommitLineData
b2441318 1// SPDX-License-Identifier: GPL-2.0
1da177e4
LT
2/*
3 * Extensible Firmware Interface
4 *
5 * Based on Extensible Firmware Interface Specification version 1.0
6 *
7 * Copyright (C) 1999 VA Linux Systems
8 * Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
9 * Copyright (C) 1999-2002 Hewlett-Packard Co.
10 * David Mosberger-Tang <davidm@hpl.hp.com>
11 * Stephane Eranian <eranian@hpl.hp.com>
12 *
13 * All EFI Runtime Services are not implemented yet as EFI only
14 * supports physical mode addressing on SoftSDV. This is to be fixed
15 * in a future version. --drummond 1999-07-20
16 *
17 * Implemented EFI runtime services and virtual mode calls. --davidm
18 *
19 * Goutham Rao: <goutham.rao@intel.com>
20 * Skip non-WB memory and ignore empty memory ranges.
21 */
22
1da177e4 23#include <linux/kernel.h>
1da177e4 24#include <linux/types.h>
1da177e4 25#include <linux/ioport.h>
1da177e4
LT
26#include <linux/efi.h>
27
1da177e4 28#include <asm/io.h>
783ac47c 29#include <asm/desc.h>
1da177e4
LT
30#include <asm/page.h>
31#include <asm/pgtable.h>
1da177e4 32#include <asm/tlbflush.h>
cc7e73f3 33#include <asm/efi.h>
1da177e4 34
1da177e4
LT
35/*
36 * To make EFI call EFI runtime service in physical addressing mode we need
23a0d4e8
IM
37 * prolog/epilog before/after the invocation to claim the EFI runtime service
38 * handler exclusively and to duplicate a memory mapping in low memory space,
39 * say 0 - 3G.
1da177e4 40 */
1da177e4 41
67a9108e
MF
42int __init efi_alloc_page_tables(void)
43{
44 return 0;
45}
46
d2f7cbe7 47void efi_sync_low_kernel_mappings(void) {}
ac81d3de
SP
48
49void __init efi_dump_pagetable(void)
50{
51#ifdef CONFIG_EFI_PGT_DUMP
52 ptdump_walk_pgd_level(NULL, swapper_pg_dir);
53#endif
54}
55
4e78eb05 56int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages)
b7b898ae
BP
57{
58 return 0;
59}
d2f7cbe7
BP
60
61void __init efi_map_region(efi_memory_desc_t *md)
62{
63 old_map_region(md);
64}
65
3b266496 66void __init efi_map_region_fixed(efi_memory_desc_t *md) {}
1fec0533 67void __init parse_efi_setup(u64 phys_addr, u32 data_len) {}
3b266496 68
744937b0 69pgd_t * __init efi_call_phys_prolog(void)
1da177e4 70{
6b68f01b 71 struct desc_ptr gdt_descr;
744937b0 72 pgd_t *save_pgd;
1da177e4 73
744937b0
IM
74 /* Current pgd is swapper_pg_dir, we'll restore it later: */
75 save_pgd = swapper_pg_dir;
6d3e32e6 76 load_cr3(initial_page_table);
8b2cb7a8 77 __flush_tlb_all();
1da177e4 78
3fa1cabb 79 gdt_descr.address = get_cpu_gdt_paddr(0);
4fbb5968
RR
80 gdt_descr.size = GDT_SIZE - 1;
81 load_gdt(&gdt_descr);
744937b0
IM
82
83 return save_pgd;
1da177e4
LT
84}
85
744937b0 86void __init efi_call_phys_epilog(pgd_t *save_pgd)
1da177e4 87{
6b68f01b 88 struct desc_ptr gdt_descr;
1da177e4 89
69218e47 90 gdt_descr.address = (unsigned long)get_cpu_gdt_rw(0);
4fbb5968
RR
91 gdt_descr.size = GDT_SIZE - 1;
92 load_gdt(&gdt_descr);
2b932f6c 93
744937b0 94 load_cr3(save_pgd);
8b2cb7a8 95 __flush_tlb_all();
1da177e4 96}
c55d016f 97
6d0cc887 98void __init efi_runtime_update_mappings(void)
c55d016f
BP
99{
100 if (__supported_pte_mask & _PAGE_NX)
101 runtime_code_page_mkexec();
102}