blob: 338402b91d2e5654b83c0530030d5aaa8f0a02c2 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Extensible Firmware Interface
3 *
4 * Based on Extensible Firmware Interface Specification version 1.0
5 *
6 * Copyright (C) 1999 VA Linux Systems
7 * Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
8 * Copyright (C) 1999-2002 Hewlett-Packard Co.
9 * David Mosberger-Tang <davidm@hpl.hp.com>
10 * Stephane Eranian <eranian@hpl.hp.com>
11 *
12 * All EFI Runtime Services are not implemented yet as EFI only
13 * supports physical mode addressing on SoftSDV. This is to be fixed
14 * in a future version. --drummond 1999-07-20
15 *
16 * Implemented EFI runtime services and virtual mode calls. --davidm
17 *
18 * Goutham Rao: <goutham.rao@intel.com>
19 * Skip non-WB memory and ignore empty memory ranges.
20 */
21
Linus Torvalds1da177e2005-04-16 15:20:36 -070022#include <linux/kernel.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070023#include <linux/types.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070024#include <linux/ioport.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070025#include <linux/efi.h>
26
Linus Torvalds1da177e2005-04-16 15:20:36 -070027#include <asm/io.h>
Paul Gortmaker783ac472011-05-27 14:46:07 -040028#include <asm/desc.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070029#include <asm/page.h>
30#include <asm/pgtable.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070031#include <asm/tlbflush.h>
Harvey Harrisoncc7e73f2008-02-13 13:26:39 -080032#include <asm/efi.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070033
Linus Torvalds1da177e2005-04-16 15:20:36 -070034/*
35 * To make EFI call EFI runtime service in physical addressing mode we need
Ingo Molnar23a0d4e2015-03-03 07:34:33 +010036 * prolog/epilog before/after the invocation to claim the EFI runtime service
37 * handler exclusively and to duplicate a memory mapping in low memory space,
38 * say 0 - 3G.
Linus Torvalds1da177e2005-04-16 15:20:36 -070039 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
Matt Fleming67a91082015-11-27 21:09:34 +000041int __init efi_alloc_page_tables(void)
42{
43 return 0;
44}
45
Borislav Petkovd2f7cbe2013-10-31 17:25:08 +010046void efi_sync_low_kernel_mappings(void) {}
Borislav Petkov11cc8512014-01-18 12:48:15 +010047void __init efi_dump_pagetable(void) {}
Mathias Krause4e78eb052014-09-07 19:42:17 +020048int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages)
Borislav Petkovb7b898a2014-01-18 12:48:17 +010049{
50 return 0;
51}
Mathias Krause4e78eb052014-09-07 19:42:17 +020052void __init efi_cleanup_page_tables(unsigned long pa_memmap, unsigned num_pages)
53{
54}
Borislav Petkovd2f7cbe2013-10-31 17:25:08 +010055
56void __init efi_map_region(efi_memory_desc_t *md)
57{
58 old_map_region(md);
59}
60
Dave Young3b266492013-12-20 18:02:14 +080061void __init efi_map_region_fixed(efi_memory_desc_t *md) {}
Dave Young1fec0532013-12-20 18:02:19 +080062void __init parse_efi_setup(u64 phys_addr, u32 data_len) {}
Dave Young3b266492013-12-20 18:02:14 +080063
Ingo Molnar744937b2015-03-03 07:48:50 +010064pgd_t * __init efi_call_phys_prolog(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070065{
Glauber de Oliveira Costa6b68f012008-01-30 13:31:12 +010066 struct desc_ptr gdt_descr;
Ingo Molnar744937b2015-03-03 07:48:50 +010067 pgd_t *save_pgd;
Linus Torvalds1da177e2005-04-16 15:20:36 -070068
Ingo Molnar744937b2015-03-03 07:48:50 +010069 /* Current pgd is swapper_pg_dir, we'll restore it later: */
70 save_pgd = swapper_pg_dir;
Matt Fleming6d3e32e2011-12-08 12:10:50 +000071 load_cr3(initial_page_table);
Huang, Ying8b2cb7a2008-01-30 13:32:11 +010072 __flush_tlb_all();
Linus Torvalds1da177e2005-04-16 15:20:36 -070073
Rusty Russell4fbb5962007-05-02 19:27:11 +020074 gdt_descr.address = __pa(get_cpu_gdt_table(0));
75 gdt_descr.size = GDT_SIZE - 1;
76 load_gdt(&gdt_descr);
Ingo Molnar744937b2015-03-03 07:48:50 +010077
78 return save_pgd;
Linus Torvalds1da177e2005-04-16 15:20:36 -070079}
80
Ingo Molnar744937b2015-03-03 07:48:50 +010081void __init efi_call_phys_epilog(pgd_t *save_pgd)
Linus Torvalds1da177e2005-04-16 15:20:36 -070082{
Glauber de Oliveira Costa6b68f012008-01-30 13:31:12 +010083 struct desc_ptr gdt_descr;
Linus Torvalds1da177e2005-04-16 15:20:36 -070084
Rusty Russell4fbb5962007-05-02 19:27:11 +020085 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
86 gdt_descr.size = GDT_SIZE - 1;
87 load_gdt(&gdt_descr);
James Bottomley2b932f62006-02-24 13:04:14 -080088
Ingo Molnar744937b2015-03-03 07:48:50 +010089 load_cr3(save_pgd);
Huang, Ying8b2cb7a2008-01-30 13:32:11 +010090 __flush_tlb_all();
Linus Torvalds1da177e2005-04-16 15:20:36 -070091}
Borislav Petkovc55d0162014-02-14 08:24:24 +010092
Sai Praneeth6d0cc882016-02-17 12:36:05 +000093void __init efi_runtime_update_mappings(void)
Borislav Petkovc55d0162014-02-14 08:24:24 +010094{
95 if (__supported_pte_mask & _PAGE_NX)
96 runtime_code_page_mkexec();
97}