esi_stub.S 2.9 KB

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