efi.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2015 Linaro Ltd <[email protected]>
  4. */
  5. #ifndef __ASM_ARM_EFI_H
  6. #define __ASM_ARM_EFI_H
  7. #include <asm/cacheflush.h>
  8. #include <asm/cachetype.h>
  9. #include <asm/early_ioremap.h>
  10. #include <asm/fixmap.h>
  11. #include <asm/highmem.h>
  12. #include <asm/mach/map.h>
  13. #include <asm/mmu_context.h>
  14. #include <asm/ptrace.h>
  15. #ifdef CONFIG_EFI
  16. void efi_init(void);
  17. void arm_efi_init(void);
  18. int efi_create_mapping(struct mm_struct *mm, efi_memory_desc_t *md);
  19. int efi_set_mapping_permissions(struct mm_struct *mm, efi_memory_desc_t *md);
  20. #define arch_efi_call_virt_setup() efi_virtmap_load()
  21. #define arch_efi_call_virt_teardown() efi_virtmap_unload()
  22. #define ARCH_EFI_IRQ_FLAGS_MASK \
  23. (PSR_J_BIT | PSR_E_BIT | PSR_A_BIT | PSR_I_BIT | PSR_F_BIT | \
  24. PSR_T_BIT | MODE_MASK)
  25. static inline void efi_set_pgd(struct mm_struct *mm)
  26. {
  27. check_and_switch_context(mm, NULL);
  28. }
  29. void efi_virtmap_load(void);
  30. void efi_virtmap_unload(void);
  31. #else
  32. #define arm_efi_init()
  33. #endif /* CONFIG_EFI */
  34. /* arch specific definitions used by the stub code */
  35. struct screen_info *alloc_screen_info(void);
  36. void free_screen_info(struct screen_info *si);
  37. /*
  38. * A reasonable upper bound for the uncompressed kernel size is 32 MBytes,
  39. * so we will reserve that amount of memory. We have no easy way to tell what
  40. * the actuall size of code + data the uncompressed kernel will use.
  41. * If this is insufficient, the decompressor will relocate itself out of the
  42. * way before performing the decompression.
  43. */
  44. #define MAX_UNCOMP_KERNEL_SIZE SZ_32M
  45. /*
  46. * phys-to-virt patching requires that the physical to virtual offset is a
  47. * multiple of 2 MiB. However, using an alignment smaller than TEXT_OFFSET
  48. * here throws off the memory allocation logic, so let's use the lowest power
  49. * of two greater than 2 MiB and greater than TEXT_OFFSET.
  50. */
  51. #define EFI_PHYS_ALIGN max(UL(SZ_2M), roundup_pow_of_two(TEXT_OFFSET))
  52. /* on ARM, the initrd should be loaded in a lowmem region */
  53. static inline unsigned long efi_get_max_initrd_addr(unsigned long image_addr)
  54. {
  55. return round_down(image_addr, SZ_4M) + SZ_512M;
  56. }
  57. struct efi_arm_entry_state {
  58. u32 cpsr_before_ebs;
  59. u32 sctlr_before_ebs;
  60. u32 cpsr_after_ebs;
  61. u32 sctlr_after_ebs;
  62. };
  63. static inline void efi_capsule_flush_cache_range(void *addr, int size)
  64. {
  65. __cpuc_flush_dcache_area(addr, size);
  66. }
  67. #endif /* _ASM_ARM_EFI_H */