efi_stub.S 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * EFI call stub.
  4. *
  5. * Copyright (C) 1999-2001 Hewlett-Packard Co
  6. * David Mosberger <[email protected]>
  7. *
  8. * This stub allows us to make EFI calls in physical mode with interrupts
  9. * turned off. We need this because we can't call SetVirtualMap() until
  10. * the kernel has booted far enough to allow allocation of struct vm_area_struct
  11. * entries (which we would need to map stuff with memory attributes other
  12. * than uncached or writeback...). Since the GetTime() service gets called
  13. * earlier than that, we need to be able to make physical mode EFI calls from
  14. * the kernel.
  15. */
  16. /*
  17. * PSR settings as per SAL spec (Chapter 8 in the "IA-64 System
  18. * Abstraction Layer Specification", revision 2.6e). Note that
  19. * psr.dfl and psr.dfh MUST be cleared, despite what this manual says.
  20. * Otherwise, SAL dies whenever it's trying to do an IA-32 BIOS call
  21. * (the br.ia instruction fails unless psr.dfl and psr.dfh are
  22. * cleared). Fortunately, SAL promises not to touch the floating
  23. * point regs, so at least we don't have to save f2-f127.
  24. */
  25. #define PSR_BITS_TO_CLEAR \
  26. (IA64_PSR_I | IA64_PSR_IT | IA64_PSR_DT | IA64_PSR_RT | \
  27. IA64_PSR_DD | IA64_PSR_SS | IA64_PSR_RI | IA64_PSR_ED | \
  28. IA64_PSR_DFL | IA64_PSR_DFH)
  29. #define PSR_BITS_TO_SET \
  30. (IA64_PSR_BN)
  31. #include <asm/processor.h>
  32. #include <asm/asmmacro.h>
  33. /*
  34. * Inputs:
  35. * in0 = address of function descriptor of EFI routine to call
  36. * in1..in7 = arguments to routine
  37. *
  38. * Outputs:
  39. * r8 = EFI_STATUS returned by called function
  40. */
  41. GLOBAL_ENTRY(efi_call_phys)
  42. .prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(8)
  43. alloc loc1=ar.pfs,8,7,7,0
  44. ld8 r2=[in0],8 // load EFI function's entry point
  45. mov loc0=rp
  46. .body
  47. ;;
  48. mov loc2=gp // save global pointer
  49. mov loc4=ar.rsc // save RSE configuration
  50. mov ar.rsc=0 // put RSE in enforced lazy, LE mode
  51. ;;
  52. ld8 gp=[in0] // load EFI function's global pointer
  53. movl r16=PSR_BITS_TO_CLEAR
  54. mov loc3=psr // save processor status word
  55. movl r17=PSR_BITS_TO_SET
  56. ;;
  57. or loc3=loc3,r17
  58. mov b6=r2
  59. ;;
  60. andcm r16=loc3,r16 // get psr with IT, DT, and RT bits cleared
  61. br.call.sptk.many rp=ia64_switch_mode_phys
  62. .ret0: mov out4=in5
  63. mov out0=in1
  64. mov out1=in2
  65. mov out2=in3
  66. mov out3=in4
  67. mov out5=in6
  68. mov out6=in7
  69. mov loc5=r19
  70. mov loc6=r20
  71. br.call.sptk.many rp=b6 // call the EFI function
  72. .ret1: mov ar.rsc=0 // put RSE in enforced lazy, LE mode
  73. mov r16=loc3
  74. mov r19=loc5
  75. mov r20=loc6
  76. br.call.sptk.many rp=ia64_switch_mode_virt // return to virtual mode
  77. .ret2: mov ar.rsc=loc4 // restore RSE configuration
  78. mov ar.pfs=loc1
  79. mov rp=loc0
  80. mov gp=loc2
  81. br.ret.sptk.many rp
  82. END(efi_call_phys)