Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | #include <linux/kernel.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | #include <linux/types.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | #include <linux/ioport.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | #include <linux/efi.h> |
| 26 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | #include <asm/io.h> |
Paul Gortmaker | 783ac47 | 2011-05-27 14:46:07 -0400 | [diff] [blame] | 28 | #include <asm/desc.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | #include <asm/page.h> |
| 30 | #include <asm/pgtable.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | #include <asm/tlbflush.h> |
Harvey Harrison | cc7e73f | 2008-02-13 13:26:39 -0800 | [diff] [blame] | 32 | #include <asm/efi.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | /* |
| 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | static unsigned long efi_rt_eflags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | |
Borislav Petkov | d2f7cbe | 2013-10-31 17:25:08 +0100 | [diff] [blame] | 42 | void efi_sync_low_kernel_mappings(void) {} |
Borislav Petkov | 11cc851 | 2014-01-18 12:48:15 +0100 | [diff] [blame] | 43 | void __init efi_dump_pagetable(void) {} |
Borislav Petkov | b7b898a | 2014-01-18 12:48:17 +0100 | [diff] [blame] | 44 | int efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages) |
| 45 | { |
| 46 | return 0; |
| 47 | } |
| 48 | void efi_cleanup_page_tables(unsigned long pa_memmap, unsigned num_pages) {} |
Borislav Petkov | d2f7cbe | 2013-10-31 17:25:08 +0100 | [diff] [blame] | 49 | |
| 50 | void __init efi_map_region(efi_memory_desc_t *md) |
| 51 | { |
| 52 | old_map_region(md); |
| 53 | } |
| 54 | |
Dave Young | 3b26649 | 2013-12-20 18:02:14 +0800 | [diff] [blame] | 55 | void __init efi_map_region_fixed(efi_memory_desc_t *md) {} |
Dave Young | 1fec053 | 2013-12-20 18:02:19 +0800 | [diff] [blame] | 56 | void __init parse_efi_setup(u64 phys_addr, u32 data_len) {} |
Dave Young | 3b26649 | 2013-12-20 18:02:14 +0800 | [diff] [blame] | 57 | |
Huang, Ying | 8b2cb7a | 2008-01-30 13:32:11 +0100 | [diff] [blame] | 58 | void efi_call_phys_prelog(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | { |
Glauber de Oliveira Costa | 6b68f01 | 2008-01-30 13:31:12 +0100 | [diff] [blame] | 60 | struct desc_ptr gdt_descr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | local_irq_save(efi_rt_eflags); |
| 63 | |
Matt Fleming | 6d3e32e | 2011-12-08 12:10:50 +0000 | [diff] [blame] | 64 | load_cr3(initial_page_table); |
Huang, Ying | 8b2cb7a | 2008-01-30 13:32:11 +0100 | [diff] [blame] | 65 | __flush_tlb_all(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | |
Rusty Russell | 4fbb596 | 2007-05-02 19:27:11 +0200 | [diff] [blame] | 67 | gdt_descr.address = __pa(get_cpu_gdt_table(0)); |
| 68 | gdt_descr.size = GDT_SIZE - 1; |
| 69 | load_gdt(&gdt_descr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | } |
| 71 | |
Huang, Ying | 8b2cb7a | 2008-01-30 13:32:11 +0100 | [diff] [blame] | 72 | void efi_call_phys_epilog(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | { |
Glauber de Oliveira Costa | 6b68f01 | 2008-01-30 13:31:12 +0100 | [diff] [blame] | 74 | struct desc_ptr gdt_descr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | |
Rusty Russell | 4fbb596 | 2007-05-02 19:27:11 +0200 | [diff] [blame] | 76 | gdt_descr.address = (unsigned long)get_cpu_gdt_table(0); |
| 77 | gdt_descr.size = GDT_SIZE - 1; |
| 78 | load_gdt(&gdt_descr); |
James Bottomley | 2b932f6 | 2006-02-24 13:04:14 -0800 | [diff] [blame] | 79 | |
Matt Fleming | 6d3e32e | 2011-12-08 12:10:50 +0000 | [diff] [blame] | 80 | load_cr3(swapper_pg_dir); |
Huang, Ying | 8b2cb7a | 2008-01-30 13:32:11 +0100 | [diff] [blame] | 81 | __flush_tlb_all(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | |
| 83 | local_irq_restore(efi_rt_eflags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | } |
Borislav Petkov | c55d016 | 2014-02-14 08:24:24 +0100 | [diff] [blame] | 85 | |
| 86 | void __init efi_runtime_mkexec(void) |
| 87 | { |
| 88 | if (__supported_pte_mask & _PAGE_NX) |
| 89 | runtime_code_page_mkexec(); |
| 90 | } |