Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[wrt350n-kernel.git] / arch / x86 / kernel / efi_32.c
blob4603833f1ad11da7e9680899c97c4431c3aa756e
1 /*
2 * Extensible Firmware Interface
4 * Based on Extensible Firmware Interface Specification version 1.0
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>
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
16 * Implemented EFI runtime services and virtual mode calls. --davidm
18 * Goutham Rao: <goutham.rao@intel.com>
19 * Skip non-WB memory and ignore empty memory ranges.
22 #include <linux/kernel.h>
23 #include <linux/types.h>
24 #include <linux/ioport.h>
25 #include <linux/efi.h>
27 #include <asm/io.h>
28 #include <asm/page.h>
29 #include <asm/pgtable.h>
30 #include <asm/tlbflush.h>
31 <<<<<<< HEAD:arch/x86/kernel/efi_32.c
32 =======
33 #include <asm/efi.h>
34 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/x86/kernel/efi_32.c
37 * To make EFI call EFI runtime service in physical addressing mode we need
38 * prelog/epilog before/after the invocation to disable interrupt, to
39 * claim EFI runtime service handler exclusively and to duplicate a memory in
40 * low memory space say 0 - 3G.
43 static unsigned long efi_rt_eflags;
44 static pgd_t efi_bak_pg_dir_pointer[2];
46 void efi_call_phys_prelog(void)
48 unsigned long cr4;
49 unsigned long temp;
50 struct desc_ptr gdt_descr;
52 local_irq_save(efi_rt_eflags);
55 * If I don't have PSE, I should just duplicate two entries in page
56 * directory. If I have PSE, I just need to duplicate one entry in
57 * page directory.
59 cr4 = read_cr4();
61 if (cr4 & X86_CR4_PSE) {
62 efi_bak_pg_dir_pointer[0].pgd =
63 swapper_pg_dir[pgd_index(0)].pgd;
64 swapper_pg_dir[0].pgd =
65 swapper_pg_dir[pgd_index(PAGE_OFFSET)].pgd;
66 } else {
67 efi_bak_pg_dir_pointer[0].pgd =
68 swapper_pg_dir[pgd_index(0)].pgd;
69 efi_bak_pg_dir_pointer[1].pgd =
70 swapper_pg_dir[pgd_index(0x400000)].pgd;
71 swapper_pg_dir[pgd_index(0)].pgd =
72 swapper_pg_dir[pgd_index(PAGE_OFFSET)].pgd;
73 temp = PAGE_OFFSET + 0x400000;
74 swapper_pg_dir[pgd_index(0x400000)].pgd =
75 swapper_pg_dir[pgd_index(temp)].pgd;
79 * After the lock is released, the original page table is restored.
81 __flush_tlb_all();
83 gdt_descr.address = __pa(get_cpu_gdt_table(0));
84 gdt_descr.size = GDT_SIZE - 1;
85 load_gdt(&gdt_descr);
88 void efi_call_phys_epilog(void)
90 unsigned long cr4;
91 struct desc_ptr gdt_descr;
93 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
94 gdt_descr.size = GDT_SIZE - 1;
95 load_gdt(&gdt_descr);
97 cr4 = read_cr4();
99 if (cr4 & X86_CR4_PSE) {
100 swapper_pg_dir[pgd_index(0)].pgd =
101 efi_bak_pg_dir_pointer[0].pgd;
102 } else {
103 swapper_pg_dir[pgd_index(0)].pgd =
104 efi_bak_pg_dir_pointer[0].pgd;
105 swapper_pg_dir[pgd_index(0x400000)].pgd =
106 efi_bak_pg_dir_pointer[1].pgd;
110 * After the lock is released, the original page table is restored.
112 __flush_tlb_all();
114 local_irq_restore(efi_rt_eflags);