blob: 0b74cdf7f816aa0e4e6f26c020821266f51aefdb [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
36 * prelog/epilog before/after the invocation to disable interrupt, to
37 * claim EFI runtime service handler exclusively and to duplicate a memory in
38 * low memory space say 0 - 3G.
39 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070040static unsigned long efi_rt_eflags;
Linus Torvalds1da177e2005-04-16 15:20:36 -070041
Borislav Petkovd2f7cbe2013-10-31 17:25:08 +010042void efi_sync_low_kernel_mappings(void) {}
43void efi_setup_page_tables(void) {}
44
45void __init efi_map_region(efi_memory_desc_t *md)
46{
47 old_map_region(md);
48}
49
Dave Young3b266492013-12-20 18:02:14 +080050void __init efi_map_region_fixed(efi_memory_desc_t *md) {}
Dave Young1fec0532013-12-20 18:02:19 +080051void __init parse_efi_setup(u64 phys_addr, u32 data_len) {}
Dave Young3b266492013-12-20 18:02:14 +080052
Huang, Ying8b2cb7a2008-01-30 13:32:11 +010053void efi_call_phys_prelog(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070054{
Glauber de Oliveira Costa6b68f012008-01-30 13:31:12 +010055 struct desc_ptr gdt_descr;
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
Linus Torvalds1da177e2005-04-16 15:20:36 -070057 local_irq_save(efi_rt_eflags);
58
Matt Fleming6d3e32e2011-12-08 12:10:50 +000059 load_cr3(initial_page_table);
Huang, Ying8b2cb7a2008-01-30 13:32:11 +010060 __flush_tlb_all();
Linus Torvalds1da177e2005-04-16 15:20:36 -070061
Rusty Russell4fbb5962007-05-02 19:27:11 +020062 gdt_descr.address = __pa(get_cpu_gdt_table(0));
63 gdt_descr.size = GDT_SIZE - 1;
64 load_gdt(&gdt_descr);
Linus Torvalds1da177e2005-04-16 15:20:36 -070065}
66
Huang, Ying8b2cb7a2008-01-30 13:32:11 +010067void efi_call_phys_epilog(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070068{
Glauber de Oliveira Costa6b68f012008-01-30 13:31:12 +010069 struct desc_ptr gdt_descr;
Linus Torvalds1da177e2005-04-16 15:20:36 -070070
Rusty Russell4fbb5962007-05-02 19:27:11 +020071 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
72 gdt_descr.size = GDT_SIZE - 1;
73 load_gdt(&gdt_descr);
James Bottomley2b932f62006-02-24 13:04:14 -080074
Matt Fleming6d3e32e2011-12-08 12:10:50 +000075 load_cr3(swapper_pg_dir);
Huang, Ying8b2cb7a2008-01-30 13:32:11 +010076 __flush_tlb_all();
Linus Torvalds1da177e2005-04-16 15:20:36 -070077
78 local_irq_restore(efi_rt_eflags);
Linus Torvalds1da177e2005-04-16 15:20:36 -070079}
Borislav Petkovc55d0162014-02-14 08:24:24 +010080
81void __init efi_runtime_mkexec(void)
82{
83 if (__supported_pte_mask & _PAGE_NX)
84 runtime_code_page_mkexec();
85}