opal-calls.S 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Copyright (c) 2016 IBM Corporation.
  4. */
  5. #include "ppc_asm.h"
  6. #include "../include/asm/opal-api.h"
  7. .text
  8. .globl opal_kentry
  9. opal_kentry:
  10. /* r3 is the fdt ptr */
  11. mtctr r4
  12. li r4, 0
  13. li r5, 0
  14. li r6, 0
  15. li r7, 0
  16. ld r11,opal@got(r2)
  17. ld r8,0(r11)
  18. ld r9,8(r11)
  19. bctr
  20. #define OPAL_CALL(name, token) \
  21. .globl name; \
  22. name: \
  23. li r0, token; \
  24. b opal_call;
  25. opal_call:
  26. mflr r11
  27. std r11,16(r1)
  28. mfcr r12
  29. stw r12,8(r1)
  30. mr r13,r2
  31. /* Set opal return address */
  32. ld r11,opal_return@got(r2)
  33. mtlr r11
  34. mfmsr r12
  35. /* switch to BE when we enter OPAL */
  36. li r11,MSR_LE
  37. andc r12,r12,r11
  38. mtspr SPRN_HSRR1,r12
  39. /* load the opal call entry point and base */
  40. ld r11,opal@got(r2)
  41. ld r12,8(r11)
  42. ld r2,0(r11)
  43. mtspr SPRN_HSRR0,r12
  44. hrfid
  45. opal_return:
  46. FIXUP_ENDIAN
  47. mr r2,r13;
  48. lwz r11,8(r1);
  49. ld r12,16(r1)
  50. mtcr r11;
  51. mtlr r12
  52. blr
  53. OPAL_CALL(opal_console_write, OPAL_CONSOLE_WRITE);
  54. OPAL_CALL(opal_console_read, OPAL_CONSOLE_READ);
  55. OPAL_CALL(opal_console_write_buffer_space, OPAL_CONSOLE_WRITE_BUFFER_SPACE);
  56. OPAL_CALL(opal_poll_events, OPAL_POLL_EVENTS);
  57. OPAL_CALL(opal_console_flush, OPAL_CONSOLE_FLUSH);