2 * PowerNV OPAL API wrappers
4 * Copyright 2011 IBM Corp.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
12 #include <linux/jump_label.h>
13 #include <asm/ppc_asm.h>
14 #include <asm/hvcall.h>
15 #include <asm/asm-offsets.h>
17 #include <asm/asm-compat.h>
18 #include <asm/feature-fixups.h>
23 * r3-r10 - OPAL call arguments
24 * STK_PARAM(R11) - OPAL opcode
25 * STK_PARAM(R12) - MSR to restore
27 _GLOBAL_TOC(__opal_call)
29 std r0,PPC_LR_STKOFF(r1)
30 ld r12,STK_PARAM(R12)(r1)
31 li r0,MSR_IR|MSR_DR|MSR_LE
33 LOAD_REG_ADDR(r11, opal_return)
35 LOAD_REG_ADDR(r11, opal)
41 ld r0,STK_PARAM(R11)(r1)
45 * Restore MSR on OPAL return. The MSR is set to big-endian.
48 ld r11,STK_PARAM(R12)(r1)
51 /* Endian can only be switched with rfi, must byte reverse MSR load */
52 .short 0x4039 /* li r10,STK_PARAM(R12) */
53 .byte (STK_PARAM(R12) >> 8) & 0xff
54 .byte STK_PARAM(R12) & 0xff
56 .long 0x280c6a7d /* ldbrx r11,r10,r1 */
57 .long 0x05009f42 /* bcl 20,31,$+4 */
58 .long 0xa602487d /* mflr r10 */
59 .long 0x14004a39 /* addi r10,r10,20 */
60 .long 0xa64b5a7d /* mthsrr0 r10 */
61 .long 0xa64b7b7d /* mthsrr1 r11 */
62 .long 0x2402004c /* hrfid */
65 ld r0,PPC_LR_STKOFF(r1)