efi.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * Copyright (C) 2015 Linaro Ltd <ard.biesheuvel@linaro.org>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. */
  8. #include <linux/efi.h>
  9. #include <asm/efi.h>
  10. #include <asm/mach/map.h>
  11. #include <asm/mmu_context.h>
  12. int __init efi_create_mapping(struct mm_struct *mm, efi_memory_desc_t *md)
  13. {
  14. struct map_desc desc = {
  15. .virtual = md->virt_addr,
  16. .pfn = __phys_to_pfn(md->phys_addr),
  17. .length = md->num_pages * EFI_PAGE_SIZE,
  18. };
  19. /*
  20. * Order is important here: memory regions may have all of the
  21. * bits below set (and usually do), so we check them in order of
  22. * preference.
  23. */
  24. if (md->attribute & EFI_MEMORY_WB)
  25. desc.type = MT_MEMORY_RWX;
  26. else if (md->attribute & EFI_MEMORY_WT)
  27. desc.type = MT_MEMORY_RWX_NONCACHED;
  28. else if (md->attribute & EFI_MEMORY_WC)
  29. desc.type = MT_DEVICE_WC;
  30. else
  31. desc.type = MT_DEVICE;
  32. create_mapping_late(mm, &desc, true);
  33. return 0;
  34. }