esi_stub.S 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. /*
  36. * Inputs:
  37. * in0 = address of function descriptor of ESI routine to call
  38. * in1 = address of array of ESI parameters
  39. *
  40. * Outputs:
  41. * r8 = result returned by called function
  42. */
  43. GLOBAL_ENTRY(esi_call_phys)
  44. .prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(2)
  45. alloc loc1=ar.pfs,2,7,8,0
  46. ld8 r2=[in0],8 // load ESI function's entry point
  47. mov loc0=rp
  48. .body
  49. ;;
  50. ld8 out0=[in1],8 // ESI params loaded from array
  51. ;; // passing all as inputs doesn't work
  52. ld8 out1=[in1],8
  53. ;;
  54. ld8 out2=[in1],8
  55. ;;
  56. ld8 out3=[in1],8
  57. ;;
  58. ld8 out4=[in1],8
  59. ;;
  60. ld8 out5=[in1],8
  61. ;;
  62. ld8 out6=[in1],8
  63. ;;
  64. ld8 out7=[in1]
  65. mov loc2=gp // save global pointer
  66. mov loc4=ar.rsc // save RSE configuration
  67. mov ar.rsc=0 // put RSE in enforced lazy, LE mode
  68. ;;
  69. ld8 gp=[in0] // load ESI function's global pointer
  70. movl r16=PSR_BITS_TO_CLEAR
  71. mov loc3=psr // save processor status word
  72. movl r17=PSR_BITS_TO_SET
  73. ;;
  74. or loc3=loc3,r17
  75. mov b6=r2
  76. ;;
  77. andcm r16=loc3,r16 // get psr with IT, DT, and RT bits cleared
  78. br.call.sptk.many rp=ia64_switch_mode_phys
  79. .ret0: mov loc5=r19 // old ar.bsp
  80. mov loc6=r20 // old sp
  81. br.call.sptk.many rp=b6 // call the ESI function
  82. .ret1: mov ar.rsc=0 // put RSE in enforced lazy, LE mode
  83. mov r16=loc3 // save virtual mode psr
  84. mov r19=loc5 // save virtual mode bspstore
  85. mov r20=loc6 // save virtual mode sp
  86. br.call.sptk.many rp=ia64_switch_mode_virt // return to virtual mode
  87. .ret2: mov ar.rsc=loc4 // restore RSE configuration
  88. mov ar.pfs=loc1
  89. mov rp=loc0
  90. mov gp=loc2
  91. br.ret.sptk.many rp
  92. END(esi_call_phys)