esi_stub.S 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * ESI call stub.
  4. *
  5. * Copyright (C) 2005 Hewlett-Packard Co
  6. * Alex Williamson <[email protected]>
  7. *
  8. * Based on EFI call stub by David Mosberger. The stub is virtually
  9. * identical to the one for EFI phys-mode calls, except that ESI
  10. * calls may have up to 8 arguments, so they get passed to this routine
  11. * through memory.
  12. *
  13. * This stub allows us to make ESI calls in physical mode with interrupts
  14. * turned off. ESI calls may not support calling from virtual mode.
  15. *
  16. * Google for "Extensible SAL specification" for a document describing the
  17. * ESI standard.
  18. */
  19. /*
  20. * PSR settings as per SAL spec (Chapter 8 in the "IA-64 System
  21. * Abstraction Layer Specification", revision 2.6e). Note that
  22. * psr.dfl and psr.dfh MUST be cleared, despite what this manual says.
  23. * Otherwise, SAL dies whenever it's trying to do an IA-32 BIOS call
  24. * (the br.ia instruction fails unless psr.dfl and psr.dfh are
  25. * cleared). Fortunately, SAL promises not to touch the floating
  26. * point regs, so at least we don't have to save f2-f127.
  27. */
  28. #define PSR_BITS_TO_CLEAR \
  29. (IA64_PSR_I | IA64_PSR_IT | IA64_PSR_DT | IA64_PSR_RT | \
  30. IA64_PSR_DD | IA64_PSR_SS | IA64_PSR_RI | IA64_PSR_ED | \
  31. IA64_PSR_DFL | IA64_PSR_DFH)
  32. #define PSR_BITS_TO_SET \
  33. (IA64_PSR_BN)
  34. #include <asm/processor.h>
  35. #include <asm/asmmacro.h>
  36. #include <asm/export.h>
  37. /*
  38. * Inputs:
  39. * in0 = address of function descriptor of ESI routine to call
  40. * in1 = address of array of ESI parameters
  41. *
  42. * Outputs:
  43. * r8 = result returned by called function
  44. */
  45. GLOBAL_ENTRY(esi_call_phys)
  46. .prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(2)
  47. alloc loc1=ar.pfs,2,7,8,0
  48. ld8 r2=[in0],8 // load ESI function's entry point
  49. mov loc0=rp
  50. .body
  51. ;;
  52. ld8 out0=[in1],8 // ESI params loaded from array
  53. ;; // passing all as inputs doesn't work
  54. ld8 out1=[in1],8
  55. ;;
  56. ld8 out2=[in1],8
  57. ;;
  58. ld8 out3=[in1],8
  59. ;;
  60. ld8 out4=[in1],8
  61. ;;
  62. ld8 out5=[in1],8
  63. ;;
  64. ld8 out6=[in1],8
  65. ;;
  66. ld8 out7=[in1]
  67. mov loc2=gp // save global pointer
  68. mov loc4=ar.rsc // save RSE configuration
  69. mov ar.rsc=0 // put RSE in enforced lazy, LE mode
  70. ;;
  71. ld8 gp=[in0] // load ESI function's global pointer
  72. movl r16=PSR_BITS_TO_CLEAR
  73. mov loc3=psr // save processor status word
  74. movl r17=PSR_BITS_TO_SET
  75. ;;
  76. or loc3=loc3,r17
  77. mov b6=r2
  78. ;;
  79. andcm r16=loc3,r16 // get psr with IT, DT, and RT bits cleared
  80. br.call.sptk.many rp=ia64_switch_mode_phys
  81. .ret0: mov loc5=r19 // old ar.bsp
  82. mov loc6=r20 // old sp
  83. br.call.sptk.many rp=b6 // call the ESI function
  84. .ret1: mov ar.rsc=0 // put RSE in enforced lazy, LE mode
  85. mov r16=loc3 // save virtual mode psr
  86. mov r19=loc5 // save virtual mode bspstore
  87. mov r20=loc6 // save virtual mode sp
  88. br.call.sptk.many rp=ia64_switch_mode_virt // return to virtual mode
  89. .ret2: mov ar.rsc=loc4 // restore RSE configuration
  90. mov ar.pfs=loc1
  91. mov rp=loc0
  92. mov gp=loc2
  93. br.ret.sptk.many rp
  94. END(esi_call_phys)
  95. EXPORT_SYMBOL_GPL(esi_call_phys)