prom_entry_64.S 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * PowerPC version
  4. * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
  5. * Rewritten by Cort Dougan (cort@cs.nmt.edu) for PReP
  6. * Copyright (C) 1996 Cort Dougan <cort@cs.nmt.edu>
  7. * Adapted for Power Macintosh by Paul Mackerras.
  8. * Low-level exception handlers and MMU support
  9. * rewritten by Paul Mackerras.
  10. * Copyright (C) 1996 Paul Mackerras.
  11. * MPC8xx modifications Copyright (C) 1997 Dan Malek (dmalek@jlc.net).
  12. *
  13. * This file contains the 64-bit prom entry code.
  14. */
  15. #include <asm/asm-offsets.h>
  16. #ifdef CONFIG_PPC_BOOK3S
  17. #include <asm/exception-64s.h>
  18. #else
  19. #include <asm/exception-64e.h>
  20. #endif
  21. #include <asm/ppc_asm.h>
  22. .section ".text","ax",@progbits
  23. _GLOBAL(enter_prom)
  24. mflr r0
  25. std r0,16(r1)
  26. stdu r1,-SWITCH_FRAME_SIZE(r1) /* Save SP and create stack space */
  27. /* Because PROM is running in 32b mode, it clobbers the high order half
  28. * of all registers that it saves. We therefore save those registers
  29. * PROM might touch to the stack. (r0, r3-r13 are caller saved)
  30. */
  31. SAVE_GPR(2, r1)
  32. SAVE_GPR(13, r1)
  33. SAVE_NVGPRS(r1)
  34. mfcr r10
  35. mfmsr r11
  36. std r10,_CCR(r1)
  37. std r11,_MSR(r1)
  38. /* Put PROM address in SRR0 */
  39. mtsrr0 r4
  40. /* Setup our trampoline return addr in LR */
  41. bcl 20,31,$+4
  42. 0: mflr r4
  43. addi r4,r4,(1f - 0b)
  44. mtlr r4
  45. /* Prepare a 32-bit mode big endian MSR
  46. */
  47. #ifdef CONFIG_PPC_BOOK3E_64
  48. rlwinm r11,r11,0,1,31
  49. mtsrr1 r11
  50. rfi
  51. #else /* CONFIG_PPC_BOOK3E_64 */
  52. LOAD_REG_IMMEDIATE(r12, MSR_SF | MSR_LE)
  53. andc r11,r11,r12
  54. mtsrr1 r11
  55. RFI_TO_KERNEL
  56. #endif /* CONFIG_PPC_BOOK3E_64 */
  57. 1: /* Return from OF */
  58. FIXUP_ENDIAN
  59. /* Just make sure that r1 top 32 bits didn't get
  60. * corrupt by OF
  61. */
  62. rldicl r1,r1,0,32
  63. /* Restore the MSR (back to 64 bits) */
  64. ld r0,_MSR(r1)
  65. MTMSRD(r0)
  66. isync
  67. /* Restore other registers */
  68. REST_GPR(2, r1)
  69. REST_GPR(13, r1)
  70. REST_NVGPRS(r1)
  71. ld r4,_CCR(r1)
  72. mtcr r4
  73. addi r1,r1,SWITCH_FRAME_SIZE
  74. ld r0,16(r1)
  75. mtlr r0
  76. blr