Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * PowerNV OPAL API wrappers
0004  *
0005  * Copyright 2011 IBM Corp.
0006  */
0007 
0008 #include <linux/jump_label.h>
0009 #include <asm/ppc_asm.h>
0010 #include <asm/hvcall.h>
0011 #include <asm/asm-offsets.h>
0012 #include <asm/opal.h>
0013 #include <asm/asm-compat.h>
0014 #include <asm/feature-fixups.h>
0015 
0016     .section ".text"
0017 
0018 /*
0019  * r3-r10       - OPAL call arguments
0020  * STK_PARAM(R11)   - OPAL opcode
0021  * STK_PARAM(R12)   - MSR to restore
0022  */
0023 _GLOBAL_TOC(__opal_call)
0024     mflr    r0
0025     std r0,PPC_LR_STKOFF(r1)
0026     ld  r12,STK_PARAM(R12)(r1)
0027     li  r0,MSR_IR|MSR_DR|MSR_LE
0028     andc    r12,r12,r0
0029     LOAD_REG_ADDR(r11, opal_return)
0030     mtlr    r11
0031     LOAD_REG_ADDR(r11, opal)
0032     ld  r2,0(r11)
0033     ld  r11,8(r11)
0034     mtspr   SPRN_HSRR0,r11
0035     mtspr   SPRN_HSRR1,r12
0036     /* set token to r0 */
0037     ld  r0,STK_PARAM(R11)(r1)
0038     hrfid
0039 opal_return:
0040     /*
0041      * Restore MSR on OPAL return. The MSR is set to big-endian.
0042      */
0043 #ifdef __BIG_ENDIAN__
0044     ld  r11,STK_PARAM(R12)(r1)
0045     mtmsrd  r11
0046 #else
0047     /* Endian can only be switched with rfi, must byte reverse MSR load */
0048     .short 0x4039    /* li r10,STK_PARAM(R12)       */
0049     .byte (STK_PARAM(R12) >> 8) & 0xff
0050     .byte STK_PARAM(R12) & 0xff
0051 
0052     .long 0x280c6a7d /* ldbrx r11,r10,r1            */
0053     .long 0x05009f42 /* bcl 20,31,$+4           */
0054     .long 0xa602487d /* mflr r10                */
0055     .long 0x14004a39 /* addi r10,r10,20         */
0056     .long 0xa64b5a7d /* mthsrr0 r10             */
0057     .long 0xa64b7b7d /* mthsrr1 r11             */
0058     .long 0x2402004c /* hrfid               */
0059 #endif
0060     ld  r2,PACATOC(r13)
0061     ld  r0,PPC_LR_STKOFF(r1)
0062     mtlr    r0
0063     blr