Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[cascardo/linux.git] / arch / x86 / platform / efi / efi_32.c
1 /*
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
22 #include <linux/kernel.h>
23 #include <linux/types.h>
24 #include <linux/ioport.h>
25 #include <linux/efi.h>
26
27 #include <asm/io.h>
28 #include <asm/desc.h>
29 #include <asm/page.h>
30 #include <asm/pgtable.h>
31 #include <asm/tlbflush.h>
32 #include <asm/efi.h>
33
34 /*
35  * To make EFI call EFI runtime service in physical addressing mode we need
36  * 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.
39  */
40
41 int __init efi_alloc_page_tables(void)
42 {
43         return 0;
44 }
45
46 void efi_sync_low_kernel_mappings(void) {}
47 void __init efi_dump_pagetable(void) {}
48 int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages)
49 {
50         return 0;
51 }
52 void __init efi_cleanup_page_tables(unsigned long pa_memmap, unsigned num_pages)
53 {
54 }
55
56 void __init efi_map_region(efi_memory_desc_t *md)
57 {
58         old_map_region(md);
59 }
60
61 void __init efi_map_region_fixed(efi_memory_desc_t *md) {}
62 void __init parse_efi_setup(u64 phys_addr, u32 data_len) {}
63
64 pgd_t * __init efi_call_phys_prolog(void)
65 {
66         struct desc_ptr gdt_descr;
67         pgd_t *save_pgd;
68
69         /* Current pgd is swapper_pg_dir, we'll restore it later: */
70         save_pgd = swapper_pg_dir;
71         load_cr3(initial_page_table);
72         __flush_tlb_all();
73
74         gdt_descr.address = __pa(get_cpu_gdt_table(0));
75         gdt_descr.size = GDT_SIZE - 1;
76         load_gdt(&gdt_descr);
77
78         return save_pgd;
79 }
80
81 void __init efi_call_phys_epilog(pgd_t *save_pgd)
82 {
83         struct desc_ptr gdt_descr;
84
85         gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
86         gdt_descr.size = GDT_SIZE - 1;
87         load_gdt(&gdt_descr);
88
89         load_cr3(save_pgd);
90         __flush_tlb_all();
91 }
92
93 void __init efi_runtime_update_mappings(void)
94 {
95         if (__supported_pte_mask & _PAGE_NX)
96                 runtime_code_page_mkexec();
97 }