18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * PowerNV OPAL API wrappers 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright 2011 IBM Corp. 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#include <linux/jump_label.h> 98c2ecf20Sopenharmony_ci#include <asm/ppc_asm.h> 108c2ecf20Sopenharmony_ci#include <asm/hvcall.h> 118c2ecf20Sopenharmony_ci#include <asm/asm-offsets.h> 128c2ecf20Sopenharmony_ci#include <asm/opal.h> 138c2ecf20Sopenharmony_ci#include <asm/asm-compat.h> 148c2ecf20Sopenharmony_ci#include <asm/feature-fixups.h> 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci .section ".text" 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci/* 198c2ecf20Sopenharmony_ci * r3-r10 - OPAL call arguments 208c2ecf20Sopenharmony_ci * STK_PARAM(R11) - OPAL opcode 218c2ecf20Sopenharmony_ci * STK_PARAM(R12) - MSR to restore 228c2ecf20Sopenharmony_ci */ 238c2ecf20Sopenharmony_ci_GLOBAL_TOC(__opal_call) 248c2ecf20Sopenharmony_ci mflr r0 258c2ecf20Sopenharmony_ci std r0,PPC_LR_STKOFF(r1) 268c2ecf20Sopenharmony_ci ld r12,STK_PARAM(R12)(r1) 278c2ecf20Sopenharmony_ci li r0,MSR_IR|MSR_DR|MSR_LE 288c2ecf20Sopenharmony_ci andc r12,r12,r0 298c2ecf20Sopenharmony_ci LOAD_REG_ADDR(r11, opal_return) 308c2ecf20Sopenharmony_ci mtlr r11 318c2ecf20Sopenharmony_ci LOAD_REG_ADDR(r11, opal) 328c2ecf20Sopenharmony_ci ld r2,0(r11) 338c2ecf20Sopenharmony_ci ld r11,8(r11) 348c2ecf20Sopenharmony_ci mtspr SPRN_HSRR0,r11 358c2ecf20Sopenharmony_ci mtspr SPRN_HSRR1,r12 368c2ecf20Sopenharmony_ci /* set token to r0 */ 378c2ecf20Sopenharmony_ci ld r0,STK_PARAM(R11)(r1) 388c2ecf20Sopenharmony_ci hrfid 398c2ecf20Sopenharmony_ciopal_return: 408c2ecf20Sopenharmony_ci /* 418c2ecf20Sopenharmony_ci * Restore MSR on OPAL return. The MSR is set to big-endian. 428c2ecf20Sopenharmony_ci */ 438c2ecf20Sopenharmony_ci#ifdef __BIG_ENDIAN__ 448c2ecf20Sopenharmony_ci ld r11,STK_PARAM(R12)(r1) 458c2ecf20Sopenharmony_ci mtmsrd r11 468c2ecf20Sopenharmony_ci#else 478c2ecf20Sopenharmony_ci /* Endian can only be switched with rfi, must byte reverse MSR load */ 488c2ecf20Sopenharmony_ci .short 0x4039 /* li r10,STK_PARAM(R12) */ 498c2ecf20Sopenharmony_ci .byte (STK_PARAM(R12) >> 8) & 0xff 508c2ecf20Sopenharmony_ci .byte STK_PARAM(R12) & 0xff 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci .long 0x280c6a7d /* ldbrx r11,r10,r1 */ 538c2ecf20Sopenharmony_ci .long 0x05009f42 /* bcl 20,31,$+4 */ 548c2ecf20Sopenharmony_ci .long 0xa602487d /* mflr r10 */ 558c2ecf20Sopenharmony_ci .long 0x14004a39 /* addi r10,r10,20 */ 568c2ecf20Sopenharmony_ci .long 0xa64b5a7d /* mthsrr0 r10 */ 578c2ecf20Sopenharmony_ci .long 0xa64b7b7d /* mthsrr1 r11 */ 588c2ecf20Sopenharmony_ci .long 0x2402004c /* hrfid */ 598c2ecf20Sopenharmony_ci#endif 608c2ecf20Sopenharmony_ci ld r2,PACATOC(r13) 618c2ecf20Sopenharmony_ci ld r0,PPC_LR_STKOFF(r1) 628c2ecf20Sopenharmony_ci mtlr r0 638c2ecf20Sopenharmony_ci blr 64