1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * PowerNV OPAL API wrappers
5 * Copyright 2011 IBM Corp.
8 #include <linux/jump_label.h>
9 #include <asm/ppc_asm.h>
10 #include <asm/hvcall.h>
11 #include <asm/asm-offsets.h>
13 #include <asm/asm-compat.h>
14 #include <asm/feature-fixups.h>
19 * r3-r10 - OPAL call arguments
20 * STK_PARAM(R11) - OPAL opcode
21 * STK_PARAM(R12) - MSR to restore
23 _GLOBAL_TOC(__opal_call)
25 std r0,PPC_LR_STKOFF(r1)
26 ld r12,STK_PARAM(R12)(r1)
27 li r0,MSR_IR|MSR_DR|MSR_LE
29 LOAD_REG_ADDR(r11, opal_return)
31 LOAD_REG_ADDR(r11, opal)
37 ld r0,STK_PARAM(R11)(r1)
41 * Restore MSR on OPAL return. The MSR is set to big-endian.
44 ld r11,STK_PARAM(R12)(r1)
47 /* Endian can only be switched with rfi, must byte reverse MSR load */
48 .short 0x4039 /* li r10,STK_PARAM(R12) */
49 .byte (STK_PARAM(R12) >> 8) & 0xff
50 .byte STK_PARAM(R12) & 0xff
52 .long 0x280c6a7d /* ldbrx r11,r10,r1 */
53 .long 0x05009f42 /* bcl 20,31,$+4 */
54 .long 0xa602487d /* mflr r10 */
55 .long 0x14004a39 /* addi r10,r10,20 */
56 .long 0xa64b5a7d /* mthsrr0 r10 */
57 .long 0xa64b7b7d /* mthsrr1 r11 */
58 .long 0x2402004c /* hrfid */
61 ld r0,PPC_LR_STKOFF(r1)