opal-calls.S 1.4 KB

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