efi_32.c 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Extensible Firmware Interface
  4. *
  5. * Based on Extensible Firmware Interface Specification version 1.0
  6. *
  7. * Copyright (C) 1999 VA Linux Systems
  8. * Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
  9. * Copyright (C) 1999-2002 Hewlett-Packard Co.
  10. * David Mosberger-Tang <davidm@hpl.hp.com>
  11. * Stephane Eranian <eranian@hpl.hp.com>
  12. *
  13. * All EFI Runtime Services are not implemented yet as EFI only
  14. * supports physical mode addressing on SoftSDV. This is to be fixed
  15. * in a future version. --drummond 1999-07-20
  16. *
  17. * Implemented EFI runtime services and virtual mode calls. --davidm
  18. *
  19. * Goutham Rao: <goutham.rao@intel.com>
  20. * Skip non-WB memory and ignore empty memory ranges.
  21. */
  22. #include <linux/kernel.h>
  23. #include <linux/types.h>
  24. #include <linux/ioport.h>
  25. #include <linux/efi.h>
  26. #include <asm/io.h>
  27. #include <asm/desc.h>
  28. #include <asm/page.h>
  29. #include <asm/pgtable.h>
  30. #include <asm/tlbflush.h>
  31. #include <asm/efi.h>
  32. /*
  33. * To make EFI call EFI runtime service in physical addressing mode we need
  34. * prolog/epilog before/after the invocation to claim the EFI runtime service
  35. * handler exclusively and to duplicate a memory mapping in low memory space,
  36. * say 0 - 3G.
  37. */
  38. int __init efi_alloc_page_tables(void)
  39. {
  40. return 0;
  41. }
  42. void efi_sync_low_kernel_mappings(void) {}
  43. void __init efi_dump_pagetable(void)
  44. {
  45. #ifdef CONFIG_EFI_PGT_DUMP
  46. ptdump_walk_pgd_level(NULL, swapper_pg_dir);
  47. #endif
  48. }
  49. int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages)
  50. {
  51. return 0;
  52. }
  53. void __init efi_map_region(efi_memory_desc_t *md)
  54. {
  55. old_map_region(md);
  56. }
  57. void __init efi_map_region_fixed(efi_memory_desc_t *md) {}
  58. void __init parse_efi_setup(u64 phys_addr, u32 data_len) {}
  59. pgd_t * __init efi_call_phys_prolog(void)
  60. {
  61. struct desc_ptr gdt_descr;
  62. pgd_t *save_pgd;
  63. /* Current pgd is swapper_pg_dir, we'll restore it later: */
  64. save_pgd = swapper_pg_dir;
  65. load_cr3(initial_page_table);
  66. __flush_tlb_all();
  67. gdt_descr.address = get_cpu_gdt_paddr(0);
  68. gdt_descr.size = GDT_SIZE - 1;
  69. load_gdt(&gdt_descr);
  70. return save_pgd;
  71. }
  72. void __init efi_call_phys_epilog(pgd_t *save_pgd)
  73. {
  74. load_fixmap_gdt(0);
  75. load_cr3(save_pgd);
  76. __flush_tlb_all();
  77. }
  78. void __init efi_runtime_update_mappings(void)
  79. {
  80. if (__supported_pte_mask & _PAGE_NX)
  81. runtime_code_page_mkexec();
  82. }